Skip to content

Commit

Permalink
CI-hardening: move permissions to the job level
Browse files Browse the repository at this point in the history
Instead of giving all jobs write permissions, default to no permissions
and enable them on a per-job basis.

This does not change anything for us, but avoids accidental write
permissions if a new job gets added without considering that it inherits
the top level permissions, even if it doesn't need them.

See https://woodruffw.github.io/zizmor/audits/#excessive-permissions
  • Loading branch information
lazka committed Dec 6, 2024
1 parent 7eed3d8 commit 5bf958f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ on:
env:
PYTHONUNBUFFERED: 1

permissions:
contents: write
permissions: {}

jobs:

schedule:
runs-on: ubuntu-22.04

permissions:
contents: write

concurrency: autobuild-maint

outputs:
Expand Down Expand Up @@ -96,6 +98,9 @@ jobs:
timeout-minutes: 4320
needs: schedule

permissions:
contents: write

concurrency: autobuild-build-${{ matrix.name }}

if: ${{ needs.schedule.outputs.build-plan != '[]' }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/maint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ on:
required: false
type: string

permissions:
contents: write
permissions: {}

concurrency: autobuild-maint

Expand All @@ -29,6 +28,9 @@ jobs:
schedule:
runs-on: ubuntu-22.04

permissions:
contents: write

steps:

- name: Dump inputs
Expand Down

0 comments on commit 5bf958f

Please sign in to comment.