Skip to content

Add PURL generation from VCS URL for SPDX NTIA compliance#155

Merged
vpetersson merged 3 commits intomasterfrom
security-contact
Jan 29, 2026
Merged

Add PURL generation from VCS URL for SPDX NTIA compliance#155
vpetersson merged 3 commits intomasterfrom
security-contact

Conversation

@vpetersson
Copy link
Contributor

NTIA Minimum Elements require a unique identifier (PURL) for the main
component. This adds automatic PURL construction for SPDX SBOMs when:

  • No PURL exists on the main package
  • VCS info is available from CI environment

Supported VCS hosts are mapped to their PURL types:

  • github.com -> pkg:github/owner/repo@sha
  • gitlab.com -> pkg:gitlab/owner/repo@sha
  • bitbucket.org -> pkg:bitbucket/owner/repo@sha

This brings SPDX to parity with CycloneDX for NTIA element 4 (unique
identifier) when the SBOM is generated in a CI environment with VCS info.

vpetersson and others added 3 commits January 29, 2026 20:10
NTIA Minimum Elements require a unique identifier (PURL) for the main
component. This adds automatic PURL construction for SPDX SBOMs when:
- No PURL exists on the main package
- VCS info is available from CI environment

Supported VCS hosts are mapped to their PURL types:
- github.com -> pkg:github/owner/repo@sha
- gitlab.com -> pkg:gitlab/owner/repo@sha
- bitbucket.org -> pkg:bitbucket/owner/repo@sha

This brings SPDX to parity with CycloneDX for NTIA element 4 (unique
identifier) when the SBOM is generated in a CI environment with VCS info.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unused `package_name` parameter from `_construct_purl_from_vcs()`
- Remove dead code for PACKAGE_MANAGER category (VCS PURLs are always OTHER)
- Handle GitLab nested groups by using last path component as repo name
- Add test for GitLab nested groups (group/subgroup/project)
- Update docstring to document behavior for self-hosted GitLab detection

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The docstring incorrectly mentioned PACKAGE-MANAGER category but the
code always uses OTHER for VCS-based PURLs (github/gitlab/bitbucket).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vpetersson vpetersson merged commit acfe805 into master Jan 29, 2026
11 checks passed
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.

1 participant