Minimally scope permissions in GitHub Actions workflows#261
Draft
desrosj wants to merge 3 commits into
Draft
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the repository’s GitHub Actions workflows by adopting a default-deny permissions posture (permissions: {}) and explicitly scoping job permissions, while also adding per-job timeouts to prevent runaway CI executions.
Changes:
- Add top-level
permissions: {}to workflows and define least-privilege job-level permissions where needed. - Add
timeout-minutesto each job across workflows. - Document why specific permissions (e.g.,
contents: write,pull-requests: write) are required for reusable workflows and automation steps.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/unit-tests-and-coverage-report.yml | Default-deny permissions; job-level permissions/timeouts for metadata + reusable code coverage workflow. |
| .github/workflows/satis-webhook.yml | Default-deny permissions; scoped contents: read for checkout; add job timeout. |
| .github/workflows/newfold-prep-release.yml | Default-deny permissions; document scoped write permissions; add job timeout for reusable release prep. |
| .github/workflows/lint.yml | Default-deny permissions; add job timeout; explicitly request contents: write for PHPCBF auto-commit flow. |
| .github/workflows/brand-plugin-test-playwright.yml | Replace workflow-wide permissions with default-deny; scope permissions per job; add timeouts. |
| .github/workflows/auto-translate.yml | Keep default-deny baseline; document scoped permissions; add job timeout for reusable translations workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+26
to
+28
| timeout-minutes: 30 | ||
| permissions: | ||
| contents: write # Required to checkout the repo and push PHPCBF fixes on main via git-auto-commit-action (github.token). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates the GitHub Actions workflow files to:
Once this PR is merged, the Settings -> Actions -> Workflow permissions setting can be changed by a repo admin to "Read repository contents and packages permissions".
For more information, see PRESS11-470.
References
Use of AI
Cursor was used with (Claude Opus 4.7 and Composer 2.0 at varying points) to analyze the repository and make the initial changes.
When this PR is marked "ready for review" it means that I have manually reviewed all permissions and timeouts that were changed and made any necessary adjustments.
As a part of the analysis, the following summary was created:
Status
auto-translate.yml,brand-plugin-test-playwright.yml,lint.yml,newfold-prep-release.yml,satis-webhook.yml,unit-tests-and-coverage-report.yml)add/scoped-workflow-permissions(created)1c2fe7b6fa2474a2Top-level
permissions: {}permissions: {}directive (added in this run):unit-tests-and-coverage-report.ymlpermissions: {}directive (added in this run):satis-webhook.ymlpermissions: {}directive (added in this run):lint.ymlpermissions: {}directive (added in this run):brand-plugin-test-playwright.yml(replaced prior top-levelpermissions: contents: readand relocated the block to immediately precedejobs:)permissions: {}directive (added in this run):auto-translate.yml(inserted the required two-line comment immediately above the existingpermissions: {})Job-level
permissions:additionspermissions:directivepermissions: {}[3]permissions:directivecontents: read[3]permissions:directivecontents: write[3]Permissions corrections (previously incorrect)
brand-plugin-test-playwright.yml:: top-level (workflow): BEFOREpermissions: contents: read-> AFTER# Disable permissions.../# Any needed...+permissions: {}immediately beforejobs:-- align with required default-deny workflow baseline; previously grantedcontents: readto the whole workflow -- [3]brand-plugin-test-playwright.yml::setup: BEFOREcontents: read-> AFTERpermissions: {}-- job only derives a branch name from ref env vars and does not useactions/checkoutor other token-backed GitHub API calls -- [3]auto-translate.yml::translate: added aligned inline comments for existingcontents: write/pull-requests: write, and moved thepermissionsblock to immediately followuses:per the audit’s job layout rule -- [3]newfold-prep-release.yml::prep-release: added aligned inline comments for existingcontents: write/pull-requests: write, and moved thepermissionsblock to immediately followuses:per the audit’s job layout rule -- [3]unit-tests-and-coverage-report.yml::unit-tests: added aligned inline comments for existingcontents: write/pull-requests: write, and moved thepermissionsblock to immediately followuses:per the audit’s job layout rule -- [3]timeout-minutesadditions101203030mainare typically well under this cap.10120wp-envinstalls can be long-running; needs a higher ceiling than lint-style jobs.120bluehost, plus an alternate plugin branch may change dependency resolution timing.12060Notes / blockers
newfold-labs/workflowswere reviewed atmainfor expectedGITHUB_TOKENusage (e.g.,reusable-codecoverage.ymlpushinggh-pagesand PR comments;reusable-translations.ymlusinggh prand git pushes;module-plugin-test-playwright.ymlcloning multiple private repos;reusable-module-prep-release.ymlusinggh pr list). If those reusables change behavior, re-validate the corresponding callerpermissionsand timeouts.satis-webhook.ymldispatches usingsecrets.WEBHOOK_TOKEN(notgithub.token); jobpermissionsonly coveractions/checkoutwith the default token.