Skip to content

Commit

Permalink
Fix issue with passing image name to 'snyk-container' hook (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabasoad authored Nov 11, 2021
1 parent eb6666a commit 7a0afb6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
19 changes: 15 additions & 4 deletions hooks/snyk-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
set -eu
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
bash "${SCRIPT_DIR}"/_check-installation.sh
name=$(openssl rand -hex 4)
tag=$(openssl rand -hex 4)
docker build -t "${name}:${tag}" .
snyk container test "${name}:${tag}" "$@"

image="snyk-container-test:$(date +%s)"
for i in "$@"; do
case $i in
-i=*|--image=*)
image="${i#*=}"
;;
*)
# unknown option
;;
esac
done

docker build -t "${image}" .
snyk container test "${image}" "$@"
1 change: 1 addition & 0 deletions hooks/snyk-iac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
set -eu
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
bash "${SCRIPT_DIR}"/_check-installation.sh

snyk iac test "$@"
1 change: 1 addition & 0 deletions hooks/snyk-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
set -eu
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
bash "${SCRIPT_DIR}"/_check-installation.sh

snyk test "$@"

0 comments on commit 7a0afb6

Please sign in to comment.