From d5fb9e378955fee817b7633e4a18abda45d6b75c Mon Sep 17 00:00:00 2001 From: mag37 Date: Sat, 21 Jan 2023 12:37:48 +0100 Subject: [PATCH] bugquash-multidigest Changed the logic in comparing the digests - if the local check had multiple digests for an image, the old logic would be inaccurate. New logic just check if the newest digest is among the list of local digests, should avoid some false positives. --- dockcheck.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dockcheck.sh b/dockcheck.sh index 825c851..c69d681 100644 --- a/dockcheck.sh +++ b/dockcheck.sh @@ -62,14 +62,14 @@ for i in $(docker ps --filter "name=$SearchName" --format '{{.Names}}') do printf ". " RepoUrl=$(docker inspect "$i" --format='{{.Config.Image}}') - LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}' | sed -e 's/.*sha256/sha256/' -e 's/\]$//') - RegHash=$($regbin image digest --list "$RepoUrl" 2>/dev/null) + LocalHash=$(docker image inspect "$RepoUrl" --format '{{.RepoDigests}}') + RegHash=$(./regctl image digest --list "$RepoUrl" 2>/dev/null) # Check if regtcl produces errors - add to GotErrors if so. if [ $? -eq 0 ] ; then - if [[ "$LocalHash" != "$RegHash" ]] ; then - GotUpdates+=("$i") - else + if [[ "$LocalHash" = *"$RegHash"* ]] ; then NoUpdates+=("$i") + else + GotUpdates+=("$i") fi else GotErrors+=("$i")