Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f85b76679f |
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
FROM aquasec/trivy:0.21.0
|
FROM aquasec/trivy:latest
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
RUN apk --no-cache add bash
|
RUN apk --no-cache add bash
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
@@ -88,43 +88,6 @@ jobs:
|
|||||||
|
|
||||||
You can find a more in-depth example here: https://github.com/aquasecurity/trivy-sarif-demo/blob/master/.github/workflows/scan.yml
|
You can find a more in-depth example here: https://github.com/aquasecurity/trivy-sarif-demo/blob/master/.github/workflows/scan.yml
|
||||||
|
|
||||||
If you would like to upload SARIF results to GitHub Code scanning even upon a non zero exit code from Trivy Scan, you can add the following to your upload step:
|
|
||||||
```yaml
|
|
||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Build an image from Dockerfile
|
|
||||||
run: |
|
|
||||||
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
|
|
||||||
format: 'template'
|
|
||||||
template: '@/contrib/sarif.tpl'
|
|
||||||
output: 'trivy-results.sarif'
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
if: always()
|
|
||||||
with:
|
|
||||||
sarif_file: 'trivy-results.sarif'
|
|
||||||
```
|
|
||||||
|
|
||||||
See this for more details: https://docs.github.com/en/actions/learn-github-actions/expressions#always
|
|
||||||
|
|
||||||
### Using Trivy to scan your Git repo
|
### Using Trivy to scan your Git repo
|
||||||
It's also possible to scan your git repos with Trivy's built-in repo scan. This can be handy if you want to run Trivy as a build time check on each PR that gets opened in your repo. This helps you identify potential vulnerablites that might get introduced with each PR.
|
It's also possible to scan your git repos with Trivy's built-in repo scan. This can be handy if you want to run Trivy as a build time check on each PR that gets opened in your repo. This helps you identify potential vulnerablites that might get introduced with each PR.
|
||||||
|
|
||||||
@@ -144,6 +107,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build an image from Dockerfile
|
||||||
|
run: |
|
||||||
|
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner in repo mode
|
- name: Run Trivy vulnerability scanner in repo mode
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
@@ -160,223 +127,6 @@ jobs:
|
|||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using Trivy to scan your rootfs directories
|
|
||||||
It's also possible to scan your rootfs directories with Trivy's built-in rootfs scan. This can be handy if you want to run Trivy as a build time check on each PR that gets opened in your repo. This helps you identify potential vulnerablites that might get introduced with each PR.
|
|
||||||
|
|
||||||
If you have [GitHub code scanning](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning) available you can use Trivy as a scanning tool as follows:
|
|
||||||
```yaml
|
|
||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner with rootfs command
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
scan-type: 'rootfs'
|
|
||||||
scan-ref: 'rootfs-example-binary'
|
|
||||||
ignore-unfixed: true
|
|
||||||
format: 'template'
|
|
||||||
template: '@/contrib/sarif.tpl'
|
|
||||||
output: 'trivy-results.sarif'
|
|
||||||
severity: 'CRITICAL'
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
with:
|
|
||||||
sarif_file: 'trivy-results.sarif'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using Trivy to scan Infrastucture as Code
|
|
||||||
It's also possible to scan your IaC repos with Trivy's built-in repo scan. This can be handy if you want to run Trivy as a build time check on each PR that gets opened in your repo. This helps you identify potential vulnerablites that might get introduced with each PR.
|
|
||||||
|
|
||||||
If you have [GitHub code scanning](https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning) available you can use Trivy as a scanning tool as follows:
|
|
||||||
```yaml
|
|
||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner in IaC mode
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
scan-type: 'config'
|
|
||||||
hide-progress: false
|
|
||||||
format: 'table'
|
|
||||||
exit-code: '1'
|
|
||||||
ignore-unfixed: true
|
|
||||||
severity: 'CRITICAL,HIGH'
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
with:
|
|
||||||
sarif_file: 'trivy-results.sarif'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Using Trivy to scan your private registry
|
|
||||||
It's also possible to scan your private registry with Trivy's built-in image scan. All you have to do is set ENV vars.
|
|
||||||
|
|
||||||
#### Docker Hub registry
|
|
||||||
Docker Hub needs `TRIVY_USERNAME` and `TRIVY_PASSWORD`.
|
|
||||||
You don't need to set ENV vars when downloading from a public repository.
|
|
||||||
```yaml
|
|
||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
|
|
||||||
format: 'template'
|
|
||||||
template: '@/contrib/sarif.tpl'
|
|
||||||
output: 'trivy-results.sarif'
|
|
||||||
env:
|
|
||||||
TRIVY_USERNAME: Username
|
|
||||||
TRIVY_PASSWORD: Password
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
with:
|
|
||||||
sarif_file: 'trivy-results.sarif'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### AWS ECR (Elastic Container Registry)
|
|
||||||
Trivy uses AWS SDK. You don't need to install `aws` CLI tool.
|
|
||||||
You can use [AWS CLI's ENV Vars][env-var].
|
|
||||||
|
|
||||||
[env-var]: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
|
|
||||||
```yaml
|
|
||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
image-ref: 'aws_account_id.dkr.ecr.region.amazonaws.com/imageName:${{ github.sha }}'
|
|
||||||
format: 'template'
|
|
||||||
template: '@/contrib/sarif.tpl'
|
|
||||||
output: 'trivy-results.sarif'
|
|
||||||
env:
|
|
||||||
AWS_ACCESS_KEY_ID: key_id
|
|
||||||
AWS_SECRET_ACCESS_KEY: access_key
|
|
||||||
AWS_DEFAULT_REGION: us-west-2
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
with:
|
|
||||||
sarif_file: 'trivy-results.sarif'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### GCR (Google Container Registry)
|
|
||||||
Trivy uses Google Cloud SDK. You don't need to install `gcloud` command.
|
|
||||||
|
|
||||||
If you want to use target project's repository, you can set it via `GOOGLE_APPLICATION_CREDENTIAL`.
|
|
||||||
```yaml
|
|
||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
|
|
||||||
format: 'template'
|
|
||||||
template: '@/contrib/sarif.tpl'
|
|
||||||
output: 'trivy-results.sarif'
|
|
||||||
env:
|
|
||||||
GOOGLE_APPLICATION_CREDENTIAL: /path/to/credential.json
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
with:
|
|
||||||
sarif_file: 'trivy-results.sarif'
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Self-Hosted
|
|
||||||
BasicAuth server needs `TRIVY_USERNAME` and `TRIVY_PASSWORD`.
|
|
||||||
if you want to use 80 port, use NonSSL `TRIVY_NON_SSL=true`
|
|
||||||
```yaml
|
|
||||||
name: build
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
|
||||||
uses: aquasecurity/trivy-action@master
|
|
||||||
with:
|
|
||||||
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
|
|
||||||
format: 'template'
|
|
||||||
template: '@/contrib/sarif.tpl'
|
|
||||||
output: 'trivy-results.sarif'
|
|
||||||
env:
|
|
||||||
TRIVY_USERNAME: Username
|
|
||||||
TRIVY_PASSWORD: Password
|
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
|
||||||
with:
|
|
||||||
sarif_file: 'trivy-results.sarif'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Customizing
|
## Customizing
|
||||||
|
|
||||||
### inputs
|
### inputs
|
||||||
@@ -386,21 +136,15 @@ 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`) |
|
||||||
| `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 specified vulnerabilities are found |
|
| `exit-code` | String | `0` | Exit code when vulnerabilities were 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 scanned for and 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-files` | String | | Comma separated list of files 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]: 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
|
||||||
|
|||||||
-35
@@ -9,10 +9,6 @@ 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,30 +41,6 @@ inputs:
|
|||||||
description: 'writes results to a file with the specified file name'
|
description: 'writes results to a file with the specified file name'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
skip-dirs:
|
|
||||||
description: 'comma separated list of directories where traversal is skipped'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
skip-files:
|
|
||||||
description: 'comma separated list of files to be skipped'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
cache-dir:
|
|
||||||
description: 'specify where the cache is stored'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
timeout:
|
|
||||||
description: 'timeout (default 5m0s)'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
ignore-policy:
|
|
||||||
description: 'filter vulnerabilities with OPA rego language'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
hide-progress:
|
|
||||||
description: 'hide progress output'
|
|
||||||
required: false
|
|
||||||
default: 'true'
|
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: "Dockerfile"
|
image: "Dockerfile"
|
||||||
@@ -83,10 +55,3 @@ runs:
|
|||||||
- '-h ${{ inputs.output }}'
|
- '-h ${{ inputs.output }}'
|
||||||
- '-i ${{ inputs.image-ref }}'
|
- '-i ${{ inputs.image-ref }}'
|
||||||
- '-j ${{ inputs.scan-ref }}'
|
- '-j ${{ inputs.scan-ref }}'
|
||||||
- '-k ${{ inputs.skip-dirs }}'
|
|
||||||
- '-l ${{ inputs.input }}'
|
|
||||||
- '-m ${{ inputs.cache-dir }}'
|
|
||||||
- '-n ${{ inputs.timeout }}'
|
|
||||||
- '-o ${{ inputs.ignore-policy }}'
|
|
||||||
- '-p ${{ inputs.hide-progress }}'
|
|
||||||
- '-q ${{ inputs.skip-files }}'
|
|
||||||
|
|||||||
Executable → Regular
+6
-75
@@ -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:p:q:" o; do
|
while getopts "a:b:c:d:e:f:g:h:i:j:" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
a)
|
a)
|
||||||
export scanType=${OPTARG}
|
export scanType=${OPTARG}
|
||||||
@@ -32,48 +32,16 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:" o; do
|
|||||||
j)
|
j)
|
||||||
export scanRef=${OPTARG}
|
export scanRef=${OPTARG}
|
||||||
;;
|
;;
|
||||||
k)
|
|
||||||
export skipDirs=${OPTARG}
|
|
||||||
;;
|
|
||||||
l)
|
|
||||||
export input=${OPTARG}
|
|
||||||
;;
|
|
||||||
m)
|
|
||||||
export cacheDir=${OPTARG}
|
|
||||||
;;
|
|
||||||
n)
|
|
||||||
export timeout=${OPTARG}
|
|
||||||
;;
|
|
||||||
o)
|
|
||||||
export ignorePolicy=${OPTARG}
|
|
||||||
;;
|
|
||||||
p)
|
|
||||||
export hideProgress=${OPTARG}
|
|
||||||
;;
|
|
||||||
q)
|
|
||||||
export skipFiles=${OPTARG}
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
scanType=$(echo $scanType | tr -d '\r')
|
scanType=$(echo $scanType | tr -d '\r')
|
||||||
export artifactRef="${imageRef}"
|
export artifactRef="${imageRef}"
|
||||||
if [ "${scanType}" = "fs" ] || [ "${scanType}" = "config" ] || [ "${scanType}" = "rootfs" ];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')
|
||||||
hideProgress=$(echo $hideProgress | tr -d '\r')
|
|
||||||
|
|
||||||
GLOBAL_ARGS=""
|
|
||||||
if [ $cacheDir ];then
|
|
||||||
GLOBAL_ARGS="$GLOBAL_ARGS --cache-dir $cacheDir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
SARIF_ARGS=""
|
|
||||||
ARGS=""
|
ARGS=""
|
||||||
if [ $format ];then
|
if [ $format ];then
|
||||||
ARGS="$ARGS --format $format"
|
ARGS="$ARGS --format $format"
|
||||||
@@ -84,13 +52,11 @@ fi
|
|||||||
if [ $exitCode ];then
|
if [ $exitCode ];then
|
||||||
ARGS="$ARGS --exit-code $exitCode"
|
ARGS="$ARGS --exit-code $exitCode"
|
||||||
fi
|
fi
|
||||||
if [ "$ignoreUnfixed" == "true" ] && [ "$scanType" != "config" ];then
|
if [ "$ignoreUnfixed" == "true" ];then
|
||||||
ARGS="$ARGS --ignore-unfixed"
|
ARGS="$ARGS --ignore-unfixed"
|
||||||
SARIF_ARGS="$SARIF_ARGS --ignore-unfixed"
|
|
||||||
fi
|
fi
|
||||||
if [ $vulnType ] && [ "$scanType" != "config" ];then
|
if [ $vulnType ];then
|
||||||
ARGS="$ARGS --vuln-type $vulnType"
|
ARGS="$ARGS --vuln-type $vulnType"
|
||||||
SARIF_ARGS="$SARIF_ARGS --vuln-type $vulnType"
|
|
||||||
fi
|
fi
|
||||||
if [ $severity ];then
|
if [ $severity ];then
|
||||||
ARGS="$ARGS --severity $severity"
|
ARGS="$ARGS --severity $severity"
|
||||||
@@ -98,41 +64,6 @@ fi
|
|||||||
if [ $output ];then
|
if [ $output ];then
|
||||||
ARGS="$ARGS --output $output"
|
ARGS="$ARGS --output $output"
|
||||||
fi
|
fi
|
||||||
if [ $skipDirs ];then
|
|
||||||
for i in $(echo $skipDirs | tr "," "\n")
|
|
||||||
do
|
|
||||||
ARGS="$ARGS --skip-dirs $i"
|
|
||||||
SARIF_ARGS="$SARIF_ARGS --skip-dirs $i"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [ $timeout ];then
|
|
||||||
ARGS="$ARGS --timeout $timeout"
|
|
||||||
fi
|
|
||||||
if [ $ignorePolicy ];then
|
|
||||||
ARGS="$ARGS --ignore-policy $ignorePolicy"
|
|
||||||
SARIF_ARGS="$SARIF_ARGS --ignore-policy $ignorePolicy"
|
|
||||||
fi
|
|
||||||
if [ "$hideProgress" == "true" ];then
|
|
||||||
ARGS="$ARGS --no-progress"
|
|
||||||
fi
|
|
||||||
if [ "$skipFiles" ];then
|
|
||||||
for i in $(echo $skipFiles | tr "," "\n")
|
|
||||||
do
|
|
||||||
ARGS="$ARGS --skip-files $i"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Running trivy with options: ${ARGS}" "${artifactRef}"
|
echo "Running trivy with options: " "${ARGS}" "${artifactRef}"
|
||||||
echo "Global options: " "${GLOBAL_ARGS}"
|
trivy ${scanType} --no-progress $ARGS ${artifactRef}
|
||||||
trivy $GLOBAL_ARGS ${scanType} $ARGS ${artifactRef}
|
|
||||||
returnCode=$?
|
|
||||||
|
|
||||||
# SARIF is special. We output all vulnerabilities,
|
|
||||||
# regardless of severity level specified in this report.
|
|
||||||
# This is a feature, not a bug :)
|
|
||||||
if [[ ${template} == *"sarif"* ]]; then
|
|
||||||
echo "Building SARIF report with options: ${SARIF_ARGS}" "${artifactRef}"
|
|
||||||
trivy --quiet ${scanType} --format template --template ${template} --output ${output} $SARIF_ARGS ${artifactRef}
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $returnCode
|
|
||||||
|
|||||||
Reference in New Issue
Block a user