Trivy

From G1Joshi/Agent-Skills · View interactive version

Trivy is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert Trivy security scanner assistance covering container image scanning, filesystem CVEs, git repositories, and IaC misconfigs. Use when scanning Docker images, auditing Kubernetes manifests, or running security checks in CI.

How to use this skill

Skill file

Trivy

Trivy (by Aqua Security) is a comprehensive and versatile security scanner. It is famous for being incredibly fast, easy to install (single binary), and covering a wide range of targets (Containers, Filesystem, Git repos, AWS).

When to Use

Quick Start

# Scan a container image
trivy image python:3.4-alpine

# Scan local filesystem (dependencies + secrets + misconfigs)
trivy fs .

# Scan a git repo
trivy repo https://github.com/knqyf263/trivy

Core Concepts

Multi-Target Scanning Architecture

Trivy scans container images, filesystems, Git repositories, AWS accounts, and Kubernetes clusters using a unified engine:

# 1. Scan Container Image
trivy image --severity HIGH,CRITICAL node:20-alpine

# 2. Scan Local Filesystem & Dependencies
trivy fs --scanners vuln,secret,misconfig .

# 3. Scan Kubernetes Cluster
trivy k8s --report summary cluster

Software Bill of Materials (SBOM) Export

Generates standardized inventory of all components and licenses in container images:

# Export CycloneDX JSON SBOM
trivy image --format cyclonedx --output sbom.json my-org/api:latest

GitHub Actions CI Security Gate

Blocks container builds containing unpatched critical CVEs:

# .github/workflows/container-scan.yml
- name: Run Trivy Vulnerability Scanner
  uses: aquasecurity/trivy-action@master
  with:
    image-ref: "my-org/api:${{ github.sha }}"
    format: "sarif"
    output: "trivy-results.sarif"
    severity: "CRITICAL,HIGH"
    exit-code: "1"

Common Patterns

Container Image Vulnerability Scanning with Exit Code Gates

Problem: Unvetted base images introduce known Remote Code Execution (RCE) flaws into cloud deployments.

Solution:

Execute Trivy container scans in CI with automated blocking on critical vulnerabilities:

# Scan container image and exit with error code 1 if CRITICAL CVEs exist
trivy image \
  --severity CRITICAL,HIGH \
  --exit-code 1 \
  --ignore-unfixed \
  myapp:latest

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :------------------ | :----------------------- | :----------------------------------------------------------------------------------- |

| DB Download Error | Rate limiting / Network. | Use TRIVY_OFFLINE_SCAN=true if using --skip-db-update inside a restricted network. |

| API Rate Limit | GitHub API limit. | Set GITHUB_TOKEN env var for Trivy to use. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.