$linuxjunkies
>

trivy(1)

Trivy is a simple and comprehensive vulnerability scanner for containers, filesystems, and repositories.

UbuntuDebianFedoraArch

Synopsis

trivy [global options] command [command options] target

Description

Trivy is an open-source vulnerability scanner that detects security issues in container images, filesystems, Git repositories, and Kubernetes clusters. It scans for known vulnerabilities in OS packages and application dependencies, providing fast and accurate results with minimal configuration.

Trivy supports multiple image sources including Docker registries, local images, and tarball files. It can generate reports in various formats (JSON, SARIF, CycloneDX) and integrates with CI/CD pipelines for automated security scanning.

Common options

FlagWhat it does
imageScan a container image for vulnerabilities
fsScan a filesystem or directory for vulnerabilities
repoScan a Git repository for vulnerabilities
--format jsonOutput results in JSON format for parsing
--format sarifOutput results in SARIF format for integration with GitHub
--severity HIGH,CRITICALFilter results by severity level
--exit-code 1Return exit code 1 if vulnerabilities are found
--skip-updateSkip updating vulnerability database
--offline-scanRun scan without internet connectivity
-o, --output FILEWrite results to a file instead of stdout

Examples

Scan the latest nginx image from Docker Hub for vulnerabilities

trivy image nginx:latest

Scan nginx image and show only critical-level vulnerabilities

trivy image --severity CRITICAL nginx:latest

Scan a local directory for vulnerable packages and dependencies

trivy fs /var/www/app

Scan image and save results in JSON format to a file

trivy image --format json nginx:latest -o results.json

Scan a Git repository for secrets and vulnerabilities

trivy repo https://github.com/owner/repo.git

Scan image and exit with code 1 if any vulnerabilities are found

trivy image --exit-code 1 myapp:v1.0

Scan a local tar file without updating the vulnerability database

trivy image --skip-update my-image.tar

Generate a SARIF report for GitHub security integration

trivy image --format sarif nginx:latest -o trivy-report.sarif

Related commands