Add match details to CycloneDX vulnerabilities#3568
Open
msnandhis wants to merge 1 commit into
Open
Conversation
Signed-off-by: msnandhis <45960035+msnandhis@users.noreply.github.com>
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.
Summary
Include Grype match details in CycloneDX vulnerability entries as a custom property.
Each vulnerability with match details now has a
grype:match:detailsproperty whose value is the completematchDetailsarray encoded as JSON. Vulnerabilities without match details do not receive the property.Motivation
CycloneDX output currently omits the evidence that explains how Grype matched a vulnerability. Consumers need that information to distinguish direct and indirect matches and make better-informed triage decisions.
Approach
models.MatchDetailscollection without changing its shape.grype:match:detailsproperty so the complete ordered collection survives both CycloneDX JSON and XML output.The issue confirms that CycloneDX properties are the intended extension point, but it does not prescribe the exact property name or whether the data should be flattened. This draft uses a single JSON-valued property to preserve nested match evidence losslessly. Maintainer feedback on that representation is welcome before this is marked ready.
Testing
go test ./grype/presenter/cyclonedx -count=1make static-analysisgit diff --checkTests cover direct and indirect match details, omission for empty details, JSON and XML round trips, and serialization errors.
Closes #3513
AI assistance
AI-assisted tools were used during implementation and test development. I reviewed the resulting diff, verified the behavior locally, and take responsibility for the contribution.