Repository navigation
feat(purl): build package urls from the ecosystem they belong to - #1398
Open
alex-powell wants to merge 2 commits into
Open
alex-powell wants to merge 2 commits into
alex-powell wants to merge 2 commits into
Conversation
compareVersions, looksLikeVersion, isPreReleaseVersion, and normalizeAdvisoryVersion keep their names. Passing a PyPI ecosystem selects PEP 440. Other callers stay on semver, including sort and filter callbacks that pass an index. A PyPI advisory whose only fix is 2026.3.post1 is reported. scripts/check-pep440.ts judges a pinned requirements file against OSV and compares a PyPI sample with packaging.
cursor
Bot
force-pushed
the
feat/ecosystem-purls
branch
from
October 25, 2026 03:23
7b7a78e to
c4823e9
Compare
An npm URL is still buildPurl. buildEcosystemPurl adds PyPI, where the name is lowercased and underscores become hyphens, and returns null when the ecosystem has no rule. SPDX and CycloneDX publish only npm.
cursor
Bot
force-pushed
the
feat/ecosystem-purls
branch
from
October 25, 2026 03:26
c4823e9 to
2904c36
Compare
This branch has not been deployed
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.
Fixes #1402
Refs #672
Depends on #1397, review the last commit.
What changed
buildPurl(name, version)still builds an npm package URL, including the%40encoding of a scoped name.buildEcosystemPurl(ecosystem, name, version)is new. Forpypiit lowercases the name and replaces_with-, and it leaves dots in place, soDjango_RESTbecomespkg:pypi/django-rest@...andpdfminer.sixstayspkg:pypi/pdfminer.six@.... An ecosystem with no rule returns null.SPDX and CycloneDX call
purlForSbom. That returns the npm URL, and null for every other ecosystem. A PyPI URL can be built. It is not written into either document. Existing tests are unchanged. The new cases are intests/utils/ecosystem-purl.test.ts. No runtime dependency was added.Done when
examples/vscode(1374 package URLs, 172 CycloneDX vulnerabilities) matched the parent commit after removing timestamps, the SPDX document namespace, and the CycloneDX serial number. The npm encoder also matched on 400, 1604, and 1788 lockfile entries, with 0 differences.tests/utils/ecosystem-purl.test.tsexpectspkg:pypi/django-rest@3.14.0,pkg:npm/%40babel/core@7.0.0, and null for Maven. The same file expectszope.interfaceandpdfminer.sixto keep their dots, and it expects PyPI and Maven packages to be absent from both SBOM documents.package.jsonis unchanged.packageurl-python 0.17.6 and packageurl-js 2.0.1 parsed the PyPI examples above and returned the same type, name, and version.
normalize_namein packageurl-python agreed with the emitted PyPI names.Verified against a production requirements.txt
I took the 20 exact pins from the pinned
requirements.txtof the production Python backend I mentioned in #672 and ran them throughbuildEcosystemPurl("PyPI", ...)andpurlForSbomfrom this commit (2904c36).purlForSbomreturns null (kept out of SPDX and CycloneDX)The one name the rule changes is
pdfminer.six, which is emitted aspkg:pypi/pdfminer.six@20260107with its dot kept, and OSV resolves that purl to the same result as the ecosystem query.