-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add scan type as option * Fix exitCode * remove all options * Add default value to scanRef and improve shell * print args * fix description. * More changes
- Loading branch information
Showing
4 changed files
with
96 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM aquasec/trivy:latest | ||
COPY entrypoint.sh / | ||
RUN apk --no-cache add bash | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
set -e | ||
while getopts "a:b:c:d:e:f:g:h:i:j:" o; do | ||
case "${o}" in | ||
a) | ||
export scanType=${OPTARG} | ||
;; | ||
b) | ||
export format=${OPTARG} | ||
;; | ||
c) | ||
export template=${OPTARG} | ||
;; | ||
d) | ||
export exitCode=${OPTARG} | ||
;; | ||
e) | ||
export ignoreUnfixed=${OPTARG} | ||
;; | ||
f) | ||
export vulnType=${OPTARG} | ||
;; | ||
g) | ||
export severity=${OPTARG} | ||
;; | ||
h) | ||
export output=${OPTARG} | ||
;; | ||
i) | ||
export imageRef=${OPTARG} | ||
;; | ||
j) | ||
export scanRef=${OPTARG} | ||
;; | ||
esac | ||
done | ||
|
||
scanType=$(echo $scanType | tr -d '\r') | ||
export artifactRef="${imageRef}" | ||
if [ "${scanType}" = "fs" ];then | ||
artifactRef=$(echo $scanRef | tr -d '\r') | ||
fi | ||
|
||
ARGS="" | ||
if [ $format ];then | ||
ARGS="$ARGS --format $format" | ||
fi | ||
if [ $template ] ;then | ||
ARGS="$ARGS --template $template" | ||
fi | ||
if [ $exitCode ];then | ||
ARGS="$ARGS --exit-code $exitCode" | ||
fi | ||
if [ "$ignoreUnfixed" == "true" ];then | ||
ARGS="$ARGS --ignore-unfixed" | ||
fi | ||
if [ $vulnType ];then | ||
ARGS="$ARGS --vuln-type $vulnType" | ||
fi | ||
if [ $severity ];then | ||
ARGS="$ARGS --severity $severity" | ||
fi | ||
if [ $output ];then | ||
ARGS="$ARGS --output $output" | ||
fi | ||
|
||
echo "Runnin trivy with options" "${ARGS}" "${artifactRef}" | ||
trivy ${scanType} $ARGS ${artifactRef} |