feat: add vulnerable version ranges to CycloneDX output#3519
Open
somaz94 wants to merge 1 commit into
Open
Conversation
Signed-off-by: somaz <genius5711@gmail.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.
This populates the
affects[].versions[]entries in Grype's CycloneDX output, addressing #3512.Today the CycloneDX
affectsarray only carries aref, so consumers cannot tell from theCycloneDX document whether a vulnerability has a fix available. This change adds:
affectedvers-syntax range(
vers:<scheme>/>=<version>) with statusunaffected, so consumers can spot availablefixes and automate remediation
The
versscheme is derived from the package PURL type and falls back togeneric. Whenneither a version nor a fix is known, the
versionsarray is omitted (no change for those).One design point worth your read: I model the fix boundary as
>=<fixedVersion>/unaffectedrather than a
<<fixedVersion>/affectedrange, because Grype reliably knows the fix versionand the matched version but not the introduced version. Happy to switch to the affected-range
form if you prefer.
Validation (run locally):
go test ./grype/presenter/cyclonedx/...passes; added table-driven tests covering theaffected / single fix / multiple fixes / not-fixed / missing-PURL / empty cases
-updateand reviewed the diffgo build ./...,gofmt,go vet, andgolangci-lint runon the package are clean (no new findings)closes #3512