fix: Matching logic for product_name and title #23
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.
This PR updates the matching logic for rules based only on
product_name
andtitle
so that both attributes need to match at the same time.The goal is to prevent the following scenario:
product_name
title
(line 370)tags
orresource_id_regexps
is_matching_rule
wrongly returnsTrue
based on the condition in line 374This would lead to a match based only on
product_name
, resulting on wrong suppressions.Testing suppressions
In my opinion, the current organization of that test cases makes it challenging to understand the flows been tested.
To try and (hopefully) make things easier to understand, I've refactored the existing tests.
fixtures/suppression.yaml
.fixtures/matching_findings.json
.fixtures/non_matching_findings.json
.fixtures/expected_matched_findings.json
.fixtures/expected_batch_update_findings.json
.This has reduced the amount of fixture files and made the tests more readable.
I've added this same information about the tests to this readme file.