Skip to content
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

Merged
merged 5 commits into from Mar 20, 2024
Merged

Conversation

sergargar
Copy link
Member

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.

@sergargar sergargar requested a review from a team as a code owner March 20, 2024 14:13
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Mar 20, 2024
@sergargar sergargar added the backport-v3 Pending to port to Prowler v3 branch label Mar 20, 2024
Copy link

codecov bot commented Mar 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.06%. Comparing base (e224215) to head (3b2ceed).
Report is 3 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jfagoagas jfagoagas left a 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"]
Copy link
Member

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.

@jfagoagas jfagoagas merged commit 64c7de9 into master Mar 20, 2024
11 checks passed
@jfagoagas jfagoagas deleted the cloudtrail-dicts branch March 20, 2024 18:05
@sergargar sergargar removed the backport-v3 Pending to port to Prowler v3 branch label Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants