feat(sbom): lockfile hashes and download URLs in the SBOM (#508, part B1) #511

Merged
sharang merged 1 commits from feat/508-sbom-data into main 2026-10-06 14:48:41 +00:00
Owner

Part B1 of #508: the hash of each component's deployable file, and its download URL. BSI TR-03183-2 requires both (the hash as SHA-512). B2 (maintainer URLs) follows.

What

  • SbomEntry gains hashes (CycloneDX alg + lowercase hex) and download_url. Both are optional in storage, so existing rows decode unchanged.

  • CycloneDX export:

    • the component carries hashes;
    • with a URL, it also gets an externalReferences entry of type distribution carrying the URL and the hashes. That's where the TR and sbomqs look.
  • syft: the same run also writes -o syft-json=<tmp>. Syft's own format keeps the lockfile metadata that its CycloneDX output drops:

    Lockfile Hash URL
    package-lock.json, yarn.lock integrity (SRI) resolved (yarn's #sha1 fragment stripped)
    pnpm-lock.yaml resolution.integrity resolution.tarball, else npmjs
    packages.lock.json contentHash (SHA-512 of the .nupkg) nuget.org flat container
    Cargo.lock checksum (SHA-256) static.crates.io, if the source is the crates.io index
  • Derived URLs (npmjs, nuget.org) are used only when the project takes the package from the public registry. This reuses the private-registry policies of the licence lookups: .npmrc/.yarnrc.yml scopes, and nuget.config sources with package source mapping. A private package keeps its hash but gets no URL.

Result

sbomqs bsi-v2.1 on the test document: 6.67 D → 7.22 C. The deployable hash is met for npm/NuGet; the download URI also for Cargo.

Still open, documented in docs/guide/sbom.md:

  • Cargo's SHA-256, which the TR rejects;
  • Python and Maven (no lockfile hash read yet);
  • committed binaries, which are inventory findings, not SBOM components;
  • the component creator (B2);
  • the concluded licence (by decision).

Tests

  • distribution unit tests: all four lockfile shapes, private-registry cases, and SRI/URL edge cases.
  • Schema validation with hashes and the distribution reference.
  • The #[ignore] sbomqs test now asserts the hash and URL scores.
  • The real syft two-output invocation, checked by hand.
  • 101 SBOM module tests pass.
  • clippy -D warnings: core, agent, MCP, dashboard.

Test plan check 28 (renumbered on merge), marked [visible]. Stage only; no tag.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p

Part B1 of #508: the hash of each component's deployable file, and its download URL. BSI TR-03183-2 requires both (the hash as SHA-512). B2 (maintainer URLs) follows. ## What - **`SbomEntry`** gains `hashes` (CycloneDX alg + lowercase hex) and `download_url`. Both are optional in storage, so existing rows decode unchanged. - **CycloneDX export:** - the component carries `hashes`; - with a URL, it also gets an `externalReferences` entry of type `distribution` carrying the URL and the hashes. That's where the TR and sbomqs look. - **syft:** the same run also writes `-o syft-json=<tmp>`. Syft's own format keeps the lockfile metadata that its CycloneDX output drops: | Lockfile | Hash | URL | |---|---|---| | `package-lock.json`, `yarn.lock` | `integrity` (SRI) | `resolved` (yarn's `#sha1` fragment stripped) | | `pnpm-lock.yaml` | `resolution.integrity` | `resolution.tarball`, else npmjs | | `packages.lock.json` | `contentHash` (SHA-512 of the `.nupkg`) | nuget.org flat container | | `Cargo.lock` | `checksum` (SHA-256) | static.crates.io, if the source is the crates.io index | - **Derived URLs** (npmjs, nuget.org) are used only when the project takes the package from the public registry. This reuses the private-registry policies of the licence lookups: `.npmrc`/`.yarnrc.yml` scopes, and `nuget.config` sources with package source mapping. A private package keeps its hash but gets no URL. ## Result sbomqs bsi-v2.1 on the test document: 6.67 D → **7.22 C**. The deployable hash is met for npm/NuGet; the download URI also for Cargo. **Still open, documented in `docs/guide/sbom.md`:** - Cargo's SHA-256, which the TR rejects; - Python and Maven (no lockfile hash read yet); - committed binaries, which are inventory findings, not SBOM components; - the component creator (B2); - the concluded licence (by decision). ## Tests - `distribution` unit tests: all four lockfile shapes, private-registry cases, and SRI/URL edge cases. - Schema validation with hashes and the distribution reference. - The `#[ignore]` sbomqs test now asserts the hash and URL scores. - The real syft two-output invocation, checked by hand. - 101 SBOM module tests pass. - clippy `-D warnings`: core, agent, MCP, dashboard. Test plan check 28 (renumbered on merge), marked [visible]. Stage only; no tag. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang added 1 commit 2026-10-06 14:39:14 +00:00
feat(sbom): lockfile hashes and download URLs in the SBOM (#508, part B1)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m37s
a1af4b0ffe
- SbomEntry gains hashes (alg + hex) and download_url, both optional in
  storage. The CycloneDX export lists the hashes on the component and, with
  a download URL, as an externalReferences "distribution" entry: BSI
  TR-03183-2's hash of the deployable component and its URI.
- One syft run now also writes its own JSON format, which keeps what the
  lockfiles say about each package's file: npm/yarn integrity + resolved,
  pnpm resolution.integrity (+ tarball), NuGet packages.lock.json
  contentHash (SHA-512 of the .nupkg), Cargo checksum (SHA-256).
- A URL the lockfile does not name is the public registry's (npmjs,
  nuget.org flat container, static.crates.io), only when the project takes
  the package from there: the npm and NuGet registry policies of the licence
  lookups decide.
- sbomqs bsi-v2.1 on the test document: 6.67 D -> 7.22 C (deployable hash
  met for npm/NuGet).
- Docs: what the export carries and what stays open. Test plan check 29.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
sharang force-pushed feat/508-sbom-data from a78f1e3d5a to a1af4b0ffe 2026-10-06 14:39:14 +00:00 Compare
sharang merged commit cd943b8d67 into main 2026-10-06 14:48:41 +00:00
Sign in to join this conversation.