New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cloudtrail): use dictionary instead of list #3579
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3579 +/- ##
=======================================
Coverage 86.06% 86.06%
=======================================
Files 690 690
Lines 21343 21343
=======================================
Hits 18369 18369
Misses 2974 2974 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch and improvement @sergargar !!
Always raising the bar 👏
@@ -7,7 +7,8 @@ | |||
class cloudtrail_insights_exist(Check): | |||
def execute(self): | |||
findings = [] | |||
for trail in cloudtrail_client.trails: | |||
for trail in cloudtrail_client.trails.values(): | |||
print(trail.arn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(trail.arn) |
@@ -45,27 +45,23 @@ def __get_trails__(self, regional_client): | |||
kms_key_id = trail["KmsKeyId"] | |||
if "CloudWatchLogsLogGroupArn" in trail: | |||
log_group_arn = trail["CloudWatchLogsLogGroupArn"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, get the trail["TrailARN"]
first and the use it in the code.
Description
In order for not having duplicate Trails in memory, use a dictionary to store unique trails based on the ARN.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.