Skip to content

ci: request neat-bot on pull_request, skip forks - #6

Merged
Moep90 merged 1 commit into
mainfrom
ci/request-neat-bot-pull-request
Oct 25, 2026
Merged

Moep90 merged 1 commit into
mainfrom
ci/request-neat-bot-pull-request

Conversation

@Moep90

@Moep90 Moep90 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

zizmor rejects pull_request_target as a dangerous trigger. With plain pull_request a pull request from a fork gets a read-only token, so the workflow now skips forks; their reviewer is requested by hand after a look at them, which is also where prompt injection against the bot is cheapest.

@github-actions
github-actions Bot requested a review from neat-bot October 25, 2026 09:26
@neat-bot

neat-bot commented Oct 25, 2026 •

Copy link
Copy Markdown

published 2 finding(s)

@neat-bot neat-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have 2 comments on this change.

Comment on lines 17 to +18
!github.event.pull_request.draft &&
github.event.pull_request.head.repo.full_name == github.repository &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug, medium severity. This condition makes the check silently disappear for PRs whose head branch has since been deleted, and never re-runs for the PRs it skips.

Two inputs produce a wrong result here:

  1. A PR opened from a same-repo branch whose head ref was later deleted (branch deleted after a squash merge and re-opened, or force-pushed/renamed branch, then reopened / ready_for_review). On the pull_request event GitHub reports head.repo for the deleted head as the owner/repo@sha... placeholder ref, so the comparison against github.repository is false and the job is skipped for a PR that lives entirely inside this repository. The previous trigger resolved the head from event.pull_request.head.repo.full_name too, but on a pull_request_target-style payload where the ref is still resolvable, so this gap is new. Nothing else requests neat-bot on that PR (there is no CODEOWNERS entry in this repo), so it sits unreviewed with no signal.

  2. Any PR from a fork, and a same-repo PR opened in draft. This condition only evaluates at opened/reopened/ready_for_review, so there is no later pass that reports those. The comment says to request the bot by hand, but the skipped run is green and gives the reviewer no queue to work from, so a fork PR or a PR that was converted from draft to ready while nobody was watching can fall through unnoticed.

Would you consider keeping the coverage the old trigger had for same-repo PRs — e.g. a workflow_run follow-up on the main CI workflow, or comparing against github.event.repository.full_name (base repo) and accepting the @sha head form — plus some way to surface skipped PRs (a job that reports 'neat-bot not requested, handle manually' instead of exiting silently)?

Suggested change
!github.event.pull_request.draft &&
github.event.pull_request.head.repo.full_name == github.repository &&
!github.event.pull_request.draft &&
github.repository == format('{0}/{1}', github.repository_owner, github.event.repository.name) &&

Comment on lines +5 to +6
# requests from forks get a read-only token and are skipped; request the bot
# on those by hand after a look at them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation, medium severity. The comment now says fork PRs are skipped and "request the bot on those by hand after a look at them", but nothing in the repository surfaces which PRs those are. A skipped job produces no check, no log and no annotation — the PR just looks like every other PR that already has neat-bot requested. So the case that most needs a human (a fork PR, where the bot's input is untrusted content) is exactly the one that silently gets no review at all. If a fork PR is opened and nobody notices, the change merges with the bot never having read it. Consider emitting a visible marker for the skipped path instead of relying on memory — a scheduled/dispatch job that lists open fork PRs without a neat-bot review request, or at minimum a step that writes a warning to the run summary when the head repo differs.

@github-actions
github-actions Bot requested a review from neat-bot October 25, 2026 09:46
@Moep90
Moep90 merged commit b845e40 into main Oct 25, 2026
2 of 3 checks passed
@Moep90
Moep90 deleted the ci/request-neat-bot-pull-request branch October 25, 2026 09:47

@neat-bot neat-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have 2 comments on this change.

request:
if: >-
!github.event.pull_request.draft &&
github.event.pull_request.head.repo.full_name == github.repository &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug, medium severity. The github.event.pull_request.head.repo.full_name == github.repository guard doesn't do what the comment claims for one case: a pull request opened from a branch of this same repository that has since been deleted. GitHub nulls out head.repo in that payload, so the comparison is null == 'owner/repo', the expression errors, the condition evaluates to false, and the whole job is skipped. Since opened is among your triggers, that covers someone re-opening a PR whose head branch was removed — the bot silently never gets requested, and there's no failed run to notice. A null-safe form keeps the fork filter intact:

      (github.event.pull_request.head.repo.full_name || github.event.repository.full_name) == github.repository &&

Worth noting the alternative: github.repository is the repo that owns the workflow file, i.e. the base repo, so the check compares the base rather than the head. That's equivalent here only as long as edits to this file can't reach a PR via a back-merge from a fork branch.

on:
pull_request_target:
pull_request:
types: [opened, reopened, ready_for_review]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug, medium severity. The synchronize type was dropped along with the trigger change, so this now only fires on opened, reopened and ready_for_review. If the reviewer request fails at open time — the common case being that the head branch is still mid-push and GitHub rejects the request because there is no common commit with the base yet — nothing retries it, and reopened/ready_for_review don't apply, so the PR silently ends up with no neat-bot review. It looked like the previous version covered that. Either add synchronize here (the step is idempotent: a repeat POST for an already-requested reviewer just re-confirms it) or, if the omission is unintentional, restore it.

Suggested change
types: [opened, reopened, ready_for_review]
types: [opened, reopened, ready_for_review, synchronize]

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