Skip to content

Trigger stage results workflow on /use comments - #3640

Merged
cquil11 merged 2 commits into
mainfrom
cquil11/stage-results-on-use
Oct 1, 2026
Merged

cquil11 merged 2 commits into
mainfrom
cquil11/stage-results-on-use

Conversation

@cquil11

@cquil11 cquil11 commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • stage-results.yml now also triggers on PR comments starting with /use, in addition to /stage-results. Same workflow, same authorization and stageability rules.
  • A well-formed /use <run-id> is treated like /stage-results <run-id> and stages that pinned run.
  • Malformed /use comments (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.
  • Full-sweep label rejection message now says "staging requires ..." so it reads correctly for both commands.

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

@cquil11
cquil11 requested a review from a team October 1, 2026 19:23
@cquil11
cquil11 merged commit 84855a2 into main Oct 1, 2026
3 checks passed
@cquil11
cquil11 deleted the cquil11/stage-results-on-use branch October 1, 2026 19:30
Comment on lines +111 to 122
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",

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.

🔴 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.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant