-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
60 lines (56 loc) · 1.88 KB
/
action.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
name: Trivy
description: "Run a Trivy Scan and upload the results"
inputs:
image-ref:
description: "image to scan"
required: true
timeout:
description: "how long to scan"
default: 15m
vuln-type:
description: "types of vulnerabilities to report"
default: "os,library"
severity:
description: "severity of issues to report"
default: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL"
format:
description: "format of scan report"
default: "sarif"
output-file:
description: "file to export scan results"
default: "trivy-results.sarif"
runs:
using: "composite"
steps:
- name: Check if GHAS is enabled
uses: actions/github-script@v7
id: ghas-enabled
with:
script: |
const response = await github.rest.repos.get({
owner: '${{ github.repository }}'.split("/")[0],
repo: '${{ github.repository }}'.split("/")[1]
});
const private = response.data.private
if (private) {
const securityEnabled = response.data.security_and_analysis?.advanced_security?.status === 'enabled';
if (!securityEnabled) {
const message = 'GitHub Advanced Security is NOT enabled and repo is private. Can not upload report';
core.setFailed(message);
}
}
- name: Run Trivy vulnerability scanner
id: scan
uses: aquasecurity/trivy-action@master
with:
image-ref: "${{ inputs.image-ref }}"
timeout: "${{ inputs.timeout }}"
vuln-type: "${{ inputs.vuln-type }}"
severity: "${{ inputs.severity }}"
format: "${{ inputs.format }}"
output: "${{ inputs.output-file }}"
- name: Upload Trivy scan results to GitHub Security tab
id: upload
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "${{ inputs.output-file }}"