Build/Test Tools: Restrict the permissions granted to jobs on GitHub Actions

The `permissions` key in a job declares the GitHub permissions that are granted to the token that's used by the job. Restricting the permissions reduces the impact that a vulnerability in the CI system can have.

Props desrosj, johnbillion

See #57865


git-svn-id: https://develop.svn.wordpress.org/trunk@55715 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2023-05-03 22:15:27 +00:00
parent eb409e4cac
commit 3bfc6611ad
13 changed files with 103 additions and 0 deletions
+8
View File
@@ -35,6 +35,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
# Runs PHP compatibility testing.
@@ -54,6 +58,8 @@ jobs:
php-compatibility:
name: Check PHP compatibility
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
@@ -121,6 +127,8 @@ jobs:
failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
permissions:
actions: write
needs: [ php-compatibility, slack-notifications ]
if: |
always() &&