feat(daemon): add POST /git/raw endpoint with allowlist validation#1163
feat(daemon): add POST /git/raw endpoint with allowlist validation#1163guitavano merged 2 commits intofeat/git-checkout-branchfrom
Conversation
Exposes git.raw() via HTTP with safety guardrails: only a curated set of read/non-destructive subcommands is allowed (checkout, branch, stash, tag, log, show, diff, merge, cherry-pick, etc.), and dangerous flags (--force, --hard, --global, --system, etc.) are blocked regardless of subcommand. Made-with: Cursor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Tagging OptionsShould a new tag be published when this PR is merged?
|
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="daemon/git.ts">
<violation number="1" location="daemon/git.ts:384">
P1: Blocked-flag check is bypassable via combined short flags (`-fb`) and `--flag=value` syntax (`--exec=cmd`). The exact-match `Set.has()` only catches flags written in isolation. For example, `["checkout", "-fb", "main"]` passes validation but git still interprets `-f`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
* feat(daemon): add POST /git/checkout-branch endpoint Adds a new git endpoint that creates and checks out a local branch from the current working state, enabling the open-pull-request workflow without publishing directly to main. Made-with: Cursor * feat(daemon): add POST /git/raw endpoint with allowlist validation (#1163) * feat(daemon): add POST /git/raw endpoint with allowlist validation Exposes git.raw() via HTTP with safety guardrails: only a curated set of read/non-destructive subcommands is allowed (checkout, branch, stash, tag, log, show, diff, merge, cherry-pick, etc.), and dangerous flags (--force, --hard, --global, --system, etc.) are blocked regardless of subcommand. Made-with: Cursor * Update daemon/git.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Summary
POST /git/rawendpoint that exposesgit.raw()with safety guardrailscheckout,branch,stash,tag,log,show,diff,merge,cherry-pick,format-patch,describe,shortlog,rev-parse,rev-list,ls-files,ls-tree,cat-file--force,-f,--hard,--global,--system,--exec400with a descriptive message on validation failureGitRawAPItype fromdaemon/mod.tsMotivation
Reduces the need to add a dedicated endpoint for every new git operation. AI agents and admin tools can now run safe, non-destructive git commands without requiring daemon changes.
Test plan
POST /git/raw { args: ["branch", "-a"] }→ returns list of branchesPOST /git/raw { args: ["log", "--oneline", "-5"] }→ returns recent commitsPOST /git/raw { args: ["push"] }→ returns 400 (not in allowlist)POST /git/raw { args: ["checkout", "-f", "main"] }→ returns 400 (blocked flag)POST /git/raw { args: ["config", "--global", "user.email", "x"] }→ returns 400Made with Cursor
Summary by cubic
Adds POST /git/raw to expose a safe subset of
git.raw()via the daemon. Lets agents and tools run non-destructive git commands without adding new endpoints.--force,-f,--hard,--global,--system,--exec.GitRawAPIfromdaemon/mod.ts.Written for commit 0bca69b. Summary will update on new commits.