Created
March 11, 2021 00:35
-
-
Save ams0/2a3ab70d7a2d03fa301e750704e03fa5 to your computer and use it in GitHub Desktop.
A script to scan all images in the current Kubernetes cluster with Trivy (https://github.com/aquasecurity/trivy) for high & critical vulnerabilities.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
if [ ! -f /usr/local/bin/trivy ]; then | |
echo "Trivy not found! Please install it from https://github.com/aquasecurity/trivy" | |
fi | |
for image in `kubectl get pods --all-namespaces -o jsonpath="{..image}" |\ | |
tr -s '[[:space:]]' '\n' |\ | |
sort |\ | |
uniq -c | awk '{print $2}'`; do trivy image -s HIGH,CRITICAL $image; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment