Skip to content

Commit 1bd8d36

Browse files
committed
Fix tags filtering for s3
Tag value is array of possible values for specified tag. Should check if specific tag contains value from this array.
1 parent 2f05667 commit 1bd8d36

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

hammer/identification/lambdas/api/s3_bucket_acl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ def remediate(security_feature, account, config, ids, tags):
4545
response[security_feature][bucket.name] = result
4646
return response
4747
else:
48-
return server_error(text="Failed to check S3 ACL")
48+
return server_error(text="Failed to check S3 ACL")

hammer/identification/lambdas/api/s3_bucket_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ def remediate(security_feature, account, config, ids, tags):
4545
response[security_feature][bucket.name] = result
4646
return response
4747
else:
48-
return server_error(text="Failed to check S3 policy")
48+
return server_error(text="Failed to check S3 policy")

hammer/library/aws/s3.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,12 @@ def encrypt_bucket(self, kms_key_id=None):
443443
return True
444444

445445
def contains_tags(self, tags):
446-
return all(tag in self.tags.items() for tag in tags.items())
446+
for tag_name in tags:
447+
if tag_name not in self.tags:
448+
return False
449+
if self.tags[tag_name] not in tags[tag_name]:
450+
return False
451+
return True
447452

448453

449454
class S3BucketsPolicyChecker(object):

0 commit comments

Comments
 (0)