-
Notifications
You must be signed in to change notification settings - Fork 3.1k
301 lines (267 loc) · 10.1 KB
/
Copy pathsecurity-audit.yml
File metadata and controls
301 lines (267 loc) · 10.1 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
name: security-audit
# Supply chain security checks.
#
# Triggers:
# - Nightly cron and manual dispatch: every audit job runs unconditionally.
# - Pull requests: GitHub path filters create a workflow run only when
# audit-relevant paths change. The gate job remains as a second check
# before the audit jobs run.
# - Pushes to develop / master / test-security: GitHub path filters create a
# workflow run only when audit-relevant paths change. The gate job remains as
# a second check before the audit jobs run.
permissions:
contents: read
actions: read
env:
# Fork PRs lack repo/org vars, so audit instead of block.
EGRESS_POLICY: >-
${{ github.event.pull_request.head.repo.fork && 'audit'
|| vars.STEP_SECURITY_EGRESS_POLICY
|| 'block' }}
on:
pull_request:
paths: &security_audit_paths
- Cargo.lock # Keep in sync with scripts/ci/security-audit-gate.sh.
- Cargo.toml
- crates/**/Cargo.toml
- crates/**/fuzz/Cargo.lock
- uv.lock
- pyproject.toml
- .pre-commit-config.yaml
- python/uv.lock
- python/pyproject.toml
- deny.toml
- .cargo/deny-fuzz.toml
- osv-scanner.toml
- .supply-chain/**
- tools.toml
- .cargo/config.toml
- .cargo/audit.toml
- rust-toolchain.toml
- scripts/cargo-tool-version.sh
- scripts/rust-toolchain.sh
- scripts/uv-version.sh
- scripts/ci/security-audit-gate.sh
- .zizmor.yml
- .github/actions/**
- .github/workflows/**
push:
branches: [develop, master, test-security]
paths: *security_audit_paths
schedule:
- cron: "0 23 * * *" # Daily at 23:00 UTC (2hrs prior to next nightly-merge)
workflow_dispatch: # Allow manual trigger
jobs:
changes:
name: changes
runs-on: ubuntu-22.04
outputs:
audit_needed: ${{ steps.filter.outputs.audit_needed }}
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
persist-credentials: false
- name: Detect audit-relevant changes
id: filter
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
PUSH_AFTER_SHA: ${{ github.event.after }}
run: bash scripts/ci/security-audit-gate.sh
zizmor:
name: zizmor
needs: changes
if: needs.changes.outputs.audit_needed == 'true'
runs-on: ubuntu-22.04
permissions:
contents: read
actions: read
security-events: write
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.SECURITY_AUDIT_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Get uv version from pyproject.toml
id: uv-version
run: echo "uv_version=$(bash scripts/uv-version.sh)" >> "$GITHUB_OUTPUT"
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
version: ${{ steps.uv-version.outputs.uv_version }}
enable-cache: true
- name: Run zizmor
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
uv run --no-project --with zizmor==1.24.1 -- \
zizmor --format sarif --min-severity medium --config .zizmor.yml .github/ \
> zizmor.sarif
- name: Upload zizmor SARIF
if: >-
always() &&
hashFiles('zizmor.sarif') != '' &&
(github.event_name != 'pull_request' ||
!github.event.pull_request.head.repo.fork)
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
with:
sarif_file: zizmor.sarif
category: zizmor
cargo-audit:
name: cargo-audit
needs: changes
if: needs.changes.outputs.audit_needed == 'true'
runs-on: ubuntu-22.04
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.SECURITY_AUDIT_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Install cargo-audit
uses: ./.github/actions/cargo-tool-install
with:
tool-name: cargo-audit
- name: Run cargo-audit
run: |
cargo audit
cargo audit --file crates/adapters/lighter/fuzz/Cargo.lock
cargo audit --file crates/adapters/derive/fuzz/Cargo.lock
cargo-deny:
name: cargo-deny
needs: changes
if: needs.changes.outputs.audit_needed == 'true'
runs-on: ubuntu-22.04
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.SECURITY_AUDIT_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Install cargo-deny
uses: ./.github/actions/cargo-tool-install
with:
tool-name: cargo-deny
- name: Run cargo-deny (advisories, licenses, sources, bans)
run: |
cargo deny --all-features check advisories licenses sources bans
cargo deny --manifest-path crates/adapters/lighter/fuzz/Cargo.toml \
--locked --all-features check --config .cargo/deny-fuzz.toml \
advisories licenses sources bans
cargo deny --manifest-path crates/adapters/derive/fuzz/Cargo.toml \
--locked --all-features check --config .cargo/deny-fuzz.toml \
advisories licenses sources bans
cargo-vet:
name: cargo-vet
needs: changes
if: needs.changes.outputs.audit_needed == 'true'
runs-on: ubuntu-22.04
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.SECURITY_AUDIT_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Install cargo-vet
uses: ./.github/actions/cargo-tool-install
with:
tool-name: cargo-vet
- name: Run cargo-vet
run: |
cargo vet --locked
cargo vet --locked --manifest-path crates/adapters/lighter/fuzz/Cargo.toml \
--store-path .supply-chain
cargo vet --locked --manifest-path crates/adapters/derive/fuzz/Cargo.toml \
--store-path .supply-chain
pip-audit:
name: pip-audit
needs: changes
if: needs.changes.outputs.audit_needed == 'true'
runs-on: ubuntu-22.04
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.SECURITY_AUDIT_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Get uv version from pyproject.toml
shell: bash
run: |
echo "UV_VERSION=$(bash scripts/uv-version.sh)" >> "$GITHUB_ENV"
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
version: ${{ env.UV_VERSION }}
- name: Install Python
run: uv python install 3.13
- name: Run pip-audit
# aiohttp 3.14.0 fixes these advisories, but remains inside uv's 3-day
# exclude-newer window while aiohttp source builds are disabled.
run: >
uv export --no-hashes --frozen |
uv run --no-project --no-build --with "pip-audit==$(bash scripts/tool-version.sh pip-audit)" --
pip-audit --disable-pip --no-deps -r /dev/stdin
--ignore-vuln GHSA-jg22-mg44-37j8
--ignore-vuln GHSA-hg6j-4rv6-33pg
osv-scanner:
name: osv-scanner
needs: changes
if: needs.changes.outputs.audit_needed == 'true'
runs-on: ubuntu-22.04
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.SECURITY_AUDIT_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Run osv-scanner
uses: google/osv-scanner-action/osv-scanner-action@9a498708959aeaef5ef730655706c5a1df1edbc2 # v2.3.8
with:
scan-args: |-
--config=osv-scanner.toml
--lockfile=Cargo.lock
--lockfile=crates/adapters/lighter/fuzz/Cargo.lock
--lockfile=crates/adapters/derive/fuzz/Cargo.lock
--lockfile=uv.lock
--lockfile=python/uv.lock