fix(is_valid_arn): include . into resource name (#2789)

This commit is contained in:
Nacho Rivera
2023-08-30 16:11:46 +02:00
committed by GitHub
parent 46f85e6395
commit 7e44116d51
2 changed files with 2 additions and 1 deletions

View File

@@ -55,5 +55,5 @@ def parse_iam_credentials_arn(arn: str) -> ARN:
def is_valid_arn(arn: str) -> bool: 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.""" """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|-iso|-iso-b)?:[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 return re.match(regex, arn) is not None

View File

@@ -318,6 +318,7 @@ class Test_ARN_Parsing:
assert is_valid_arn( assert is_valid_arn(
"arn:aws:lambda:eu-west-1:123456789012:function:lambda-function" "arn:aws:lambda:eu-west-1:123456789012:function:lambda-function"
) )
assert is_valid_arn("arn:aws:sns:eu-west-1:123456789012:test.fifo")
assert not is_valid_arn("arn:azure:::012345678910:user/test") 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:iam::account:user/test")
assert not is_valid_arn("arn:aws:::012345678910:resource") assert not is_valid_arn("arn:aws:::012345678910:resource")