Skip to content

Commit

Permalink
feat: add ignore-policy option to filter vulnerabilities (#48)
Browse files Browse the repository at this point in the history
* feat: add ignore-policy option to filter vulnerabilities

* fix: format README
  • Loading branch information
anandg112 authored May 26, 2021
1 parent 0ce0e69 commit 09b815c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ Following inputs can be used as `step.with` keys:
| `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
Expand Down
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -75,3 +79,4 @@ runs:
- '-l ${{ inputs.input }}'
- '-m ${{ inputs.cache-dir }}'
- '-n ${{ inputs.timeout }}'
- '-o ${{ inputs.ignore-policy }}'
8 changes: 7 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -92,6 +95,9 @@ 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}

0 comments on commit 09b815c

Please sign in to comment.