Skip to content

fix(security): split-workflow pattern + same-repo guard for docs PR AI menu (SEC-043)#6484

Merged
theletterf merged 1 commit into
mainfrom
fix/sec-043-docs-pr-ai-menu-fork-guard
May 13, 2026
Merged

fix(security): split-workflow pattern + same-repo guard for docs PR AI menu (SEC-043)#6484
theletterf merged 1 commit into
mainfrom
fix/sec-043-docs-pr-ai-menu-fork-guard

Conversation

@theletterf
Copy link
Copy Markdown
Member

Summary

  • Replaces pull_request_target with the split-workflow pattern to fix the SEC-043 dangerous-trigger finding while preserving the AI PR menu for fork PRs.
  • Adds a same-repo guard to evaluate-trigger so fork contributors cannot toggle the checkbox to reach the COPILOT_GITHUB_TOKEN path.

How it works:

  1. New docs-pr-ai-menu-collect.yml — triggered by pull_request (read-only, no secrets). Saves the PR number as an artifact.
  2. docs-pr-ai-menu.yml — now triggered by workflow_run on the collect workflow. Downloads the PR number artifact and passes it to the existing script via process.env.PULL_REQUEST_NUMBER. Runs in the trusted base-repo context.
  3. evaluate-trigger — fetches the PR on issue_comment events and short-circuits with docs_review_triggered=false if head.repo.full_name doesn't match the base repo.

This mirrors the fix applied to the canonical template in elastic/oblt-aw#896.

Test plan

  • Open a same-repo PR → collect workflow runs, then main workflow posts the AI PR menu comment.
  • Open a fork PR → collect workflow runs (read-only), then main workflow posts the menu on the fork PR too.
  • workflow_dispatch with a PR number → still works.
  • Fork contributor toggling the checkbox → evaluate-trigger short-circuits, no docs review triggered.

🤖 Generated with Claude Code

…I menu (SEC-043)

Replace pull_request_target with the split-workflow pattern to eliminate
the SEC-043 dangerous-trigger finding without losing fork PR support:

- New docs-pr-ai-menu-collect.yml: triggered by pull_request (read-only,
  no secrets), saves the PR number as an artifact.
- docs-pr-ai-menu.yml: now triggered by workflow_run on the collect
  workflow. Downloads the PR number artifact from the trusted base-repo
  context and passes it to the existing external script via env var.
- evaluate-trigger: add pull-requests: read permission and a same-repo
  guard that fetches the PR and short-circuits with
  docs_review_triggered=false for fork PRs, preventing untrusted
  contributors from reaching the COPILOT_GITHUB_TOKEN path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@theletterf theletterf requested a review from a team as a code owner May 13, 2026 17:31
@theletterf theletterf requested a review from technige May 13, 2026 17:31
@github-actions
Copy link
Copy Markdown
Contributor

Elastic Docs AI PR menu

Check the box to run an AI review for this pull request.

  • Review docs changes (docs-review). Status: not started.

Powered by GitHub Agentic Workflows and docs-actions. For more information, reach out to the docs team.

@theletterf theletterf merged commit dd998e8 into main May 13, 2026
12 of 13 checks passed
@theletterf theletterf deleted the fix/sec-043-docs-pr-ai-menu-fork-guard branch May 13, 2026 17:34
theletterf added a commit that referenced this pull request May 17, 2026
)

## Summary

The same-repo guard introduced in #6484 (SEC-043) unconditionally
blocked fork PRs from triggering the docs review, even when the actor
was an Elastic org member. This caused confusion (see #6537) where a
repo member checking the box on a fork PR was silently ignored.

**Change:** the guard now calls `checkMembershipForUser` before
short-circuiting. Org members can trigger reviews on fork PRs;
non-members are still blocked.

```
fork PR + non-member → blocked (unchanged)
fork PR + org member → allowed (new)
same-repo PR         → unchanged
```

The companion change in the canonical template is in
elastic/oblt-aw#896.

## Test plan

- [ ] Fork PR: org member checks the box → `evaluate-trigger` passes,
docs review runs
- [ ] Fork PR: fork contributor checks the box → `evaluate-trigger`
short-circuits, no review
- [ ] Same-repo PR: unchanged behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants