Created
November 22, 2019 08:25
-
-
Save eoftedal/4f319dd694896770e771e3b6931cdc48 to your computer and use it in GitHub Desktop.
Scan an image using OWASP Dependency check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export COLOR_NC=$(tput sgr0) | |
export COLOR_GREEN=$(tput setaf 2) | |
if [ $# -ne 2 ]; then | |
echo "ERROR: no image given" | |
echo "USAGE: ./scan.sh <some_image>[:some_tag] <path in image>" | |
exit 1 | |
fi | |
REPORT_DIR=$(pwd)/dep-check | |
mkdir -p $REPORT_DIR | |
chmod -R 777 $REPORT_DIR | |
IMAGE=$1 | |
PATH_IN_IMAGE=$2 | |
echo "$COLOR_GREEN" | |
echo "Report dir: $REPORT_DIR" | |
echo "Image : $IMAGE" | |
echo "Path : $PATH_IN_IMAGE" | |
echo " " | |
echo "Creating temporary scanning image..." | |
echo "$COLOR_NC" | |
echo " | |
FROM $IMAGE AS source | |
FROM owasp/dependency-check AS depcheck | |
COPY --from=source $PATH_IN_IMAGE/* /src/" | docker build -t temp-depcheck-scan - | |
docker volume inspect owasp-dep-check > /dev/null 2>&1 || docker volume create owasp-dep-check | |
echo "$COLOR_GREEN" | |
echo "Running scan...$COLOR_NC" | |
docker run --rm \ | |
--volume owasp-dep-check:/usr/share/dependency-check/data \ | |
--volume "$REPORT_DIR":/report \ | |
temp-depcheck-scan \ | |
--scan /src \ | |
--format "ALL" \ | |
--project "Scan of image $IMAGE" \ | |
--out /report | |
echo "$COLOR_GREEN" | |
echo "Deleting temporary scan image... $COLOR_NC" | |
docker rmi temp-depcheck-scan | |
echo "$COLOR_GREEN" | |
echo "Done. See reports in $REPORT_DIR $COLOR_NC" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment