Production-grade guide to sbom implementation guide covering architecture patterns, implementation strategies, testing approaches, and operational best practices for enterprise engineering teams.
An SBOM (Software Bill of Materials) is a formal, machine-readable inventory of software components used to build and run a system. This guide details how to implement SBOMs across a DevSecOps pipeline, from initial capture to integration with vulnerability management, compliance, and deployment. It is essential when enforcing supply chain security, automating compliance reporting, or responding to incidents requiring full component traceability.
The first step is capturing a complete, accurate inventory of all dependencies, including transitive ones. Use a tool that generates a standard SBOM format—such as SPDX or CycloneDX—and ensure it runs consistently across build systems.
For a Go project using go mod, generate an SBOM with:
go mod tidy
spdx-gen --output sbom.spdx --format spdx
This produces a .spdx file with the full dependency graph, including version, license, and source URLs.
For a Node.js project with package.json and package-lock.json, use cyclonedx-npm:
npx cyclonedx-npm --output sbom.cdx.json
This generates a CycloneDX JSON file with all dependencies, metadata, and resolved versions.
To standardize across multiple languages and build types, use syft, a CLI tool from the Syft project:
syft . -o cyclonedx-json -o spdx -o json -o table
This produces multiple SBOM formats from a single command. The syft command reads the current directory, resolves all dependencies, and outputs a full SBOM with:
name, version, purl (Package URL), license, hash, and origin metadatadependencies as a list of purl referencescomponent metadata for each packageThe default output format is CycloneDX JSON, but the -o flag supports spdx, json, and table formats.
--all flag with syft to capture all layers of a container image: syft docker://myapp:latest --all -o cyclonedx-json -o table
This includes base OS packages, language runtime, and application-level dependencies.
--file to specify a custom input file, e.g., --file Dockerfile to generate an SBOM from a Dockerfile’s build context. - name: Generate SBOM
run: |
syft . -o cyclonedx-json -o spdx -o json -o table
outputs:
sbom-cdx: ${{ steps.generate-sbom.outputs.cdx }}
sbom-spdx: ${{ steps.generate-sbom.outputs.spdx }}
syft runs in a deterministic environment: use the same base image, pinned dependencies, and consistent filesystem layout.A generated SBOM is only as good as the input data. Validate it by checking for missing or incorrect metadata.
Use cyclonedx-cli to validate a CycloneDX JSON file:
cyclonedx validate --schema ./schema/cyclonedx.schema.json sbom.cdx.json
This checks for required fields, correct types, and valid purl formats.
Check that all purl values are correctly formatted. A purl should follow the pattern:
pkg:<type>/<namespace>/<name>@<version>
Example: pkg:github/owner/[email protected]
Common issues:
version field in componentspurl with incorrect namespace or namelicense field missing or using a non-standard name (e.g., "MIT License" instead of "MIT")To detect these, use jq to query and report:
jq -r '
.components[] |
select(.version == null) |
.name + " (" + .purl + ") has null version"
' sbom.cdx.json
This outputs all components missing a version field.
Transitive dependencies are often included but inconsistently resolved. A common failure is including a library but missing its own dependencies.
Use syft with --resolve to ensure all transitive dependencies are resolved to a concrete version:
syft . --resolve -o cyclonedx-json
Without --resolve, syft includes direct dependencies but may miss the actual versions of nested packages.
The --resolve flag reads package-lock.json, go.sum, or Pipfile.lock to resolve all transitive dependencies and update version and hash fields.
A silent failure occurs when syft runs on a directory with a node_modules folder but no package-lock.json. In this case, it uses the package.json but does not resolve transitive dependencies. The resulting SBOM includes package.json dependencies but may have incorrect version and hash values.
Always ensure that package-lock.json, yarn.lock, or equivalent is present and committed in the source tree.
An SBOM must be created and validated at each stage of the pipeline. The most common integration is to generate an SBOM during the build and store it in a registry.
In a GitLab CI pipeline:
build:
stage: build
script:
- npm install
- npx cyclonedx-npm --output sbom.cdx.json
- syft . --all -o cyclonedx-json -o table
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
artifacts:
paths:
- sbom.cdx.json
- syft-report.txt
expire_in: 1 week
This ensures that every build produces an SBOM and makes it available for later inspection.
Use curl to upload the SBOM to an artifact store, such as a S3 bucket:
curl -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AWS_TOKEN" \
--data-binary @sbom.cdx.json \
"https://s3.amazonaws.com/artifacts/$PROJECT/$CI_COMMIT_SHA/sbom.cdx.json"
This exposes the SBOM to downstream systems.
Use diff and jq to detect changes between SBOMs from different builds.
To compare two SBOMs:
jq -s '
[
.[0].components[].purl as $p1 |
.[1].components[].purl as $p2 |
[ $p1, $p2 ]
] | unique | .[] | select(.p1 != .p2)
' sbom-1.cdx.json sbom-2.cdx.json
This outputs a list of purl values that differ between two SBOMs.
For a full change report, write a script that computes:
Use jq and sort to compute deltas:
#!/bin/bash
OLD_SBOM=$1
NEW_SBOM=$2
OLD_PURLS=$(jq -r '.components[].purl' $OLD_SBOM | sort)
NEW_PURLS=$(jq -r '.components[].purl' $NEW_SBOM | sort)
echo "Added:"
comm -13 <(echo "$OLD_PURLS") <(echo "$NEW_PURLS")
echo "Removed:"
comm -23 <(echo "$OLD_PURLS") <(echo "$NEW_PURLS")
echo "Updated:"
comm -12 <(echo "$OLD_PURLS") <(echo "$NEW_PURLS")
Run this as a CI job to detect dependency drift between releases.
SBOMs power vulnerability scanning, compliance checks, and incident response.
Use grype, a CLI tool from the Syft project, to scan a container image and enrich it with vulnerability data:
grype docker://myapp:latest --sbom sbom.cdx.json --output json --output table
This command:
The --sbom flag ensures that the scan uses the provided SBOM to enrich the analysis, even if the image has its own metadata.
An SBOM is more useful when augmented with metadata. Use jq to update the SBOM with build context:
jq '
.metadata = {
"build": {
"builder": "GitHub Actions",
"commit": $CI_COMMIT_SHA,
"branch": $CI_COMMIT_REF_NAME,
"timestamp": $CI_PIPELINE_STARTED_AT
},
"source": {
"repository": $CI_REPOSITORY,
"url": $CI_REPOSITORY_URL,
"ref": $CI_COMMIT_REF_NAME
}
}
' sbom.cdx.json
This adds metadata about the build environment, enabling traceability.
In a CI job, inject these variables at runtime:
variables:
CI_PIPELINE_STARTED_AT: $CI_PIPELINE_STARTED_AT
CI_COMMIT_SHA: $CI_COMMIT_SHA
CI_COMMIT_REF_NAME: $CI_COMMIT_REF_NAME
CI_REPOSITORY: $CI_REPOSITORY
CI_REPOSITORY_URL: $CI_REPOSITORY_URL
Then use jq to merge them into the SBOM.
Integrate SBOMs with a vulnerability scanner like Trivy, which supports SBOM input:
trivy image --sbom docker://myapp:latest --output vuln-report.json --format json
This generates a vulnerability report that includes:
The --sbom flag tells Trivy to use the provided SBOM to enrich the scan, especially for components not present in the base image.
For a full integration, use trivy to scan the image and then write the results to a database using psql:
trivy image --sbom docker://myapp:latest --output - --format json |
psql -c "
INSERT INTO vulnerabilities (image, component, cve, severity, description, references)
VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (image, component, cve) DO UPDATE SET severity = EXCLUDED.severity;
" -v image=myapp:latest
This enables real-time tracking of vulnerabilities across all deployed images.
Maintain SBOMs over time. Store them in a version-controlled repository:
git init
git add sbom.cdx.json
git commit -m "Update SBOM for $CI_COMMIT_SHA"
git push origin main
Use git to track SBOMs across releases. Tag each SBOM with the release version:
git tag -a v1.2.3 -m "SBOM for release v1.2.3" HEAD
git push origin v1.2.3
This allows rolling back to the SBOM for any release.
For large systems, maintain a central SBOM registry. Use curl to upload SBOMs to a REST API:
POST /sboms HTTP/1.1
Host: sbom-api.example.com
Authorization: Bearer $API_TOKEN
Content-Type: application/json
{
"image": "myapp:latest",
"version": "v1.2.3",
"commit": "abc123",
"sbom": {
"format": "cyclonedx",
"content": "<base64-encoded-json>"
}
}
Use jq to generate the content field:
jq -c '
.sbom = {
format: "cyclonedx",
content: (.[0] | @base64)
}
' sbom.cdx.json
This enables querying SBOMs by image, version, or component.
purl fields: Components lack purl values, making it difficult to correlate components across systems. Validate with jq 'map(select(.purl == null))'.package.lock files: A package-lock.json is generated but not committed, leading to different SBOMs across CI and local environments.version field in components: syft outputs version, but a downstream tool expects version in a different location (e.g., properties.version).version field is missing or in the wrong key.jq outputs ordered objects, but comm expects sorted lines; use sort -u to normalize.An SBOM is not a one-off artifact but a continuous artifact in the DevSecOps pipeline. Generate it early, validate it rigorously, integrate it into CI/CD, enrich it with metadata, and consume it for security and compliance. Use standard tools—syft, grype, trivy, jq, curl, psql, git, docker, kubectl, systemctl—to build a robust, repeatable, and maintainable SBOM implementation.
This page was rewritten on 12 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.
We use cookies for analytics (Google Analytics) and advertising (Google AdSense) to improve your experience and support free content. Privacy Policy