dsh-approval-gate: DeepSeek Harness Command Approval and Blocking Plugin

The DeepSeek Harness plugin ecosystem allows for customizable behavior, but if the sandbox configuration is permissive, an agent can still execute dangerous operations. dsh-approval-gate intercepts actions before tool execution by registering tools.guard. It routes commands it cannot fully inspect to DSH’s native approval workflow and blocks recognized dangerous operations.

Plugin Introduction

This is a DeepSeek Harness native command-approval plugin maintained by GooDAnDReaY. It is an MIT-licensed open-source tool that provides security interception for bash commands and file-writing tools.

Installation and Activation

Install the plugin via the npm registry. After installation, ensure the gate remains enabled in the corresponding profile.

dsh plugin --profile web add @goodandready/dsh-approval-gate@0.1.3

Core Functionality

The plugin registers tools.guard to reject calls before tool bodies run. Its core capabilities include:

  1. Command Preprocessing and Blocking: Uses lib/bands.js for fast two-band pre-filtering (Band 0 hard block, Band 1 safety check). For known dangerous operations (e.g., rm -rf, DROP TABLE), it directly returns a block string.
  2. Uncertain Command Routing: Routes commands that cannot be fully inspected (such as unclosed quotes, pipes, heredocs) to the DSH native approval flow.
  3. File-Write Protection: Classifies file-writing tools (e.g., write, edit, str_replace) by path rather than regex text to prevent writing to sensitive files (e.g., .env, id_rsa, /etc/shadow).
  4. Environment and Credential Protection: Prevents environment variable leaks, procfs reads, and key dumps via lib/inspect-env.js. Redacts sensitive information in audit messages via lib/redact.js.
  5. Circuit-Breaker Mechanism: Prevents infinite agent retry loops caused by security blocks via lib/breaker.js.

Configuration

The plugin supports configuration through cordis.patch.yml. Available fields include:

Field Type Default Description
toolName string bash Specify the command parameter of the tool to inspect
fileWriteTools string[] write, edit, Write, Edit, str_replace, apply_patch File-writing tools classified by path

Example configuration:

- insert:
    - id: dsh-approval-gate
      name: @goodandready/dsh-approval-gate
      config:
        toolName: bash
        fileWriteTools:
          - write
          - edit
          - Write
          - Edit
          - str_replace
          - apply_patch

Typical Usage

The plugin classifies command behaviors as follows:

  • Blocked:
    • rm -rf /tmp/x, sudo rm -r ...: Blocked.
    • chmod/chown modifying .env / id_rsa: Blocked.
    • mysql << EOF DROP TABLE...: Blocked.
    • curl ... \| python3: Blocked.
    • bash -c "rm -rf /tmp/x": Blocked (nested shell).
    • kill / pkill / killall as the main command: Blocked.
  • Requests Approval:
    • source script.sh, . script.sh: Requests approval.
    • Commands with unclosed quotes, $IFS, $(...), or heredoc <<: Requests approval.

Caveats and Use Cases

  • Not a full parser: It is not a complete bash parser. Unknown or incomplete syntax will request approval. If approval is unavailable or set to approval=never, DSH will reject the call.
  • File-scan limitation: For script files created earlier and executed later, the plugin will not open and scan the file (it only checks the execution command itself).
  • Not a system sandbox: It only intercepts DSH tool calls. cron and systemd never pass through tools.guard.
  • Permission requirements: The plugin runs with the current dsh process privileges. Review the source code and license before installation.

Conclusion

By pre-execution interception and routing uncertain commands, this plugin provides a lightweight command security layer for DSH.

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

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

Xiaoye