diff --git a/prowler/CHANGELOG.md b/prowler/CHANGELOG.md index cea371d0bb..9512f073d7 100644 --- a/prowler/CHANGELOG.md +++ b/prowler/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to the **Prowler SDK** are documented in this file. - Fix package name location in pyproject.toml while replicating for prowler-cloud [(#7531)](https://github.com/prowler-cloud/prowler/pull/7531). - Remove cache in PyPI release action [(#7532)](https://github.com/prowler-cloud/prowler/pull/7532). - Add the correct values for logger.info inside iam service [(#7526)](https://github.com/prowler-cloud/prowler/pull/7526). +- Update S3 bucket naming validation to accept dots [(#7545)](https://github.com/prowler-cloud/prowler/pull/7545). - Handle new FlowLog model properties in Azure [(#7546)](https://github.com/prowler-cloud/prowler/pull/7546). --- diff --git a/prowler/providers/aws/lib/arguments/arguments.py b/prowler/providers/aws/lib/arguments/arguments.py index 7f0f7872f5..ff5a9ddf77 100644 --- a/prowler/providers/aws/lib/arguments/arguments.py +++ b/prowler/providers/aws/lib/arguments/arguments.py @@ -224,7 +224,10 @@ def validate_arguments(arguments: Namespace) -> tuple[bool, str]: def validate_bucket(bucket_name: str) -> str: """validate_bucket validates that the input bucket_name is valid""" - if search("(?!(^xn--|.+-s3alias$))^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$", bucket_name): + if search( + "^(?!^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$)(?!.*\.{2})(?!.*\.-)(?!.*-\.)(?!^xn--)(?!^sthree-)(?!^amzn-s3-demo-)(?!.*--table-s3$)[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$", + bucket_name, + ): return bucket_name else: raise ArgumentTypeError( diff --git a/tests/lib/cli/parser_test.py b/tests/lib/cli/parser_test.py index 37bec15d94..22ac60d2ba 100644 --- a/tests/lib/cli/parser_test.py +++ b/tests/lib/cli/parser_test.py @@ -1320,9 +1320,11 @@ class Test_Parser: def test_validate_bucket_invalid_bucket_names(self): bad_bucket_names = [ "xn--bucket-name", + "sthree-bucket-name", + "amzn-s3-demo-bucket-name", "mrryadfpcwlscicvnrchmtmyhwrvzkgfgdxnlnvaaummnywciixnzvycnzmhhpwb", "192.168.5.4", - "bucket-name-s3alias", + "bucket-name--table-s3", "bucket-name-s3alias-", "bucket-n$ame", "bu", @@ -1338,7 +1340,9 @@ class Test_Parser: ) def test_validate_bucket_valid_bucket_names(self): - valid_bucket_names = ["bucket-name" "test" "test-test-test"] + valid_bucket_names = [ + "bucket-name" "test" "test-test-test" "test.test.test" "abc" + ] for bucket_name in valid_bucket_names: assert validate_bucket(bucket_name) == bucket_name