TExcelTAD
Home › Software Supply Chain Security: SBOM, SLSA & Sigstore › Toolkit: Syft, Grype, Trivy & osv-scanner

Toolkit: Syft, Grype, Trivy & osv-scanner

The SBOM and scanning tools in one place: what each is for, the flags you'll use daily, and how to move their options from long command lines into reviewed config files.

At a glance

Tool Does Strengths Watch out for
Syft (Anchore) SBOMs from directories, files, images, archives widest cataloger set, rich syft-json with file locations, SPDX and CycloneDX it records what package managers recorded; vendored or copied binaries may be missed
Grype (Anchore) vulnerability matching for Syft catalogs and SBOMs GHSA-precise ecosystem matching, EPSS/KEV/risk in reports, VEX, ignore rules CPE matches against NVD add findings that need triage
Trivy (Aqua) vulnerabilities, secrets, misconfigurations, licenses; SBOM generation; Kubernetes one tool for many scanners, distro-accurate OS data, --ignore-unfixed, ignore files with expiry Java scanning needs its separate Java DB; many features, so pin the config
osv-scanner (Google) scans lockfiles, SBOMs and images against OSV.dev OSV data straight from ecosystem sources, call-graph analysis for Go (and some other languages), guided remediation for npm/Maven needs network for the OSV API (an offline DB mode exists)
govulncheck (Go team) Go modules and binaries reports only vulnerabilities whose vulnerable functions are reachable Go only (go-modules)
ecosystem auditors npm audit, pip-audit, cargo audit, dotnet list package --vulnerable native to each ecosystem one ecosystem each; mostly not for images

Daily flags

Want Syft Grype Trivy
machine-readable output -o syft-json, -o cyclonedx-json=f -o json -f json
SBOM formats -o spdx-json, -o cyclonedx-json -o cyclonedx-json (with vulns) -f cyclonedx, -f spdx-json
scan an SBOM (n/a) sbom:file.json trivy sbom file.json
severity filter / gate --fail-on high --severity HIGH,CRITICAL --exit-code 1
fixed only --only-fixed --ignore-unfixed
CVE ids --by-cve (default)
VEX --vex f.json --vex f.json
name the subject --source-name, --source-version --name
all layers --scope all-layers --scope all-layers (default: per layer)

Config files instead of flags

All three read a config file from the working directory, so a pipeline's policy lives in the repository and changes go through review:

bash · try it yourself
cat > .syft.yaml <<'YAML'
output:
  - cyclonedx-json=sbom.cdx.json
source:
  name: shop-web
  version: 1.4.2
YAML
cat > .grype.yaml <<'YAML'
output: json
fail-on-severity: high
only-fixed: true
by-cve: true
YAML
cat > trivy.yaml <<'YAML'
format: json
severity: [HIGH, CRITICAL]
exit-code: 1
scan:
  scanners: [vuln]
vulnerability:
  ignore-unfixed: true
YAML
syft scan /opt/samples/node-app -q && jq -c '.metadata.component | {name, version}' sbom.cdx.json
grype sbom:sbom.cdx.json -q | jq -r '[.matches[].vulnerability.id] | join(" ")'; echo "grype exit ${PIPESTATUS[0]}"
trivy sbom sbom.cdx.json --config trivy.yaml -q | jq -r '[.Results[].Vulnerabilities[]?.VulnerabilityID] | join(" ")'; echo "trivy exit ${PIPESTATUS[0]}"
{"name":"shop-web","version":"1.4.2"}
CVE-2021-23337 CVE-2021-44906 CVE-2020-8203 CVE-2020-28500 CVE-2026-4800 CVE-2025-13465 CVE-2026-2950
grype exit 2
CVE-2020-8203 CVE-2021-23337 CVE-2026-4800 NSWG-ECO-516 CVE-2021-44906
trivy exit 1

Syft and Grype pick up .syft.yaml / .grype.yaml automatically (also under .syft/config.yaml, ~/.config/…); Trivy reads trivy.yaml from the current directory or --config. Every option also has an environment variable (GRYPE_FAIL_ON_SEVERITY, TRIVY_SEVERITY, …), which is how this course's image disables database updates.

Catalogers

bash · try it yourself
syft cataloger list -o json 2> /dev/null | jq -r '.catalogers[] | select(.name | test("javascript|python|go-module|alpm|apk|dpkg|rpm")) | .name' | head -14
alpm-db-cataloger
apk-db-cataloger
dpkg-db-cataloger
go-module-binary-cataloger
go-module-file-cataloger
javascript-lock-cataloger
javascript-package-cataloger
python-installed-package-cataloger
python-package-cataloger
rpm-archive-cataloger
rpm-db-cataloger

When an SBOM misses something, this list is the first place to look: is there a cataloger for that ecosystem, and does it run for this kind of source (directory vs image)?

osv-scanner (non-run)

osv-scanner isn't in the course image (it queries the OSV.dev API). Version 2 commands:

bash
osv-scanner scan source -r .                       # every lockfile under the directory
osv-scanner scan source -L package-lock.json       # one lockfile
osv-scanner scan image alpine:3.18.0               # an image (needs docker or a tarball with --archive)
osv-scanner scan source --format sarif -r . > osv.sarif
osv-scanner fix --strategy=in-place -L package-lock.json   # guided remediation (npm, Maven)

It reads the same osv-scanner.toml ignore entries ([[IgnoredVulns]] with id, ignoreUntil, reason) that you'd expect from the Ignore Rules lesson.

Database operations

Task Command
show Grype's DB build date grype db status
update Grype's DB / check for one grype db update, grype db check
run Grype from a mirrored DB GRYPE_DB_UPDATE_URL=https://mirror/…/latest.json or grype db import file.tar.zst
Trivy: download only trivy image --download-db-only (and --download-java-db-only)
Trivy: from a mirror --db-repository, --java-db-repository (OCI registries)
Trivy: air-gapped --skip-db-update --offline-scan with a pre-populated cache (what this course uses)

In CI, cache the databases between jobs (they're tens to hundreds of MB) but refresh them at least daily, and print the DB date in every report.

Test yourself

Which tool reports Go vulnerabilities only when the vulnerable function is reachable from your code?

  1. Syft
  2. Grype
  3. govulncheck
  4. Trivy

Why put scanner options in .grype.yaml / trivy.yaml instead of CI command lines?

  1. Config files run faster
  2. The policy is versioned and reviewed with the code, and identical locally and in CI
  3. Flags are deprecated
  4. CI can't pass flags

Which Trivy flags make it run against a pre-populated DB without network access?

  1. --quiet
  2. --skip-db-update and --offline-scan
  3. --ignore-unfixed
  4. --exit-code 0