Skip to content

Commit bccbdb1

Browse files
authored
chore(ci): harden workflow by setting default permission to read only (#320)
Defines per action permissions scoping, defaulting to read only RE: ``` - uses: actions/checkout@v5 with: persist-credentials: false ``` See: actions/checkout#485 This does not yet introduce pinning to hashes, I want to find a good way to maintain this first. Apparently Dependabot has a feature for this.
1 parent 8f35660 commit bccbdb1

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: CI
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
58
branches: [main]
@@ -30,6 +33,8 @@ jobs:
3033
flags: "--all-features"
3134
steps:
3235
- uses: actions/checkout@v5
36+
with:
37+
persist-credentials: false
3338
- uses: dtolnay/rust-toolchain@master
3439
with:
3540
toolchain: ${{ matrix.rust }}
@@ -50,6 +55,8 @@ jobs:
5055
timeout-minutes: 30
5156
steps:
5257
- uses: actions/checkout@v5
58+
with:
59+
persist-credentials: false
5360
- uses: dtolnay/rust-toolchain@stable
5461
- uses: Swatinem/rust-cache@v2
5562
with:
@@ -61,6 +68,8 @@ jobs:
6168
timeout-minutes: 30
6269
steps:
6370
- uses: actions/checkout@v5
71+
with:
72+
persist-credentials: false
6473
- uses: dtolnay/rust-toolchain@stable
6574
- uses: taiki-e/install-action@cargo-hack
6675
- uses: Swatinem/rust-cache@v2
@@ -74,9 +83,9 @@ jobs:
7483
timeout-minutes: 30
7584
steps:
7685
- uses: actions/checkout@v5
77-
- uses: dtolnay/rust-toolchain@stable
7886
with:
79-
components: clippy
87+
persist-credentials: false
88+
- uses: dtolnay/rust-toolchain@clippy
8089
- uses: Swatinem/rust-cache@v2
8190
with:
8291
cache-on-failure: true
@@ -89,6 +98,8 @@ jobs:
8998
timeout-minutes: 30
9099
steps:
91100
- uses: actions/checkout@v5
101+
with:
102+
persist-credentials: false
92103
- uses: dtolnay/rust-toolchain@nightly
93104
- uses: Swatinem/rust-cache@v2
94105
with:
@@ -102,6 +113,8 @@ jobs:
102113
timeout-minutes: 30
103114
steps:
104115
- uses: actions/checkout@v5
116+
with:
117+
persist-credentials: false
105118
- uses: dtolnay/rust-toolchain@nightly
106119
with:
107120
components: rustfmt
@@ -113,6 +126,7 @@ jobs:
113126
ci-success:
114127
runs-on: ubuntu-latest
115128
if: always()
129+
permissions: {}
116130
needs:
117131
- test
118132
- doctest

0 commit comments

Comments
 (0)