chore(): Adds new attach scan report script
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
Elia el Lazkani 2023-07-04 21:51:49 +02:00
parent 9ebf78caca
commit ca43188adf
2 changed files with 32 additions and 1 deletions

31
scripts/attach-scan-report Executable file
View file

@ -0,0 +1,31 @@
#!/bin/sh
set -xe
TIMESTAMP=$(date "+%F %T %Z")
image="$@"
printf "Set image to $image...\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
extra_vars="$extra_vars -a \"org.opencontainers.trivy.created=$TIMESTAMP\" -a \"org.opencontainers.trivy.status=Passed\" -a \"org.opencontainers.trivy.tag=${DRONE_COMMIT_SHA:0:8}\""
printf "Checking for result file...\n"
if [ -e result.json ]; then
printf "Result file found, attaching it to container...\n"
oras attach $extra_vars --artifact-type=application/json $image "result.json"
else
printf "Result file not found !\n"
exit 1
fi

View file

@ -21,7 +21,7 @@ fi
if [ ! -z REGISTRY_PASSWORD ]; then if [ ! -z REGISTRY_PASSWORD ]; then
printf "Found registry password\n" printf "Found registry password\n"
extra_vars="$extra_vars --password $REGISTRY_PASSWORD " extra_vars="$extra_vars --password $REGISTRY_PASSWORD"
fi fi