FIELD GUIDE 12Infrastructure and security

aquasecurity / trivy

Trivy earns its place by scanning the artifact you actually ship

One command can cover packages, operating-system vulnerabilities, application dependencies, secrets, configuration and SBOM output. The difficult part begins when a finding needs evidence, ownership and a repair decision.

WHAT TO KNOW FIRST

  1. Trivy brings several scanners to the same targets, but vulnerability, secret, configuration and license findings have different evidence and remediation paths.
  2. Database age, package detection and upstream advisory quality affect results. A clean scan is not proof that an artifact has no exploitable weakness.
  3. The useful unit is a maintained policy: pinned tool behavior, saved output, accountable exceptions and rechecks after the artifact or intelligence changes.

01One interface, several distinct questions

Trivy describes itself as a comprehensive and versatile security scanner. It can inspect container images, filesystems, repositories and other supported targets for multiple classes of issue. Vulnerability scanning looks for known problems in operating-system packages and application dependencies. Misconfiguration scanning evaluates infrastructure and deployment definitions. Secret scanning searches content for credential-like material. License scanning and software bill of materials features answer additional supply-chain questions.

These capabilities share a command-line interface, but they should not be collapsed into one undifferentiated risk score. A vulnerable package has advisory, version and fix evidence. A misconfiguration maps code to a rule about secure setup. A secret finding concerns credential exposure and rotation. An SBOM is an inventory artifact rather than a verdict. Trivy's convenience is that the same build and repository context can produce all of them. A sound workflow preserves the distinctions when routing findings to owners.

02Choose the target that matches the release boundary

Scanning source before a build gives early feedback on lock files, manifests, secrets and configuration. Scanning a filesystem can inspect an unpacked application or host-like tree. Scanning the final container image includes operating-system packages and application material that actually reached the artifact. Kubernetes and cloud-oriented modes evaluate another layer of deployed or configured state. No one target fully represents all the others.

This is why an image scan can disagree with a repository scan without either result being a bug. A multi-stage build may leave compilers and development dependencies behind. The final image may add a base-layer package absent from source manifests. Generated configuration may exist only in deployment output. The strongest pipeline scans early enough to give developers context and scans the final immutable artifact before promotion. The saved result should identify the exact digest, commit or path so a later reviewer knows what was examined.

03Vulnerability matching depends on package evidence

Trivy detects package metadata, determines installed versions and compares them with vulnerability data from supported advisory sources. For operating-system packages, distribution-specific advisories can be more relevant than a generic version comparison because vendors may backport fixes without changing the upstream version in an obvious way. Application dependencies rely on their ecosystem's package and advisory information. Findings can include severity, affected package, installed version, fixed version and references.

A scanner does not reproduce an exploit or prove reachability. A package can be present but unused, a vulnerable function can be unreachable, or an advisory can later be corrected. The reverse is also important: absence from a vulnerability database does not prove safety. Triage should begin with artifact presence and advisory detail, then consider exposure and available fixes. Suppressing a finding because it appears unreachable is a recorded risk decision, not a correction to the package inventory.

  • Keep vulnerability databases fresh and record when a scan ran.
  • Prefer fixed-version and vendor-advisory evidence over severity labels alone.
  • Re-scan unchanged artifacts when advisory data changes, because the code is not the only input to the result.

04Misconfiguration scanning moves review before deployment

Trivy can evaluate supported infrastructure-as-code and configuration formats against built-in checks. This catches risky declarations while they are still code, such as an exposed service, a permissive container setting or an unencrypted resource where a rule applies. The result normally includes the source location, check identifier, message and remediation guidance. That location makes the finding suitable for pull-request feedback and ownership by the team proposing the change.

A static rule cannot know every environmental control or business exception. A public endpoint may be intentional and protected elsewhere. A secure-looking setting may still be ineffective because the deployed platform ignores it. Rules can also change as Trivy updates its checks. Teams should test rule-set upgrades, document exceptions narrowly and verify critical controls against deployed state. Misconfiguration scanning is most valuable as an early policy conversation, followed by runtime or platform evidence where the control matters.

