Skip to content

Commit

Permalink
chore: Include skip options other than severity filter option when bu…
Browse files Browse the repository at this point in the history
…ilding SARIF report. (#79)
  • Loading branch information
rahul2393 authored Nov 10, 2021
1 parent 1ccef26 commit 2a2157e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ if [ $cacheDir ];then
GLOBAL_ARGS="$GLOBAL_ARGS --cache-dir $cacheDir"
fi

SARIF_ARGS=""
ARGS=""
if [ $format ];then
ARGS="$ARGS --format $format"
Expand All @@ -82,9 +83,11 @@ if [ $exitCode ];then
fi
if [ "$ignoreUnfixed" == "true" ] && [ "$scanType" != "config" ];then
ARGS="$ARGS --ignore-unfixed"
SARIF_ARGS="$SARIF_ARGS --ignore-unfixed"
fi
if [ $vulnType ] && [ "$scanType" != "config" ];then
ARGS="$ARGS --vuln-type $vulnType"
SARIF_ARGS="$SARIF_ARGS --vuln-type $vulnType"
fi
if [ $severity ];then
ARGS="$ARGS --severity $severity"
Expand All @@ -96,13 +99,15 @@ if [ $skipDirs ];then
for i in $(echo $skipDirs | tr "," "\n")
do
ARGS="$ARGS --skip-dirs $i"
SARIF_ARGS="$SARIF_ARGS --skip-dirs $i"
done
fi
if [ $timeout ];then
ARGS="$ARGS --timeout $timeout"
fi
if [ $ignorePolicy ];then
ARGS="$ARGS --ignore-policy $ignorePolicy"
SARIF_ARGS="$SARIF_ARGS --ignore-policy $ignorePolicy"
fi
if [ "$hideProgress" == "true" ];then
ARGS="$ARGS --no-progress"
Expand All @@ -117,8 +122,8 @@ returnCode=$?
# regardless of severity level specified in this report.
# This is a feature, not a bug :)
if [[ ${template} == *"sarif"* ]]; then
echo "Building SARIF report"
trivy --quiet ${scanType} --format template --template ${template} --output ${output} ${artifactRef}
echo "Building SARIF report with options: ${SARIF_ARGS}" "${artifactRef}"
trivy --quiet ${scanType} --format template --template ${template} --output ${output} $SARIF_ARGS ${artifactRef}
fi

exit $returnCode

0 comments on commit 2a2157e

Please sign in to comment.