Skip to content

Instantly share code, notes, and snippets.

@mdespriee
Created July 13, 2023 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdespriee/9fd04fcacf94825e0ef01decac2aae73 to your computer and use it in GitHub Desktop.
Save mdespriee/9fd04fcacf94825e0ef01decac2aae73 to your computer and use it in GitHub Desktop.
List vulnerabilities on ecr recent images
#!/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