syft: generate a packaged-based Software Bill Of Materials (SBOM) from container images and filesystems (Anchore syft)
syft [scan] SOURCE [-o FORMAT[=FILE]] [flags]
What it does
Catalogs the packages in a container image or a directory (OS packages, language dependencies, binaries) and writes them as an SBOM. SOURCE is an image (from the Docker daemon if present, else pulled directly from the registry), a path, or a scheme-prefixed source: registry:IMAGE, docker:IMAGE, docker-archive:FILE.tar, oci-dir:DIR, dir:PATH, file:PATH.
Options you will use
-o, --output FORMAT[=FILE]- Report output format (<format>=<file> to output to a file): syft-table (default), syft-json, syft-text, spdx-json, spdx-tag-value, cyclonedx-json, cyclonedx-xml, github-json, template ... A version can follow: [email protected].
-s, --scope SCOPE- Selection of layers to catalog, options=[squashed all-layers deep-squashed] (default squashed: what the final filesystem holds).
--platform PLATFORM- An optional platform specifier for container image sources (e.g. 'linux/arm64', 'linux/arm64/v8', 'arm64', 'linux').
--from SOURCE- Specify the source behavior to use (e.g. docker, registry, oci-dir, ...).
--exclude GLOB- Exclude paths from being scanned using a glob expression.
-t, --template FILE- Specify the path to a Go template file (with -o template).
-q, --quiet- Suppress all logging output.
-v, --verbose- Increase verbosity (-v = info, -vv = debug).
Examples
$ syft registry.lab/shop/api:2.3a table of packages: NAME, VERSION, TYPE
$ syft registry.lab/shop/api:2.3 -o spdx-json > sbom.jsonan SPDX 2.3 JSON SBOM
$ syft scan alpine:latest -o cyclonedx-json=sbom.cdx.jsonCycloneDX, written to a file
Gotchas
- An SBOM lists what is in the image; it does not judge it. Feed it to a scanner (trivy sbom sbom.json, grype sbom:sbom.json) to get the vulnerabilities.
- Without a scheme, syft first asks the Docker daemon for the image: registry:IMAGE skips the daemon and pulls directly.
Try syft in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.