38
38
39
39
steps :
40
40
- uses : actions/checkout@v5
41
+ with :
42
+ persist-credentials : false
41
43
- uses : extractions/setup-just@v3
42
44
- name : Read the MSRV
43
45
run : |
60
62
61
63
steps :
62
64
- uses : actions/checkout@v5
65
+ with :
66
+ persist-credentials : false
63
67
- uses : extractions/setup-just@v3
64
68
- name : Ensure we start out clean
65
69
run : git diff --exit-code
75
79
76
80
steps :
77
81
- uses : actions/checkout@v5
82
+ with :
83
+ persist-credentials : false
78
84
- name : Prerequisites
79
85
run : |
80
86
prerequisites=(
@@ -177,6 +183,8 @@ jobs:
177
183
178
184
steps :
179
185
- uses : actions/checkout@v5
186
+ with :
187
+ persist-credentials : false
180
188
- uses : dtolnay/rust-toolchain@stable
181
189
- uses : Swatinem/rust-cache@v2
182
190
- name : Setup dependencies
@@ -197,6 +205,8 @@ jobs:
197
205
198
206
steps :
199
207
- uses : actions/checkout@v5
208
+ with :
209
+ persist-credentials : false
200
210
- uses : dtolnay/rust-toolchain@stable
201
211
- uses : Swatinem/rust-cache@v2
202
212
- uses : extractions/setup-just@v3
@@ -221,6 +231,8 @@ jobs:
221
231
222
232
steps :
223
233
- uses : actions/checkout@v5
234
+ with :
235
+ persist-credentials : false
224
236
- uses : dtolnay/rust-toolchain@stable
225
237
- uses : Swatinem/rust-cache@v2
226
238
- name : cargo check default features
@@ -268,6 +280,8 @@ jobs:
268
280
269
281
steps :
270
282
- uses : actions/checkout@v5
283
+ with :
284
+ persist-credentials : false
271
285
- uses : dtolnay/rust-toolchain@stable
272
286
- uses : Swatinem/rust-cache@v2
273
287
- uses : taiki-e/install-action@v2
@@ -339,6 +353,8 @@ jobs:
339
353
apt-get install --no-install-recommends -y -- "${prerequisites[@]}"
340
354
shell : bash # This step needs `bash`, and the default in container jobs is `sh`.
341
355
- uses : actions/checkout@v5
356
+ with :
357
+ persist-credentials : false
342
358
- name : Install Rust via Rustup
343
359
run : |
344
360
# Specify toolchain to avoid possible misdetection based on the 64-bit running kernel.
@@ -365,6 +381,8 @@ jobs:
365
381
366
382
steps :
367
383
- uses : actions/checkout@v5
384
+ with :
385
+ persist-credentials : false
368
386
- uses : dtolnay/rust-toolchain@stable
369
387
with :
370
388
targets : ${{ env.TARGET }}
@@ -382,6 +400,8 @@ jobs:
382
400
383
401
steps :
384
402
- uses : actions/checkout@v5
403
+ with :
404
+ persist-credentials : false
385
405
- uses : dtolnay/rust-toolchain@master
386
406
with :
387
407
toolchain : stable
@@ -412,6 +432,8 @@ jobs:
412
432
413
433
steps :
414
434
- uses : actions/checkout@v5
435
+ with :
436
+ persist-credentials : false
415
437
- uses : EmbarkStudios/cargo-deny-action@v2
416
438
with :
417
439
command : check advisories
@@ -422,6 +444,8 @@ jobs:
422
444
423
445
steps :
424
446
- uses : actions/checkout@v5
447
+ with :
448
+ persist-credentials : false
425
449
- uses : EmbarkStudios/cargo-deny-action@v2
426
450
with :
427
451
command : check bans licenses sources
@@ -441,6 +465,8 @@ jobs:
441
465
442
466
steps :
443
467
- uses : actions/checkout@v5
468
+ with :
469
+ persist-credentials : false
444
470
- name : Install Rust
445
471
run : |
446
472
rustup update stable
@@ -520,6 +546,8 @@ jobs:
520
546
521
547
steps :
522
548
- uses : actions/checkout@v5
549
+ with :
550
+ persist-credentials : false
523
551
- name : Check that working tree is initially clean
524
552
run : |
525
553
set -x
@@ -533,6 +561,33 @@ jobs:
533
561
git status
534
562
git diff --exit-code
535
563
564
+ # Check that all `actions/checkout` in CI jobs have `persist-credentials: false`.
565
+ check-no-persist-credentials :
566
+ runs-on : ubuntu-latest
567
+
568
+ env :
569
+ GLOB : .github/workflows/*.@(yaml|yml)
570
+
571
+ steps :
572
+ - uses : actions/checkout@v5
573
+ with :
574
+ persist-credentials : false
575
+ sparse-checkout : ' .github/workflows'
576
+ - name : List workflows to be scanned
577
+ run : |
578
+ shopt -s extglob
579
+ printf '%s\n' ${{ env.GLOB }}
580
+ - name : Scan workflows
581
+ run : |
582
+ shopt -s extglob
583
+ yq '.jobs.*.steps[]
584
+ | select(.uses == "actions/checkout@*" and .with.["persist-credentials"]? != false)
585
+ | {"file": filename, "line": line, "name": (.name // .uses)}
586
+ | .file + ":" + (.line | tostring) + ": " + .name
587
+ ' -- ${{ env.GLOB }} >query-output.txt
588
+ cat query-output.txt
589
+ test -z "$(<query-output.txt)" # Report failure if we found anything.
590
+
536
591
# Check that only jobs intended not to block PR auto-merge are omitted as
537
592
# dependencies of the `tests-pass` job below, so that whenever a job is
538
593
# added, a decision is made about whether it must pass for PRs to merge.
@@ -557,6 +612,7 @@ jobs:
557
612
echo "WORKFLOW_PATH=${relative_workflow_with_ref%@*}" >> "$GITHUB_ENV"
558
613
- uses : actions/checkout@v5
559
614
with :
615
+ persist-credentials : false
560
616
sparse-checkout : ${{ env.WORKFLOW_PATH }}
561
617
- name : Get all jobs
562
618
run : yq '.jobs | keys.[]' -- "$WORKFLOW_PATH" | sort | tee all-jobs.txt
@@ -586,6 +642,7 @@ jobs:
586
642
- lint
587
643
- cargo-deny
588
644
- check-packetline
645
+ - check-no-persist-credentials
589
646
- check-blocking
590
647
591
648
if : always() # Always run even if dependencies fail.
0 commit comments