Skip to content

fix(source-control): add --repo flag to babysit-readiness-gate - #2449

Merged
kyle-sexton merged 1 commit into
mainfrom
cursor/babysit-readiness-repo-flag-63e1
Aug 12, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
cursor/babysit-readiness-repo-flag-63e1

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Closes #1086

Summary

Add --repo owner/name to babysit-readiness-gate.sh so recheck passes can target a PR without cwd being the target checkout.

Related

N/A

Live comment fetch no longer depends on cwd when the orchestrator gates a PR
in another repository. --repo owner/repo exports FETCH_COMMENTS_OWNER/REPO for
fetch-all-pr-comments.sh.

Fixes #1086

Co-authored-by: Kyle Sexton <[email protected]>
@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@claude

claude Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 19s —— View job


Security review — PR #2449

  • Fetch PR diff (origin/main...HEAD) and read changed files
  • Trace --repo/REPO_SLUG data flow into fetch-all-pr-comments.sh (FETCH_COMMENTS_OWNER/FETCH_COMMENTS_REPO → gh api)
  • Check input validation, quoting, and downstream sinks for injection risk
  • Post findings

Scope: plugins/source-control/scripts/babysit-readiness-gate.sh and its test file, per the diff for this PR.

Findings: none.

Walked the new --repo owner/repo flag end to end:

  • babysit-readiness-gate.sh#L224-L232 validates REPO_SLUG against ^[^/[:space:]]+/[^/[:space:]]+$ before use, fails closed (unproven bad-args 3) on mismatch, and rejects whitespace/newlines (via [:space:]), so it can't smuggle an extra line into the stdout verdict contract this script is built around.
  • The derived FETCH_COMMENTS_OWNER/FETCH_COMMENTS_REPO are only ever consumed in fetch-all-pr-comments.sh#L141 as gh api --paginate "repos/$OWNER/$REPO/$endpoint?..." — a single quoted argv element passed to the gh binary, never through eval/bash -c/sh -c. Embedded shell metacharacters in the value are inert there (no command injection), and the regex's single-slash constraint blocks extra path segments (no path-segment smuggling into a different API route).
  • No secrets/tokens are handled directly — auth stays inside gh's own credential handling, unchanged by this diff.
  • --repo is an operator-supplied CLI flag (or wired through by the invoking skill), not attacker-controlled data from PR content, so there's no privilege-escalation angle: whoever can pass --repo already has equivalent gh api access directly.
  • The error-path printf that echoes the resolved owner/repo back (babysit-readiness-gate.sh#L255-L258) writes to stderr only, so it can't corrupt the machine-readable stdout verdict stream even in principle.

No GitHub Actions files, permissions, or dependency pins are touched by this PR, so those lanes (covered by zizmor) don't apply here.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ff6f702f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@claude

claude Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 46s —— View job


Claude finished reviewing this PR

Todo List

  • Gather context (diff, changed files, CLAUDE.md/REVIEW.md)
  • Understand the request
  • Review babysit-readiness-gate.sh changes
  • Review babysit-readiness-gate.test.sh changes
  • Post findings

Summary

This PR adds a --repo owner/repo flag to babysit-readiness-gate.sh so a caller whose cwd isn't a checkout of the target repo can still resolve the live comment fetch (closes #1086). Validation and wiring into FETCH_COMMENTS_OWNER/FETCH_COMMENTS_REPO (consumed by fetch-all-pr-comments.sh) looks correct, and the new tests (--help documents --repo, bad --repo → exit 3) pass for what they cover.

I found one correctness issue and left it as an inline comment:

  • plugins/source-control/scripts/babysit-readiness-gate.sh:224-232 — --repo only threads through to the bash-degrade fetch path (fetch-all-pr-comments.sh). The gate's preferred path — the Python override at lines 500-519, used whenever Python 3.11+ is on PATH (the common case) — calls babysit_findings.py --pr "$PR_NUMBER" --self "..." without --repo, and that script's resolve_repo() only consults an explicit --repo arg or gh repo view on $PWD, ignoring the FETCH_COMMENTS_OWNER/REPO env vars entirely. So in the exact scenario this PR targets (cwd ≠ target repo), the Python path still resolves against cwd — and if cwd happens to be some other repo, it silently overwrites the correct bash-computed counts with wrong ones from the wrong repo, rather than failing closed. This also means there's no test exercising the live (--pr, non---comments-json) path with --repo under Python, which is what would have caught it.

No security-relevant findings in scope for this lane (this repo runs claude-security-review, so vulnerabilities/injection are left to that lane — and I didn't see any argument-injection issues in the --repo handling regardless: the value is regex-validated and only ever used as owner/repo env vars, not shelled out raw).
· Branch

@github-actions

Copy link
Copy Markdown
Contributor

Claude has reviewed this PR 1 time. The lane skips further automatic reviews after 5; deleting this comment resets the count.

@kyle-sexton
kyle-sexton merged commit 0e4f41a into main Aug 12, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the cursor/babysit-readiness-repo-flag-63e1 branch August 12, 2026 14:57
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.

bug(source-control/babysit-prs): readiness gate resolves repo from CWD, silently scores wrong PR cross-repo

2 participants