git-for-dsh: Execute Git Outside the Sandbox Using an Allowlist

Introduction

In DeepSeek Harness (DSH), the common approach to letting models operate Git is to rely on the shell or bash tool within the file sandbox. Testing has shown that while local read/write operations within the sandbox (such as git init, git add, git commit) can often be completed, operations involving TLS credentials, credential helpers, or the ssh.exe included with MSYS2 will fail under process-level restrictions. On Windows, interactive bash and ACL sandboxes can also compound issues with PTY and signal pipes. The result is “able to modify the workspace, but difficult to push/fetch.”

git-for-dsh is a DSH client plugin released by maintainer theRMM714 (GitHub: theRMM714/git-for-dsh). Instead of continuing to confine Git within the file sandbox, it explicitly invokes ctx.shell with sandboxPolicy: { mode: 'danger-full-access' } to execute one-off git commands. The security boundary is instead handled by a user-selected subcommand allowlist and multiple gates. The README notes at the beginning: this is a project for personal testing; the author assumes no liability for any issues arising from use. You should read the source code and the MIT license before installing.

What is this

The plugin consists of two halves; install once and it is ready to use:

  • Host half (src/index.js): Registers the tool git_exec with the model and implements the allowlist, argument gates, configuration write gates, repository configuration auditing, and execution environment hardening.
  • Client half (src/client.js): Renders a checkbox page in “Settings → Git Tool” where the user decides which git subcommands to allow; the selection results are persisted to the Profile’s cordis.patch.yml.

The current package version is 0.0.9 (subject to the repository’s package.json). Community directory page: SkillHub - git-for-dsh (independent site, with no official affiliation with DeepSeek/High-Flyer).

Core Functionality

Model Tool git_exec

Parameter Required Meaning
argv Yes Git arguments following the program name, with the first element being the subcommand, e.g., ["log", "--oneline", "-n", "20"]
paths No Involved files or directories; the plugin constructs git <subcommand> … -- <paths>
description Yes A one-sentence explanation of the purpose, displayed in the interface
workdir No Working directory; defaults to the session workspace
timeoutMs No Timeout in milliseconds; default 120000 for local, 300000 when touching remote
justification No A one-sentence reason when approval is required

Return fields include exitCode, signal, timedOut, operation, command, stdout, stderr. Paths should be placed in paths, not stuffed into argv, to avoid escaping issues with spaces, wildcards, etc. Tool descriptions and system prompts are generated in real-time based on the current allowlist.

Commands are parsed by the host’s shell (bash on Linux/macOS, pwsh on Windows); arguments are consistently wrapped in single quotes, and the plugin handles arguments containing single quotes or commas according to the platform.

Three Risk Tiers and 47 Subcommands

src/git-catalog.js is the single source of truth, with operations divided into three tiers:

Tier Meaning Operation Count Default
read Read-only repository, index, references, and configuration 22 Enabled
write Modifies workspace, staging area, or local branches 16 Disabled
remote Cloning, pushing, or permanently discarding history and untracked files 9 Disabled

Unselected subcommands are rejected before the process starts; the model sees “this operation is not enabled.” Some subcommands (such as branch, tag, remote) have branches that are “formally read-only but actually write state”; these forms are handled as write-tier or rejected directly by rules (e.g., remote set-url, config writes).

Five Gates (Summary)

  1. Allowlist: Only user-selected subcommands can start a process.
  2. Argument Gate: Rejects -c, --git-dir, --exec, etc. in global positions; -u is distinguished by subcommand (e.g., rejected if the short form --upload-pack is found on fetch).
  3. Configuration cannot become a program: Restricts config writes; pins core.fsmonitor, credential.helper, etc. via environment variables; forces --no-ext-diff --no-textconv for diff class commands.
  4. Repository Configuration Audit: Checks for dangerous keys using git config --local --includes --list --name-only -z before execution; policies can be selected in the settings page (default refuse-repo, etc.).
  5. Execution Environment Hardening: Works in concert with the above items; validation script instructions are provided in the README.

Installation and Activation

This package includes dsh.bundle.patch (cordis.patch.yml). After installation, it merges into the bundle layer stack of the profile; no manual configuration file editing is required.

# From npm (after release)
dsh plugin --profile <profile> add git-for-dsh

# Or directly from GitHub (lib/ is committed, no build approval needed)
dsh plugin --profile <profile> add github:theRMM714/git-for-dsh

# Or local path (development: link creates a symbolic link, changes take effect immediately)
dsh plugin --profile <profile> add /path/to/git-for-dsh

Update:

dsh plugin --profile <profile> update git-for-dsh

When installing or updating from GitHub, the shell needs access to github.com; if a proxy is needed, set HTTPS_PROXY first.

Restart the Profile after installation: the model gains git_exec; a “Git Tool” page appears in settings. When the environment variable DSH_GIT_TOOL_DISABLED=1 is set, the tool-git entry in cordis.patch.yml does not load, facilitating quick disabling of the plugin without modifying files.

If the same id: tool-git is restated in the profile’s own cordis.patch.yml, the user layer overrides it line by line. There is a “Page Version” build fingerprint at the bottom of the settings page; if it is inconsistent with lib/client.js, force refresh the browser.

Typical Usage

Below is a reproducible invocation form for read-only viewing of recent commits (the log subcommand must be checked in settings):

The model calls git_exec, for example:

  • argv: ["log", "--oneline", "-n", "20"]
  • description: View the latest 20 one-line logs
  • Optional workdir pointing to the repository root directory

Write operations and remote operations are not checked by default; after enabling, some write-tier commands will go through an approval flow (see “Formal Risk” and gate descriptions in the README). Pushing, pulling, etc. require explicitly enabling the corresponding subcommands in the remote tier in “Git Tool,” and understanding that commands are executed outside the sandbox with the permissions of the current DSH process user.

Suitable Scenarios and Precautions

Suitable for: Developers who need to let models execute controlled Git workflows (including remote) within a DSH session and are willing to use a checkbox list instead of “git entirely inside the sandbox.”

Important Notes:

  • Every git_exec is equivalent to running git on the local machine with dsh process permissions, not a restricted call within the file sandbox.
  • README Disclaimer: Personal test project; check the source code, gate logic, and MIT license before installation.
  • For untrusted repositories, do not arbitrarily set repository configuration auditing to off; the default policy aims to prevent indirect program execution via dangerous keys in .git/config and includes.
  • On Windows, the plugin uses ctx.shell for one-off commands and danger-full-access, without relying on interactive PTY; still use the settings page to control write and remote tiers.

Conclusion

git-for-dsh turns “which git subcommands the AI can use” into a persistent allowlist, and moves execution outside the sandbox, constrained by multiple gates on arguments and repository configuration, to address the issue that sandboxed git cannot perform remote and credential-related operations. Directory and source code:

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye