-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (72 loc) · 2.42 KB
/
trivy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
#
# This workflow runs Trivy on a Docker image
# It can pull the image from a container registry
# or download a tar file. The latter is used
# to check a container image prior to publishing
# to the registry.
name: Run Trivy on a Docker image and push results to GitHub
on:
workflow_call:
inputs:
SOURCE_TYPE: # 'tar' or 'image'
required: true
type: string
TARFILE_NAME: # only used if SOURCE_TYPE=='tar'
required: false
type: string
IMAGE_NAME:
required: true
type: string
EXIT_CODE:
required: false
type: number
env:
sarif_file_name: trivy-results.sarif
jobs:
trivy:
name: Trivy
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download tar file
id: tar-download
uses: actions/download-artifact@v4
if: ${{ inputs.SOURCE_TYPE == 'tar' }}
with:
name: ${{ inputs.TARFILE_NAME }}
path: /tmp
- name: load docker image from tar file
if: ${{ inputs.SOURCE_TYPE == 'tar' }}
run: cat ${{ steps.tar-download.outputs.download-path
}}/${{ inputs.TARFILE_NAME
}} | docker import - ${{ inputs.IMAGE_NAME }}
- name: Run Trivy vulnerability scanner for any major issues
uses: aquasecurity/[email protected]
id: trivy
with:
image-ref: ${{ inputs.IMAGE_NAME }}
ignore-unfixed: true # skip vul'ns for which there is no fix
# list files to skip, each with a justification
#skip-files: |
severity: 'CRITICAL,HIGH'
format: 'sarif'
# only output findings for configured severities
limit-severities-for-sarif: true
output: ${{ env.sarif_file_name }}
exit-code: ${{ inputs.EXIT_CODE }}
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/[email protected]
# This is the recommended way to upload scan results
# after Trivy exits with HIGH/CRITICAL findings
# See https://github.com/aquasecurity/trivy-action?\
# tab=readme-ov-file#using-trivy-with-github-code-scanning
if: ${{ success() || steps.trivy.conclusion=='failure' }}
with:
sarif_file: ${{ env.sarif_file_name }}
wait-for-processing: true
...