Trivy¶
pre-commit hook¶
Usage:
- repo: https://github.com/mxab/pre-commit-trivy.git
rev: v0.12.0
hooks:
- id: trivyconfig-docker
args:
- Containerfile
Config¶
- Configuration
- Cli options can be exported as env vars (i.e.
--debug->TRIVY_DEBUG=true trivy ...)
Ignore checks¶
Ignore checks with a .trivyignore¶
$ cat .trivyignore
# Root file system is not read-only
# https://avd.aquasec.com/misconfig/kubernetes/general/avd-ksv-0014/
AVD-KSV-0014
Inline ignores¶
- Docs: Ignore by Inline Comments
- Only work in certain files, i.e. OpenTofu files, doesn't seem to work in
Containerfilei.e. - i.e.:
#trivy:ignore:AVD-GCP-0051
Usage¶
Show the different trivy component versions (core, Vulnerability DB, Check Bundle) together with download times:
Filesystem scan¶
Scan local filesystem (i.e. to check a Containerfile, next to others):
Scan container image¶
trivy image php:8.4.4-apache-bullseye
trivy image php:8.4.4-apache-bullseye | head -5 # Hide details
TRIVY_IGNORE_UNFIXED=true trivy image php:8.4.4-apache-bullseye # Only show fixed CVEs
Kubernetes scanning¶
Usage:
Speed up scanning¶
Use --skip-images flag, which speeds up scanning:
trivy --debug k8s --skip-images --report all --timeout 30m -o trivy-scan.log
trivy --debug k8s --skip-images --report all --timeout 30m --format json -o trivy-scan.json
trivy-operator¶
Usage¶
List trivy-operator CRDs:
List all custom resources on cluster:
for crd in $(k get crd | grep aqua | cut -d' ' -f1); do echo -e "\n${crd}:"; kubectl get -A $crd; done
Troubleshooting¶
Reports¶
- Docs: Reporting
- Tools for viewing Trivy reports
- trivy-vulnerability-explorer
- Unforunatly still no support for K8s cluster report
scan2html¶
Install:
Generate html report: