Skip to content

The SBOM of a release carries a serial number, so the release can attest it - #1151

Merged
jmrplens merged 4 commits into
mainfrom
fix/sbom-serial-number
Nov 17, 2026
Merged

jmrplens merged 4 commits into
mainfrom
fix/sbom-serial-number

Conversation

@jmrplens

Copy link
Copy Markdown
Owner

What was wrong

The 4.0.0 release run (https://github.com/jmrplens/phonometry/actions/runs/44065469371) uploaded the wheel and the sdist to PyPI, recorded the build provenance of the wheel, the sdist, the checksum file and the SBOM, and then failed at "Attest the SBOM" with Unsupported SBOM format. Must be valid SPDX or CycloneDX JSON. actions/attest-sbom takes a CycloneDX document only when bomFormat, specVersion and serialNumber are all set, and the release writes the SBOM with cyclonedx-py environment ... --output-reproducible, which leaves the serial number out. A rehearsal never calls the attestation, so no rehearsal could have shown it.

I made the v4.0.0 tag and GitHub Release by hand from the files that run built and attested. 4.0.0 therefore has its build provenance and its PEP 740 attestations on PyPI but no SBOM attestation, and the rebuild on macOS after the release did not run for it; Python CI had rebuilt the same commit on macOS, and its checksums equal the published phonometry-4.0.0.sha256 byte for byte.

Looking at what else a release runs before anything a rehearsal or a pull request has run, I found three more: cyclonedx-python-lib, which writes its own version into the SBOM, was not pinned; PyPI refuses an unknown Trove classifier only at the upload; and the job that verifies the PEP 740 attestation of the published wheel installed whatever pypi-attestations was newest that day.

What is now true

  • scripts/release_sbom.py writes the serial number: urn:uuid: and the version 5 UUID (RFC 9562, URL namespace) of pkg:pypi/phonometry@<version>, # and the SHA-256 of the finished document without its serial number, keys sorted. One SBOM of a release always gets the same serial number and so the same bytes; two different SBOMs never share one, as the CycloneDX schema asks. A serial number the tool wrote is replaced.
  • The script refuses, and writes nothing, an SBOM the attestation would refuse: bomFormat other than CycloneDX, no specVersion, a serial number out of the schema's urn:uuid: form, or a file larger than the 16 MiB the attestation reads. It runs in the build job, so a rehearsal now fails on what stopped 4.0.0.
  • requirements-release.txt pins everything cyclonedx-bom installs on the Python 3.13 the release runs, and the script refuses an SBOM whose metadata.tools names a tool at a version that file does not pin. Written again, the SBOM of a release differs only in what pip resolves that day.
  • requirements-release.txt also pins trove-classifiers, so setuptools holds the classifiers of pyproject.toml to the list PyPI takes and the build refuses one PyPI would refuse, in a rehearsal and on every pull request. The release files of the current tree are the same bytes with it and without it.
  • The job that installs the published version from PyPI verifies the wheel's PEP 740 attestation with pypi-attestations and everything it installs pinned in the new requirements-attestations.txt, read from a sparse checkout of that one file; the job now holds contents: read for that checkout. Dependabot's pip entry at the root covers the new file.
  • SECURITY.md says that 4.0.0 has no SBOM attestation and why, shows the SBOM attestation command for a release after 4.0.0, and says that the rebuild after the release did not run for 4.0.0. The release steps in CONTRIBUTING.md say what a rehearsal and a release now check. The CHANGELOG has a Fixed entry under [Unreleased].

How I checked it

  • New tests in tests/test_release_tooling.py apply the predicate of src/sbom.ts in actions/attest to the file the script writes, compute the serial number by hand from RFC 9562 and hashlib, check that two writings of one document give the same bytes and that another numpy gives another serial number, hold the size limit to the byte, and hold the SBOM's tools to the pins. tests/test_release_workflow.py checks that the build installs the classifier list, and reads every pip install of release.yml and publish-stub.yml, accepting only a pinned requirements file, the run's own wheel, the version it published and pip itself.
  • Red first: the three changed test modules, run in the tree of 4.0.0, give 21 failed and 148 passed (the serial number, attestation, size, tool pin, classifier and pinned install tests). On this branch they pass.
  • The SBOM 4.0.0 published: the attestation's predicate refuses it as it is (no serialNumber). Finished by the new script it gains only "serialNumber": "urn:uuid:6d699f7f-4167-5ee7-b9a9-7d6a4a24265d", the predicate accepts it, the strict JSON validator of cyclonedx-python-lib 11.12.0 for CycloneDX 1.6 finds no error, and finishing it again gives the same bytes. Two fresh writings of the SBOM of the 4.0.0 wheel, each in its own environment with the pinned tools, finish to exactly those bytes.
  • A scratch commit adding the classifier Topic :: Scientific/Engineering :: Acoustics :: Not A Real One built and passed twine check --strict with the 4.0.0 pins; with the new pins the build stops at configuration error: `project.classifiers[9]` must be trove-classifier.
  • The pinned verifier, installed from requirements-attestations.txt on Python 3.14, prints OK: phonometry-4.0.0-py3-none-any.whl for the wheel PyPI serves.
  • ruff check, ruff format --check, mypy src scripts stub/src tests/static_typing and bare mypy, bandit, zizmor, the Markdown prose guards and the 16 test modules that read the release tooling, SECURITY.md, CONTRIBUTING.md and CHANGELOG.md (1318 passed, 7 skipped) are clean. make llms changes nothing, and the 4.0.0 release notes written from this CHANGELOG are the same bytes as before.

What this does not do

  • A rehearsal still does not call actions/attest-sbom; the build job holds the SBOM to the same checks instead, so a release remains the first run that calls the action itself.
  • 4.0.0 stays without an SBOM attestation. The SBOM command in SECURITY.md shows <version> until the next release is stamped.
  • Nothing here makes a release.

…ld refuses one the SBOM attestation would refuse

actions/attest-sbom takes a CycloneDX document only when bomFormat,
specVersion and serialNumber are all set. cyclonedx-py writes no serial
number under --output-reproducible, so the 4.0.0 run failed at "Attest the
SBOM" with "Unsupported SBOM format" after the files were on PyPI. A
rehearsal attests nothing, so no rehearsal could see it.

scripts/release_sbom.py now writes the serial number as urn:uuid: and the
version 5 UUID, in the URL namespace, of pkg:pypi/phonometry@<version>, "#"
and the SHA-256 of the finished document without its serial number. One
SBOM of a release gets the same serial number every time it is written, and
two SBOMs that differ, even of one release, never share one, as the
CycloneDX schema asks of every BOM: a rehearsal run again after numpy
publishes a release writes another document. The script reports an SBOM
without bomFormat CycloneDX, without specVersion, with a serial number out
of the schema's form, or larger than the 16 MiB the attestation reads, in
the build job, where a rehearsal runs it too, and then writes nothing.

The new tests apply the predicate of actions/attest to the file the script
writes, check the serial number against RFC 9562 and SHA-256 computed by
hand, check that two writings of one document give the same bytes and that
another numpy gives another serial number, and hold the size limit to the
byte. Against the script of 4.0.0, 14 of them fail.
…every release after it does

The 4.0.0 run uploaded to PyPI and recorded the build provenance of all four
files, then stopped at the SBOM attestation; the tag and the GitHub Release
were made by hand from the files that run built. SECURITY.md promised an
SBOM attestation for every release from 4.0.0 on and showed the command for
4.0.0, which finds nothing. It now says which releases carry it, shows that
command for a release after 4.0.0, and says that the rebuild on macOS after
the release did not run for 4.0.0, while Python CI had rebuilt the same
commit on macOS to the bytes the release published. The CHANGELOG says what
was fixed.
…, and the build refuses an SBOM a tool at another version wrote

requirements-release.txt pinned cyclonedx-bom 8.0.1 and left the library
that writes the document to its range, cyclonedx-python-lib>=8,<12. The
library writes its own version into metadata.tools, so the SBOM of one
release written with 11.11.0 and with 11.12.0 differs at that line, under
the same serial number. The file now pins everything cyclonedx-bom installs
on the Python 3.13 the release runs, as pip resolves it today, so Dependabot
moves each of them in a pull request.

scripts/release_sbom.py also holds every tool the SBOM names in
metadata.tools to the version requirements-release.txt pins
(cyclonedx-py is the command of cyclonedx-bom), and writes nothing when one
differs or is not pinned. Against the pins of 4.0.0, the SBOM 4.0.0
published is refused for cyclonedx-python-lib 11.12.0, and so is an SBOM
written today with 11.11.0. Two writings of the SBOM of the 4.0.0 wheel,
each from its own environment and its own cyclonedx-py run, now give the
same bytes. The CHANGELOG entry says what that holds to.
…ier of the wheel's attestation is pinned

Two steps of a release run nothing a rehearsal or a pull request runs
first. PyPI refuses an unknown Trove classifier at the upload, and
setuptools checks the classifiers of pyproject.toml only when
trove-classifiers is installed, which requirements-release.txt did not
install. A scratch commit that adds the classifier
"Topic :: Scientific/Engineering :: Acoustics :: Not A Real One" built with
the release tooling and passed twine check --strict; with
trove-classifiers 2026.9.21.13 beside it, the same build stops at
"project.classifiers[9] must be trove-classifier". The pinned list now makes the build, in a rehearsal and
on every pull request, refuse what the upload would. The release files of
the current tree are the same bytes with it and without it.

The job that installs the published version from PyPI verified the PEP 740
attestation of the wheel with whatever pypi-attestations was newest that
day. It now installs it, with everything it brings, from
requirements-attestations.txt, read from a sparse checkout of that one
file (the job now holds contents: read for it, as the verify job does), so
Dependabot moves the verifier in a pull request; the pinned
verifier passes on phonometry 4.0.0 as PyPI serves it. A test reads every
pip install of release.yml and publish-stub.yml and accepts a pinned
requirements file, the run's own wheel, the version it published and pip
itself, and nothing else.
@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Sorry @jmrplens, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 11 hours and 24 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 39f1973 and 7bd2fa3.

Files selected for processing: 10

  • .github/workflows/release.yml
  • CHANGELOG.md
  • CONTRIBUTING.md
  • SECURITY.md
  • requirements-attestations.txt
  • requirements-release.txt
  • scripts/release_sbom.py
  • tests/test_release_tooling.py
  • tests/test_release_workflow.py
  • tests/test_scripts_without_numpy.py
  • 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

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci Workflows, linting and developer tooling area: core Shared internals and cross-cutting code every domain depends on labels Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.35%. Comparing base (39f1973) to head (7bd2fa3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1151   +/-   ##
=======================================
  Coverage   97.35%   97.35%           
=======================================
  Files         477      477           
  Lines       97722    97722           
=======================================
  Hits        95136    95136           
  Misses       2586     2586           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Numerical conformance

All 1899 conformance checks pass, across 111 domains, against 230 normative designations and 121 further published sources

1899/1899 checks pass across 111 domains, against 230 normative designations and 121 further published sources.

Used in the tables below is how much of that clause's published tolerance the deviation consumes: 100 % sits exactly on the limit, 5 % uses a twentieth of the allowance, and a dash means the clause states no two-sided tolerance for the quantity, so there is no budget to spend. It is reported and never used to decide a verdict, which is settled at full precision before any rounding.

Nothing moved: same 1899 checks, same verdicts, same numbers.

Closest to their published limit (top 5)

The rows with the least room left, so the ones a change is most likely to push over.

Standard Quantity Deviation Used
ISO/TR 17534-3:2015 Table 3 Ground-projected path length dp, m 0.005 m 100 %
DIN 4150-2:1999-06 Annex C, Example 5 KB_FTr with hammer b) in the rest hours, Formula (5) -0.005 100 %
DIN 4150-2:1999-06 Annex C, Example 8 KB_FTm over the record with the passage maxima alone -0.0005 100 %
E DIN 4150-2:2023-08 Annex B, Table B.1 KB_FTm,Zug of the metro north by Formula (5) -0.0005 100 %
Jarvis (1996) NPL CIRA(EXT) 010 Appendix B, folio 26 Volume of the coupler of the example, v = pi r^2 L -0.00000000005 m³ 100 %

Pass Tests & coverage: 367860 tests, 0 failures (all green)
Python Version Tests Failures Coverage Status
macos-latest-3.12 40880 0 97.3% Pass Passed
macos-latest-3.13 40880 0 97.3% Pass Passed
macos-latest-3.14 40880 0 97.3% Pass Passed
ubuntu-26.04-3.12 40880 0 97.4% Pass Passed
ubuntu-26.04-3.13 40880 0 97.4% Pass Passed
ubuntu-26.04-3.14 40880 0 97.4% Pass Passed
windows-latest-3.12 40860 0 97.3% Pass Passed
windows-latest-3.13 40860 0 97.3% Pass Passed
windows-latest-3.14 40860 0 97.3% Pass Passed

Full report at this commit: docs/CONFORMANCE.md · docs/conformance.json · full CI artifacts

@sonarqubecloud

Copy link
Copy Markdown

@jmrplens
jmrplens merged commit a1968f9 into main Nov 17, 2026
76 checks passed
@jmrplens
jmrplens deleted the fix/sbom-serial-number branch November 17, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Shared internals and cross-cutting code every domain depends on ci Workflows, linting and developer tooling documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant