How do you generate an SBOM with Syft?
BeginnerHands-onSBOM
Answer
Short answer
Syft (by Anchore) creates SBOMs from container images, folders or archives. Run syft <target> -o <format> — for example syft shop-api:1.4.0 -o cyclonedx-json > sbom.json.
Commands
brew install syft # or curl the install script / use the Docker image
syft shop-api:1.4.0 # human-readable table
syft shop-api:1.4.0 -o cyclonedx-json > sbom.cdx.json
syft shop-api:1.4.0 -o spdx-json > sbom.spdx.json
syft dir:. -o cyclonedx-json > source-sbom.json # from source (lockfiles)
syft registry:ghcr.io/org/shop-api:1.4.0 -o spdx-json # straight from a registry, no docker daemon
Table output (shortened)
NAME VERSION TYPE
express 4.19.2 npm
jackson-databind 2.17.1 java-archive
libssl3 3.0.13-1 deb
Which ecosystems
OS packages (apk, deb, rpm) and language packages (npm, pip, Maven/Gradle JARs, Go modules, NuGet, Ruby gems, Rust crates and more).
What to say in the interview
"Syft generates SBOMs from images, directories or registries in SPDX or CycloneDX, covering OS and language packages. We run it after building the image so the SBOM reflects exactly what ships."
More on SBOM
What is an SBOM and how do you generate one?BeginnerWhat is an SBOM and why does it matter?BeginnerWhat are SPDX and CycloneDX?BeginnerHow do you scan an SBOM for vulnerabilities with Grype or Trivy?BeginnerWhat should an SBOM contain? (NTIA minimum elements)IntermediateWhat is the difference between an SBOM from source and an SBOM from a container image?Intermediate