Skip to content

Commit e9faabc

Browse files
committed
feat: harden workflows with permissions and persist-credentials
Refs: RATY-350
1 parent 822b37c commit e9faabc

7 files changed

Lines changed: 62 additions & 0 deletions

File tree

.github/workflows/ci-django-api.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ on:
4747
required: false
4848
workflow_dispatch:
4949

50+
permissions:
51+
contents: read
52+
pull-requests: read
53+
5054
env:
5155
SECRET_KEY: topsecret123
5256
DATABASE_URL: ${{ inputs.use-postgis == true && 'postgis' || 'postgres' }}://test_user:test_password@localhost/test_db
@@ -60,6 +64,8 @@ jobs:
6064
steps:
6165
- name: Checkout
6266
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
67+
with:
68+
persist-credentials: false
6369
- name: Run commitlint
6470
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
6571
with:
@@ -71,6 +77,8 @@ jobs:
7177
steps:
7278
- name: Checkout
7379
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
80+
with:
81+
persist-credentials: false
7482
- name: Setup Python ${{ inputs.python-version }}
7583
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
7684
with:
@@ -126,6 +134,7 @@ jobs:
126134
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
127135
with:
128136
fetch-depth: 1
137+
persist-credentials: false
129138
- name: Install system packages
130139
run: |
131140
sudo apt-get update
@@ -188,6 +197,7 @@ jobs:
188197
# Required by SonarQube Cloud for blame information
189198
with:
190199
fetch-depth: 0
200+
persist-credentials: false
191201
- name: Restore coverage.xml
192202
uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
193203
with:

.github/workflows/ci-node.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@ on:
5757
required: true
5858
workflow_dispatch:
5959

60+
permissions:
61+
contents: read
62+
pull-requests: read
63+
6064
jobs:
6165
commitlint:
6266
name: Check commit messages
6367
runs-on: ubuntu-latest
6468
steps:
6569
- name: Checkout
6670
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
71+
with:
72+
persist-credentials: false
6773
- name: Run commitlint
6874
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
6975
with:
@@ -78,6 +84,8 @@ jobs:
7884
working-directory: ${{ inputs.working-directory }}
7985
steps:
8086
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
87+
with:
88+
persist-credentials: false
8189
- name: Use Node.js ${{ inputs.node-version }} with dependency path
8290
if: ${{ inputs.working-directory != '.' }}
8391
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
@@ -146,6 +154,8 @@ jobs:
146154
working-directory: ${{ inputs.working-directory }}
147155
steps:
148156
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
157+
with:
158+
persist-credentials: false
149159
- name: Use Node.js ${{ inputs.node-version }} with dependency path
150160
if: ${{ inputs.working-directory != '.' }}
151161
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
@@ -203,6 +213,7 @@ jobs:
203213
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
204214
with:
205215
fetch-depth: 0
216+
persist-credentials: false
206217
# Coverage path logic (keep in sync with tests job's cache/save step):
207218
# Resolves the effective directory (app-directory if set, else working-directory),
208219
# then prefixes 'coverage' with '<dir>/' when running in a subdirectory.

.github/workflows/ci-npm-publish.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ on:
4343
type: boolean
4444
default: false
4545

46+
permissions:
47+
contents: read
48+
4649
jobs:
4750
publish-npm-stable:
4851
runs-on: ubuntu-latest
@@ -51,6 +54,8 @@ jobs:
5154
id-token: write
5255
steps:
5356
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
57+
with:
58+
persist-credentials: false
5459
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
5560
with:
5661
node-version: ${{ inputs.node-version }}

.github/workflows/ci-pnpm-node.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ on:
6565
required: false
6666
workflow_dispatch:
6767

68+
permissions:
69+
contents: read
70+
pull-requests: read
71+
6872
jobs:
6973
commitlint:
7074
name: Check commit messages
7175
runs-on: ubuntu-latest
7276
steps:
7377
- name: Checkout
7478
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
79+
with:
80+
persist-credentials: false
7581
- name: Run commitlint
7682
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
7783
with:
@@ -86,6 +92,8 @@ jobs:
8692
working-directory: ${{ inputs.working-directory }}
8793
steps:
8894
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
95+
with:
96+
persist-credentials: false
8997

9098
- name: Setup pnpm
9199
uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6.0.5
@@ -158,6 +166,8 @@ jobs:
158166
working-directory: ${{ inputs.working-directory }}
159167
steps:
160168
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
169+
with:
170+
persist-credentials: false
161171

162172
- name: Setup pnpm
163173
uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6.0.5
@@ -215,6 +225,7 @@ jobs:
215225
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
216226
with:
217227
fetch-depth: 0
228+
persist-credentials: false
218229

219230
# Coverage path logic (keep in sync with tests job's cache/save step):
220231
# Resolves the effective directory (app-directory if set, else working-directory),

.github/workflows/ci-python-library.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ on:
3535
description: "GITHUB_TOKEN. Required if enable-sonar is set to true."
3636
required: false
3737

38+
permissions:
39+
contents: read
40+
3841
jobs:
3942
commitlint:
4043
name: Check commit messages
@@ -43,6 +46,8 @@ jobs:
4346
steps:
4447
- name: Checkout
4548
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
49+
with:
50+
persist-credentials: false
4651

4752
- name: Run commitlint
4853
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
@@ -55,6 +60,8 @@ jobs:
5560
steps:
5661
- name: Checkout
5762
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
63+
with:
64+
persist-credentials: false
5865

5966
- name: Setup Python ${{ inputs.python-version }}
6067
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -75,6 +82,8 @@ jobs:
7582

7683
steps:
7784
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
85+
with:
86+
persist-credentials: false
7887

7988
- name: Set up Python ${{ matrix.python_version }}
8089
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -119,6 +128,7 @@ jobs:
119128
with:
120129
# Required by SonarQube Cloud
121130
fetch-depth: 0
131+
persist-credentials: false
122132

123133
- name: Download coverage reports
124134
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1

.github/workflows/ci-uv-django-api.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ on:
4747
required: false
4848
workflow_dispatch:
4949

50+
permissions:
51+
contents: read
52+
5053
env:
5154
SECRET_KEY: topsecret123
5255
DATABASE_URL: ${{ inputs.use-postgis == true && 'postgis' || 'postgres' }}://test_user:test_password@localhost/test_db
@@ -60,6 +63,8 @@ jobs:
6063
steps:
6164
- name: Checkout
6265
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
66+
with:
67+
persist-credentials: false
6368
- name: Run commitlint
6469
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
6570
with:
@@ -71,6 +76,8 @@ jobs:
7176
steps:
7277
- name: Checkout
7378
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
79+
with:
80+
persist-credentials: false
7481
- name: Setup Python ${{ inputs.python-version }}
7582
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
7683
with:
@@ -126,6 +133,7 @@ jobs:
126133
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
127134
with:
128135
fetch-depth: 1
136+
persist-credentials: false
129137
- name: Install system packages
130138
run: |
131139
sudo apt-get update
@@ -177,6 +185,7 @@ jobs:
177185
# Required by SonarQube Cloud for blame information
178186
with:
179187
fetch-depth: 0
188+
persist-credentials: false
180189
- name: Restore coverage.xml
181190
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
182191
with:

.github/workflows/sync-files.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ on:
44
branches:
55
- main
66
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
711
jobs:
812
sync:
913
runs-on: ubuntu-latest
1014
steps:
1115
- name: Checkout Repository
1216
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
17+
with:
18+
persist-credentials: false
1319
- uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
1420
id: app-token
1521
with:

0 commit comments

Comments
 (0)