Skip to content

✨ feat(release): publish SBOMs as release assets - #3299

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:feat/release-sbom-assets
Sep 23, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:feat/release-sbom-assets

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

The CycloneDX SBOM reaches users only inside the wheel, and the release workflow keeps a copy as a workflow artifact that expires. Someone auditing the zipapp, or running a scanner that reads SPDX only, has no file to download. I attach virtualenv.cdx.json and an SPDX 2.3 rendering, virtualenv.spdx.json, to every GitHub release. Both go into the one gh release create call, because immutable releases reject assets uploaded later.

tasks/cyclonedx_to_spdx.py renders the SPDX document from the CycloneDX document the wheel build embedded, using the standard library alone. Generating it in hatch_build.py would put a second SBOM in the wheel. I validate the output with spdx-tools, the SPDX project's own Python library, in the tooling envs only: tox r -e spdx renders and runs pyspdxtools, and tasks/validate_sbom.py parses and validates the rendering in the readme env. The library imports beartype, whose latest release fails to import on Python 3.15, so I kept it out of the test dependencies and pinned both envs to Python 3.14. The output depends on its input alone: created comes from the CycloneDX timestamp, which follows SOURCE_DATE_EPOCH, and the document namespace ends in the CycloneDX serial, which hatch_build derives from the content. The SPDX side keeps packages, SHA-256 hashes, declared licenses, purls, containment, dependencies and build tools. Per-file hashes stay in CycloneDX only: SPDX 2.3 requires a SHA-1 on every file and wheel RECORD files carry SHA-256. The same goes for the build formulation, which SPDX 2.3 has no field for.

A second actions/attest step attests the SPDX file against the sdist and wheel under https://spdx.dev/Document/v2.3. After publication the verify job downloads both assets, compares the CycloneDX one with the SBOM inside the published wheel and the SPDX one with the build artifact, and validates the SPDX file with pyspdxtools. For both predicate types it then runs gh attestation verify on the sdist and wheel and checks that the attested predicate matches the asset. I ran that attestation check against the 21.10.0 wheel and sdist with the CycloneDX predicate. The SPDX predicate has no attestation to check until the next release. #3305 describes these assets for users; here docs/development.rst only covers how the SBOM gets generated and which tox env renders and validates it. 📦

@gaborbernat gaborbernat added enhancement security Fixes a vulnerability or hardens the supply chain, CI or release labels Sep 22, 2026
@gaborbernat
gaborbernat force-pushed the feat/release-sbom-assets branch from 4fe1d1d to a64f2a4 Compare September 22, 2026 23:40
@gaborbernat
gaborbernat force-pushed the feat/release-sbom-assets branch from a64f2a4 to 09b7b46 Compare September 22, 2026 23:58
The CycloneDX SBOM only reached users inside the wheel or as a
workflow artifact that expires. Scanners that read SPDX had nothing.

Render the embedded CycloneDX document as SPDX 2.3 with the standard
library, validate the result with spdx-tools in the tooling envs,
attest it against the sdist and wheel, and attach both files in the
single gh release create call that immutable releases require. The
verify job downloads both assets and checks them against the wheel
and the attestations.

spdx-tools imports beartype, which fails on Python 3.15, so it stays
out of the test dependencies and the readme and spdx envs pin 3.14.
@gaborbernat
gaborbernat force-pushed the feat/release-sbom-assets branch from 09b7b46 to f56cc88 Compare September 23, 2026 00:08
@gaborbernat gaborbernat changed the title feat(release): publish SBOMs as release assets ✨ feat(release): publish SBOMs as release assets Sep 23, 2026
@gaborbernat
gaborbernat merged commit 1a9fe24 into pypa:main Sep 23, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant