Skip to content

Commit

Permalink
feat: add support for cache dire and timeout inputs (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldpiret authored Apr 7, 2021
1 parent e2054f8 commit b38389f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ Following inputs can be used as `step.with` keys:
| `vuln-type` | String | `os,library` | Vulnerability types (os,library) |
| `severity` | String | `UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL` | Severities of vulnerabilities to be displayed |
| `skip-dirs` | String | | Comma separated list of directories where traversal is skipped |

| `cache-dir` | String | | Cache directory |
| `timeout` | String | `2m0s` | Scan timeout duration |
[release]: https://github.com/aquasecurity/trivy-action/releases/latest
[release-img]: https://img.shields.io/github/release/aquasecurity/trivy-action.svg?logo=github
[marketplace]: https://github.com/marketplace/actions/aqua-security-trivy
Expand Down
10 changes: 10 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ inputs:
description: 'comma separated list of directories where traversal is skipped'
required: false
default: ''
cache-dir:
description: 'specify where the cache is stored'
required: false
default: ''
timeout:
description: 'timeout (default 2m0s)'
required: false
default: ''
runs:
using: 'docker'
image: "Dockerfile"
Expand All @@ -65,3 +73,5 @@ runs:
- '-j ${{ inputs.scan-ref }}'
- '-k ${{ inputs.skip-dirs }}'
- '-l ${{ inputs.input }}'
- '-m ${{ inputs.cache-dir }}'
- '-n ${{ inputs.timeout }}'
14 changes: 13 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:" o; do
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:" o; do
case "${o}" in
a)
export scanType=${OPTARG}
Expand Down Expand Up @@ -38,6 +38,12 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:" o; do
l)
export input=${OPTARG}
;;
m)
export cacheDir=${OPTARG}
;;
n)
export timeout=${OPTARG}
;;
esac
done

Expand Down Expand Up @@ -77,6 +83,12 @@ fi
if [ $skipDirs ];then
ARGS="$ARGS --skip-dirs $skipDirs"
fi
if [ $cacheDir ];then
ARGS="$ARGS --cache-dir $cacheDir"
fi
if [ $timeout ];then
ARGS="$ARGS --timeout $timeout"
fi

echo "Running trivy with options: " --no-progress "${ARGS}" "${artifactRef}"
trivy ${scanType} --no-progress $ARGS ${artifactRef}

0 comments on commit b38389f

Please sign in to comment.