-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
78 lines (64 loc) · 2.05 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# yamllint disable rule:line-length
---
name: run trivy docker scan
description: use trivy to scan docker image for vulnerabilities
inputs:
working-directory:
description: set working directory. Default is ./.
required: false
default: "."
registry:
description: dtr compatible registry
required: false
default: docker.io
organization:
description: dtr compatible organization identified
required: false
default: ""
image:
description: name of image
required: true
tag:
description: value for tag
required: false
default: dev.${GITHUB_SHA:0:7}
trivy-severity:
description: trivy scan reporting threshold
required: false
default: "LOW,MEDIUM,HIGH,CRITICAL"
trivy-additional-args:
description: additional custom command line flags
required: false
default: ""
security-scan-nofail:
description: >
security scan revealing issues will not cause pipeline to fail,
instead the scan output will be uploaded as a pipeline artifact
required: false
default: "false"
runs:
using: "composite"
steps:
- name: trivy image scan
working-directory: ${{ inputs.working-directory }}
shell: bash
run: |
#!/usr/bin/env bash
set -eo pipefail
outfilename="${{ inputs.image }}_${{ inputs.tag }}_trivy_scan.log"
echo "outfilename=$outfilename" >> $GITHUB_ENV
exitcode="--exit-code 1"
if [[ "${{ inputs.security-scan-nofail }}" == "true" ]]; then
exitcode=""
fi
trivy image --severity ${{ inputs.trivy-severity }} \
$exitcode \
${{ inputs.trivy-additional-args }} \
${{ inputs.registry }}/${{ inputs.organization }}/${{ inputs.image }}:${{ inputs.tag }} 2>&1 | tee $outfilename \
- name: upload trivy scan log as saved artifact
if: ${{ inputs.security-scan-nofail == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.outfilename }}
path: ${{ env.outfilename }}
retention-days: 7