Grype — Container Image Vulnerability Scanner
Grype is a vulnerability scanner for container images and filesystems. It matches installed packages against vulnerability databases (CVE, GHSA) to identify known security issues — essential for securing your container supply chain.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install 87aec817-372b-11f1-9bc6-00163e2b0d79 --target codex先 dry-run,确认写入项后再运行此命令。
What it is
Grype is a vulnerability scanner for container images and filesystems built by Anchore. It identifies installed packages in a container image and matches them against vulnerability databases including CVE (Common Vulnerabilities and Exposures) and GHSA (GitHub Security Advisories). Grype outputs a list of known vulnerabilities with severity ratings, affected versions, and fix versions when available.
Grype targets DevOps engineers, security teams, and developers who need to scan container images before deployment. It integrates into CI/CD pipelines as a gate to prevent deploying images with critical vulnerabilities.
How it saves time or tokens
Manually checking package versions against vulnerability databases is impractical for containers with hundreds of installed packages. Grype automates this by scanning the image's SBOM (Software Bill of Materials) and cross-referencing every package against multiple vulnerability feeds. A full scan completes in seconds.
Grype works with Syft (also by Anchore) for SBOM generation, enabling a two-step workflow: generate the SBOM once with Syft, then scan it repeatedly with Grype as vulnerability databases update.
How to use
- Install Grype:
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
- Scan a container image:
grype nginx:latest
- Scan with severity filtering:
grype nginx:latest --fail-on critical
The --fail-on flag returns a non-zero exit code when vulnerabilities at or above the specified severity are found, making it ideal for CI/CD gates.
Example
# Scan an image and output as JSON for further processing
grype alpine:3.19 -o json > scan-results.json
# Scan a local directory
grype dir:/path/to/project
# Scan an SBOM generated by Syft
syft nginx:latest -o spdx-json > sbom.json
grype sbom:sbom.json
# CI/CD pipeline gate
grype myapp:latest --fail-on high
if [ $? -ne 0 ]; then
echo 'Vulnerabilities found. Blocking deployment.'
exit 1
fi
Related on TokRepo
- Security tools -- Browse other security scanning and auditing tools
- DevOps tools -- Explore container and infrastructure tools
Common pitfalls
- Grype's vulnerability database needs periodic updates. The first run downloads the database automatically, but stale databases miss recently disclosed vulnerabilities. Run
grype db updateregularly or set up automated updates in CI. - False positives are common with OS-level packages. Some reported vulnerabilities may not be exploitable in your context. Use Grype's ignore rules (
.grype.yaml) to suppress known false positives after review. - Grype scans package metadata, not running code. It cannot detect vulnerabilities in custom application code or misconfigurations. Pair it with SAST and DAST tools for comprehensive security coverage.
常见问题
Both are container vulnerability scanners. Grype focuses on vulnerability matching with a fast, lightweight design. Trivy by Aqua Security includes additional features like IaC scanning, secret detection, and license scanning. Grype pairs with Syft for SBOM generation, while Trivy generates SBOMs internally.
Yes. Grype can scan images from a registry without pulling the full image locally. It reads the image manifest and layer metadata directly from the registry. You can also scan local tar archives and OCI directories.
Partially. Grype needs to download the vulnerability database at least once. After that, it can scan images offline using the cached database. You can pre-download and distribute the database for air-gapped environments.
Grype supports table (default terminal output), JSON, CycloneDX, SARIF, and template-based custom formats. The JSON and SARIF formats integrate with GitHub Security, GitLab, and other CI/CD platforms for automated vulnerability tracking.
Grype's vulnerability database is updated multiple times per day from upstream sources including the National Vulnerability Database (NVD), GitHub Advisory Database, and distribution-specific feeds. Run grype db update to pull the latest data.
引用来源 (3)
- Grype GitHub— Grype is a vulnerability scanner by Anchore
- Grype Documentation— Matches against CVE and GHSA databases
- Syft GitHub— Syft SBOM integration
讨论
相关资产
Clair — Container Image Vulnerability Scanner
Perform static vulnerability analysis on OCI and Docker container images by indexing their contents and matching against multiple security databases.
Vuls — Agent-less Vulnerability Scanner for Linux and Containers
An open-source, agent-less vulnerability scanner written in Go that detects known vulnerabilities in Linux, FreeBSD, containers, and application dependencies by correlating installed packages with multiple CVE databases.
Dockur Windows — Run Windows Inside a Docker Container
A Docker image that boots a full Windows installation inside a container using KVM acceleration, enabling automated testing, CI pipelines, and legacy app hosting without dedicated VMs.
Thumbor — Smart Image Cropping and Processing Server
Thumbor is an open-source HTTP image server that performs on-demand cropping, resizing, and filtering with smart detection of important image regions, making it ideal for serving optimized images at scale.