Harden auto-merge workflow collaborator check - #7
Conversation
Pass the repository name, sender login, and pull request number to the reusable auto-merge workflow's run step through env: variables and GraphQL variables, and match the approving collaborator in the shell, instead of expanding GitHub context expressions directly into the inline script. This keeps event data out of the interpreted command as defense-in-depth for a reusable workflow that runs with contents: write across many repositories. While rewriting the collaborator lookup, also make it more robust: paginate the collaborators connection so an approver beyond the first page is still recognized, and fail closed (exit non-zero) on an API error rather than treating the failure as "not a collaborator". Auto-merge is still enabled only for approved bot pull requests whose approver is a repository collaborator. Co-Authored-By: Claude <noreply@anthropic.com> Ref: EC-2055
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe auto-merge workflow now uses environment variables, retrieves collaborators through paginated GraphQL requests, handles API failures, and enables auto-merge only when the sender is a collaborator. ChangesAuto-merge collaborator validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The workflow hardens handling of event-provided values while preserving auto-merge behavior; no actionable merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant AutoMergeWorkflow
participant GitHubGraphQLAPI
participant PullRequest
AutoMergeWorkflow->>GitHubGraphQLAPI: Retrieve paginated collaborators
GitHubGraphQLAPI-->>AutoMergeWorkflow: Return collaborator data or API error
AutoMergeWorkflow->>PullRequest: Compare SENDER_LOGIN and enable auto-merge when matched
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
PR Summary by QodoHarden auto-merge workflow collaborator check against context injection
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
What
The reusable
auto-mergeworkflow expanded GitHub context expressions(repository name, sender login, PR number) directly into its inline
run:script. This change passes them through
env:and GraphQL variables andmatches the approving collaborator in the shell instead.
Why
The workflow runs with
contents: writeand is reused across manyrepositories. Keeping event-provided data out of the interpreted command
is defense-in-depth against context-expression injection in a shared,
write-capable component.
Also included
While rewriting the collaborator lookup, made it more robust:
approver beyond the first page is still recognized.
being silently treated as "not a collaborator".
Behavior
Auto-merge is still enabled only for approved bot pull requests whose
approver is a repository collaborator.
Validation
actionlint+shellcheckclean${{ }}expansions remain in therun:body (onlyenv:and thejob-level
if:)Ref: EC-2055