1
1
name : Docker Image Scanners
2
2
on :
3
+ workflow_dispatch :
3
4
push :
4
5
branches :
5
6
- " master"
8
9
pull_request :
9
10
branches :
10
11
- " master"
11
- merge_group :
12
+
13
+ permissions :
14
+ contents : read
15
+ security-events : write
12
16
13
17
jobs :
14
18
scanners :
15
19
runs-on : ubuntu-latest
16
20
steps :
17
21
- name : Checkout
18
- uses : actions/checkout@v3
22
+ uses : actions/checkout@v4
19
23
- name : Setup Env
20
24
id : vars
21
25
shell : bash
22
26
run : |
23
- echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> "${GITHUB_ENV}"
27
+ # Store values in local variables
28
+ SHA_SHORT=$(git rev-parse --short HEAD)
29
+ REPO_NAME=${{ github.event.repository.name }}
30
+
31
+ # Append -sqlite to SHA_SHORT if repo is hydra
32
+ if [ "${REPO_NAME}" = "hydra" ]; then
33
+ echo "Repo is hydra, appending -sqlite to SHA_SHORT"
34
+ IMAGE_NAME="oryd/${REPO_NAME}:${SHA_SHORT}-sqlite"
35
+ else
36
+ echo "Repo is not hydra, using default IMAGE_NAME"
37
+ IMAGE_NAME="oryd/${REPO_NAME}:${SHA_SHORT}"
38
+ fi
39
+
40
+ # Output values for debugging
41
+ echo "Values to be set:"
42
+ echo "SHA_SHORT: ${SHA_SHORT}"
43
+ echo "REPO_NAME: ${REPO_NAME}"
44
+ echo "IMAGE_NAME: ${IMAGE_NAME}"
45
+
46
+ # Set GitHub Environment variables
47
+ echo "SHA_SHORT=${SHA_SHORT}" >> "${GITHUB_ENV}"
48
+ echo "IMAGE_NAME=${IMAGE_NAME}" >> "${GITHUB_ENV}"
24
49
- name : Set up QEMU
25
- uses : docker/setup-qemu-action@v2
50
+ uses : docker/setup-qemu-action@v3
26
51
- name : Set up Docker Buildx
27
- uses : docker/setup-buildx-action@v2
52
+ uses : docker/setup-buildx-action@v3
28
53
- name : Build images
29
54
shell : bash
30
55
run : |
31
56
IMAGE_TAG="${{ env.SHA_SHORT }}" make docker
57
+
58
+ - name : Login to GitHub Container Registry
59
+ uses : docker/login-action@v3
60
+ with :
61
+ registry : ghcr.io
62
+ username : ${{ github.actor }}
63
+ password : ${{ secrets.GITHUB_TOKEN }}
64
+
65
+ - name : Configure Trivy
66
+ run : |
67
+ mkdir -p $HOME/.cache/trivy
68
+ echo "TRIVY_USERNAME=${{ github.actor }}" >> $GITHUB_ENV
69
+ echo "TRIVY_PASSWORD=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
70
+
32
71
- name : Anchore Scanner
33
- uses : anchore/scan-action@v3
72
+ uses : anchore/scan-action@v5
34
73
id : grype-scan
35
74
with :
36
- image : oryd/keto: ${{ env.SHA_SHORT }}
75
+ image : ${{ env.IMAGE_NAME }}
37
76
fail-build : true
38
77
severity-cutoff : high
39
78
add-cpes-if-none : true
@@ -46,34 +85,38 @@ jobs:
46
85
echo "::endgroup::"
47
86
- name : Anchore upload scan SARIF report
48
87
if : always()
49
- uses : github/codeql-action/upload-sarif@v2
88
+ uses : github/codeql-action/upload-sarif@v3
50
89
with :
51
90
sarif_file : ${{ steps.grype-scan.outputs.sarif }}
52
- # - name: Kubescape scanner
53
- # uses: kubescape/github-action@main
54
- # id: kubescape
55
- # with:
56
- # image: oryd/keto: ${{ env.SHA_SHORT }}
57
- # verbose: true
58
- # format: pretty-printer
59
- # # can't whitelist CVE yet: https://github.com/kubescape/kubescape/pull/1568
60
- # severityThreshold: critical
91
+ - name : Kubescape scanner
92
+ uses : kubescape/github-action@main
93
+ id : kubescape
94
+ with :
95
+ image : ${{ env.IMAGE_NAME }}
96
+ verbose : true
97
+ format : pretty-printer
98
+ # can't whitelist CVE yet: https://github.com/kubescape/kubescape/pull/1568
99
+ severityThreshold : critical
61
100
- name : Trivy Scanner
62
101
uses : aquasecurity/trivy-action@master
63
102
if : ${{ always() }}
64
103
with :
65
- image-ref : oryd/keto: ${{ env.SHA_SHORT }}
104
+ image-ref : ${{ env.IMAGE_NAME }}
66
105
format : " table"
67
106
exit-code : " 42"
68
107
ignore-unfixed : true
69
108
vuln-type : " os,library"
70
109
severity : " CRITICAL,HIGH"
71
- scanners : " vuln,secret,config"
110
+ scanners : " vuln,secret,misconfig"
111
+ env :
112
+ TRIVY_SKIP_JAVA_DB_UPDATE : " true"
113
+ TRIVY_DISABLE_VEX_NOTICE : " true"
114
+
72
115
- name : Dockle Linter
73
- uses : erzz/dockle-action@v1.3.2
116
+ uses : erzz/dockle-action@v1
74
117
if : ${{ always() }}
75
118
with :
76
- image : oryd/keto: ${{ env.SHA_SHORT }}
119
+ image : ${{ env.IMAGE_NAME }}
77
120
exit-code : 42
78
121
failure-threshold : high
79
122
- name : Hadolint
90
133
shell : bash
91
134
run : |
92
135
echo "::group::Hadolint Scan Details"
93
- echo "${HADOLINT_RESULTS}" | jq '.'
136
+ echo "${HADOLINT_RESULTS}" | jq '.'
94
137
echo "::endgroup::"
0 commit comments