Skip to content

Commit e09775c

Browse files
committed
ci(regression): add explicit least-privilege permissions
Addresses CodeQL warning 'Workflow does not contain permissions'. Defaults the workflow GITHUB_TOKEN to `contents: read` only. The build-image job elevates to `actions: write` because `docker/build-push-action` with `cache-from/to: type=gha` uses the GitHub Actions cache API, which needs read+write on the actions scope.
1 parent 6802e3b commit e09775c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/regression.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ concurrency:
1111
group: regression-${{ github.ref }}
1212
cancel-in-progress: true
1313

14+
# Least-privilege token: only reading code. Jobs that need more (e.g. GHA
15+
# cache reads/writes from docker/build-push-action with `type=gha`) elevate
16+
# their own permissions inline.
17+
permissions:
18+
contents: read
19+
1420
jobs:
1521
changes:
1622
name: Detect changes
@@ -42,6 +48,9 @@ jobs:
4248
if: needs.changes.outputs.code == 'true'
4349
runs-on: ubuntu-latest
4450
timeout-minutes: 20
51+
permissions:
52+
contents: read
53+
actions: write # docker/build-push-action `type=gha` cache reads + writes
4554
steps:
4655
- name: Checkout
4756
uses: actions/checkout@v4

0 commit comments

Comments
 (0)