Initial commit
This commit is contained in:
38
entrypoint.sh
Normal file
38
entrypoint.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
INPUT_IMAGE_NAME=$imageName
|
||||
INPUT_IMAGE_PREFIX=$imagePrefix
|
||||
INPUT_CONFIG_PATH=$config
|
||||
|
||||
set -e
|
||||
|
||||
# shellcheck disable=SC2155
|
||||
export LOWERCASE_INPUT_IMAGE_PREFIX="$(echo "$INPUT_IMAGE_PREFIX" | tr '[:upper:]' '[:lower:]')"
|
||||
IMAGE_NAME="$(echo "$LOWERCASE_INPUT_IMAGE_PREFIX" | sed 's/^https\?:\/\///')$INPUT_IMAGE_NAME"
|
||||
|
||||
if [ -n "$DOCKER_CONFIG_BASE64" ]; then
|
||||
echo "Retrieving docker config"
|
||||
mkdir "$HOME/.docker/"
|
||||
echo "$DOCKER_CONFIG_BASE64" | base64 -d > "$HOME/.docker/config.json"
|
||||
fi;
|
||||
|
||||
echo "Full image name: $IMAGE_NAME"
|
||||
|
||||
if [ -z "$INPUT_IMAGE_NAME" ]; then
|
||||
echo "No image name given."
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
GRYPE_OPTIONS=("-v")
|
||||
|
||||
if [ -n "$INPUT_CONFIG_PATH" ]; then
|
||||
GRYPE_OPTIONS+=("-c" "$INPUT_CONFIG_PATH")
|
||||
fi
|
||||
|
||||
GRYPE_OPTIONS+=("registry:${IMAGE_NAME}")
|
||||
|
||||
# shellcheck disable=SC2145
|
||||
echo "Running grype container scanning with options: ${GRYPE_OPTIONS[@]}"
|
||||
grype "${GRYPE_OPTIONS[@]}"
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user