Trivy — All-in-One Security Scanner for Containers & Code
Trivy is an open-source, comprehensive security scanner that finds vulnerabilities, misconfigurations, secrets, and SBOM issues in containers, Kubernetes, code repos, and clouds.
先审查再安装
这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。
npx -y tokrepo@latest install 302fe2bb-3535-11f1-9bc6-00163e2b0d79 --target codex先 dry-run,确认写入项后再运行此命令。
What it is
Trivy is an open-source security scanner by Aqua Security that detects vulnerabilities in OS packages and language dependencies, misconfigurations in Terraform and Dockerfiles, leaked secrets like API keys, and SBOM issues -- all from a single binary with zero configuration. It scans Docker images, Git repositories, Kubernetes clusters, and local filesystems.
Trivy targets DevSecOps engineers, platform teams, and developers who need security scanning integrated into CI/CD pipelines without managing multiple specialized tools.
How it saves time or tokens
Trivy consolidates what used to require four or five separate tools (vulnerability scanner, secret detector, IaC linter, SBOM generator, Kubernetes auditor) into one binary. A single trivy image nginx:latest command replaces a chain of Grype, detect-secrets, checkov, and kube-bench commands. The scanner runs offline-capable with a local vulnerability database, so CI pipelines avoid network round-trips to external APIs.
How to use
- Install Trivy:
# macOS
brew install trivy
# Debian/Ubuntu
sudo apt install trivy
- Scan a Docker image for vulnerabilities:
trivy image nginx:latest
- Scan a Git repository for secrets and misconfigurations:
trivy repo https://github.com/your-org/your-repo
- Audit a running Kubernetes cluster:
trivy k8s --report=summary cluster
Example
# Scan a project filesystem with all scanners enabled
trivy fs --scanners vuln,misconfig,secret /path/to/project
# Output as JSON for CI/CD integration
trivy image --format json --output results.json myapp:v2.1
# Fail the build if critical vulnerabilities are found
trivy image --exit-code 1 --severity CRITICAL myapp:v2.1
# Generate an SBOM in CycloneDX format
trivy image --format cyclonedx --output sbom.json myapp:v2.1
Related on TokRepo
- Security tools directory -- Other security scanning and auditing tools
- DevOps tools -- CI/CD and infrastructure automation solutions
Common pitfalls
- The first scan downloads a vulnerability database (~30MB) which can timeout in air-gapped environments; pre-download with
trivy image --download-db-onlybefore going offline - Scanning large monorepo filesystems with all scanners enabled can be slow; use
--scannersflag to limit to specific scan types - The
--exit-code 1flag only triggers on findings matching the specified severity; omitting--severitymeans any finding fails the build
常见问题
Trivy scans container images, local filesystems, Git repositories, Kubernetes clusters, and cloud infrastructure (AWS, GCP, Azure). Each target type supports the full range of scanners: vulnerabilities, misconfigurations, secrets, and SBOM generation.
Grype focuses solely on vulnerability scanning for container images. Snyk is a commercial platform covering vulnerabilities and IaC. Trivy covers vulnerabilities, misconfigurations, secrets, and SBOM in a single open-source binary, making it broader in scope than Grype and free unlike Snyk.
Yes. Trivy provides JSON, SARIF, and table output formats. The --exit-code flag lets you fail builds on findings. Official GitHub Actions, GitLab CI templates, and Jenkins plugins are available. The scanner runs as a single binary with no daemon or server dependency.
Trivy can work offline after the initial vulnerability database download. Run 'trivy image --download-db-only' to cache the database, then use '--skip-db-update' for subsequent scans. This is useful for air-gapped environments.
Trivy detects API keys, passwords, tokens, private keys, and other credentials embedded in source code, Dockerfiles, and container image layers. It uses pattern matching and entropy analysis to minimize false positives.
引用来源 (3)
- Trivy GitHub— Trivy is a comprehensive security scanner by Aqua Security
- Trivy Documentation— Supports scanning containers, filesystems, repos, and Kubernetes
- Trivy SBOM Docs— SBOM generation in CycloneDX and SPDX formats
讨论
相关资产
txtai — All-in-One Embeddings Database
txtai is an all-in-one embeddings database for semantic search, LLM orchestration, and language model workflows. 10.4K+ GitHub stars. Vector search + SQL + RAG pipelines. Apache 2.0.
Web-Check — All-in-One Website OSINT and Analysis Dashboard
Web-Check is a self-hosted dashboard that aggregates DNS, SSL, security headers, performance, and dozens of other checks for any website into a single comprehensive report.
SpeechBrain — Open-Source All-in-One Speech and Audio Processing Toolkit
SpeechBrain is a PyTorch-based toolkit covering speech recognition, speaker verification, text-to-speech, speech separation, language modeling, and spoken language understanding in a single framework.
Ferdium — All Your Messaging Services in One App
A desktop application that combines all your messaging and web services into a single window with workspaces, notifications, and a unified interface.