refactor(github-app): shared real-permission scaffold for action commands (#824) - #839
Conversation
…ion commands (#824) maybeProcessGateOverrideCommand and maybeProcessPrPanelRetrigger each inlined the same security-critical authorization flow (resolve real repo permission → isAuthorizedCommandActor) plus the same advisory build. As #778/#769 add more action commands (auto-merge/close/request-changes), that duplication is a safety risk — each new command must independently get the real-permission check right (the #788 hazard). Extract two helpers in processors.ts: - authorizePrActionActor: the SINGLE real-permission authorization gate. Resolves the actor's real repo permission via resolveRealRepoPermissionAssociation (never the spoofable author_association), runs the optional miner detection, and returns the isAuthorizedCommandActor decision. Every action command authorizes through here, so no future command can fall back to a weaker check. - buildAuthorizedPrActionAdvisory: the common load-repo-context + buildPullRequestAdvisory step. Both action commands refactored onto them; each keeps its own trigger/skip/deny/success handling. No behavior change — full suite green (1996 passed).
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
gittensory · advisory review Reviewed 2 changed file(s) — two independent AI reviewers. Changed files: Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · No blocking issues spotted. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #839 +/- ##
==========================================
+ Coverage 96.56% 96.58% +0.01%
==========================================
Files 98 98
Lines 14197 14196 -1
Branches 5174 5172 -2
==========================================
+ Hits 13710 13711 +1
Misses 105 105
+ Partials 382 380 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…thorizePrActionActor (#824) The miner-detection branch of the extracted authorizePrActionActor helper (a confirmed-miner PR author retriggering their own panel via review-now) was previously untested — every panel-retrigger test authorized via maintainer. Adds an end-to-end test exercising it, restoring the patch coverage the refactor surfaced.
Closes #824. Agent-layer write-safety prerequisite (the structural complement to #788).
Why
maybeProcessGateOverrideCommandandmaybeProcessPrPanelRetriggereach inlined the same security-critical authorization flow — resolve the actor's real repo permission →isAuthorizedCommandActor— plus the same advisory build. As #778/#769 add more action commands (auto-merge / close / request-changes), that duplication is a safety risk: each new command would have to independently get the real-permission check right, and one could silently fall back to the spoofableauthor_association(the #788 hazard).What
Two helpers in
processors.ts:authorizePrActionActor— the single real-permission authorization gate for action commands. Resolves the actor's real repo permission viaresolveRealRepoPermissionAssociation(neverauthor_association), runs the optional miner detection, and returns theisAuthorizedCommandActordecision. Every action command authorizes through here, so no future command can bypass it.buildAuthorizedPrActionAdvisory— the common load-repo-context +buildPullRequestAdvisorystep.Both action commands refactored onto them; each keeps its own trigger / skip / deny / success handling (those legitimately differ — distinct skip strings asserted in tests, distinct mutations). #778's write-commands build on
authorizePrActionActor.No behavior change
Pure refactor — the extracted code is identical to what was inlined. Full suite 1996 passed, 1 skipped (same as before), typecheck clean. The gate-override + panel-retrigger + #788 Q&A-auth tests all stay green.
Relates #788 (the auth-hardening this centralizes), #778 / #769 (write-actions that build on it), #538.