Skip to content

Commit

Permalink
feat: improve script
Browse files Browse the repository at this point in the history
  • Loading branch information
nutellinoit committed Aug 23, 2024
1 parent 36d4e48 commit 9bec8cf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions patch_images_with_copacetic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@ file="to_be_patched.txt"

docker run --detach --rm --privileged -p 127.0.0.1:8888:8888/tcp --name buildkitd --entrypoint buildkitd moby/buildkit:v0.11.4 --addr tcp://0.0.0.0:8888 # --platform linux/amd64

echo "PATCH IMAGE REPORT:" > patch_report.txt

while IFS= read -r line; do
secured=$(echo "$line" | sed 's|registry.sighup.io/fury|registry.sighup.io/fury/secured|')
docker pull $line # --platform linux/amd64
trivy image -q --vuln-type os --ignore-unfixed -f json -o $(basename $line).json $line # --platform=linux/amd64
if copa patch -r $(basename $line).json -i $line -a tcp://0.0.0.0:8888 ; then
echo "############## SUCCESS, will execute:"
echo "############## SUCCESS, we will execute:"
echo "----> docker tag $line-patched $secured"
echo "----> docker push $secured"
echo "$secured: SUCCESS" > patch_report.txt
else
echo "%%%%%%%%%%%%%% COPA FAILED, will execute:"
echo "%%%%%%%%%%%%%% COPA FAILED, we will still execute:"
echo "----> docker tag $line $secured"
echo "----> docker push $secured"
echo "$secured: SKIPPED" > patch_report.txt
fi

done < "$file"

docker stop buildkitd
docker rm buildkitd
docker rm buildkitd

cat patch_report.txt

0 comments on commit 9bec8cf

Please sign in to comment.