From 3ba305bae192d9c79366ceb3f30bce0ff07a123b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Drvo=C5=A1t=C4=9Bp?= Date: Tue, 16 Jul 2024 10:26:24 +0200 Subject: [PATCH 1/2] Experiment: Allow bucket names ending with `-s3alias` --- src/parse.jl | 2 +- test/runtests.jl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/parse.jl b/src/parse.jl index 2c73b58..046abd7 100644 --- a/src/parse.jl +++ b/src/parse.jl @@ -40,7 +40,7 @@ function validate_bucket_name(bucket_name, accelerate) !(3 <= ncodeunits(bucket_name) <= 63) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must be between 3 (min) and 63 (max) characters long.")) occursin("..", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not contain two adjacent periods.")) startswith(bucket_name, "xn--") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not start with the prefix `xn--`.")) - endswith(bucket_name, "-s3alias") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not end with the suffix `-s3alias`.")) + # endswith(bucket_name, "-s3alias") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not end with the suffix `-s3alias`.")) accelerate && occursin(".", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Buckets used with Amazon S3 Transfer Acceleration can't have dots (.) in their names.")) !contains(bucket_name, r"^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-). Bucket names must begin and end with a letter or number.")) diff --git a/test/runtests.jl b/test/runtests.jl index 358c4d5..be444d8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -884,8 +884,8 @@ end @test !parse_s3_url(bucket="a..b", accelerate=false)[1] @test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", false) @test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=false) - @test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", false) - @test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=false) + # @test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", false) + # @test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=false) @test_throws ArgumentError CloudStore.validate_bucket_name("abcA", false) @test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=false) @test_throws ArgumentError CloudStore.validate_bucket_name("abc-", false) @@ -911,8 +911,8 @@ end @test !parse_s3_url(bucket="a..b", accelerate=true)[1] @test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", true) @test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=true) - @test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", true) - @test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=true) + # @test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", true) + # @test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=true) @test_throws ArgumentError CloudStore.validate_bucket_name("abcA", true) @test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=true) @test_throws ArgumentError CloudStore.validate_bucket_name("abc-", true) From b1aea3db9bbb669f4de779af469d2feb7dc38cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Drvo=C5=A1t=C4=9Bp?= Date: Tue, 16 Jul 2024 12:17:07 +0200 Subject: [PATCH 2/2] . --- Project.toml | 2 +- src/parse.jl | 2 -- test/runtests.jl | 13 +++++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 6a68dfc..f8c6ef1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CloudStore" uuid = "3365d9ee-d53b-4a56-812d-5344d5b716d7" authors = ["quinnj "] -version = "1.6.3" +version = "1.6.4" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/parse.jl b/src/parse.jl index 046abd7..4ed1526 100644 --- a/src/parse.jl +++ b/src/parse.jl @@ -39,8 +39,6 @@ const AWS_REGIONS = Set{String}([ function validate_bucket_name(bucket_name, accelerate) !(3 <= ncodeunits(bucket_name) <= 63) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must be between 3 (min) and 63 (max) characters long.")) occursin("..", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not contain two adjacent periods.")) - startswith(bucket_name, "xn--") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not start with the prefix `xn--`.")) - # endswith(bucket_name, "-s3alias") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not end with the suffix `-s3alias`.")) accelerate && occursin(".", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Buckets used with Amazon S3 Transfer Acceleration can't have dots (.) in their names.")) !contains(bucket_name, r"^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-). Bucket names must begin and end with a letter or number.")) diff --git a/test/runtests.jl b/test/runtests.jl index be444d8..38ca542 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -882,10 +882,6 @@ end @test_throws ArgumentError parse_s3_url(bucket="a"^64, accelerate=false) @test_throws ArgumentError CloudStore.validate_bucket_name("a..b", false) @test !parse_s3_url(bucket="a..b", accelerate=false)[1] - @test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", false) - @test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=false) - # @test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", false) - # @test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=false) @test_throws ArgumentError CloudStore.validate_bucket_name("abcA", false) @test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=false) @test_throws ArgumentError CloudStore.validate_bucket_name("abc-", false) @@ -909,10 +905,6 @@ end @test_throws ArgumentError parse_s3_url(bucket="a"^64, accelerate=true) @test_throws ArgumentError CloudStore.validate_bucket_name("a..b", true) @test !parse_s3_url(bucket="a..b", accelerate=true)[1] - @test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", true) - @test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=true) - # @test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", true) - # @test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=true) @test_throws ArgumentError CloudStore.validate_bucket_name("abcA", true) @test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=true) @test_throws ArgumentError CloudStore.validate_bucket_name("abc-", true) @@ -927,6 +919,11 @@ end @test CloudStore.validate_bucket_name("a.b-c1", false) == "a.b-c1" @test CloudStore.validate_bucket_name("a"^63, false) == "a"^63 @test CloudStore.validate_bucket_name("a"^3, false) == "a"^3 + # xn-- prefix and -s3alias suffix are apparently illegal in bucket names create by + # the user but can be received from AWS, see e.g. + # https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points-alias.html + @test CloudStore.validate_bucket_name("xn--a", false) == "xn--a" + @test CloudStore.validate_bucket_name("a-s3alias", false) == "a-s3alias" @test_throws ArgumentError("Validation failed for `region` \"xx-xxxx-x\"") CloudStore.parseAWSBucketRegionKey("https://bucket.vpce-1a2b3c4d-5e6f.s3.xx-xxxx-x.vpce.amazonaws.com/bucket-name") @test_throws ArgumentError("Validation failed for `bucket` name \"bn\": Bucket names must be between 3 (min) and 63 (max) characters long.") CloudStore.parseAWSBucketRegionKey("https://bucket.vpce-1a2b3c4d-5e6f.s3.us-west-2.vpce.amazonaws.com/bn")