-
Notifications
You must be signed in to change notification settings - Fork 0
243 lines (206 loc) · 7.44 KB
/
Copy pathsecurity.yml
File metadata and controls
243 lines (206 loc) · 7.44 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# spell-checker: ignore anchore, aquasecurity, gacts
name: Security
on:
schedule:
- cron: "0 2 * * 1"
pull_request:
branches: [ main, develop ]
push:
branches: [ main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
security-events: write
defaults:
run:
shell: bash
jobs:
changes:
name: Detect Changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
run-root-python: ${{ steps.detect.outputs.run-root-python }}
run-backend-python: ${{ steps.detect.outputs.run-backend-python }}
run-docs-node: ${{ steps.detect.outputs.run-docs-node }}
run-frontend-app-node: ${{ steps.detect.outputs.run-frontend-app-node }}
run-frontend-web-node: ${{ steps.detect.outputs.run-frontend-web-node }}
run-container-images: ${{ steps.detect.outputs.run-container-images }}
container-security-matrix: ${{ steps.detect.outputs.container-security-matrix }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Detect changes
id: detect
uses: ./.github/actions/detect-security-changes
secret-scan:
name: Secret Scan
if: github.event_name != 'merge_group'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0
- name: Run gitleaks
uses: gacts/gitleaks@c9a0338361dc45a01aa7ebaaa5330179f3c62873
with:
version: 8.30.1
env:
GITLEAKS_CONFIG: .github/gitleaks.toml
python-audit-root:
name: Python Audit (root)
needs: [ changes ]
if: github.event_name != 'pull_request' && needs.changes.outputs.run-root-python == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up runtime
uses: ./.github/actions/setup-runtime
with:
setup-python: "true"
uv-cache-dependency-glob: uv.lock
- name: Install root dependencies
run: uv sync --frozen
- name: Run root dependency audit
run: just audit-root
backend-python-audit:
name: Python Audit (backend)
needs: [ changes ]
if: github.event_name != 'pull_request' && needs.changes.outputs.run-backend-python == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up runtime
uses: ./.github/actions/setup-runtime
with:
setup-python: "true"
uv-cache-dependency-glob: backend/uv.lock
- name: Install dependencies
run: just backend/install
- name: Run dependency audit
run: just backend/audit
docs-node-audit:
name: Node Audit (docs)
needs: [ changes ]
if: github.event_name != 'pull_request' && needs.changes.outputs.run-docs-node == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up runtime
uses: ./.github/actions/setup-runtime
with:
setup-node: "true"
cache-dependency-path: docs/pnpm-lock.yaml
- name: Install dependencies
run: just docs/install
- name: Run dependency audit
run: |
set -o pipefail
output="$(just docs/audit 2>&1)"
status=$?
printf '%s\n' "$output"
if [ "$status" -ne 0 ]; then
exit "$status"
fi
if printf '%s\n' "$output" | grep -Eq '^Found [1-9][0-9]* known vulnerability|^Vulnerabilities:'; then
echo "::warning title=Docs dependency audit::Vulnerabilities were found in docs dependencies. Review the audit output above."
{
printf '### Docs dependency audit\n\n'
printf 'Warning: vulnerabilities were found in docs dependencies.\n\n'
printf 'This check is intentionally non-blocking so the pull request can still be merged.\n\n'
printf 'Review the audit output in the step log above.\n'
} >> "$GITHUB_STEP_SUMMARY"
fi
frontend-app-node-audit:
name: Node Audit (frontend-app)
needs: [ changes ]
if: github.event_name != 'pull_request' && needs.changes.outputs.run-frontend-app-node == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up runtime
uses: ./.github/actions/setup-runtime
with:
setup-node: "true"
cache-dependency-path: frontend-app/pnpm-lock.yaml
- name: Install dependencies
run: just frontend-app/install
- name: Run dependency audit
run: just frontend-app/audit
frontend-web-node-audit:
name: Node Audit (frontend-web)
needs: [ changes ]
if: github.event_name != 'pull_request' && needs.changes.outputs.run-frontend-web-node == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up runtime
uses: ./.github/actions/setup-runtime
with:
setup-node: "true"
cache-dependency-path: frontend-web/pnpm-lock.yaml
- name: Install dependencies
run: just frontend-web/install
- name: Run dependency audit
run: just frontend-web/audit
container-security:
name: Container Security (${{ matrix.service }})
needs: [ changes ]
if: needs.changes.outputs.run-container-images == 'true'
runs-on: ubuntu-latest
timeout-minutes: 35
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.changes.outputs.container-security-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
- name: Build image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
load: true
pull: true
tags: ${{ matrix.image_ref }}
- name: Scan image with Trivy
uses: aquasecurity/trivy-action@1f0aa582c8c8f5f7639610d6d38baddfea4fdcee
with:
image-ref: ${{ matrix.image_ref }}
format: table
exit-code: "1"
ignore-unfixed: true
severity: HIGH,CRITICAL
trivyignores: .github/trivyignore
- name: Generate SBOM
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610
with:
image: ${{ matrix.image_ref }}
format: spdx-json
output-file: sbom-${{ matrix.service }}.spdx.json
- name: Archive container security artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: security-${{ matrix.service }}-artifacts
path: sbom-${{ matrix.service }}.spdx.json
retention-days: 14