-
Notifications
You must be signed in to change notification settings - Fork 20
111 lines (100 loc) · 3.17 KB
/
scan.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Platform Vulnerability Scanning
on:
push:
branches:
- main
pull_request:
branches:
- main
- stable**
workflow_dispatch:
inputs:
cve_severity:
description: 'Severities of vulnerabilities to scanned for, [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL]'
required: false
default: 'CRITICAL,HIGH'
ignore_unfixed:
description: 'Include unfixed vulnerabilities in scan [true,false]'
required: false
default: 'true'
workflow_call:
inputs:
cve_severity:
description: 'Severities of vulnerabilities to scanned for, [UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL]'
required: false
default: 'CRITICAL,HIGH'
type: string
ignore_unfixed:
description: 'Include unfixed vulnerabilities in scan [true,false]'
required: false
default: 'true'
type: string
exit_code:
description: 'Exit code if vulnerabilities found [0,1]'
required: false
default: '1'
type: string
jobs:
scan_repo:
name: Scan Repo
env:
SEVERITY: 'HIGH,CRITICAL'
REPORT: 'repo-results.sarif'
IGNORE_UNFIXED: 'true'
EXIT_CODE: '1'
TRIVY_SKIP_DB_UPDATE: true
TRIVY_SKIP_JAVA_DB_UPDATE: true
runs-on: ubuntu-latest
steps:
- name: Adding code-scanning URL
run: echo "### [code-scanning results](https://github.com/${{ github.repository }}/security/code-scanning?query=branch%3A${{ github.ref_name }})" >> $GITHUB_STEP_SUMMARY
- name: Set inputs
if: github.event_name == 'workflow_call' || github.event_name == 'workflow_dispatch'
run: |
echo "SEVERITY=${{ inputs.cve_severity }}" >> $GITHUB_ENV
echo "IGNORE_UNFIXED=${{ inputs.ignore_unfixed }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
- name: Trivy vulnerability scanner
if: env.SEVERITY != ''
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
exit-code: '1'
ignore-unfixed: ${{ env.IGNORE_UNFIXED }}
severity: ${{ env.SEVERITY }}
scanners: 'vuln'
skip-dirs: './docker'
- name: Trivy Configuration scanner (no fail)
if: env.SEVERITY != ''
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
exit-code: '0'
ignore-unfixed: ${{ env.IGNORE_UNFIXED }}
severity: ${{ env.SEVERITY }}
scanners: 'config,secret'
skip-dirs: './docker'
- name: Create Report
if: success() || failure()
uses: aquasecurity/trivy-action@master
with:
format: 'sarif'
output: ${{ env.REPORT }}
scan-type: 'fs'
exit-code: '0'
ignore-unfixed: ${{ env.IGNORE_UNFIXED }}
scanners: 'vuln'
skip-dirs: './docker'
- name: Upload Trivy scan results to GitHub Security tab
if: success() || failure()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ env.REPORT }}
- name: Store CVE report
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ env.REPORT }}
path: ${{ env.REPORT }}
retention-days: 3