Agent Wranglers

STK-95Recommended Open source

Use Trivy for the bill of materials and cosign to sign releases

Write a CycloneDX bill of materials for every release image with Trivy, and sign the image and its bill with cosign in CI.

How to do it

The Trivy you already run for scans also writes SPDX and CycloneDX files, so the bill needs no new tool. cosign 1.0 came out on 28 July 2021, and 3.1.4 shipped on 20 October 2026. It belongs to Sigstore, an OpenSSF project, and its repository had about 6,400 stars in October 2026. Keyless signing uses the CI job's identity, so no private key can leak. Each signature goes into Sigstore's public log, which shows the repository name. Private projects sign with a key held in their secrets store instead. Pin cosign by digest, as the Trivy rule does. What to publish is in Publish what is in each release. Verify before each deploy, as Build releases only in CI and verify them before deploy says. Choose something else when your registry already signs with Notation from the Notary Project, and keep one signer for every image.

Examples

Shell example

IMAGE=registry.example.com/shop@sha256:0000000000000000000000000000000000000000000000000000000000000000
trivy image --format cyclonedx --output sbom.cdx.json "$IMAGE"
cosign sign --yes "$IMAGE"
cosign attest --yes --type cyclonedx --predicate sbom.cdx.json "$IMAGE"

Shell example 2

cosign verify \
  --certificate-identity-regexp '^https://github.com/example/shop/' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  "$IMAGE"

How to check

Each release image has a CycloneDX attestation. cosign verify with the expected CI identity passes, and it fails for an image pushed from a laptop.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/sbom-and-signing">Agent Wranglers software choices playbook</a>. In code you write, add a comment next to it with the same link.