Skip to content

Commit

Permalink
fixup! feat(cve-scan-patch): improve logging and bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
g-iannelli committed Oct 7, 2024
1 parent 2d6d449 commit e145689
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CVEs/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ BLACK='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
WHITE='\033[1;37m'

function info() {
echo -e ">>\t[INFO] $(date +"%Y-%m-%dT%H:%M:%S.%3NZ"): $*"
echo -e ">>\t${CYAN}[INFO]${NC} $(date +"%Y-%m-%dT%H:%M:%S.%3NZ"): $*"
}

function warn() {
Expand Down
17 changes: 8 additions & 9 deletions CVEs/patch_images_with_copacetic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ fi
mkdir -p "$TRIVY_SCAN_OUTPUT_DIR" "$COPA_PATCH_OUTPUT_DIR" "$DOCKERFILE_OUTPUT_DIR" "$LOG_OUTPUT_DIR"
echo -n "" > "${PATCH_ERROR_OUTPUT_FILE}"

{
[[ -n $IMAGE_TO_PATCH ]] && printf "# %s\n\n" $IMAGE_TO_PATCH
printf "Last updated %s\n\n" "$(date +'%Y-%m-%d')";
printf "## CVEs patched\n\n" ;
echo "| Source Image | Source Image Hash |CVE | Severity | Description | Patched Image| Patched Image Hash |"
echo "| --- | --- | --- | --- |--- | --- | --- |"
} > "${PATCH_REPORT_OUTPUT_FILE}"


REGISTRY_BASE_URL='registry.sighup.io/fury/'
REGISTRY_SECURED_BASE_URL='registry.sighup.io/fury-secured/'

Expand Down Expand Up @@ -89,6 +80,14 @@ function patch_image() {

if [ "$copa_exit_code" -eq 0 ]
then
{
[[ -n $IMAGE_TO_PATCH ]] && printf "# %s\n\n" $IMAGE_TO_PATCH
printf "Last updated %s\n\n" "$(date +'%Y-%m-%d')";
printf "## CVEs patched\n\n" ;
echo "| Source Image | Source Image Hash |CVE | Severity | Description | Patched Image| Patched Image Hash |"
echo "| --- | --- | --- | --- |--- | --- | --- |"
} > "${PATCH_REPORT_OUTPUT_FILE}"

FIXED_CVES=$(jq '.statements[] | select(.status=="fixed") | .vulnerability."@id"' -r < "$COPA_REPORT_OUTPUT_FILE" | sort -r )
info "${FIXED_CVES//[$'\r\n']/ } patched in $image_to_patch-patched"
DOCKER_LABELS=
Expand Down

0 comments on commit e145689

Please sign in to comment.