/security-tooling-skills:trivy-vulnerability-scanningfrom security-tooling-skills
Guides deep, tool-specific use of Aqua Trivy to scan container images, filesystems, git repos, and IaC for vulnerabilities, misconfigurations, secrets, and license issues.
Ships in security-tooling-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Trivy (Aqua Security) is a single, self-contained binary that scans five
distinct target types — container images, filesystems/repositories, git
repos over the network, Kubernetes clusters, and Infrastructure-as-Code
(IaC) source — for four distinct finding classes: known CVEs in OS
packages and language dependencies, misconfigurations in IaC/manifests,
hardcoded secrets, and license issues. Its value operationally is
consolidation: a team that would otherwise run a separate dependency
scanner, a separate Dockerfile/Kubernetes linter, and a separate secret
scanner can often cover the first pass of all three with one pinned
binary, one output format, and one severity model. This skill goes deep
on Trivy's specific scan modes, flags, exit-code semantics, and
.trivyignore/trivy-config-ignore syntax — for the general concept of
scanning dependencies for known vulnerabilities (tool selection,
remediation SLAs, SBOM relationship), see
software-composition-analysis-sca.
trivy image (built artifact, includes
OS packages) from trivy fs (source tree/lockfiles only) from trivy repo (remote git URL, no local clone needed) and picks the wrong one
for their target.trivy config) rather than
vulnerabilities.--severity,
--exit-code) so CI fails only on findings that matter..trivyignore file, or wants
time-boxed suppressions with an expiry/justification convention.--format cyclonedx/spdx-json) as
an input to a downstream SBOM/provenance pipeline.>= 0.55 for stable trivy config (IaC) behavior and
unified --scanners flag syntax (older 0.3x/0.4x releases used
separate --security-checks, now removed). Install via the official
binary, brew install trivy, or the aquasec/trivy container image —
pin the image tag/digest in CI rather than :latest.trivy-db and trivy-java-db bundles; for air-gapped environments,
mirror the DB internally and point Trivy at it with
--db-repository/TRIVY_DB_REPOSITORY.trivy image: access to the image itself, either already pulled
locally, in a registry Trivy can authenticate to
(TRIVY_USERNAME/TRIVY_PASSWORD or a Docker config), or as a
.tar produced by docker save.trivy fs: a checked-out source tree with lockfiles present
(package-lock.json, go.sum, requirements.txt/poetry.lock,
Gemfile.lock, pom.xml, Cargo.lock) — Trivy resolves transitive
dependencies from the lockfile, not the top-level manifest alone.trivy config: no network target needed, just the IaC source
directory; Trivy bundles its own policy set (built on the Rego-based
trivy-checks project) so no separate policy engine install is
required for baseline checks.trivy returns exit code 0 by default even with CRITICAL
findings present, which surprises teams expecting scan-fails-build
behavior out of the box.Pick the right scan mode for the target — this is the single most common Trivy mistake:
# Built, runnable artifact (base OS packages + app deps baked in)
trivy image myorg/myapp:1.4.2
# Source tree / lockfiles only, no image build required
trivy fs --scanners vuln .
# Remote repo, no local clone
trivy repo https://github.com/example-org/checkout-service
# IaC / manifests — misconfiguration, not CVEs
trivy config ./infra/terraform
# Live cluster — scans workloads' images already running
trivy k8s --report summary cluster
trivy image and trivy fs report different things even on the same
codebase: image includes the base OS package layer (apt/apk
packages), fs typically does not unless pointed at a real
filesystem root.
Scope scanners explicitly with --scanners (Trivy >=0.49
replaced the older --security-checks flag) rather than relying on
defaults, since default scanner sets differ by target type:
trivy image --scanners vuln,secret,license myorg/myapp:1.4.2
trivy fs --scanners vuln,secret .
trivy config --scanners misconfig ./k8s
Set severity and exit-code together — without --exit-code,
Trivy always exits 0 regardless of findings, so a naive CI step
with no flags will never fail the build:
trivy image \
--severity CRITICAL,HIGH \
--exit-code 1 \
--ignore-unfixed \
--format table \
myorg/myapp:1.4.2
--ignore-unfixed excludes CVEs with no vendor patch available yet —
without it, a build can be permanently blocked by an unfixable
upstream CVE.
Wire into CI using the official action or the CLI directly:
# GitHub Actions
name: trivy
on: [pull_request]
jobs:
image-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build -t myorg/myapp:${{ github.sha }} .
- name: Trivy image scan
uses: aquasecurity/[email protected]
with:
image-ref: 'myorg/myapp:${{ github.sha }}'
severity: 'CRITICAL,HIGH'
exit-code: '1'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-image.sarif'
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-image.sarif'
GitLab CI equivalent:
trivy_scan:
image:
name: aquasec/trivy:0.55.2
entrypoint: [""]
script:
- trivy image --severity CRITICAL,HIGH --exit-code 1 --ignore-unfixed
--format template --template "@contrib/gitlab.tpl"
-o gl-container-scanning-report.json "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
artifacts:
reports:
container_scanning: gl-container-scanning-report.json
Scan IaC separately from the runtime artifact, since misconfiguration checks and CVE checks have different remediation paths (fix a Terraform attribute vs. bump a package version):
trivy config --severity HIGH,CRITICAL --exit-code 1 ./infra/terraform
Sample finding:
AVD-AWS-0089 (HIGH): S3 Bucket does not have logging enabled.
── infra/terraform/s3.tf:12-18 ──────────────────────────
12 resource "aws_s3_bucket" "data" {
13 bucket = "example-data-bucket"
...
Suppress with an expiry and justification, never a bare CVE ID,
using .trivyignore (vulnerabilities) or inline #trivy:ignore
comments (misconfig):
# .trivyignore
# CVE-2024-XXXXX: no upstream fix yet; library only used in build
# tooling, not shipped to the runtime image. Re-review 2026-10-01.
# Tracked: JIRA-5521
CVE-2024-XXXXX
# trivy:ignore:AVD-AWS-0089 -- logging intentionally disabled for
# ephemeral dev-only bucket; re-review before promoting to prod.
resource "aws_s3_bucket" "dev_scratch" {
bucket = "example-dev-scratch"
}
Generate an SBOM as a byproduct, if downstream tooling (provenance attestation, license auditing) needs it:
trivy image --format cyclonedx --output sbom.cdx.json myorg/myapp:1.4.2
Cache the vulnerability DB between CI runs to keep scans fast — Trivy downloads a multi-hundred-MB DB bundle on a cold cache, which dominates scan time on ephemeral runners:
- uses: actions/cache@v4
with:
path: ~/.cache/trivy
key: trivy-db-${{ github.run_id }}
restore-keys: trivy-db-
trivy image against the final built artifact in CI, not just
trivy fs against source — a base-image CVE only shows up once the
image is actually assembled, and fs mode alone will miss it.--exit-code as mandatory in CI, not optional — the default
"always exit 0" behavior is a common source of a Trivy gate that
silently never blocks anything.--ignore-unfixed for the day-to-day blocking gate and run a
separate, non-blocking scan without it on a schedule to track
unfixed CVEs for awareness (a future release may patch them, or the
risk calculus may change)..trivyignore entries auditable: one CVE per line, a comment
with rationale and a re-review date, never a blanket rule that
suppresses a whole package or severity tier.trivy config) and the resulting running artifact
(trivy image/trivy k8s) — a clean Terraform scan doesn't catch
drift introduced by manual console changes after apply; periodic
trivy k8s cluster scans catch that gap.Symptom: CI ran trivy image and reported CRITICAL findings, but
the pipeline stage still shows green.
Fix: --exit-code was omitted. Trivy's default exit code is 0
regardless of findings; add --exit-code 1 (or the equivalent
exit-code: '1' action input) explicitly.
Symptom: trivy fs . against a Node.js/Python repo reports zero
vulnerabilities even though npm audit/pip-audit finds several.
Fix: Trivy needs the lockfile, not just the manifest, to resolve
a real dependency tree — confirm package-lock.json/poetry.lock/
Gemfile.lock etc. is present and checked into the scanned path;
scanning a directory with only package.json (no lockfile) yields an
incomplete or empty result.
Symptom: The same image scanned twice in the same week shows a
new CRITICAL finding with no code or image changes.
Fix: This is expected — a CVE was newly disclosed against an
already-installed package version. Confirm the CVE ID against the
vendor advisory, then patch (bump the base image or package) or
suppress with a dated, justified .trivyignore entry; it is not a
scanner regression.
Symptom: trivy config on a Kubernetes manifest directory reports
a huge number of misconfigurations that were already accepted risk in
a prior review (e.g. hostNetwork: true on a deliberately
privileged DaemonSet).
Fix: Add scoped # trivy:ignore:<AVD-ID> comments with a
one-line rationale on the specific resource rather than disabling the
check globally with --skip-check, which suppresses it repo-wide and
hides the same misconfiguration if it appears somewhere unintended
later.
Symptom: Every CI run takes several extra minutes downloading the
Trivy vulnerability database before scanning even starts.
Fix: Cache ~/.cache/trivy between runs (see step 8), or run a
self-hosted Trivy DB mirror for air-gapped/high-volume environments
and point Trivy at it with TRIVY_DB_REPOSITORY, instead of pulling
the full DB fresh on every ephemeral runner.
A team's checkout-service has Trivy added at three points: an IaC gate
on Terraform PRs, an image-scan gate on the built container, and a
scheduled unfixed-CVE tracking scan.
.github/workflows/trivy.yml:
name: trivy
on:
pull_request:
schedule:
- cron: '0 4 * * 1' # weekly unfixed-CVE tracking
jobs:
iac-scan:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Trivy IaC scan
uses: aquasecurity/[email protected]
with:
scan-type: 'config'
scan-ref: 'infra/terraform'
severity: 'CRITICAL,HIGH'
exit-code: '1'
image-scan:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t checkout-service:${{ github.sha }} .
- name: Trivy image scan (blocking)
uses: aquasecurity/[email protected]
with:
image-ref: 'checkout-service:${{ github.sha }}'
severity: 'CRITICAL,HIGH'
exit-code: '1'
ignore-unfixed: true
unfixed-tracking:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build -t checkout-service:latest .
- name: Trivy image scan (informational, includes unfixed)
uses: aquasecurity/[email protected]
with:
image-ref: 'checkout-service:latest'
severity: 'CRITICAL,HIGH,MEDIUM'
exit-code: '0'
format: 'json'
output: 'trivy-unfixed-tracking.json'
Sample blocking finding on the image-scan job:
checkout-service (debian 12.5)
===============================
Total: 1 (CRITICAL: 1)
┌──────────┬────────────────┬──────────┬────────┬───────────────┬───────────────┐
│ Library │ Vulnerability │ Severity │ Status │ Installed Ver │ Fixed Ver │
├──────────┼────────────────┼──────────┼────────┼───────────────┼───────────────┤
│ libxml2 │ CVE-2024-ZZZZZ │ CRITICAL │ fixed │ 2.9.14-r1 │ 2.9.14-r2 │
└──────────┴────────────────┴──────────┴────────┴───────────────┴───────────────┘
Remediation: bump the base image tag (or explicitly apt-get install libxml2=2.9.14-r2 if pinned) and re-run trivy image locally to
confirm the finding clears before pushing.
What SKILL.md sets; muted values are Claude Code's defaults
15 skills in this plugin
/certificate-lifecycle-management-at-scaleGuides managing TLS/mTLS certificate lifecycle across many services and environments beyond a single Kubernetes cluster — enterprise CA integration (ACME private CA, Microsoft AD CS, cloud-managed private CAs), cross-service rotation automation, expiry monitoring/alerting, and CA hierarchy/trust-chain management for a mixed fleet of VMs, on-prem servers, and multiple clusters. Use when the user asks to "automate cert rotation across our whole fleet," "integrate with our enterprise CA," "why do we keep having certificate expiry outages," "design a CA hierarchy for the org," "track every certificate's expiry date across environments," or "cert-manager only covers our Kubernetes clusters, what about everything else." Distinct from cert-manager's Kubernetes-native scope — see `../../../kubernetes-platform/skills/cert-manager-tls-automation/SKILL.md`.
/enterprise-sso-and-idp-federation-configurationGuides configuring enterprise workforce single sign-on — SAML 2.0 and OIDC federation between an identity provider (Okta, Azure AD/Entra ID, Keycloak) and downstream applications, including metadata exchange, attribute/claim mapping, group-to-role provisioning (SCIM), and multi-IdP federation trust. Use when the user asks to "set up SAML SSO with Okta," "configure Azure AD/Entra ID as our OIDC provider," "stand up Keycloak as an internal IdP," "map IdP groups to application roles," "debug a SAML assertion that won't validate," or "federate a second IdP for an acquired company's users." Distinct from cloud-iam-hardening (workload/service IAM in a cloud provider) — this skill is about federating *human workforce* identity into applications for SSO.
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin security-tooling-skillsOther plugins' skills for the same job