[Refactor:System] Add top-level permissions#12464
[Refactor:System] Add top-level permissions#12464williamjallen merged 5 commits intoSubmitty:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12464 +/- ##
=========================================
Coverage 21.66% 21.66%
Complexity 9638 9638
=========================================
Files 268 268
Lines 36233 36233
Branches 486 486
=========================================
Hits 7849 7849
Misses 27902 27902
Partials 482 482
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
The title check CI test is failing, ensure your title meets the guidelines at https://submitty.org/developer/getting_started/make_a_pull_request. |
|
Hi @IDzyre Sir, I've updated the title to [Refactor:System] Add top-level permissions and synced the branch with main. The workflows are currently awaiting approval to run. |
williamjallen
left a comment
There was a problem hiding this comment.
Changes look good to me. I also adjusted the repository settings to make the GITHUB_TOKEN read-only by default.
IDzyre
left a comment
There was a problem hiding this comment.
As we don't need more than read permissions for the existing CI runs, the changes look valid to me. The CI passes, so there I see no reason to doubt the permissions for the existing workflow.
|
Thank you @williamjallen @IDzyre for the review and the merge! |
Why is this Change Important & Necessary?
Fixes #12463
The CI workflows do not set a top-level
permissions:block. Without one, all jobs without explicit job-level permissions inherit the defaultGITHUB_TOKENpermissions which onpushevents includes write access to contents, packages, deployments, etc.This follows the GitHub-recommended least-privilege principle for workflow tokens and reduces the blast radius if a dependency or action is compromised.
What is the New Behavior?
Added a top-level
permissionsblock to all 11 workflow files that were missing one:contents: readactions/checkout; codecov uses its own tokencontents: readcontents: readSUBMITTYBOT_DEPENDENCY_TOKEN{}(none)SUBMITTYBOT_DEPENDENCY_TOKENcontents: read{}(none)curlwith Zulip secret{}(none)curlwith Zulip secretcontents: readcontents: readwrite-alloverride remains intactcontents: readpull-requests: writeoverride remains intactcontents: readpull-requests: writeoverride remains intactJobs that need elevated permissions retain their existing job-level overrides, which take precedence over the top-level default.
What steps should a reviewer take to reproduce or test the bug or new feature?
permissions:block is placed correctly (betweenon:andenv:/jobs:)permissions:(e.g., first_issue_reply.yml, first_pr_open.yml, label_stale_prs.yml) still have their overrides intactAutomated Testing & Documentation
GITHUB_TOKENwrite access beyond what's already declared at job-levelOther information
permissionsonly restricts the default; job-level overrides are unaffected