IAM: Fix resource list matching (#5908)
This commit is contained in:
parent
8cc9518662
commit
749a8572ba
@ -378,7 +378,7 @@ class IAMPolicyStatement(object):
|
|||||||
if is_action_concerned:
|
if is_action_concerned:
|
||||||
if self.is_unknown_principal(self._statement.get("Principal")):
|
if self.is_unknown_principal(self._statement.get("Principal")):
|
||||||
return PermissionResult.NEUTRAL
|
return PermissionResult.NEUTRAL
|
||||||
same_resource = self._match(self._statement["Resource"], resource)
|
same_resource = self._check_element_matches("Resource", resource)
|
||||||
if self._statement["Effect"] == "Allow" and same_resource:
|
if self._statement["Effect"] == "Allow" and same_resource:
|
||||||
return PermissionResult.PERMITTED
|
return PermissionResult.PERMITTED
|
||||||
else: # Deny
|
else: # Deny
|
||||||
|
@ -37,6 +37,20 @@ class TestBucketPolicy:
|
|||||||
({"resource": "arn:aws:s3:::mybucket/test_txt"}, 200),
|
({"resource": "arn:aws:s3:::mybucket/test_txt"}, 200),
|
||||||
({"resource": "arn:aws:s3:::notmybucket/*"}, 403),
|
({"resource": "arn:aws:s3:::notmybucket/*"}, 403),
|
||||||
({"resource": "arn:aws:s3:::mybucket/other*"}, 403),
|
({"resource": "arn:aws:s3:::mybucket/other*"}, 403),
|
||||||
|
({"resource": ["arn:aws:s3:::mybucket", "arn:aws:s3:::mybucket/*"]}, 200),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"resource": [
|
||||||
|
"arn:aws:s3:::notmybucket",
|
||||||
|
"arn:aws:s3:::notmybucket/*",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
403,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"resource": ["arn:aws:s3:::mybucket", "arn:aws:s3:::notmybucket/*"]},
|
||||||
|
403,
|
||||||
|
),
|
||||||
({"effect": "Deny"}, 403),
|
({"effect": "Deny"}, 403),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user