Q: What is SBOM and why does your CI pipeline need to generate one?
An SBOM in your CI pipeline is a machine-readable inventory (a software bill of materials) of every package and library inside a build artifact.
Want to master this scenario in a live sandbox? KodeKloud's Enterprise GitOps with ArgoCD & Kubernetes Rollouts covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: An <strong>SBOM in your CI pipeline</strong> is a machine-readable inventory (a software bill of materials) of every package and library inside a build artifact. Generating it on each build gives you provenance and lets you answer "are we affected?" within minutes when a new vulnerability is published, instead of re-scanning old images. Interviewers ask this to test supply chain security awareness: format choice (CycloneDX or SPDX), where the SBOM is generated, how it is stored with the image, and how it is used to gate releases.
What an SBOM is and why CI should produce it
The SBOM is evidence tied to a specific build.
- Content: package names, versions, licenses, hashes and dependency relationships, for OS packages and language dependencies.
- Formats: CycloneDX and SPDX are the two common standards; most scanners read both.
- Incident response: when a new CVE appears, search stored SBOMs instead of pulling and scanning every old image.
- Compliance: customers and auditors increasingly request SBOMs and license data per release.
Generating the SBOM from the built image
Scan the final artifact, not just the source tree, so base image packages are included.
# Generate from the pushed image
syft registry.example.com/my-app:1.4.2 -o cyclonedx-json=sbom.cdx.json
# Or let BuildKit attach it during build
docker buildx build --sbom=true --push -t registry.example.com/my-app:1.4.2 .
# Quick sanity check: component count
jq '.components | length' sbom.cdx.json
- Syft: catalogues an image, directory or archive and emits CycloneDX or SPDX JSON.
- BuildKit attestation:
docker buildx build --sbom=trueattaches an SBOM attestation to the pushed image. - Pin by digest: record the image digest in the SBOM metadata so the file maps to one exact artifact.
- Artifact upload: keep the SBOM as a build artifact even if it is also attached to the registry.
Scanning the SBOM and gating the pipeline
Use the SBOM as input to vulnerability and license checks.
grype sbom:sbom.cdx.json --fail-on high
trivy sbom sbom.cdx.json --severity HIGH,CRITICAL --exit-code 1
- Grype: scans an SBOM directly and can fail the build above a severity threshold.
- Trivy:
trivy sbomscans an existing SBOM file. - Policy: fail on fixable high or critical findings, allow documented exceptions with expiry.
- Rescan later: run the same scan on a schedule, because new CVEs affect old SBOMs.
Attaching and signing the SBOM
An unsigned file next to an image proves little.
cosign attest --yes --key cosign.key --type cyclonedx \
--predicate sbom.cdx.json registry.example.com/my-app@sha256:<digest>
cosign verify-attestation --key cosign.pub --type cyclonedx \
registry.example.com/my-app@sha256:<digest>
# GitHub Actions
- uses: anchore/sbom-action@v0
with:
image: registry.example.com/my-app:1.4.2
format: cyclonedx-json
output-file: sbom.cdx.json
- cosign attest: binds the SBOM to the image digest as a signed in-toto attestation stored in the registry.
- Verification: consumers or admission controllers verify the attestation before deployment.
- Retention: keep SBOMs for as long as the release is supported.
- Workflow example: a GitHub Actions step produces and uploads the file for every build.
Limits and production practice
An SBOM is inventory, not proof of safety.
- Accuracy limits: statically linked binaries or vendored code can be missed; compare tools when completeness matters.
- Vulnerability context: combine with VEX statements to mark findings as not exploitable.
- Admission control: enforce signed attestations with Kyverno or Sigstore policy-controller.
- Reproducibility: generate in the same pipeline run that builds, never later from a mutable tag.
- An SBOM is a machine-readable list of all components in a build, in CycloneDX or SPDX format, generated per build in CI.
- I generate it from the final image digest with Syft or BuildKit, then validate it by scanning with Grype or Trivy.
- I sign and attach it with cosign, fail the pipeline on fixable high findings, and re-scan stored SBOMs on a schedule.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Generating the SBOM from source manifests only It misses OS packages from the base image, so scans under-report real exposure.
- Referencing the image by a mutable tag The SBOM may describe a different artifact than what is deployed; use the digest.
- Generating an SBOM but never storing or scanning it again The value is in looking up affected releases later when new CVEs are published.
- Shipping the SBOM unsigned Without an attestation bound to the digest nobody can trust it was produced by your pipeline.