Skip to content

Commit

Permalink
Merge pull request #13 from simar7/sarif-support
Browse files Browse the repository at this point in the history
SARIF: Add support for sarif output
  • Loading branch information
simar7 authored Jul 28, 2020
2 parents f498173 + 8cc32f7 commit 6d50808
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,42 @@ jobs:
severity: 'CRITICAL,HIGH'
```
### Using Trivy with GitHub Code Scanning
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: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.14
- 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 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 Security tab
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: 'trivy-results.sarif'
```
## Customizing
### inputs
Expand All @@ -59,7 +95,9 @@ Following inputs can be used as `step.with` keys:
| Name | Type | Default | Description |
|------------------|---------|------------------------------------|-----------------------------------------------|
| `image-ref` | String | | Image reference, e.g. `alpine:3.10.2` |
| `format` | String | `table` | Output format (`table`, `json`) |
| `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 |
| `ignore-unfixed` | Boolean | false | Ignore unpatched/unfixed vulnerabilities |
| `severity` | String | `UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL` | Severities of vulnerabilities to be displayed |
Expand Down
12 changes: 11 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,26 @@ inputs:
required: false
default: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
format:
description: 'output format (table, json)'
description: 'output format (table, json, template)'
required: false
default: 'table'
template:
description: 'use an existing template for rendering output (@contrib/sarif.tpl, @contrib/gitlab.tpl, @contrib/junit.tpl'
required: false
default: ''
output:
description: 'writes results to a file with the specified file name'
required: false
default: ''
runs:
using: 'docker'
image: 'docker://docker.io/aquasec/trivy:latest'
args:
- 'image'
- '--format=${{ inputs.format }}'
- '--template=${{ inputs.template }}'
- '--exit-code=${{ inputs.exit-code }}'
- '--ignore-unfixed=${{ inputs.ignore-unfixed }}'
- '--severity=${{ inputs.severity }}'
- '--output=${{ inputs.output }}'
- '${{ inputs.image-ref }}'

0 comments on commit 6d50808

Please sign in to comment.