What it does
An SBOM is the ingredient list of software. When a new CVE appears (like Log4Shell), you search your SBOMs instead of scanning everything again. Syft (Anchore) reads container images, folders, archives and OCI registries and writes SBOMs in CycloneDX or SPDX (and its own JSON). Grype scans the SBOM for vulnerabilities; cosign can attach and sign it.
US and EU rules (the EU Cyber Resilience Act) push vendors to deliver SBOMs.
How to write it
syft [scan] SOURCE [-o FORMAT[=FILE]]Main parts
Sources
IMAGE(docker.io/…,ghcr.io/…)- Pull and read an image.
dir:PATH- A folder.
file:PATH- One file or archive.
docker:IMAGE/podman:IMAGE- An image from the local daemon.
oci-archive:FILE/docker-archive:FILE- Saved image archives.
registry:IMAGE- Read straight from the registry.
Options 7
Most used
Flags
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1List the packages of an image
syft nginx:1.27 syft ghcr.io/s0sta/shop:1.4.0 -o table | head -202Write CycloneDX and SPDX files at once
syft ghcr.io/s0sta/shop:1.4.0 -o cyclonedx-json=shop.cdx.json -o spdx-json=shop.spdx.json3SBOM of a source folder
syft dir:. -o cyclonedx-json=sbom.cdx.json4Find a library in the SBOM
jq -r '.components[] | select(.name|test("log4j")) | "\(.name) \(.version)"' shop.cdx.json5Scan the SBOM for CVEs
grype sbom:shop.cdx.json6Count packages per type
7Convert formats
syft convert shop.cdx.json -o spdx-json=shop.spdx.json8Attach a signed SBOM to the image
syft attest --key cosign.key ghcr.io/s0sta/shop:1.4.0 -o cyclonedx-json9Make SBOMs in GitHub Actions
cat .github/workflows/sbom.yml - uses: anchore/sbom-action@v0 with: { image: "ghcr.io/s0sta/shop:1.4.0", format: cyclonedx-json }10SBOM of all layers
syft --scope all-layers ghcr.io/s0sta/shop:1.4.0 -o table
Nothing matches this filter.
Watch out
- An SBOM is only as good as what Syft can detect; static binaries without metadata may be missing.
- Keep SBOMs with the release (as artifacts or attestations), or they are useless later.
Files
.syft.yaml- Project defaults.
Tips to remember
- Store one SBOM per released image digest, not per tag.
Exit codes
0 | Success. |
1 | Error. |