05Secret findings demand a different clock

Secret scanning searches files for patterns and entropy associated with credentials and tokens. Running it in a developer workflow can stop obvious exposure before a commit or image is shared. Running it against repositories and final artifacts can reveal secrets introduced through configuration, generated files or build context. The result points to content that needs careful handling, so logs and retained reports should avoid unnecessarily redistributing the sensitive value.

If a real credential has entered version history or a published artifact, deleting the current line is not sufficient. The credential may remain usable in earlier commits, caches, logs or pulled images. The owner should revoke or rotate it, assess access and then remove the material from the appropriate surfaces. Pattern matching also produces false positives, so validation must be prompt but controlled. A broad permanent ignore for one false positive can hide a later real secret in the same path.

06SBOM output is inventory that can travel

Trivy can generate and consume software bills of materials in supported formats. An SBOM records components associated with an artifact and can be stored alongside release evidence. This decouples some inventory work from later vulnerability analysis. A producer can generate an SBOM during the trusted build, and a consumer or security service can scan it as advisory information changes without necessarily unpacking the original artifact again.

Inventory quality still depends on detection. Vendored binaries, dynamically fetched plugins, generated packages and runtime downloads may not appear in an SBOM derived from one filesystem view. Conversely, a manifest-based inventory can include dependencies that never reached production. Record how and when the SBOM was produced, connect it to an immutable artifact identifier and protect its integrity. The document is most useful when it complements provenance and build records rather than being presented as a complete security certificate.

07CI policy needs exceptions with an expiry

Trivy exposes exit-code, severity, ignore and output controls that make it suitable for automated gates. The tempting policy is to fail every build on every high-severity finding. Existing applications can then become permanently red, teaching developers that the gate is background noise. A better rollout establishes a baseline, blocks newly introduced actionable findings and gives older items owners and target dates. Machine-readable formats preserve enough detail for tracking and later review.

Ignore mechanisms are necessary for disputed, accepted or non-applicable findings, but every exception should be narrow. Identify the advisory or check, target scope, reason, approver and expiration. Revisit it after tool and database updates. Pinning a Trivy version improves reproducibility, while updating it and its databases maintains coverage; both goals need a planned cadence. Canary builds can inform testing, but production gates should use a chosen release and reviewed rule behavior.

08What a scanner can and cannot establish

Trivy can establish that a particular version of the tool, with particular databases and configuration, found or did not find specified issues in a defined target. It cannot establish that the target is secure against unknown vulnerabilities, runtime attacks, compromised build infrastructure or unsafe application logic. It also does not decide business impact. A low-severity issue in an exposed control path can matter more than a critical package that is unreachable in a build stage never shipped.

The repository's Apache-2.0 license is permissive, and the official releases make the scanner easy to place in varied workflows. The lasting value comes from evidence discipline. Identify the artifact, retain the result, update intelligence, route each class of finding and verify remediation. Used this way, Trivy is more than a colorful build check. It becomes a repeatable inventory and policy step that connects development changes with security decisions.

A SENSIBLE FIRST HOUR

Start small enough to learn the repo

  1. Install a signed or checksummed official release using a documented method, then record the exact Trivy version in the repository or CI configuration.
  2. Scan one small repository or container image with the default vulnerability and secret behavior. Save machine-readable output as an artifact rather than relying only on terminal color.
  3. Review each reported package, installed version, fixed version and source path. Confirm whether the affected component is present in the shipped artifact and whether a fix is actually available.
  4. Add a bounded CI policy with an owner, severity threshold, ignore expiry and database-update strategy. Start by preventing new actionable findings instead of blocking every historical issue at once.

SOURCE LEDGER

What this review is built on

We use the project repository and first-party documentation. Access, licenses and project direction can change, so recheck the linked source before making a production decision.

  1. aquasecurity/trivy repositoryrepository
  2. Trivy documentationdocumentation
  3. Trivy vulnerability scanner documentationdocumentation
  4. Trivy releasesrelease
  5. Apache 2.0 licenselicense