Created
September 19, 2024 09:03
-
-
Save dejanu/1fe3117992ef674385b38de4b9e1c45c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
########################################### | |
# ## | |
# @dejanualex: Trivy based image scanner ## | |
# ## | |
########################################### | |
# CreatedSince: how long vs. CreatedAt: exact timestamp | |
echo -e "\e[36mYou have \e[33m$(docker system info --format '{{ .Images}}')\e[36m images on your machine:\e[0m" | |
docker images --format "{{ .Repository }}:{{ .Tag }} -----> Created: {{ .CreatedSince }}" | |
echo -e "\e[36mPass the image name to scan: i.e repo:tag\e[0m" | |
read image_name | |
echo -e "\e[36mScanning image...${image_name}, Report will be generated at /tmp/report/report_$(date +%d_%m_%Y_%S).html\e[0m" | |
timestamp=$(date +%d_%m_%Y_%S) | |
# trivy scan | |
mkdir -p /tmp/report | |
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/Library/Caches:/root/.cache/ -v /tmp/report:/tmp aquasec/trivy:latest image \ | |
-f template --template "@contrib/html.tpl" -o /tmp/report_"${timestamp}".html ${image_name} | |
echo -e "\e[36mConsider running: \e[33mdocker container prune -f && docker image prune -f\e[36m to clean-up your local machine\e[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment