Skip to content

fix(code-review): respect agent execution contexts - #25

Draft
esthor wants to merge 5 commits into
mainfrom
esthor/fix-codex-host-auth
Draft

fix(code-review): respect agent execution contexts#25
esthor wants to merge 5 commits into
mainfrom
esthor/fix-codex-host-auth

Conversation

@esthor

@esthor esthor commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • verify CodeRabbit CLI authentication from the same execution context that runs the review
  • keep host-native agents such as Claude Code on their normal shell and authentication path
  • tell sandboxed agents such as Codex to use only command-scoped host/network approval for the auth check and review
  • fail closed on secrets before transmitting the selected diff
  • replace retired -t scope selectors with the current CLI flags: --committed, --uncommitted, and --include-untracked

Why

A restricted Codex command sandbox may not expose authentication already stored by the host CodeRabbit CLI. A sandbox-only preflight can therefore report a false unauthenticated state. That behavior is specific to sandboxed execution and must not replace the normal host-shell workflow used by Claude Code and other native integrations.

The portable rule is to verify authentication in the same authoritative execution context that will perform the review. Sandboxed agents use their harness's normal command-scoped host/network approval without disabling the sandbox; host-native agents use their normal shell. If the authoritative check is unauthenticated, the user is asked to authenticate explicitly.

Validation

  • coderabbit 0.7.1 help verified the current authentication and review flags
  • all Markdown frontmatter parses as YAML
  • plugin JSON manifests parse successfully
  • git diff --check
  • host-context coderabbit auth status --agent confirmed existing authentication
  • local CodeRabbit review was requested but hit a temporary included-review rate limit before analysis

Draft status

This remains a draft intentionally. The original change generalized a Codex-only workaround across every supported agent. The branch now separates sandboxed and host-native behavior, but it should receive owner and full CodeRabbit review before it is considered ready.

The repository-level CodeRabbit policy remains isolated in #26.

Summary by CodeRabbit

  • Documentation

    • Updated review guidance with clearer CLI availability and authentication checks.
    • Added instructions for sandboxed execution and command-scoped host/network approval.
    • Documented supported review scopes, including committed, uncommitted, and untracked changes.
    • Clarified consent requirements and secret scanning before submitting review content.
    • Added guidance for CLI installation and unsupported versions.
  • Bug Fixes

    • Improved review command handling by mapping review types to their dedicated scope options.
    • Separated version and authentication checks for clearer prerequisite validation.
    • Updated descriptions and argument hints for supported review options.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updated review instructions to verify CLI availability and authentication in the execution context. Sandboxed agents now require command-scoped host and network approval without sandbox bypasses. Review commands now use explicit committed, uncommitted, and untracked scope flags. Documentation describes the updated authentication behavior and scope options.

Suggested reviewers: juanpflores, nehal-a2z

Poem

A rabbit checks the CLI with care,
Then hops through scopes declared fair.
Auth stays safe, approvals clear,
Untracked files now appear near.
Review runs bright from burrow to lair.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change to respect agent execution contexts during code review.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch esthor/fix-codex-host-auth
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch esthor/fix-codex-host-auth

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
@esthor

esthor commented Aug 7, 2026

Copy link
Copy Markdown
Author

move the yaml config to its own PR; mark this PR ready for review (not draft)

@esthor esthor left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

address all before mergeable

Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
Comment thread .coderabbit.yaml Outdated
@esthor
esthor marked this pull request as ready for review August 7, 2026 02:47
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 7, 2026
@esthor

esthor commented Aug 7, 2026

Copy link
Copy Markdown
Author

Moved the repository CodeRabbit policy to #26 and applied every requested setting there: inheritance disabled, assertive profile, review status/fortune/poem enabled, simplify enabled, one-commit auto-pause, and the request-changes workflow as the all-comments approval gate. PR #25 is now auth-only and ready for review.

@esthor
esthor marked this pull request as draft August 8, 2026 11:00
@esthor esthor changed the title fix(code-review): reuse host authentication in Codex fix(code-review): respect agent execution contexts Aug 8, 2026
@esthor

esthor commented Aug 8, 2026

Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@commands/coderabbit-review.md`:
- Around line 40-61: In commands/coderabbit-review.md at lines 40-61, add a
fail-closed secret/credential preflight over the complete selected review scope,
including untracked files when requested, before invoking coderabbit
"${args[@]}"; stop without running the review when a secret is detected. Apply
the same preflight before coderabbit review --agent in agents/code-reviewer.md
at lines 38-44, preserving each entry point’s existing scope selection and
authentication behavior.
- Around line 40-61: The review command flow must perform the fail-closed secret
preflight before invoking coderabbit with args. Update the Run Review section
around the args construction to apply the complete-scope check from
skills/code-review/SKILL.md for all review types, including untracked files, and
abort rather than running the command when secrets are detected.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 2e6029b1-dd9b-4dee-9613-2382ccbd6706

📥 Commits

Reviewing files that changed from the base of the PR and between bbb4ab2 and 90d32b6.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • README.md
  • agents/code-reviewer.md
  • commands/coderabbit-review.md
  • skills/code-review/SKILL.md
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • coderabbitai/bitbucket (manual)
📜 Review details
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~148-~148: Consider using a different verb for a more formal wording.
Context: ...dings grouped by severity 4. Optionally fix issues and re-review Sandboxed agents ...

(FIX_RESOLVE)

🔇 Additional comments (5)
skills/code-review/SKILL.md (1)

31-74: LGTM!

Also applies to: 83-100, 110-126

README.md (1)

145-154: LGTM!

commands/coderabbit-review.md (2)

3-3: 🎯 Functional Correctness

Keep the base selector consistent with the shared skill.

skills/code-review/SKILL.md documents --base-commit, but this command accepts only --base <branch> and forwards only base. A commit-based review cannot use this entry point. Add a separate base_commit argument and forward --base-commit, or remove that mode from the shared skill.


29-30: LGTM!

Also applies to: 71-72

CHANGELOG.md (1)

21-25: LGTM!

Comment on lines +40 to +61
**If the CLI is not authenticated**, ask the user to run:

### Run Review
```bash
coderabbit auth login
```

Do not start the login flow without the user's explicit action. Claude Code runs
these checks in its normal host shell; sandboxed agents must follow the portable
skill's execution-context guidance instead.

Once prerequisites are met:
### Run Review

```bash
# type defaults to "all"; add --base and --dir only when specified
args=(review --agent -t "${type:-all}")
args=(review --agent)
case "${type:-all}" in
all) ;;
committed) args+=(--committed) ;;
uncommitted) args+=(--uncommitted) ;;
untracked) args+=(--uncommitted --include-untracked) ;;
*) echo "Unsupported review type: $type" >&2; exit 2 ;;
esac

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- commands/coderabbit-review.md ---'
sed -n '1,180p' commands/coderabbit-review.md

printf '%s\n' '--- agents/code-reviewer.md ---'
sed -n '1,140p' agents/code-reviewer.md

printf '%s\n' '--- secret-related references ---'
rg -n -i --glob '!node_modules' --glob '!dist' --glob '!build' \
  'secret|credential|sensitive|preflight|portable.*skill|include-untracked|coderabbit review' \
  commands agents skills .github 2>/dev/null || true

printf '%s\n' '--- repository files near portable review skill ---'
git ls-files | rg -i 'review|secret|credential|portable|skill' | head -200

Repository: coderabbitai/skills

Length of output: 9202


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- skills/code-review/SKILL.md: control and workflow ---'
sed -n '1,190p' skills/code-review/SKILL.md

printf '%s\n' '--- references to the portable review skill ---'
rg -n -C 4 'skills/code-review|code-review/SKILL|secret|credential|coderabbit review --agent|commands/coderabbit-review' \
  commands agents skills --glob '*.md' --glob '*.toml'

printf '%s\n' '--- command and agent invocation structure ---'
rg -n -C 6 'coderabbit(\s+|\")|review --agent|Run Review|Run CodeRabbit Review' \
  commands/coderabbit-review.md agents/code-reviewer.md skills/code-review/SKILL.md

Repository: coderabbitai/skills

Length of output: 28539


Sensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor

Reachability: External · Exploitability: Moderate

Add the fail-closed secret preflight to both direct review entry points.

Before invoking coderabbit, inspect the complete selected scope, including untracked files when requested. Stop if a secret or credential is present.

  • commands/coderabbit-review.md: run the check before coderabbit "${args[@]}".
  • agents/code-reviewer.md: run the same check before coderabbit review --agent.
📍 Affects 2 files
  • commands/coderabbit-review.md#L40-L61 (this comment)
  • agents/code-reviewer.md#L38-L44
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@commands/coderabbit-review.md` around lines 40 - 61, In
commands/coderabbit-review.md at lines 40-61, add a fail-closed
secret/credential preflight over the complete selected review scope, including
untracked files when requested, before invoking coderabbit "${args[@]}"; stop
without running the review when a secret is detected. Apply the same preflight
before coderabbit review --agent in agents/code-reviewer.md at lines 38-44,
preserving each entry point’s existing scope selection and authentication
behavior.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- command context ---'
sed -n '1,140p' commands/coderabbit-review.md
printf '%s\n' '--- portable skill references ---'
rg -n -C 4 'secret|credential|preflight|fail.closed|coderabbit review|include-untracked|review --agent' skills/code-review/SKILL.md commands
printf '%s\n' '--- invocation references ---'
rg -n -C 3 'coderabbit "\$\{args|coderabbit review|commands/coderabbit-review|coderabbit-review' .

Repository: coderabbitai/skills

Length of output: 15570


Sensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor

Reachability: External · Exploitability: Moderate

Add the fail-closed secret preflight before coderabbit "${args[@]}". The command can transmit credentials in the selected diff because it does not apply the complete-scope check required by skills/code-review/SKILL.md, including for untracked files.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@commands/coderabbit-review.md` around lines 40 - 61, The review command flow
must perform the fail-closed secret preflight before invoking coderabbit with
args. Update the Run Review section around the args construction to apply the
complete-scope check from skills/code-review/SKILL.md for all review types,
including untracked files, and abort rather than running the command when
secrets are detected.

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.

1 participant