Compare commits

...
3 Commits
Author SHA1 Message Date
Valentin Laurin ac8de07fd1 Pass --cache-dir as global argument to Trivy (#51) 2021-05-27 09:03:06 -07:00
Anand Gautam 09b815c470 feat: add ignore-policy option to filter vulnerabilities (#48)
* feat: add ignore-policy option to filter vulnerabilities

* fix: format README
2021-05-26 13:12:03 -07:00
Simar 0ce0e69d98 Update README.md 2021-05-17 12:03:58 -07:00
3 changed files with 22 additions and 7 deletions
+3 -2
View File
@@ -284,13 +284,14 @@ Following inputs can be used as `step.with` keys:
| `format` | String | `table` | Output format (`table`, `json`, `template`) | | `format` | String | `table` | Output format (`table`, `json`, `template`) |
| `template` | String | | Output template (`@/contrib/sarif.tpl`, `@/contrib/gitlab.tpl`, `@/contrib/junit.tpl`)| | `template` | String | | Output template (`@/contrib/sarif.tpl`, `@/contrib/gitlab.tpl`, `@/contrib/junit.tpl`)|
| `output` | String | | Save results to a file | | `output` | String | | Save results to a file |
| `exit-code` | String | `0` | Exit code when vulnerabilities were found | | `exit-code` | String | `0` | Exit code when specified vulnerabilities are found |
| `ignore-unfixed` | Boolean | false | Ignore unpatched/unfixed vulnerabilities | | `ignore-unfixed` | Boolean | false | Ignore unpatched/unfixed vulnerabilities |
| `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 scanned for and 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 | | `cache-dir` | String | | Cache directory |
| `timeout` | String | `2m0s` | Scan timeout duration | | `timeout` | String | `2m0s` | Scan timeout duration |
| `ignore-policy` | String | | Filter vulnerabilities with OPA rego language |
[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
+5
View File
@@ -57,6 +57,10 @@ inputs:
description: 'timeout (default 2m0s)' description: 'timeout (default 2m0s)'
required: false required: false
default: '' default: ''
ignore-policy:
description: 'filter vulnerabilities with OPA rego language'
required: false
default: ''
runs: runs:
using: 'docker' using: 'docker'
image: "Dockerfile" image: "Dockerfile"
@@ -75,3 +79,4 @@ runs:
- '-l ${{ inputs.input }}' - '-l ${{ inputs.input }}'
- '-m ${{ inputs.cache-dir }}' - '-m ${{ inputs.cache-dir }}'
- '-n ${{ inputs.timeout }}' - '-n ${{ inputs.timeout }}'
- '-o ${{ inputs.ignore-policy }}'
+14 -5
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:l:m:n:" o; do while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:" o; do
case "${o}" in case "${o}" in
a) a)
export scanType=${OPTARG} export scanType=${OPTARG}
@@ -44,6 +44,9 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:" o; do
n) n)
export timeout=${OPTARG} export timeout=${OPTARG}
;; ;;
o)
export ignorePolicy=${OPTARG}
;;
esac esac
done done
@@ -58,6 +61,11 @@ if [ $input ]; then
fi fi
ignoreUnfixed=$(echo $ignoreUnfixed | tr -d '\r') ignoreUnfixed=$(echo $ignoreUnfixed | tr -d '\r')
GLOBAL_ARGS=""
if [ $cacheDir ];then
GLOBAL_ARGS="$GLOBAL_ARGS --cache-dir $cacheDir"
fi
ARGS="" ARGS=""
if [ $format ];then if [ $format ];then
ARGS="$ARGS --format $format" ARGS="$ARGS --format $format"
@@ -86,12 +94,13 @@ if [ $skipDirs ];then
ARGS="$ARGS --skip-dirs $i" ARGS="$ARGS --skip-dirs $i"
done done
fi fi
if [ $cacheDir ];then
ARGS="$ARGS --cache-dir $cacheDir"
fi
if [ $timeout ];then if [ $timeout ];then
ARGS="$ARGS --timeout $timeout" ARGS="$ARGS --timeout $timeout"
fi fi
if [ $ignorePolicy ];then
ARGS="$ARGS --ignore-policy $ignorePolicy"
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} echo "Global options: " "${GLOBAL_ARGS}"
trivy $GLOBAL_ARGS ${scanType} --no-progress $ARGS ${artifactRef}