Skip to content

Commit c056a6c

Browse files
committed
feat: harden workflows with permissions and persist-credentials
Refs: RATY-350
1 parent 909ad43 commit c056a6c

8 files changed

Lines changed: 68 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
@@ -62,13 +62,19 @@ on:
6262
required: false
6363
workflow_dispatch:
6464

65+
permissions:
66+
contents: read
67+
pull-requests: read
68+
6569
jobs:
6670
commitlint:
6771
name: Check commit messages
6872
runs-on: ubuntu-latest
6973
steps:
7074
- name: Checkout
7175
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
76+
with:
77+
persist-credentials: false
7278
- name: Run commitlint
7379
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
7480
with:
@@ -83,6 +89,8 @@ jobs:
8389
working-directory: ${{ inputs.working-directory }}
8490
steps:
8591
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
92+
with:
93+
persist-credentials: false
8694
- name: Use Node.js ${{ inputs.node-version }} with dependency path
8795
if: ${{ inputs.working-directory != '.' }}
8896
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
@@ -151,6 +159,8 @@ jobs:
151159
working-directory: ${{ inputs.working-directory }}
152160
steps:
153161
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
162+
with:
163+
persist-credentials: false
154164
- name: Use Node.js ${{ inputs.node-version }} with dependency path
155165
if: ${{ inputs.working-directory != '.' }}
156166
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
@@ -208,6 +218,7 @@ jobs:
208218
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
209219
with:
210220
fetch-depth: 0
221+
persist-credentials: false
211222
# Coverage path logic (keep in sync with tests job's cache/save step):
212223
# Resolves the effective directory (app-directory if set, else working-directory),
213224
# 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ on:
3535
description: "GITHUB_TOKEN. Required if enable-sonar is set to true."
3636
required: false
3737

38+
permissions:
39+
contents: read
40+
pull-requests: read
41+
3842
jobs:
3943
commitlint:
4044
name: Check commit messages
@@ -43,6 +47,8 @@ jobs:
4347
steps:
4448
- name: Checkout
4549
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
50+
with:
51+
persist-credentials: false
4652

4753
- name: Run commitlint
4854
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
@@ -55,6 +61,8 @@ jobs:
5561
steps:
5662
- name: Checkout
5763
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
64+
with:
65+
persist-credentials: false
5866

5967
- name: Setup Python ${{ inputs.python-version }}
6068
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -75,6 +83,8 @@ jobs:
7583

7684
steps:
7785
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
86+
with:
87+
persist-credentials: false
7888

7989
- name: Set up Python ${{ matrix.python_version }}
8090
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -119,6 +129,7 @@ jobs:
119129
with:
120130
# Required by SonarQube Cloud
121131
fetch-depth: 0
132+
persist-credentials: false
122133

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

.github/workflows/ci-uv-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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
80+
with:
81+
persist-credentials: false
7482
- name: Setup Python ${{ inputs.python-version }}
7583
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
7684
with:
@@ -126,6 +134,7 @@ jobs:
126134
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
127135
with:
128136
fetch-depth: 1
137+
persist-credentials: false
129138
- name: Install system packages
130139
run: |
131140
sudo apt-get update
@@ -177,6 +186,7 @@ jobs:
177186
# Required by SonarQube Cloud for blame information
178187
with:
179188
fetch-depth: 0
189+
persist-credentials: false
180190
- name: Restore coverage.xml
181191
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
182192
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:

.github/workflows/test-reusable-workflows.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ jobs:
5151
upload-artifacts: true
5252
skip-sonar: true
5353
extra-commands: "node --version"
54+
commitlint-config-file: .github/workflow-test-fixtures/commitlint.config.mjs
5455
secrets:
56+
SONAR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
test-ci-pnpm-node-assert-artifact:
5559
name: Test ci-pnpm-node (assert artifact)
5660
runs-on: ubuntu-latest
5761
needs: test-ci-pnpm-node

0 commit comments

Comments
 (0)