Skip to content

Commit a235ac8

Browse files
committed
Use actions/checkout with persist-credentials: false
When `actions/checkout` is used to check out the repository on CI, it persists credentials related to the GitHub token in the local scope configuration at `.git/config`, unless `persist-credentials` is explicitly set to `false`. This facilitates subsequent remote operations on the repository that could otherwise fail, but we have no such operations in any of our workflows. As an added layer of protection to keep these credentials from leaking into logs (or otherwise being displayed or subject to exfiltration) in case there is ever unintended coupling between the operation of the test suite (or any step subsequent to checkout that is used to prepare or run tests or other checks) and the cloned `gitoxide` repository itself, this: - Adds `persist-credentials: false` in a `with` mapping on every step that uses `actions/checkout`. - Adds a new CI job that checks that every `actions/checkout` step in any job in any workflow sets `persist-credentials` to `false`. In addition to usual testing on CI, the `release.yml` workflow is among the workflows changed here, and it has also been tested: https://github.com/EliahKagan/gitoxide/actions/runs/17899238656 See also: - https://github.com/actions/checkout/blob/main/README.md (Covers what happens with/without `persist-credentials: false`). - actions/checkout#485
1 parent f8be65f commit a235ac8

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838

3939
steps:
4040
- uses: actions/checkout@v5
41+
with:
42+
persist-credentials: false
4143
- uses: extractions/setup-just@v3
4244
- name: Read the MSRV
4345
run: |
@@ -60,6 +62,8 @@ jobs:
6062

6163
steps:
6264
- uses: actions/checkout@v5
65+
with:
66+
persist-credentials: false
6367
- uses: extractions/setup-just@v3
6468
- name: Ensure we start out clean
6569
run: git diff --exit-code
@@ -75,6 +79,8 @@ jobs:
7579

7680
steps:
7781
- uses: actions/checkout@v5
82+
with:
83+
persist-credentials: false
7884
- name: Prerequisites
7985
run: |
8086
prerequisites=(
@@ -177,6 +183,8 @@ jobs:
177183

178184
steps:
179185
- uses: actions/checkout@v5
186+
with:
187+
persist-credentials: false
180188
- uses: dtolnay/rust-toolchain@stable
181189
- uses: Swatinem/rust-cache@v2
182190
- name: Setup dependencies
@@ -197,6 +205,8 @@ jobs:
197205

198206
steps:
199207
- uses: actions/checkout@v5
208+
with:
209+
persist-credentials: false
200210
- uses: dtolnay/rust-toolchain@stable
201211
- uses: Swatinem/rust-cache@v2
202212
- uses: extractions/setup-just@v3
@@ -221,6 +231,8 @@ jobs:
221231

222232
steps:
223233
- uses: actions/checkout@v5
234+
with:
235+
persist-credentials: false
224236
- uses: dtolnay/rust-toolchain@stable
225237
- uses: Swatinem/rust-cache@v2
226238
- name: cargo check default features
@@ -268,6 +280,8 @@ jobs:
268280

269281
steps:
270282
- uses: actions/checkout@v5
283+
with:
284+
persist-credentials: false
271285
- uses: dtolnay/rust-toolchain@stable
272286
- uses: Swatinem/rust-cache@v2
273287
- uses: taiki-e/install-action@v2
@@ -339,6 +353,8 @@ jobs:
339353
apt-get install --no-install-recommends -y -- "${prerequisites[@]}"
340354
shell: bash # This step needs `bash`, and the default in container jobs is `sh`.
341355
- uses: actions/checkout@v5
356+
with:
357+
persist-credentials: false
342358
- name: Install Rust via Rustup
343359
run: |
344360
# Specify toolchain to avoid possible misdetection based on the 64-bit running kernel.
@@ -365,6 +381,8 @@ jobs:
365381

366382
steps:
367383
- uses: actions/checkout@v5
384+
with:
385+
persist-credentials: false
368386
- uses: dtolnay/rust-toolchain@stable
369387
with:
370388
targets: ${{ env.TARGET }}
@@ -382,6 +400,8 @@ jobs:
382400

383401
steps:
384402
- uses: actions/checkout@v5
403+
with:
404+
persist-credentials: false
385405
- uses: dtolnay/rust-toolchain@master
386406
with:
387407
toolchain: stable
@@ -412,6 +432,8 @@ jobs:
412432

413433
steps:
414434
- uses: actions/checkout@v5
435+
with:
436+
persist-credentials: false
415437
- uses: EmbarkStudios/cargo-deny-action@v2
416438
with:
417439
command: check advisories
@@ -422,6 +444,8 @@ jobs:
422444

423445
steps:
424446
- uses: actions/checkout@v5
447+
with:
448+
persist-credentials: false
425449
- uses: EmbarkStudios/cargo-deny-action@v2
426450
with:
427451
command: check bans licenses sources
@@ -441,6 +465,8 @@ jobs:
441465

442466
steps:
443467
- uses: actions/checkout@v5
468+
with:
469+
persist-credentials: false
444470
- name: Install Rust
445471
run: |
446472
rustup update stable
@@ -520,6 +546,8 @@ jobs:
520546

521547
steps:
522548
- uses: actions/checkout@v5
549+
with:
550+
persist-credentials: false
523551
- name: Check that working tree is initially clean
524552
run: |
525553
set -x
@@ -557,6 +585,7 @@ jobs:
557585
echo "WORKFLOW_PATH=${relative_workflow_with_ref%@*}" >> "$GITHUB_ENV"
558586
- uses: actions/checkout@v5
559587
with:
588+
persist-credentials: false
560589
sparse-checkout: ${{ env.WORKFLOW_PATH }}
561590
- name: Get all jobs
562591
run: yq '.jobs | keys.[]' -- "$WORKFLOW_PATH" | sort | tee all-jobs.txt

.github/workflows/cron.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v5
17+
with:
18+
persist-credentials: false
1719
- uses: Swatinem/rust-cache@v2
1820
- name: stress
1921
run: make stress

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141
steps:
4242
- name: Checkout repository
4343
uses: actions/checkout@v5
44+
with:
45+
persist-credentials: false
4446

4547
- name: Get the release version from the tag
4648
if: env.VERSION == ''
@@ -234,6 +236,8 @@ jobs:
234236
steps:
235237
- name: Checkout repository
236238
uses: actions/checkout@v5
239+
with:
240+
persist-credentials: false
237241

238242
- name: Install packages (Ubuntu)
239243
# Because openssl doesn't work on musl by default, we resort to max-pure.
@@ -537,6 +541,8 @@ jobs:
537541

538542
steps:
539543
- uses: actions/checkout@v5
544+
with:
545+
persist-credentials: false
540546
- name: Install Rust
541547
uses: dtolnay/rust-toolchain@master
542548
with:

0 commit comments

Comments
 (0)