Skip to content

Commit 71451b5

Browse files
authored
[CIRDEVOPS-2553] Adds parameters to debug trivy issues (#99)
* [CIRDEVOPS-2553] parameterize trivy output format * [CIRDEVOPS-2553] parameterize trivy output filename * [CIRDEVOPS-2553] parameterize trivy output filename [1] * [CIRDEVOPS-2553] Add parameter to inspect trivy output * [CIRDEVOPS-2553] When trivy inspect is on, upload result as an artifact
1 parent 5b1c150 commit 71451b5

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

.github/workflows/terraform.yaml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ on:
77
type: boolean
88
default: true
99
required: false
10+
trivy_format:
11+
description: Output format (table, json, sarif, github)
12+
type: string
13+
default: sarif
14+
required: false
15+
trivy_output:
16+
description: Save results to a file
17+
type: string
18+
default: 'trivy-results.sarif'
19+
required: false
20+
trivy_inspect_output:
21+
description: Print trivy output for inspection, set to 'true' for debugging purposes
22+
type: string
23+
default: 'false'
24+
required: false
1025
main_branch:
1126
description: Name of the main branch
1227
type: string
@@ -326,22 +341,30 @@ jobs:
326341
with:
327342
scan-type: 'config'
328343
hide-progress: false
329-
format: 'sarif'
330-
output: 'trivy-results.sarif'
344+
format: ${{ inputs.trivy_format }}
345+
output: ${{ inputs.trivy_output }}
331346
ignore-unfixed: true
332347
severity: 'CRITICAL,HIGH'
333348

349+
- name: Upload Trivy scan results to Github for inspection
350+
if: ${{ inputs.trivy_inspect_output == 'true' }}
351+
uses: actions/upload-artifact@v4
352+
with:
353+
path: ${{ inputs.trivy_output }}
354+
retention-days: 1
355+
334356
# https://github.com/aquasecurity/trivy/issues/5003
335357
- name: Remove git from url for sarif uploading
358+
if: ${{ inputs.trivy_format == 'sarif' && inputs.trivy_output != '' }}
336359
shell: bash
337360
run: |
338-
sed -i 's#git::https:/##g' trivy-results.sarif
361+
sed -i 's#git::https:/##g' ${{ inputs.trivy_output }}
339362
340363
- name: Upload Trivy scan results to GitHub Security tab
364+
if: inputs.upload_sarif == true
341365
uses: github/codeql-action/upload-sarif@v3
342366
with:
343-
sarif_file: 'trivy-results.sarif'
344-
# if: inputs.upload_sarif == true
367+
sarif_file: ${{ inputs.trivy_output }}
345368

346369
- name: Get changed files
347370
id: changed-files

0 commit comments

Comments
 (0)