Skip to content

Commit 1f6384b

Browse files
authored
docs(report): improve documentation around Using Trivy to generate SBOM and sending it to Github (#307)
* Improved documentation with details on how to send output as an artifact on Github and giving an example of a private image scan * formatting * better name for job
1 parent 84384bd commit 1f6384b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,49 @@ jobs:
337337
github-pat: ${{ secrets.GITHUB_TOKEN }} # or ${{ secrets.github_pat_name }} if you're using a PAT
338338
```
339339

340+
When scanning images you may want to parse the actual output JSON as Github Dependency doesn't show all details like the file path of each dependency for instance.
341+
342+
You can upload the report as an artifact and download it, for instance using the [upload-artifact action](https://github.com/actions/upload-artifact):
343+
344+
```yaml
345+
---
346+
name: Pull Request
347+
on:
348+
push:
349+
branches:
350+
- main
351+
352+
## GITHUB_TOKEN authentication, add only if you're not going to use a PAT
353+
permissions:
354+
contents: write
355+
356+
jobs:
357+
build:
358+
name: Checks
359+
runs-on: ubuntu-20.04
360+
steps:
361+
- name: Scan image in a private registry
362+
uses: aquasecurity/trivy-action@master
363+
with:
364+
image-ref: "private_image_registry/image_name:image_tag"
365+
scan-type: image
366+
format: 'github'
367+
output: 'dependency-results.sbom.json'
368+
github-pat: ${{ secrets.GITHUB_TOKEN }} # or ${{ secrets.github_pat_name }} if you're using a PAT
369+
severity: "MEDIUM,HIGH,CRITICAL"
370+
scanners: "vuln"
371+
env:
372+
TRIVY_USERNAME: "image_registry_admin_username"
373+
TRIVY_PASSWORD: "image_registry_admin_password"
374+
375+
- name: Upload trivy report as a Github artifact
376+
uses: actions/upload-artifact@v4
377+
with:
378+
name: trivy-sbom-report
379+
path: '${{ github.workspace }}/dependency-results.sbom.json'
380+
retention-days: 20 # 90 is the default
381+
```
382+
340383
### Using Trivy to scan your private registry
341384
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.
342385

0 commit comments

Comments
 (0)