Skip to content

sbom: Derive document name and namespace from downstream purl - #1371

Merged
mergify[bot] merged 1 commit into
python-wheel-build:mainfrom
arewm:fix/sbom-document-identity
Oct 16, 2026
Merged

mergify[bot] merged 1 commit into
python-wheel-build:mainfrom
arewm:fix/sbom-document-identity

Conversation

@arewm

@arewm arewm commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Pull Request Description

What

Derive the SPDX document name and documentNamespace from the
downstream purl instead of the resolved upstream version, and append a
random UUID to the namespace for per-document uniqueness:

  • The document name and namespace now honor purl.name /
    purl.version overrides, and the SPDXRef-wheel entry reuses the
    same computed values, so the document header and the package it
    DESCRIBES cannot drift apart.
  • The namespace is now
    <namespace>/<name>-<version>-<uuid>.spdx.json (name and version
    percent-encoded so the namespace stays a valid URI even when
    overrides contain URI-hostile characters), satisfying the SPDX 2.3
    §6.5.1 requirement that the URI be unique per document version.
  • SPDXRef-upstream is unchanged.
  • Settings docstrings updated (they feed the autodoc config
    reference).

Why

Fixes #1370 — when a purl.version override was set (e.g. a rebuild
flow stamping a downstream local-version suffix onto the built
distribution), the document header named the resolved upstream version
while SPDXRef-wheel carried the override, so the SBOM disagreed with
itself and with the artifact it described. The namespace was also
reused verbatim across rebuilds and regenerations.

Tests: reproduction test for the issue (document identity follows the
purl version override, upstream identity preserved), uniqueness test
(two generations produce distinct namespaces), percent-encoding test
for URI-hostile overrides, and updated exact-namespace and
purl-name-override assertions.

Assisted-by: goose (glm-5-3)

@arewm
arewm requested a review from a team as a code owner October 14, 2026 20:36
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: python-wheel-build/fromager/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4b3a5606-619f-4a7c-940b-48c174b4b072
📥 Commits

Reviewing files that changed from the base of the PR and between cb40929 and 06f50f5.

📒 Files selected for processing: 1
  • src/fromager/packagesettings/_models.py
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/fromager/packagesettings/_models.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

SBOM generation now derives the document name and namespace from the downstream purl name and version. The namespace percent-encodes those values and includes a UUID. The wheel entry uses the same downstream name and version. Tests cover overridden purl values, namespace uniqueness, and encoding.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 06f50

The documented SPDX identity matches the generated output for the supported values examined. No confirmed issue blocks merging.

Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue [#1370] requires downstream identity alignment, unique namespaces, and unchanged upstream identity. The summary reports that generate_sbom derives the document name and namespace from the down…
Out of Scope Changes check Passed The reported changes stay within [#1370]. Production changes implement document identity and namespace generation. Tests verify those changes. Settings docstrings describe the resulting behavior and s…
Title check Passed The title clearly and concisely describes the main change: deriving the SBOM document name and namespace from the downstream purl.
Description check Passed The description directly explains the purl-based identity changes, UUID uniqueness, percent-encoding, preserved upstream identity, tests, and issue addressed.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify mergify Bot added the ci label Oct 14, 2026
rd4398
rd4398 previously approved these changes Oct 14, 2026

@rd4398 rd4398 left a comment

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.

This looks good to me! Thanks for the fix

@mergify

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

mprpic
mprpic previously approved these changes Oct 14, 2026

@mprpic mprpic left a comment

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.

LGTM!

Comment thread src/fromager/packagesettings/_models.py
The document header previously used the resolved upstream version, so
it could disagree with the SPDXRef-wheel package entry it DESCRIBES
when purl name/version overrides were set. A random UUID suffix keeps
the namespace unique per generated document as SPDX 2.3 requires, and
percent-encoding the name and version keeps it a valid URI even when
overrides contain URI-hostile characters.

Assisted-by: goose (glm-5-3)
Signed-off-by: arewm <arewm@users.noreply.github.com>
@arewm
arewm dismissed stale reviews from mprpic and rd4398 via 06f50f5 October 15, 2026 00:06
@arewm
arewm force-pushed the fix/sbom-document-identity branch from cb40929 to 06f50f5 Compare October 15, 2026 00:06
@mergify
mergify Bot merged commit 45241aa into python-wheel-build:main Oct 16, 2026
74 checks passed
@LalatenduMohanty

Copy link
Copy Markdown
Member

Thank you for this fix. We found two related SBOM version problems. They existed before this PR:

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SBOM document name and namespace use resolved version instead of purl-overridden wheel version; namespace lacks per-document uniqueness

4 participants