From 0db6232a711e0cbf7433365c283920157364dad8 Mon Sep 17 00:00:00 2001 From: "Calin Marina (OSV)" Date: Tue, 10 Oct 2023 15:54:08 +0100 Subject: [PATCH] add debug mode parameter --- action.yaml | 5 +++++ entrypoint.sh | 8 +++++++- test/test.bats | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 3e37c9b..0ecb85b 100644 --- a/action.yaml +++ b/action.yaml @@ -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' @@ -119,3 +123,4 @@ runs: - '-u ${{ inputs.github-pat }}' - '-v ${{ inputs.trivy-config }}' - '-z ${{ inputs.limit-severities-for-sarif }}' + - '-x ${{ inputs.debug }}' diff --git a/entrypoint.sh b/entrypoint.sh index 26a9dae..4a5405a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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} @@ -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 @@ -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 diff --git a/test/test.bats b/test/test.bats index 13a69ce..98fd603 100644 --- a/test/test.bats +++ b/test/test.bats @@ -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",' +}