Skip to content

fix: authorize custom org repository roles via base permission - #45641

Merged
pelikhan merged 16 commits into
mainfrom
copilot/fix-on-roles-custom-org-repository-roles
Jul 15, 2026
Merged

fix: authorize custom org repository roles via base permission#45641
pelikhan merged 16 commits into
mainfrom
copilot/fix-on-roles-custom-org-repository-roles

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Since #37959, checkRepositoryPermission prefers role_name over permission for authorization. Custom org repository roles (e.g. Security Champions) set role_name to their custom string, which never matches any on.roles value — making them permanently unauthorizable even when their base permission (write) is in the required set.

Changes

  • check_permissions_utils.cjs: Defines a STANDARD_ROLES set (admin, maintain, write, triage, read). When role_name is a custom (non-standard) role, also checks normalizedPermission in the hasPermission evaluation. Standard roles retain exact role_name matching, preserving Honor role_name in runtime role authorization for on.roles (maintain/triage) #37959's maintain/triage precision.

  • check_permissions_utils.test.cjs: Adds two fixtures for the custom role case — authorized when base permission matches, rejected when it does not.

// Before: rejected — "Security Champions" !== "write"
{ permission: "write", role_name: "Security Champions" }  // required: ["admin", "maintain", "write"]

// After: authorized via base permission fallback

The maintain-over-write exact-match behavior from #37959 is unchanged: a user with role_name: "maintain" is still rejected if only write is required.

Copilot AI and others added 2 commits July 15, 2026 06:09
…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 AI changed the title [WIP] Fix on.roles rejection of custom org repository roles fix: authorize custom org repository roles via base permission Jul 15, 2026
Copilot AI requested a review from pelikhan July 15, 2026 06:10
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot update specification

…nd glossary

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot update specification

Updated in commit docs: document custom org role base-permission fallback in triggers and glossary:

  • docs/src/content/docs/reference/triggers.md: Added a "Custom organization repository roles" subsection explaining that actors with custom org roles are authorized via their base permission (e.g. a user with role Security Champions (base: write) is authorized when write is in the required set).
  • docs/src/content/docs/reference/glossary.md: Updated the Role Filtering entry to note that custom org role actors are matched on the base permission the role confers, not the custom role name.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category bug
Risk medium
Score 65/100 (impact:35, urgency:18, quality:12)
Action fast_track

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.

Generated by 🔧 PR Triage Agent · 143.8 AIC · ⌖ 7.64 AIC · ⊞ 5.6K ·

@pelikhan
pelikhan marked this pull request as ready for review July 15, 2026 07:23
Copilot AI review requested due to automatic review settings July 15, 2026 07:23
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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/).

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef
@copilot please run the pr-finisher skill, refresh this branch for the latest base branch state if needed, and rerun checks once finished.

Run: https://github.com/github/gh-aw/actions/runs/29397228615

Generated by 👨‍🍳 PR Sous Chef · 13.6 AIC · ⌖ 6.54 AIC · ⊞ 5.1K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address any unresolved review feedback, refresh the branch if needed, and rerun checks once updates are complete.

...

Addressed in 6d19a2a. I refreshed the branch with origin/main, kept the custom-role authorization/test coverage intact, and reran local validation (actions/setup/js typecheck + targeted tests, then make fmt, make lint, make test-unit, make test, make recompile, and make agent-report-progress). The earlier CJS failure was the pre-refresh awf_reflect typecheck issue, and the Smoke CI failure was an agent missing-tool/incomplete-run case. CI on this HEAD is still unverified until a maintainer re-triggers it.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot use the w3c-specification-writer agent to update the safe outputs specification

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot use the w3c-specification-writer agent to update the safe outputs specification

Addressed in 7f36978.

Updated the safe outputs replay docs and the W3C-style safe outputs specification to require exact admin/maintain authorization, document inherited standard-role resolution for custom organization repository roles, and specify fail-closed behavior when GitHub does not provide the inherited role.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot add logging for debugability

Copilot AI and others added 4 commits July 15, 2026 11:12
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>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add logging for debugability

Addressed in 9224d6c.

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 (effective-role vs inherited-standard-role), and the fail-closed case when inherited-role metadata is missing. Verified with make lint-cjs, npm run typecheck, targeted check_permissions_utils tests, make agent-report-progress, and final PR validation.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 6.57 AIC · ⌖ 15.8 AIC · ⊞ 7.5K ·
Comment /souschef to run again

…custom-org-repository-roles

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

...

Addressed in a5b0da2. I refreshed the branch with origin/main, reviewed the unresolved in-scope feedback against the current branch state, and reran local validation. actions/setup/js typecheck plus targeted check_permissions_utils tests passed, make fmt and make lint passed, and the full make test-unit/make test/make agent-report-progress runs still fail on pre-existing pkg/cli bootstrap tests that try to read github/central-agentic-ops over the blocked public API path in this sandbox. CI on this HEAD is unverified until a maintainer re-triggers it.

@pelikhan
pelikhan merged commit 73443f4 into main Jul 15, 2026
@pelikhan
pelikhan deleted the copilot/fix-on-roles-custom-org-repository-roles branch July 15, 2026 12:25
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef
@copilot please run the pr-finisher skill, reconcile the remaining instability with the current review state, keep the custom-role logging/docs changes coherent, and rerun checks once the branch is up to date.

Run: https://github.com/github/gh-aw/actions/runs/29414813374

Generated by 👨‍🍳 PR Sous Chef · 15.4 AIC · ⌖ 5.73 AIC · ⊞ 7.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

on.roles rejects custom org repository roles despite base write permission (regression from #37959)

4 participants