Repository navigation
Trigger stage results workflow on /use comments - #3640
Conversation
| if body.strip(COMMAND_SPACE).startswith("/use"): | ||
| # /use is owned by the reuse workflow; only well-formed requests also stage. | ||
| command = use_command(body) | ||
| if not command: | ||
| return None | ||
| else: | ||
| command = re.fullmatch( | ||
| rf"/stage-results(?:[{COMMAND_SPACE}]+([0-9]+))?", body.strip(COMMAND_SPACE) | ||
| ) | ||
| if not command: | ||
| reject( | ||
| "Unsupported /stage-results syntax", |
There was a problem hiding this comment.
🔴 A low-privilege collaborator who posts a well-formed /use <run-id> purely to trigger sweep reuse now also gets a public PR comment exposing their repo permission/role and a failed CI check, which never happened before this PR wired /use into stage-results. reuse.py authorizes /use for any OWNER/MEMBER/COLLABORATOR author_association (reuse.py:30), including read/triage-only collaborators, but stage_results.py:132 still requires permission/role in {admin, maintain, write}. Since stage-results.yml:21 now fires on /use, this hits reject() at stage_results.py:137-141, publicly posting the actor's permission/role and failing the job despite a legitimate reuse request. Fix: treat permission/label rejection on /use as a silent no-op, or gate it on the same author_association check reuse.py uses.
Why this was flagged
Trigger: a repo collaborator with COLLABORATOR author_association but only read/triage permission posts /use 123 on a full- or non-full-sweep PR, intending only sweep-run reuse (authorized per reuse.py:30-41, DEFAULT_ALLOWED_AUTHOR_ASSOCIATIONS). Entry: stage-results.yml:18-21 now matches startsWith(body,'/use'), so request() in stage_results.py runs; use_command() matches (well-formed), so the malformed-only short-circuit at stage_results.py:114-115 is skipped. The permission check at stage_results.py:125-132 then compares GitHub's write/maintain/admin permission requirement against an actor who was never required to have it for /use, and reject() at 137-141 publicly posts the actor's exact permission and role string and raises RuntimeError, failing the Authorize job. On base, /use never reached this code at all, so no such comment or failure occurred for ordinary reuse requests.
Verification: reuse.py authorizes /use for any OWNER/MEMBER/COLLABORATOR author_association (reuse.py:30), which includes read/triage-only collaborators. stage-results.yml:21 now also fires on /use, so for a well-formed /use 123, stage_results.py:111-115 matches and does not short-circuit.
Summary
stage-results.ymlnow also triggers on PR comments starting with/use, in addition to/stage-results. Same workflow, same authorization and stageability rules./use <run-id>is treated like/stage-results <run-id>and stages that pinned run./usecomments (e.g./use,/useful,/use 123 extra) exit quietly with no staging comment, since the reuse workflow already reacts to them. The acknowledge and dispatch steps are skipped when no run is selected.Example trigger: #3578 (comment)
Testing
uv run --locked pytest infx/tests/workflows/test_stage_results.py(51 passed)zizmor .github/workflows/stage-results.yml: no findings