fix: authorize custom org repository roles via base permission - #45641
Conversation
…yPermission Custom organization repository roles (e.g. "Security Champions") return a non-standard role_name from the GitHub API alongside a base permission (e.g. "write"). The previous logic used role_name exclusively when present, causing these roles to be rejected since their name doesn't match any on.roles enum value. Fix: for standard GitHub roles (admin, maintain, write, triage, read) keep exact role_name matching (preserving #37959's maintain/triage precision). For custom org roles, also check the base permission so that an actor whose custom role confers write is authorized when write is in the required set. Adds two test cases covering: (1) custom role authorized via base permission, (2) custom role rejected when base permission is insufficient. Closes #45536 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…case Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot update specification |
…nd glossary Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated in commit
|
🤖 PR Triage
Authorizes custom org repository roles via base permission — fixes access denial for roles like 'Security Champions'. Draft, small change (+46/-4). Undraft and verify via CI.
|
|
✅ Test Quality Sentinel completed test quality analysis. |
|
✅ PR Code Quality Reviewer completed the code quality review. |
There was a problem hiding this comment.
Pull request overview
Adds authorization fallback for custom repository roles based on their reported permission level.
Changes:
- Adds custom-role detection and permission fallback.
- Adds matching and rejection tests.
- Documents custom-role behavior.
Show a summary per file
| File | Description |
|---|---|
actions/setup/js/check_permissions_utils.cjs |
Implements custom-role authorization. |
actions/setup/js/check_permissions_utils.test.cjs |
Tests custom-role outcomes. |
docs/src/content/docs/reference/triggers.md |
Documents trigger behavior. |
docs/src/content/docs/reference/glossary.md |
Updates role-filtering terminology. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Medium
| const hasPermission = requiredPermissions.some(requiredPerm => { | ||
| const normalizedRequired = requiredPerm === "maintainer" ? "maintain" : requiredPerm; | ||
| return normalizedRequired === effectiveRole; | ||
| return normalizedRequired === effectiveRole || (isCustomRole && normalizedRequired === normalizedPermission); |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ |
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (0 additions in default business logic dirs: src/, lib/, pkg/, internal/, app/, core/, domain/, services/, api/). |
|
Run: https://github.com/github/gh-aw/actions/runs/29397228615
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed in |
|
@copilot use the w3c-specification-writer agent to update the safe outputs specification |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in Updated the safe outputs replay docs and the W3C-style safe outputs specification to require exact |
|
@copilot add logging for debugability |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Addressed in Added debug logging around repository permission resolution so custom-role authorization is easier to trace: raw API permission fields, computed effective/inherited roles, match path ( |
|
@copilot please run the
|
…custom-org-repository-roles Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed in |
|
Run: https://github.com/github/gh-aw/actions/runs/29414813374
|
|
🎉 This pull request is included in a new release. Release: |
Since #37959,
checkRepositoryPermissionprefersrole_nameoverpermissionfor authorization. Custom org repository roles (e.g.Security Champions) setrole_nameto their custom string, which never matches anyon.rolesvalue — making them permanently unauthorizable even when their base permission (write) is in the required set.Changes
check_permissions_utils.cjs: Defines aSTANDARD_ROLESset (admin,maintain,write,triage,read). Whenrole_nameis a custom (non-standard) role, also checksnormalizedPermissionin thehasPermissionevaluation. Standard roles retain exactrole_namematching, preserving Honorrole_namein runtime role authorization foron.roles(maintain/triage) #37959'smaintain/triageprecision.check_permissions_utils.test.cjs: Adds two fixtures for the custom role case — authorized when base permission matches, rejected when it does not.The
maintain-over-writeexact-match behavior from #37959 is unchanged: a user withrole_name: "maintain"is still rejected if onlywriteis required.