-
-
Notifications
You must be signed in to change notification settings - Fork 25
74 lines (64 loc) · 2.13 KB
/
reusable-trivy-scan-image.yaml
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
---
name: Trivy Scan Image
on:
workflow_call:
inputs:
image:
# 'ghcr.io/${{ github.repository }}:${{ github.sha }}'
description: Image to scan
required: true
type: string
exit-code:
description: 1 if you want job to fail when CVEs are found
required: false
type: string
default: '0'
severity:
description: Comma delimited list of severities to scan for UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
required: false
type: string
default: 'HIGH,CRITICAL'
ignore-unfixed:
description: Ignore unpatched/unfixed vulnerabilities
required: false
type: boolean
default: true
upload-results:
description: Upload scan results to GitHub Security tab
required: false
type: boolean
default: false
secrets:
registry-username:
description: Username for registry
required: true
registry-password:
description: Password for registry
required: true
jobs:
build:
name: CVE Image Scan
runs-on: ubuntu-latest
permissions: read-all
steps:
- name: Which image are we scanning?
run: |
echo "Image to scan: ${{ inputs.image }}"
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: ${{ inputs.image }}
format: table # table, json, sarif
exit-code: ${{ inputs.exit-code }} # 1 or 0. 0 means don't fail the job if issues are found
ignore-unfixed: ${{ inputs.ignore-unfixed }} # Ignore unpatched/unfixed vulnerabilities
vuln-type: 'os,library'
severity: ${{ inputs.severity }} # UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL
timeout: 10m0s
env:
TRIVY_USERNAME: ${{ secrets.registry-username }}
TRIVY_PASSWORD: ${{ secrets.registry-password }}
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always() && inputs.upload-results
with:
sarif_file: 'trivy-results.sarif'