Created
July 13, 2023 18:11
-
-
Save mdespriee/9fd04fcacf94825e0ef01decac2aae73 to your computer and use it in GitHub Desktop.
List vulnerabilities on ecr recent images
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
#!/bin/bash | |
repositories=$(aws ecr describe-repositories | jq -r '.repositories[].repositoryName') | |
for repo in $repositories | |
do | |
# latest image, having a version tag | |
latest_image=$(aws ecr describe-images --repository-name $repo --query 'sort_by(imageDetails,& imagePushedAt)[*]' | jq -r '.[] | select(.imageTags[] | startswith("v")) | "imageDigest=\(.imageDigest),imageTag=\(.imageTags[0])"' 2>/dev/null | tail -n 1 ) | |
if [ -z "$latest_image" ]; then | |
continue | |
fi | |
echo $repo $latest_image | |
findings=$(aws ecr describe-image-scan-findings --repository-name $repo --image-id $latest_image | jq '.imageScanFindings.findingSeverityCounts' ) | |
echo $findings | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment