feat: add agentreview github webhook reviewer #28

Merged
benvin merged 4 commits from benvin/agentreview into main 2026-11-18 22:37:17 +11:00
Member

GitHub PRs get no automated review today. A webhook-driven Claude Code reviewer posts Copilot-style feedback on each newly opened PR automatically.

  • add agentreview serve: HMAC-verified POST /webhook and GET /healthz
  • review opened/reopened/ready PRs (non-draft) from --allow repos only, async with bounded concurrency and per-PR dedup
  • clone over https from the configured GitHub host + full_name, auth host-scoped, symlinks as plain files
  • run claude -p read-only (Read/Grep/Glob, restricted) over the head clone and a size-capped PR diff
  • support subscription OAuth or gateway auth via env only
  • post a COMMENT review; failures are logged with secrets redacted, outputs containing secrets are not posted
  • ship it in the RPM, release assets, completions and docs
GitHub PRs get no automated review today. A webhook-driven Claude Code reviewer posts Copilot-style feedback on each newly opened PR automatically. - add `agentreview serve`: HMAC-verified `POST /webhook` and `GET /healthz` - review opened/reopened/ready PRs (non-draft) from `--allow` repos only, async with bounded concurrency and per-PR dedup - clone over https from the configured GitHub host + `full_name`, auth host-scoped, symlinks as plain files - run `claude -p` read-only (Read/Grep/Glob, restricted) over the head clone and a size-capped PR diff - support subscription OAuth or gateway auth via env only - post a `COMMENT` review; failures are logged with secrets redacted, outputs containing secrets are not posted - ship it in the RPM, release assets, completions and docs
unkin-agent added 2 commits 2026-11-16 23:06:20 +11:00
chore: drop stray agentreview binary
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
37125a0bdd
unkin-agent added 1 commit 2026-11-16 23:06:22 +11:00
chore: drop stray agentreview binary
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
37125a0bdd
Author
Member
  • cmd/agentreview/review.go:964 — head checkout may contain symlinks (e.g. x -> /proc/self/environ) that Read/Grep follow out of work/, exposing the OAuth/gateway token which is then posted publicly; nothing tests this → after checkout remove all symlinks under repo/ (or prove --restricted resolves them) and add a test with a hostile symlink.
  • cmd/agentreview/review.go:936 — model output is posted verbatim to a public PR with no secret guard → refuse to post (log only) if text contains any of githubToken or the authEnv values.
  • cmd/agentreview/main.go:248 — no repo/owner allowlist: any repo that can sign with the shared secret gets Claude runs and a GitHub-token-authenticated clone of repository.clone_url → add an allowed-owner/repo flag, or confirm the secret is per-repo.
  • nit: cmd/agentreview/main.go:442 — goroutines queue unboundedly on s.sem (one per distinct PR) → cap the pending queue and drop with a log when full.
  • nit: AGENTS.md:44 — review.go # ... breaks the column alignment of the neighbouring cmd/ lines → align; also "agentreview run" is not a command, reword to "review pipeline".
- cmd/agentreview/review.go:964 — head checkout may contain symlinks (e.g. `x -> /proc/self/environ`) that Read/Grep follow out of `work/`, exposing the OAuth/gateway token which is then posted publicly; nothing tests this → after checkout remove all symlinks under `repo/` (or prove `--restricted` resolves them) and add a test with a hostile symlink. - cmd/agentreview/review.go:936 — model output is posted verbatim to a public PR with no secret guard → refuse to post (log only) if `text` contains any of githubToken or the authEnv values. - cmd/agentreview/main.go:248 — no repo/owner allowlist: any repo that can sign with the shared secret gets Claude runs and a GitHub-token-authenticated clone of `repository.clone_url` → add an allowed-owner/repo flag, or confirm the secret is per-repo. - nit: cmd/agentreview/main.go:442 — goroutines queue unboundedly on `s.sem` (one per distinct PR) → cap the pending queue and drop with a log when full. - nit: AGENTS.md:44 — `review.go # ...` breaks the column alignment of the neighbouring `cmd/` lines → align; also "agentreview run" is not a command, reword to "review pipeline".
unkin-agent added 1 commit 2026-11-16 23:11:23 +11:00
fix(agentreview): require repo allowlist, pin clone host, block symlinks and secret leaks
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
be7801a6ed
Author
Member
  • cmd/agentreview/review.go:124 — http.extraHeader applies to every URL git talks to, including redirects, and --github-url/--github-api accept plain http:// (token sent in clear) → scope the header to http.<githubWeb>/.extraHeader, set http.followRedirects=false, and reject non-https URLs at startup.
  • cmd/agentreview/review.go:87 — scrub is a literal substring match on the posted text only; review failed: %v logs (main.go:347; claude result and stderr in review.go:180/:241) go unscrubbed → run logged errors through the same redaction and also match the base64/URL-encoded forms of each secret.
  • cmd/agentreview/main.go:339 — body says "bounded queue" but every distinct PR parks a goroutine on s.sem with no cap → cap pending reviews (reject with 503) or fix the body.
  • cmd/agentreview/main.go:328 — an event for a PR already in flight is dropped even if HeadSHA differs, and failed reviews are never retried, so a reopened/ready_for_review during a run is silently lost → key on SHA or requeue once after the running review ends.
  • cmd/agentreview/review.go:223 — diff io.ReadAll is unbounded → wrap in io.LimitReader and fail past a cap.
  • cmd/agentreview/main.go:131 — --allow "a, b" keeps the leading space, so b silently never matches (fails closed but confusing) → strings.TrimSpace each entry.
  • cmd/agentreview/main_test.go — no test for shutdown draining, per-review timeout, or secret redaction in logged errors → add them alongside the fixes above.
  • nit: cmd/agentreview/main_test.go:170 — TestStartBoundsConcurrency relies on 20ms sleeps → use channels to hold reviews open.
  • nit: AGENTS.md:38 — the whole structure block is re-aligned for one new line → keep the existing alignment and add the two rows only.
- cmd/agentreview/review.go:124 — `http.extraHeader` applies to every URL git talks to, including redirects, and `--github-url`/`--github-api` accept plain `http://` (token sent in clear) → scope the header to `http.<githubWeb>/.extraHeader`, set `http.followRedirects=false`, and reject non-https URLs at startup. - cmd/agentreview/review.go:87 — scrub is a literal substring match on the posted text only; `review failed: %v` logs (main.go:347; claude result and stderr in review.go:180/:241) go unscrubbed → run logged errors through the same redaction and also match the base64/URL-encoded forms of each secret. - cmd/agentreview/main.go:339 — body says "bounded queue" but every distinct PR parks a goroutine on `s.sem` with no cap → cap pending reviews (reject with 503) or fix the body. - cmd/agentreview/main.go:328 — an event for a PR already in flight is dropped even if `HeadSHA` differs, and failed reviews are never retried, so a `reopened`/`ready_for_review` during a run is silently lost → key on SHA or requeue once after the running review ends. - cmd/agentreview/review.go:223 — diff `io.ReadAll` is unbounded → wrap in `io.LimitReader` and fail past a cap. - cmd/agentreview/main.go:131 — `--allow "a, b"` keeps the leading space, so `b` silently never matches (fails closed but confusing) → `strings.TrimSpace` each entry. - cmd/agentreview/main_test.go — no test for shutdown draining, per-review timeout, or secret redaction in logged errors → add them alongside the fixes above. - nit: cmd/agentreview/main_test.go:170 — `TestStartBoundsConcurrency` relies on 20ms sleeps → use channels to hold reviews open. - nit: AGENTS.md:38 — the whole structure block is re-aligned for one new line → keep the existing alignment and add the two rows only.
unkin-agent added 1 commit 2026-11-16 23:15:47 +11:00
fix(agentreview): scope git auth to the GitHub host, redact logged errors, cap diff size
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
01e2f94a1f
Author
Member
  • nit: cmd/agentreview/review.go:255 — body says "size-capped PR diff" but a diff over 5 MiB fails the whole review (TestOversizedDiffFailsReview) → reword the body, or truncate the diff and review the rest.
  • nit: AGENTS.md:38 — the Structure block is re-indented wholesale to add two lines, burying the real change → keep the old alignment and add the agentreview rows only.
  • nit: cmd/agentreview/review.go:135 — clone doc comment wraps mid-sentence into one long line → rewrap.
  • nit: README.md (agentreview section) — first paragraph has one over-long line → rewrap to match the file.
- nit: cmd/agentreview/review.go:255 — body says "size-capped PR diff" but a diff over 5 MiB fails the whole review (TestOversizedDiffFailsReview) → reword the body, or truncate the diff and review the rest. - nit: AGENTS.md:38 — the Structure block is re-indented wholesale to add two lines, burying the real change → keep the old alignment and add the agentreview rows only. - nit: cmd/agentreview/review.go:135 — clone doc comment wraps mid-sentence into one long line → rewrap. - nit: README.md (agentreview section) — first paragraph has one over-long line → rewrap to match the file.
benvin merged commit e21f41f35c into main 2026-11-18 22:37:17 +11:00
benvin deleted branch benvin/agentreview 2026-11-18 22:37:17 +11:00
Sign in to join this conversation.