feat: add vulnerable version ranges to CycloneDX output - #3519
Merged
Conversation
Signed-off-by: somaz <genius5711@gmail.com>
somaz94
marked this pull request as ready for review
June 23, 2026 09:40
…cted-ranges # Conflicts: # grype/presenter/cyclonedx/testdata/snapshot/TestCycloneDxPresenterDir.golden # grype/presenter/cyclonedx/testdata/snapshot/TestCycloneDxPresenterImage.golden
Contributor
Author
|
Friendly ping — this has been green (14/14) for about five weeks with no review yet. It adds vulnerable version ranges to the CycloneDX output, so downstream consumers can tell which versions a finding actually applies to. Happy to rebase, or to split the schema change from the formatting change if that would make it easier to review. |
spiffcs
approved these changes
Aug 10, 2026
Contributor
|
Apologies @somaz94. We're a small team so it's hard to get to all the PR across all our tools. Thank you for the contribution here! You should see it in the next release. |
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