mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
fix(aws): update bucket naming validation to accept dots (#7576)
Co-authored-by: Andoni Alonso <14891798+andoniaf@users.noreply.github.com> Co-authored-by: Sergio Garcia <hello@mistercloudsec.com>
This commit is contained in:
@@ -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).
|
||||
|
||||
---
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user