Skip to content

feat: add vulnerable version ranges to CycloneDX output - #3519

Merged
spiffcs merged 2 commits into
anchore:mainfrom
somaz94:feat/cyclonedx-affected-ranges
Aug 10, 2026
Merged

feat: add vulnerable version ranges to CycloneDX output#3519
spiffcs merged 2 commits into
anchore:mainfrom
somaz94:feat/cyclonedx-affected-ranges

Conversation

@somaz94

@somaz94 somaz94 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This populates the affects[].versions[] entries in Grype's CycloneDX output, addressing #3512.

Today the CycloneDX affects array only carries a ref, so consumers cannot tell from the
CycloneDX document whether a vulnerability has a fix available. This change adds:

  • the matched package version, recorded with status affected
  • for vulnerabilities with known fixed-in versions, each fix as a vers-syntax range
    (vers:<scheme>/>=<version>) with status unaffected, so consumers can spot available
    fixes and automate remediation

The vers scheme is derived from the package PURL type and falls back to generic. When
neither a version nor a fix is known, the versions array is omitted (no change for those).

One design point worth your read: I model the fix boundary as >=<fixedVersion> / unaffected
rather than a <<fixedVersion> / affected range, because Grype reliably knows the fix version
and 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 the
    affected / single fix / multiple fixes / not-fixed / missing-PURL / empty cases
  • regenerated the CycloneDX golden files with -update and reviewed the diff
  • go build ./..., gofmt, go vet, and golangci-lint run on the package are clean (no new findings)

closes #3512

Signed-off-by: somaz <genius5711@gmail.com>
@somaz94
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
@somaz94

somaz94 commented Jul 28, 2026

Copy link
Copy Markdown
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
spiffcs merged commit 308a399 into anchore:main Aug 10, 2026
16 checks passed
@spiffcs

spiffcs commented Aug 10, 2026

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include vulnerable ranges in CycloneDX output format

2 participants