Skip to content

feat(cg/transformers): add chainguard osv transformer#3474

Open
crosleyzack wants to merge 7 commits into
anchore:mainfrom
crosleyzack:crosley/chainguard-osv-transformer
Open

feat(cg/transformers): add chainguard osv transformer#3474
crosleyzack wants to merge 7 commits into
anchore:mainfrom
crosleyzack:crosley/chainguard-osv-transformer

Conversation

@crosleyzack

@crosleyzack crosleyzack commented May 29, 2026

Copy link
Copy Markdown
Contributor

What

Add Chainguard transformer for new OSV feed. This also sets the architecture on packages so vuln matches can be filtered by architecture. Test images from Chainguard are currently being reviewed and should be in our GCR bucket soon.

Why

Allows grype to convert the vunnel output into vuln matches

Notes

Similar but updated version of #3255

Part of Chainguard issue INT-520

Comment thread grype/db/v6/blobs.go Outdated
Comment thread grype/db/v6/vulnerability.go Outdated
Comment thread grype/db/v6/vulnerability_test.go
@crosleyzack crosleyzack changed the title feat(cg/transformers) INT-512: add chainguard osv transformer feat(cg/transformers): add chainguard osv transformer May 29, 2026
Comment thread grype/db/v6/build/transformers/osv/transform_cg.go
@crosleyzack crosleyzack force-pushed the crosley/chainguard-osv-transformer branch 2 times, most recently from 867ffd9 to 2cc549e Compare June 2, 2026 17:08
Comment on lines +9 to +19
// OSVVulnerability extends the standard OSV Vulnerability model with additional
// fields used by Chainguard/Wolfi advisories that aren't yet in the osv-scanner library.
type OSVVulnerability struct {
models.Vulnerability

// TODO should this be put into upstream osv-scanner?
// Upstream contains IDs of upstream vulnerabilities that this advisory addresses.
// Per OSV spec, this is semantically correct for distro advisories that reference
// upstream CVEs. Included alongside "related" for backwards compatibility.
// See: https://ossf.github.io/osv-schema/
Upstream []string `json:"upstream,omitempty"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be put into the upstream models.Vulnerability?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"github.com/google/osv-scanner/pkg/models" is deprecated and not getting updates any more. We might need to implement our own structs in this repo soon. I think this approach is ok for this PR.

@crosleyzack crosleyzack force-pushed the crosley/chainguard-osv-transformer branch 2 times, most recently from df13edc to 8e81f7c Compare June 5, 2026 19:19
Signed-off-by: crosleyzack <mail@crosleyzack.com>
Signed-off-by: crosleyzack <mail@crosleyzack.com>
Signed-off-by: crosleyzack <mail@crosleyzack.com>
Signed-off-by: crosleyzack <mail@crosleyzack.com>
@crosleyzack crosleyzack force-pushed the crosley/chainguard-osv-transformer branch from 8e81f7c to 81fbdad Compare June 8, 2026 18:08
Signed-off-by: crosleyzack <mail@crosleyzack.com>
@crosleyzack crosleyzack force-pushed the crosley/chainguard-osv-transformer branch from 4817276 to d9d6fde Compare June 10, 2026 01:20
Comment on lines +41 to +46
// setArchFromPURL runs for every format: no SBOM decoder populates grype's
// pkg.Arch field directly, so without this the architecture qualifier on
// distro-keyed vulnerabilities can't filter by package arch.
enhancers := []Enhancer{setArchFromPURL}
if fmtID != syftjson.ID {
enhancers = purlEnhancers(applyChannel)
enhancers = append(enhancers, setUpstreamsFromPURL, setDistroFromPURL(applyChannel))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want normal scans to also include the arch information if available

Comment on lines +38 to +41
// setArchFromPURL is applied for image scans because syft does not populate
// grype's pkg.Arch field directly — without this the architecture qualifier
// on distro-keyed vulnerabilities can't filter by package arch.
packages := FromCollection(s.Artifacts.Packages, s.Relationships, config.SynthesisConfig, setArchFromPURL)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include arch information in sbom scans

Signed-off-by: crosleyzack <mail@crosleyzack.com>
@crosleyzack crosleyzack force-pushed the crosley/chainguard-osv-transformer branch from fc60746 to 6d183ed Compare June 10, 2026 18:06
Signed-off-by: crosleyzack <mail@crosleyzack.com>
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.

2 participants