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

View File

@@ -284,13 +284,14 @@ Following inputs can be used as `step.with` keys:
| `format` | String | `table` | Output format (`table`, `json`, `template`) |
| `template` | String | | Output template (`@/contrib/sarif.tpl`, `@/contrib/gitlab.tpl`, `@/contrib/junit.tpl`)|
| `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 |
| `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 |
| `cache-dir` | String | | Cache directory |
| `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-img]: https://img.shields.io/github/release/aquasecurity/trivy-action.svg?logo=github

View File

@@ -57,6 +57,10 @@ inputs:
description: 'timeout (default 2m0s)'
required: false
default: ''
ignore-policy:
description: 'filter vulnerabilities with OPA rego language'
required: false
default: ''
runs:
using: 'docker'
image: "Dockerfile"
@@ -75,3 +79,4 @@ runs:
- '-l ${{ inputs.input }}'
- '-m ${{ inputs.cache-dir }}'
- '-n ${{ inputs.timeout }}'
- '-o ${{ inputs.ignore-policy }}'

View File

@@ -1,6 +1,6 @@
#!/bin/bash
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
a)
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)
export timeout=${OPTARG}
;;
o)
export ignorePolicy=${OPTARG}
;;
esac
done
@@ -58,6 +61,11 @@ if [ $input ]; then
fi
ignoreUnfixed=$(echo $ignoreUnfixed | tr -d '\r')
GLOBAL_ARGS=""
if [ $cacheDir ];then
GLOBAL_ARGS="$GLOBAL_ARGS --cache-dir $cacheDir"
fi
ARGS=""
if [ $format ];then
ARGS="$ARGS --format $format"
@@ -86,12 +94,13 @@ if [ $skipDirs ];then
ARGS="$ARGS --skip-dirs $i"
done
fi
if [ $cacheDir ];then
ARGS="$ARGS --cache-dir $cacheDir"
fi
if [ $timeout ];then
ARGS="$ARGS --timeout $timeout"
fi
if [ $ignorePolicy ];then
ARGS="$ARGS --ignore-policy $ignorePolicy"
fi
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}