Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions .github/scripts/check_ecr_image_scan_results.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

if [ -z "${REPOSITORY_NAME}" ]; then
echo "REPOSITORY_NAME not set"
Expand All @@ -17,12 +18,14 @@ function wait_for_scan() {
echo "SCAN IS NOT YET COMPLETE..."
sleep 3
done
echo "Final sleep to ensure suppressions are applied correctly"
sleep 5
}

function check_for_high_critical_vuln() {
scan_results=$(aws ecr describe-image-scan-findings --repository-name "${REPOSITORY_NAME}" --image-id imageTag="${IMAGE_TAG}")
high=$(echo "$scan_results" | jq .imageScanFindings.findingSeverityCounts.HIGH)
critical=$(echo "$scan_results" | jq .imageScanFindings.findingSeverityCounts.CRITICAL)
high=$(echo "$scan_results" | jq '.imageScanFindings.enhancedFindings[]? | select(.severity == "HIGH" and .status != "SUPPRESSED")')
critical=$(echo "$scan_results" | jq '.imageScanFindings.enhancedFindings[]? | select(.severity == "CRITICAL" and .status != "SUPPRESSED")')
}

function return_scan_results() {
Expand All @@ -35,20 +38,31 @@ function return_error() {
echo -e "\n**********************************************************"
echo "**********************************************************"
echo "**********************************************************"
echo "ERROR: There are CRITICAL/HIGH vulnerabilties. Stopping build."
echo "ERROR: There are CRITICAL/HIGH vulnerabilities. Stopping build."
echo "**********************************************************"
echo "**********************************************************"
echo "**********************************************************"
exit 2
}

function analyze_scan_results() {
if [[ $critical -gt 0 ]]; then
echo "ERROR: There are CRITICAL vulnerabilties. Stopping build."
if [[ -n "$critical" ]]; then
echo "ERROR: There are CRITICAL vulnerabilities. Stopping build."

echo "=== BEGIN CRITICAL IMAGE SCAN RESULTS ==="
echo "$critical"
echo "=== END CRITICAL IMAGE SCAN RESULTS ==="

return_scan_results

return_error
elif [[ $high -gt 0 ]]; then
echo "ERROR: There are HIGH vulnerabilties. Stopping build."
elif [[ -n "$high" ]]; then
echo "ERROR: There are HIGH vulnerabilities. Stopping build."

echo "=== BEGIN HIGH IMAGE SCAN RESULTS ==="
echo "$high"
echo "=== END HIGH IMAGE SCAN RESULTS ==="

return_scan_results
return_error
else
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ RUN asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
# install some common node versions that are used in builds to speed things up
RUN asdf install nodejs 20.19.1
RUN asdf install nodejs 23.9.0
RUN asdf install nodejs 20.17.0
RUN asdf install nodejs 20.19.0
RUN asdf install nodejs 22.12.0

Expand Down