Fix CPE update field handling for non-JVM packages #2845
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.
Fix CPE update field handling for non-JVM packages
Problem
The CPE matching logic was only considering the
update
field for JVM packages, but it should also handle other packages where the update field contains important version information. For example, with NTP and OpenSSH:The current code would only use
4.2.8
for version matching, ignoring thep18
update field, which should be combined to form the complete version4.2.8p18
.Solution
combineVersionAndUpdate
function that handles CPE version and update field combinations for all package typesMatchPackageByCPEs
andfilterCPEsByVersion
functions to use the new general functiontransformJvmVersion
functionChanges
combineVersionAndUpdate
function ingrype/matcher/internal/cpe.go
Testing
Before
After