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

aws - account access-analyzer filter #6075

Merged
merged 13 commits into from Sep 11, 2020

Conversation

Lucas-Irvine
Copy link
Contributor

Addresses #6054.

I'm unsure what the status and trust values should default to if they are not provided, or whether they should be made to be required. Let me know what you think.

c7n/resources/account.py Outdated Show resolved Hide resolved
c7n/resources/account.py Outdated Show resolved Hide resolved
c7n/resources/account.py Outdated Show resolved Hide resolved
@Lucas-Irvine
Copy link
Contributor Author

@kapilt Any updates on this one?

c7n/resources/account.py Outdated Show resolved Hide resolved
@PratMis PratMis requested a review from kapilt September 10, 2020 17:17
c7n/resources/account.py Outdated Show resolved Hide resolved

def process(self, resources, event=None):
account = resources[0]
if not account.get('c7n:matched_analyzers'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the intent on the condition, if matched is defined, and we don't execute the conditional here, the analyzers will be undefined later. typical use account.setdefault('c7n:matched_analyzers', []) .. the previous version had two separate annotations one for the analyzers, one for api cached analyzers and one for a matched analyzer. this version does away with the api cached analyzers, which is fine, but the condition logic here doesn't cleanly handle both condition states.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep makes sense, that was definitely a bug. I think it should be fixed now - I iterate through each analyzer and if it matches then I add it to matched_analyzers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this use of annotation cache by the filter is actually another bug imo, ie it short-circuits the filter evaluation based on the presence of a previous match.

also when using an annotation key (c7n:matched-analyzers) repeatedly its better to define as a class variable to avoid typos in usage.

generally i think we also want to support chaining these filters, ie find active && last analyzed more than 30 days old.

i'll push an update to address.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense - thanks for the help on this one!

Copy link
Collaborator

@kapilt kapilt left a comment

Choose a reason for hiding this comment

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

lgtm

@kapilt kapilt merged commit 9bc2897 into cloud-custodian:master Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants