fix(fp): allow stricter matching of suppression CPE 2.2 URI prefixes to only whole parts#8548
Open
chadlwilson wants to merge 1 commit into
Open
Conversation
Matching rules with a trailing : indicate a strict match of the last part is intended; rather than potentially matching only a substring of the part (usually an application name) Signed-off-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors suppression/hint property handling by making PropertyType immutable with factory helpers and cached regex compilation, and updates suppression matching logic/tests accordingly.
Changes:
- Make
PropertyTypeimmutable, add factory methods, and memoize compiled regex patterns. - Adjust SAX handlers to construct
PropertyTypevia constructor instead of setters. - Refine CPE suppression matching semantics (prefix + optional “part boundary” via trailing
:) and update/add tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/org/owasp/dependencycheck/xml/suppression/PropertyType.java | Makes PropertyType immutable, adds factories, caches compiled regex |
| core/src/main/java/org/owasp/dependencycheck/xml/suppression/SuppressionHandler.java | Updates suppression XML parsing to new PropertyType construction |
| core/src/main/java/org/owasp/dependencycheck/xml/hints/HintHandler.java | Updates hint XML parsing to new PropertyType construction |
| core/src/main/java/org/owasp/dependencycheck/xml/suppression/SuppressionRule.java | Refactors identifier matching + CPE prefix/part-boundary behavior |
| core/src/test/java/org/owasp/dependencycheck/xml/suppression/SuppressionRuleTest.java | Updates suppression rule tests + adds GAV/PURL matching test |
| core/src/test/java/org/owasp/dependencycheck/xml/suppression/PropertyTypeTest.java | Updates tests for new matching & regex compilation failure behavior |
| core/src/test/java/org/owasp/dependencycheck/analyzer/UnusedSuppressionRuleAnalyzerTest.java | Reformats and modernizes helper usage / PropertyType creation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of Change
Follows up on #8509 to allow rules with a trailing
:to indicate a strict match of the last part is intended; rather than potentially matching only a substring of the part (usually an application name). Without this, we'd also need to correct all of the base suppressions to regex, like done in #8522.e.g.
DependencyCheck/core/src/main/resources/dependencycheck-base-suppression.xml
Lines 13 to 19 in c5f5f68
Main goal as with #8509 is to reduce false negatives from other products with the same "prefiix" in the name.
Some
CpeIdentifiersdon't include the version at all; making the changes in #8509 fail to suppress someVulnerableSoftwareIdentifiers.This change
PropertyTypeimmutable to do soI can split up the regex stuff if preferred; I kept them together since they both touch the same tests.
Related issues
Have test cases been added to cover the new functionality?
yes