Skip to content

✨ feat(sbom): link and check other tools' SBOMs - #8

Merged
gaborbernat merged 11 commits into
mainfrom
other-sboms
Nov 9, 2026
Merged

gaborbernat merged 11 commits into
mainfrom
other-sboms

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Wheels built with maturin or repaired with auditwheel already carry an SBOM of their own: maturin lists the Rust crates, auditwheel the system libraries it bundled. python-sbom's SBOM sat next to them without naming them, and python-sbom validate skipped maturin's .cyclonedx.json file, reporting "no SBOM found" on a wheel that held one. 🔗

Now the SBOM python-sbom writes links to every other file in the wheel's .dist-info/sboms/ directory, so a scanner reading it can find the Rust crates or bundled libraries too. validate checks maturin's file alongside the .cdx.json ones.

The how-to guides gain a backends section with one page per build backend: hatchling, pdm-backend, setuptools, meson-python, scikit-build-core, maturin, flit-core, poetry-core and uv-build, plus the wrapper page for any other. Each page pulls its code from an example project under docs/examples/, and one tox environment per backend (tox r -e example-maturin, or tox r -m examples for all) builds that project and compares python-sbom's output with what the page shows. CI runs them, so a page that drifts from the code fails the check. 📚

Architecture

When python-sbom reads a wheel, it now also collects the other files under sboms/ with their SHA-256, leaving out python-sbom's own so a second embed does not link to the copy it replaces. The root component gets one CycloneDX bom external reference per file: a URL relative to its own SBOM, which sits in the same directory, plus the file's digest, so a reader can tell whether a later step changed it. The links are format-agnostic, so an SPDX file gets linked too; validate still checks CycloneDX files alone.

Impact

I checked two wheels from PyPI. On peryx 2026.1104.0, validate now passes and checks maturin's SBOM. On pipdeptree 4.2.14's musllinux wheel it now fails: the auditwheel.cdx.json that auditwheel 6.8.2 wrote lists the root package twice under the same bom-ref, which CycloneDX forbids, because auditwheel puts the same component in both metadata.component and components. The auditwheel example hits the same failure, and its page says so. I reported it as pypa/auditwheel#750. Until auditwheel fixes it, validate fails on wheels where auditwheel copied in a library and wrote its SBOM.

The backend guides moved from how-to/<backend> to how-to/backends/<backend>, so links to the old pages on Read the Docs break unless the project adds redirects there. The delocate example runs only on the macOS job, and the test compares output with the wheel tags masked, so the macOS wheel name its page shows is not checked.

@gaborbernat gaborbernat added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 9, 2026
Every backend gets an example project under docs/examples and a tox
environment of its own, so tox r -e maturin builds and checks just that
project and tox r -m examples runs all of them. Each test replays the
session the docs show and compares python-sbom's output with it, so the
docs fail CI when they drift. CI runs every example on Linux and
delocate on macOS.
The backend guides move under how-to/backends, one page per backend,
and every page includes its configuration and session from the example
projects instead of inline copies. The validate guide now says which
checks an SBOM another tool wrote gets.
@gaborbernat
gaborbernat marked this pull request as ready for review November 9, 2026 23:15
@gaborbernat
gaborbernat merged commit 0c2f96f into main Nov 9, 2026
37 checks passed
@gaborbernat
gaborbernat deleted the other-sboms branch November 9, 2026 23:15
gaborbernat added a commit to tox-dev/tox that referenced this pull request Nov 10, 2026
A labeled factor value that contains a dash, such as `flit-core`,
generated its environment, but `{factor:label}` inside that environment
resolved to the wrong value. With `factors = [{backend = ["flit",
"flit-core"]}]`, `build-flit-core` substituted `flit`; with no shorter
value to fall back on, it substituted the default, which is empty unless
set. tox raised no error either way. I hit this turning per-backend
environments into one `env_base` template in
[tox-dev/python-sbom#8](tox-dev/python-sbom#8),
where `flit-core` had to become `flit_core`. 🐛

The cause was in
[`replace_factor`](https://github.com/tox-dev/tox/blob/5fc90aaaff3ce80c0d004c8bd3d46c29f480c2d9/src/tox/config/loader/replacer.py#L1179-L1183):
it split the environment name on `-` and looked each value up among the
single segments, so a value spanning two segments never matched. The
substitution now matches a value as a run of consecutive segments of the
name, and when several values match, the longest wins, so `flit-core`
beats `flit`. Values without a dash resolve as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant