Geavanceerd
Zoeken inInstallatiegidsen
Zo zoek je
  • Plak een foutmelding tussen aanhalingstekens, bijv. "permission denied", om de oplossingstabel te vinden.
  • Kies een gebied en een deel van de gids (installeren, eerste instellingen, dagelijks gebruik, beveiliging, oplossingen) om direct naar de juiste stap te gaan.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Gids 64Grype · Security

Install and set up Grype (vulnerability scanner)

Grype finds known vulnerabilities (CVEs) in container images, folders and SBOMs. It is fast, works offline with a local database, and fits CI gates: fail the build on high or critical findings, with a clear list of fixed versions. It pairs naturally with Syft (make the SBOM once, scan it again every day). This guide installs Grype, manages its database, writes a config with ignore rules that have reasons, and builds the CI gate.

  • 8 Lessen
  • 6 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

64.1

Know it before you install

Grype finds the packages (with Syft's catalogers, or from an SBOM you give it) and matches them against its vulnerability database (NVD, GitHub advisories, distro security data). Each match has a severity, a fix state (fixed, not-fixed, wont-fix) and the fixed version.

ItemValue
Programgrype (one binary from Anchore)
Database~/.cache/grype/db/ (updated automatically, or grype db update)
SourcesIMAGE, registry:IMAGE, dir:PATH, sbom:FILE
Config.grype.yaml in the project
Outputstable, json, cyclonedx, sarif, template

Commando's in deze les

64.2

Install on RHEL and Ubuntu

curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh -o grype-install.sh
less grype-install.sh
sh grype-install.sh -b /usr/local/bin
grype version
grype db update
grype db status

Or the .rpm / .deb from github.com/anchore/grype/releases, or the container anchore/grype.

64.3

First configuration: scan and set the gate

grype nginx:1.27
NAME      INSTALLED         FIXED-IN          TYPE  VULNERABILITY   SEVERITY
libssl3   3.0.15-1~deb12u1  3.0.16-1~deb12u1  deb   CVE-2025-xxxx   High
…
grype registry:harbor.example.com/shop/shop:1.4.0 --only-fixed --fail-on high
grype sbom:sbom.cdx.json -o sarif > grype.sarif
grype dir:. --fail-on critical

A config file for the project:

.grype.yaml
fail-on-severity: high
only-fixed: true
output: table
ignore:
  - vulnerability: CVE-2024-12345
    reason: "Not reachable: the vulnerable function is not used. Ticket SEC-142, review 2027-03-31."
  - vulnerability: GHSA-xxxx-yyyy-zzzz
    package:
      name: example-lib
      version: 1.2.3
  - fix-state: wont-fix
SettingWhy
fail-on-severity: highExit code 1 on high or critical — the CI job stops.
only-fixedShow only CVEs that have a fix (you can act on them now).
ignore with a reasonAccepted risks are written down, with a ticket and a review date.
fix-state: wont-fixHide issues the distro will never fix (decide this as a team).

Commando's in deze les

64.4

Daily use: the commands and the real uses

grype IMAGE -o json | jq '[.matches[] | .vulnerability.severity] | group_by(.) | map({(.[0]): length}) | add'
grype IMAGE --by-cve
grype explain --id CVE-2025-xxxx < report.json
grype IMAGE --vex openvex.json
grype db check
GRYPE_DB_AUTO_UPDATE=false grype sbom:sbom.cdx.json

--vex reads a VEX document that says "this CVE does not affect our product" — the standard way to record not-affected decisions.

Real uses at work:

  • CI gate after the image build (or on the SBOM from Syft).
  • A nightly job that re-scans all stored SBOMs with the newest database and opens tickets for new high/critical CVEs.
  • Compare base images: which one has fewer fixable CVEs?

64.5

Make it safe

Security checklist:

  • Fresh database for every run (or daily); in air-gapped networks, mirror the DB and update it regularly.
  • Every ignore has a reason, an owner and a review date; prefer VEX documents.
  • Scan the image digest you ship; keep the reports with the release.
  • Pin the Grype version in CI.
  • A clean scan does not mean "safe": also use SAST (Semgrep), secrets scanning (Gitleaks), and runtime detection (Falco).

64.6

Update and remove

Run the install script again (or the new package), then grype db update. Remove: rm /usr/local/bin/grype and rm -rf ~/.cache/grype.

64.7

Fix common problems

ProblemCauseFix
failed to load vulnerability db / download errorNo internet or proxy issues.Set HTTPS_PROXY; grype db update; offline: import a DB archive (grype db import).
db is too old warningThe database was not updated.grype db update, or turn on auto update.
Too many findingsAll severities, unfixed CVEs, old base image.--only-fixed, --fail-on high; update the base image first (biggest win).
A false positiveWrong package match (CPE) or not affected.Add an ignore rule with a reason, or a VEX statement.
Private image can not be pulledNo registry login.docker login, or GRYPE_REGISTRY_AUTH_* variables; registry: source.
Results differ from TrivyDifferent data sources and matching.Normal; pick one tool as the gate per pipeline.

64.8

Next steps

1What does --only-fixed change?

Grype shows only vulnerabilities that already have a fixed version.

2How do you document that a CVE does not affect your product?

An ignore rule with a reason and review date, or better a VEX document passed with --vex.

Commando's in deze les

Alle commando's in dit hoofdstuk