Compare commits

...

1 Commits

Author SHA1 Message Date
Donald Piret
b38389f8ef feat: add support for cache dire and timeout inputs (#35) 2021-04-07 12:50:09 -07:00
3 changed files with 25 additions and 2 deletions

View File

@@ -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

View File

@@ -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 }}'

View File

@@ -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}