Skip to content

feat(daemon): add POST /git/raw endpoint with allowlist validation#1163

Merged
guitavano merged 2 commits intofeat/git-checkout-branchfrom
feat/git-raw-endpoint
Apr 9, 2026
Merged

feat(daemon): add POST /git/raw endpoint with allowlist validation#1163
guitavano merged 2 commits intofeat/git-checkout-branchfrom
feat/git-raw-endpoint

Conversation

@guitavano
Copy link
Copy Markdown
Contributor

@guitavano guitavano commented Apr 9, 2026

Summary

  • Adds POST /git/raw endpoint that exposes git.raw() with safety guardrails
  • Allowlist of permitted subcommands: checkout, branch, stash, tag, log, show, diff, merge, cherry-pick, format-patch, describe, shortlog, rev-parse, rev-list, ls-files, ls-tree, cat-file
  • Blocklist of dangerous flags regardless of subcommand: --force, -f, --hard, --global, --system, --exec
  • Returns 400 with a descriptive message on validation failure
  • Exports GitRawAPI type from daemon/mod.ts

Motivation

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 branches
  • POST /git/raw { args: ["log", "--oneline", "-5"] } → returns recent commits
  • POST /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 400

Made 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.

  • New Features
    • Endpoint: POST /git/raw (body: { args: string[] }); responds with { result: string }.
    • Allowlist: checkout, branch, stash, tag, log, show, diff, merge, cherry-pick, format-patch, describe, shortlog, rev-parse, rev-list, ls-files, ls-tree, cat-file.
    • Blocked flags: --force, -f, --hard, --global, --system, --exec.
    • Returns 400 with a clear message on validation failure; exports GitRawAPI from daemon/mod.ts.

Written for commit 0bca69b. Summary will update on new commits.

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
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0a399ac-8248-496d-a599-2d0b34f567a8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/git-raw-endpoint

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.

❤️ Share

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 1.194.2 update
  • 🎉 for Minor 1.195.0 update
  • 🚀 for Major 2.0.0 update

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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>
@guitavano guitavano merged commit a1d61eb into feat/git-checkout-branch Apr 9, 2026
1 check passed
@guitavano guitavano deleted the feat/git-raw-endpoint branch April 9, 2026 14:15
guitavano added a commit that referenced this pull request Apr 9, 2026
* 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>
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