Skip to content

Commit

Permalink
add debug mode parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
calinmarina committed Oct 10, 2023
1 parent 69cbbc0 commit 0d42daf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ inputs:
limit-severities-for-sarif:
description: 'limit severities for SARIF format'
required: false
debug-mode:
description: 'debug mode'
required: false
default: 'false'

runs:
using: 'docker'
Expand Down Expand Up @@ -119,3 +123,4 @@ runs:
- '-u ${{ inputs.github-pat }}'
- '-v ${{ inputs.trivy-config }}'
- '-z ${{ inputs.limit-severities-for-sarif }}'
- '-x ${{ inputs.debug }}'
8 changes: 7 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:z:" o; do
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:z:x:" o; do
case "${o}" in
a)
export scanType=${OPTARG}
Expand Down Expand Up @@ -71,6 +71,9 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:z:" o; do
z)
export limitSeveritiesForSARIF=${OPTARG}
;;
x)
export debugMode=${OPTARG}
;;
esac
done

Expand Down Expand Up @@ -157,6 +160,9 @@ fi
if [ "$hideProgress" == "true" ];then
ARGS="$ARGS --no-progress"
fi
if [ "$debugMode" == "true" ];then
ARGS="$ARGS --debug"
fi

listAllPkgs=$(echo $listAllPkgs | tr -d '\r')
if [ "$listAllPkgs" == "true" ];then
Expand Down
6 changes: 6 additions & 0 deletions test/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ bats_load_library bats-file
echo "$output"
assert_files_equal yamlconfig.test ./test/data/yamlconfig.test
}

@test "trivy image with debug mode on" {
# trivy image --debug github knqyf263/vuln-image:1.2.3
run ./entrypoint.sh "-x true" "-a image" "-b github" "-i knqyf263/vuln-image:1.2.3"
assert_output --partial '"package_url": "pkg:apk/ca-certificates@20171114-r0",'
}

0 comments on commit 0d42daf

Please sign in to comment.