mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
fix(arn validator): include : in regex (#2471)
This commit is contained in:
@@ -47,5 +47,5 @@ def parse_iam_credentials_arn(arn: str) -> ARN:
|
||||
|
||||
def is_valid_arn(arn: str) -> bool:
|
||||
"""is_valid_arn returns True or False whether the given AWS ARN (Amazon Resource Name) is valid or not."""
|
||||
regex = r"^arn:aws(-cn|-us-gov)?:[a-zA-Z0-9\-]+:([a-z]{2}-[a-z]+-\d{1})?:(\d{12})?:[a-zA-Z0-9\-_\/]+(:\d+)?$"
|
||||
regex = r"^arn:aws(-cn|-us-gov|-iso|-iso-b)?:[a-zA-Z0-9\-]+:([a-z]{2}-[a-z]+-\d{1})?:(\d{12})?:[a-zA-Z0-9\-_\/:]+(:\d+)?$"
|
||||
return re.match(regex, arn) is not None
|
||||
|
||||
@@ -314,6 +314,11 @@ class Test_ARN_Parsing:
|
||||
assert is_valid_arn("arn:aws:iam::012345678910:user/test")
|
||||
assert is_valid_arn("arn:aws-cn:ec2:us-east-1:123456789012:vpc/vpc-12345678")
|
||||
assert is_valid_arn("arn:aws-us-gov:s3:::bucket")
|
||||
assert is_valid_arn("arn:aws-iso:iam::012345678910:user/test")
|
||||
assert is_valid_arn("arn:aws-iso-b:ec2:us-east-1:123456789012:vpc/vpc-12345678")
|
||||
assert is_valid_arn(
|
||||
"arn:aws:lambda:eu-west-1:123456789012:function:lambda-function"
|
||||
)
|
||||
assert not is_valid_arn("arn:azure:::012345678910:user/test")
|
||||
assert not is_valid_arn("arn:aws:iam::account:user/test")
|
||||
assert not is_valid_arn("arn:aws:::012345678910:resource")
|
||||
|
||||
Reference in New Issue
Block a user