-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(mutelist): change logic for tags in aws mutelist #4786
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1677105
feat(aws): change logic for tags
pedrooot 63dbbce
docs(mutelist): improve docs about mutelist
pedrooot 902d2aa
fix(mutelist): improve tests
pedrooot a06ad20
fix(mutelist): add tests and improve docs
pedrooot 684ebdc
fix: typo
pedrooot 14fd589
docs(mutelist): improve docs
pedrooot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'd say that this is still a bit confusing, as it mentions first to be using both AND or OR, but then later only mentions using AND. You guys could probably add some of the explanation of #4782 (comment) in here to make clear how to use both use cases 🙇
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.
@dlouzan I've just updated the docs, tell me your thoughts!
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.
@pedrooot Now it's much clearer, but this has led to some more questions 😃
Without having delved too much into the codebase, I see that this part is doing a
re.match
on the tags:finding_items
when the function is called? Is that a comma-separated list of tags in a string?re.match
, can't users do here a lot of magic (intendedly or unintendedly 😅). E.g. would your OR sample also match withproject=(test|stage)
?Name=myhost
but the actual resource hasName=myhost.mydomain
, I think this will match the rule in your example? But that would also depend on the syntax that is passed onfinding_items
.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.
It's using re.search for this part, findings_items are a string whose format can be seen on
unroll_dict
docstring fromprowler/prowler/lib/outputs/utils.py
.For your second and third point, we check that the mutelist follow a defined schema (
prowler/lib/mutelist/models.py
) and yes,project=(test|stage)
will muteproject=test
andproject=stage
. I'll add this to docs and tests to cover this cases.Regarding to the last point: yes, it will match the rule because the mutelist contains the substring from the resource. If you don't want this to happen remember that mutelist is using regular expressions, just modify your rule to
Name=myhost(?!\.)
to ensure thatName=myhost.mydomain
won't be muted.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.
@pedrooot Thanks for the clarifications, appreciated. AFAIU the substring case might need some more thinking depending on the case, e.g. a mute rule with
Name=my_host
would also match a resource withName=my_host_is_not_really_this
. We probably would need something likeName=my_host\\b
, but honestly I have not really thought this through and I'm starting my holidays today 😁The fact that the regex depends on matching the pipechar-separated string from
unroll_dict
might make this a bit weird. Perhaps it'd be best if the match was done iterating over a list for each tag of the resource individually, that would make possible to anchor searches or provide options to specify whether to do regex or substring searches. But here I'm just speculating as I do not know the codebase and there might be good reasons for the current behaviour.