Skip to content

fix(purl): resolve Docker Hardened Images apk/dhi and deb/dhi PURLs - #5715

Open
aubm wants to merge 2 commits into
google:masterfrom
aubm:dhi-purl-mapping
Open

fix(purl): resolve Docker Hardened Images apk/dhi and deb/dhi PURLs#5715
aubm wants to merge 2 commits into
google:masterfrom
aubm:dhi-purl-mapping

Conversation

@aubm

@aubm aubm commented Jul 27, 2026

Copy link
Copy Markdown

DHI advisories publish release-lineage PURLs — pkg:apk/dhi/<name> (Alpine lineage) and pkg:deb/dhi/<name> (Debian lineage) — but the reverse PURL map only knew pkg:dhi/<name>, so PURL-form /v1/query requests never resolved to the Docker Hardened Images ecosystem.

This adds (apk, dhi) and (deb, dhi) to the reverse lookup map. The dhi namespace disambiguates from Alpine (apk, alpine) and Debian (deb, debian), so there is no collision.

Forward generation (package_to_purl) is intentionally left as pkg:dhi/…: it receives the ecosystem name after ecosystems.normalize() has stripped the :Alpine:/:Debian: lineage, so it cannot choose apk vs deb — and DHI feed records always ship their own PURL, so that path is not exercised for DHI in practice.

Tests added in osv/purl_helpers_test.py. Relates to #4388.

🤖 Generated with Claude Code

@google-cla

google-cla Bot commented Jul 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@aubm
aubm force-pushed the dhi-purl-mapping branch from 47042a5 to 19b7621 Compare July 27, 2026 17:28
@aubm aubm mentioned this pull request Jul 27, 2026
6 tasks
DHI advisories publish release-lineage PURLs (pkg:apk/dhi/<name> for the
Alpine lineage, pkg:deb/dhi/<name> for the Debian lineage), but the reverse
PURL map only knew pkg:dhi/<name>, so PURL-form queries never resolved to the
Docker Hardened Images ecosystem. Add both (apk,dhi) and (deb,dhi) to the
reverse map; the dhi namespace disambiguates from Alpine (apk,alpine) and
Debian (deb,debian). Forward generation is intentionally left as pkg:dhi/
because package_to_purl only sees the normalized (lineage-stripped) ecosystem
name, and DHI records always ship their own PURL.
@aubm
aubm force-pushed the dhi-purl-mapping branch from 19b7621 to f898c75 Compare July 27, 2026 19:09
@Ly-Joey

Ly-Joey commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Hi @aubm, thanks for picking up the onboarding of Docker Hardened Images!
We have migrated our logic for purl conversion to Go, so please add the PURL conversion logic and tests to go/purl instead.

Per review feedback on google#5715, purl conversion has migrated to Go, so this
implements the Docker Hardened Images mapping in go/purl and removes the
earlier Python implementation.

DHI advisories publish release-lineage PURLs (pkg:apk/dhi/<name> for the
Alpine lineage, pkg:deb/dhi/<name> for Debian). Register parsers for both so
PURL-form queries resolve to the ecosystem; the dhi namespace disambiguates
from Alpine (apk/alpine) and Debian (deb/debian). Generation stays pkg:dhi/.
@aubm

aubm commented Jul 28, 2026

Copy link
Copy Markdown
Author

Hi @aubm, thanks for picking up the onboarding of Docker Hardened Images! We have migrated our logic for purl conversion to Go, so please add the PURL conversion logic and tests to go/purl instead.

Thanks @Ly-Joey! Should be good to test now.

@Ly-Joey
Ly-Joey requested a review from michaelkedar July 31, 2026 00:02

@michaelkedar michaelkedar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Happy to merge this, just one tiny thing

Comment on lines 70 to +77
registerSimple(osvconstants.EcosystemDockerHardenedImages, "dhi", "", nil)
// DHI advisories also publish release-lineage PURLs -- pkg:apk/dhi/<name>
// for the Alpine lineage and pkg:deb/dhi/<name> for Debian -- so map both
// back to the ecosystem for PURL queries. Generation stays pkg:dhi/ (the
// registerSimple above); the dhi namespace disambiguates from Alpine
// (apk/alpine) and Debian (deb/debian), so there is no parser collision.
registerParser("apk", "dhi", simpleParser{ecosystem: osvconstants.EcosystemDockerHardenedImages})
registerParser("deb", "dhi", simpleParser{ecosystem: osvconstants.EcosystemDockerHardenedImages})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: just to make this easier to visually scan, can we move all the dhi stuff later in the init function (so all the regular non-namespace ecosystems stay together, and this comment doesn't break it up)

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.

3 participants