|
7 | 7 | type: boolean
|
8 | 8 | default: true
|
9 | 9 | 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 |
10 | 25 | main_branch:
|
11 | 26 | description: Name of the main branch
|
12 | 27 | type: string
|
@@ -326,22 +341,30 @@ jobs:
|
326 | 341 | with:
|
327 | 342 | scan-type: 'config'
|
328 | 343 | hide-progress: false
|
329 |
| - format: 'sarif' |
330 |
| - output: 'trivy-results.sarif' |
| 344 | + format: ${{ inputs.trivy_format }} |
| 345 | + output: ${{ inputs.trivy_output }} |
331 | 346 | ignore-unfixed: true
|
332 | 347 | severity: 'CRITICAL,HIGH'
|
333 | 348 |
|
| 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 | + |
334 | 356 | # https://github.com/aquasecurity/trivy/issues/5003
|
335 | 357 | - name: Remove git from url for sarif uploading
|
| 358 | + if: ${{ inputs.trivy_format == 'sarif' && inputs.trivy_output != '' }} |
336 | 359 | shell: bash
|
337 | 360 | run: |
|
338 |
| - sed -i 's#git::https:/##g' trivy-results.sarif |
| 361 | + sed -i 's#git::https:/##g' ${{ inputs.trivy_output }} |
339 | 362 |
|
340 | 363 | - name: Upload Trivy scan results to GitHub Security tab
|
| 364 | + if: inputs.upload_sarif == true |
341 | 365 | uses: github/codeql-action/upload-sarif@v3
|
342 | 366 | with:
|
343 |
| - sarif_file: 'trivy-results.sarif' |
344 |
| - # if: inputs.upload_sarif == true |
| 367 | + sarif_file: ${{ inputs.trivy_output }} |
345 | 368 |
|
346 | 369 | - name: Get changed files
|
347 | 370 | id: changed-files
|
|
0 commit comments