tricks/scripts/get-scan-report
Elia el Lazkani ca43188adf
Some checks are pending
continuous-integration/drone/push Build is running
chore(): Adds new attach scan report script
2023-07-04 23:11:09 +02:00

44 lines
1 KiB
Bash
Executable file

#!/bin/sh
set -e
image=$@
image_information=$(oras discover --artifact-type application/json "$image")
#printf "$image_information\n"
printf "Found image $image...\n"
report_digest=$(echo "$image_information" | tail -n1 | awk -F ' ' '{print $2}')
#printf "$report_digest\n"
printf "Found digests for scan report...\n"
extra_vars=""
if [ ! -z $REGISTRY_USERNAME ]; then
printf "Found registry username...\n"
extra_vars="$extra_vars --username $REGISTRY_USERNAME"
fi
if [ ! -z REGISTRY_PASSWORD ]; then
printf "Found registry password\n"
extra_vars="$extra_vars --password $REGISTRY_PASSWORD"
fi
printf "Cleaning result file, if it already exists...\n"
if [ -e result.json ]; then
rm result.json
fi
image_base=$(echo "$image" | awk -F ':' '{print $1}')
printf "Pulling $image_base:@$report_digest...\n"
oras pull $extra_vars $image_base:@$report_digest
printf "Checking for result file..."
if [ -e result.json ]; then
printf "Result file found !"
exit 0
else
printf "Result file not found !"
exit 1
fi