Compare commits

...
3 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
rahul2393andSimarpreet Singh e2054f8b6a Added input option support (#34)
* Added input option support

* Fix position of input flag

* update readme

* Update README.md

Co-authored-by: Simarpreet Singh <simar@linux.com>
2021-03-24 13:54:13 -07:00
Simarpreet Singh 6890ac5cba Update README.md 2021-03-19 15:25:03 -07:00
3 changed files with 38 additions and 1 deletions
+3
View File
@@ -136,6 +136,7 @@ Following inputs can be used as `step.with` keys:
| Name | Type | Default | Description | | Name | Type | Default | Description |
|------------------|---------|------------------------------------|-----------------------------------------------| |------------------|---------|------------------------------------|-----------------------------------------------|
| `scan-type` | String | `image` | Scan type, e.g. `image` or `fs`| | `scan-type` | String | `image` | Scan type, e.g. `image` or `fs`|
| `input` | String | | Tar reference, e.g. `alpine-latest.tar` |
| `image-ref` | String | | Image reference, e.g. `alpine:3.10.2` | | `image-ref` | String | | Image reference, e.g. `alpine:3.10.2` |
| `scan-ref` | String | `/github/workspace/` | Scan reference, e.g. `/github/workspace/` or `.`| | `scan-ref` | String | `/github/workspace/` | Scan reference, e.g. `/github/workspace/` or `.`|
| `format` | String | `table` | Output format (`table`, `json`, `template`) | | `format` | String | `table` | Output format (`table`, `json`, `template`) |
@@ -146,6 +147,8 @@ Following inputs can be used as `step.with` keys:
| `vuln-type` | String | `os,library` | Vulnerability types (os,library) | | `vuln-type` | String | `os,library` | Vulnerability types (os,library) |
| `severity` | String | `UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL` | Severities of vulnerabilities to be displayed | | `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 | | `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]: https://github.com/aquasecurity/trivy-action/releases/latest
[release-img]: https://img.shields.io/github/release/aquasecurity/trivy-action.svg?logo=github [release-img]: https://img.shields.io/github/release/aquasecurity/trivy-action.svg?logo=github
[marketplace]: https://github.com/marketplace/actions/aqua-security-trivy [marketplace]: https://github.com/marketplace/actions/aqua-security-trivy
+15
View File
@@ -9,6 +9,10 @@ inputs:
image-ref: image-ref:
description: 'image reference(for backward compatibility)' description: 'image reference(for backward compatibility)'
required: true required: true
input:
description: 'reference of tar file to scan'
required: false
default: ''
scan-ref: scan-ref:
description: 'Scan reference' description: 'Scan reference'
required: false required: false
@@ -45,6 +49,14 @@ inputs:
description: 'comma separated list of directories where traversal is skipped' description: 'comma separated list of directories where traversal is skipped'
required: false required: false
default: '' default: ''
cache-dir:
description: 'specify where the cache is stored'
required: false
default: ''
timeout:
description: 'timeout (default 2m0s)'
required: false
default: ''
runs: runs:
using: 'docker' using: 'docker'
image: "Dockerfile" image: "Dockerfile"
@@ -60,3 +72,6 @@ runs:
- '-i ${{ inputs.image-ref }}' - '-i ${{ inputs.image-ref }}'
- '-j ${{ inputs.scan-ref }}' - '-j ${{ inputs.scan-ref }}'
- '-k ${{ inputs.skip-dirs }}' - '-k ${{ inputs.skip-dirs }}'
- '-l ${{ inputs.input }}'
- '-m ${{ inputs.cache-dir }}'
- '-n ${{ inputs.timeout }}'
+20 -1
View File
@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -e set -e
while getopts "a:b:c:d:e:f:g:h:i:j:k:" o; do while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:" o; do
case "${o}" in case "${o}" in
a) a)
export scanType=${OPTARG} export scanType=${OPTARG}
@@ -35,6 +35,15 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:" o; do
k) k)
export skipDirs=${OPTARG} export skipDirs=${OPTARG}
;; ;;
l)
export input=${OPTARG}
;;
m)
export cacheDir=${OPTARG}
;;
n)
export timeout=${OPTARG}
;;
esac esac
done done
@@ -43,6 +52,10 @@ export artifactRef="${imageRef}"
if [ "${scanType}" = "fs" ];then if [ "${scanType}" = "fs" ];then
artifactRef=$(echo $scanRef | tr -d '\r') artifactRef=$(echo $scanRef | tr -d '\r')
fi fi
input=$(echo $input | tr -d '\r')
if [ $input ]; then
artifactRef="--input $input"
fi
ignoreUnfixed=$(echo $ignoreUnfixed | tr -d '\r') ignoreUnfixed=$(echo $ignoreUnfixed | tr -d '\r')
ARGS="" ARGS=""
@@ -70,6 +83,12 @@ fi
if [ $skipDirs ];then if [ $skipDirs ];then
ARGS="$ARGS --skip-dirs $skipDirs" ARGS="$ARGS --skip-dirs $skipDirs"
fi 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}" echo "Running trivy with options: " --no-progress "${ARGS}" "${artifactRef}"
trivy ${scanType} --no-progress $ARGS ${artifactRef} trivy ${scanType} --no-progress $ARGS ${artifactRef}