Skip to content

Commit

Permalink
add option to update docker-host via cli parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
calinmarina committed Oct 10, 2023
1 parent 69cbbc0 commit 430ebd8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ inputs:
limit-severities-for-sarif:
description: 'limit severities for SARIF format'
required: false
docker-host:
description: 'unix domain socket path to use for docker scanning'
required: false

runs:
using: 'docker'
Expand Down Expand Up @@ -119,3 +122,4 @@ runs:
- '-u ${{ inputs.github-pat }}'
- '-v ${{ inputs.trivy-config }}'
- '-z ${{ inputs.limit-severities-for-sarif }}'
- '-y ${{ inputs.docker-host }}'
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:y:" 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}
;;
y)
export dockerHost=${OPTARG}
;;
esac
done

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

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

@test "trivy image with custom docker-host" {
# trivy image --docker-host unix:///var/run/docker.sock --severity CRITICAL --output image.test knqyf263/vuln-image:1.2.3
run ./entrypoint.sh '-y unix:///var/run/docker.sock' '-a image' '-i knqyf263/vuln-image:1.2.3' '-h image.test' '-g CRITICAL'
run diff image.test ./test/data/image.test
echo "$output"
assert_files_equal image.test ./test/data/image.test
}

0 comments on commit 430ebd8

Please sign in to comment.