Build a container image security gate with Trivy
Build a container image security gate with Trivy
A container image can pass a functional test while still carrying an unpatched package, a credential left in a layer, or a Dockerfile setting that is unsuitable for the environment where it will run. Those are different problems, so a useful build gate needs to report them separately and make its failure policy explicit.
This guide builds a small, repeatable gate around Trivy 0.73.0. The result is a CI job that scans a pinned container image for high and critical vulnerabilities, checks the source tree for infrastructure-as-code problems and secrets, saves machine-readable reports, and fails only when the policy says it should. It is appropriate for a repository that builds an OCI image and has a controlled CI environment. The commands are documentation-verified; adapt image names, registries, retention, and approval rules to the local delivery process.