From b38389f8efef9798810fe0c5b5096ac198cffd54 Mon Sep 17 00:00:00 2001 From: Donald Piret Date: Thu, 8 Apr 2021 03:50:09 +0800 Subject: [PATCH] feat: add support for cache dire and timeout inputs (#35) --- README.md | 3 ++- action.yaml | 10 ++++++++++ entrypoint.sh | 14 +++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68a8edd..6d14c81 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yaml b/action.yaml index fa49835..239c2e9 100644 --- a/action.yaml +++ b/action.yaml @@ -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" @@ -65,3 +73,5 @@ runs: - '-j ${{ inputs.scan-ref }}' - '-k ${{ inputs.skip-dirs }}' - '-l ${{ inputs.input }}' + - '-m ${{ inputs.cache-dir }}' + - '-n ${{ inputs.timeout }}' diff --git a/entrypoint.sh b/entrypoint.sh index 1f8090e..1ad4065 100644 --- 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:" 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} @@ -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 @@ -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}