Skip to content

Commit 1c6afd0

Browse files
Merge pull request #4355 from bcgov/chore-move-trivy-container-scanning-to-nightly-build-only
Move trivy container scanning to nightly build
2 parents 73ba751 + a70a023 commit 1c6afd0

4 files changed

Lines changed: 60 additions & 60 deletions

File tree

.github/workflows/main.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,6 @@ jobs:
132132
nx_project: compliance
133133
secrets: inherit
134134
trivy:
135-
needs:
136-
[
137-
build-backend,
138-
build-administration,
139-
build-compliance,
140-
build-dashboard,
141-
build-registration,
142-
build-reporting,
143-
]
144135
uses: ./.github/workflows/trivy.yaml
145136
codeql:
146137
uses: ./.github/workflows/codeql.yaml

.github/workflows/nightly.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ jobs:
127127
uses: ./.github/workflows/schemaspy.yaml
128128
secrets: inherit
129129
trivy:
130+
uses: ./.github/workflows/trivy.yaml
131+
trivy-containers:
130132
needs:
131133
[
132134
build-backend,
@@ -136,7 +138,7 @@ jobs:
136138
build-registration,
137139
build-reporting,
138140
]
139-
uses: ./.github/workflows/trivy.yaml
141+
uses: ./.github/workflows/trivy-containers.yaml
140142
codeql:
141143
uses: ./.github/workflows/codeql.yaml
142144
notify:
@@ -154,6 +156,7 @@ jobs:
154156
zap-owasp,
155157
schemaspy,
156158
trivy,
159+
trivy-containers,
157160
codeql,
158161
]
159162
env:
@@ -169,6 +172,7 @@ jobs:
169172
&& needs.zap-owasp.result == 'success'
170173
&& needs.schemaspy.result == 'success'
171174
&& needs.trivy.result == 'success'
175+
&& needs.trivy-containers.result == 'success'
172176
&& needs.codeql.result == 'success'
173177
&& 'success'
174178
|| 'failure'
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Trivy Container Scan
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
scan-containers:
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 60
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
include:
14+
- image: cas-reg-backend
15+
category: trivy-container-backend
16+
- image: cas-reg-frontend
17+
category: trivy-container-registration
18+
- image: cas-admin-frontend
19+
category: trivy-container-administration
20+
- image: cas-compliance-frontend
21+
category: trivy-container-compliance
22+
- image: cas-dash-frontend
23+
category: trivy-container-dashboard
24+
- image: cas-rep-frontend
25+
category: trivy-container-reporting
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v6
29+
- name: Cache Scan Dependencies
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.cache/trivy
33+
key: callee-trivy-${{ github.workflow }}-${{ github.run_id }}
34+
restore-keys: callee-trivy-${{ github.workflow }}-
35+
- name: Run Trivy vulnerability scanner on container image
36+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
37+
with:
38+
scan-type: image
39+
image-ref: ghcr.io/bcgov/${{ matrix.image }}:${{ github.sha }}
40+
format: sarif
41+
output: trivy-container-results.sarif
42+
exit-code: "0"
43+
ignore-unfixed: false
44+
severity: CRITICAL,HIGH,MEDIUM
45+
timeout: 10m0s
46+
- name: Upload Trivy container scan results to GitHub Security tab
47+
uses: github/codeql-action/upload-sarif@v4
48+
with:
49+
sarif_file: trivy-container-results.sarif
50+
category: ${{ matrix.category }}
51+
- name: Upload Trivy container scan results as artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: trivy-container-results-${{ matrix.image }}
55+
path: trivy-container-results.sarif

.github/workflows/trivy.yaml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -38,53 +38,3 @@ jobs:
3838
with:
3939
name: trivy-results
4040
path: trivy-results.sarif
41-
42-
scan-containers:
43-
runs-on: ubuntu-latest
44-
timeout-minutes: 60
45-
strategy:
46-
fail-fast: false
47-
matrix:
48-
include:
49-
- image: cas-reg-backend
50-
category: trivy-container-backend
51-
- image: cas-reg-frontend
52-
category: trivy-container-registration
53-
- image: cas-admin-frontend
54-
category: trivy-container-administration
55-
- image: cas-compliance-frontend
56-
category: trivy-container-compliance
57-
- image: cas-dash-frontend
58-
category: trivy-container-dashboard
59-
- image: cas-rep-frontend
60-
category: trivy-container-reporting
61-
steps:
62-
- name: Checkout code
63-
uses: actions/checkout@v6
64-
- name: Cache Scan Dependencies
65-
uses: actions/cache@v4
66-
with:
67-
path: ~/.cache/trivy
68-
key: callee-trivy-${{ github.workflow }}-${{ github.run_id }}
69-
restore-keys: callee-trivy-${{ github.workflow }}-
70-
- name: Run Trivy vulnerability scanner on container image
71-
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
72-
with:
73-
scan-type: image
74-
image-ref: ghcr.io/bcgov/${{ matrix.image }}:${{ github.sha }}
75-
format: sarif
76-
output: trivy-container-results.sarif
77-
exit-code: "0"
78-
ignore-unfixed: false
79-
severity: CRITICAL,HIGH,MEDIUM
80-
timeout: 10m0s
81-
- name: Upload Trivy container scan results to GitHub Security tab
82-
uses: github/codeql-action/upload-sarif@v4
83-
with:
84-
sarif_file: trivy-container-results.sarif
85-
category: ${{ matrix.category }}
86-
- name: Upload Trivy container scan results as artifact
87-
uses: actions/upload-artifact@v4
88-
with:
89-
name: trivy-container-results-${{ matrix.image }}
90-
path: trivy-container-results.sarif

0 commit comments

Comments
 (0)