DeepSeek Harness plugin

dsh-safeguard

DSH plugin: block dangerous shell commands and secret leakage before execution (tools/pre-execute veto)

Jump to install

Source facts

Repository
ZhijiangTang/dsh-safeguard
Latest update
Aug 16, 2026
Category
Tools & Capabilities
GitHub stars
0
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/ZhijiangTang/dsh-safeguard
Plugin: dsh-safeguard
Author: ZhijiangTang

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer3 files
README.mdSource · read only

dsh-safeguard

面向 DeepSeek Harness(DSH)的危险命令 + 密钥泄漏拦截插件。挂载到 tools/pre-execute waterfall,在工具解析前短路拒绝,被拦截的副作用不会发生。

简介

  • 危险命令拦截:对 bash 工具的命令做正则匹配,命中即 deny
  • 密钥泄漏拦截:对所有工具的 arguments 做 JSON.stringify 后扫描常见密钥模式,命中即 deny
  • 可配置:危险/密钥检测开关、额外正则、精确豁免名单。
  • 两个辅助工具guard_list(列出当前规则)与 guard_check(纯检查不拦截,供调试/自检)。

> 重要:本插件是基于正则的启发式拦截,不验签、不识别密钥真伪、不做沙箱隔离。它无法替代密钥扫描器、签名校验或操作系统级沙箱,只能拦截明显的高风险动作。

安装

dsh plugin --profile <profile> add dsh-safeguard

本地开发安装:

dsh plugin --profile <profile> add file:./plugins/dsh-safeguard

默认规则表

危险命令(enableDanger

| 规则名 | 匹配内容 | |---|---| | rm -rf | rm -rf / rm -fr 且目标是 /*./../., ~$HOME | | git push --force | git push --force / --force-with-lease / -f | | git reset --hard | git reset --hard | | git clean -fd | git clean-fd / -df 等同时含 f、d 的标志 | | chmod -R 777 | chmod -R 777 | | mkfs | mkfs / mkfs.ext4 等 | | dd 写盘 | dd if=... of=/dev/... | | 重定向到块设备 | > /dev/sd[a-z] | | curl\|sh 管道执行 | curl ... \| shwget ... \| bash 等 | | SQL DROP | 以 DROP TABLE/DATABASE/INDEX/... 开头 | | SQL DELETE | 以 DELETE FROM 开头 | | SQL TRUNCATE | 以 TRUNCATE [TABLE] ... 开头 |

密钥泄漏(enableSecrets

| 规则名 | 匹配模式 | |---|---| | AWS Access Key (AKIA) | AKIA[0-9A-Z]{16} | | sk- API Key | sk-[A-Za-z0-9]{20,} | | GitHub PAT (ghp_) | ghp_[A-Za-z0-9]{30,} | | GitHub Fine-grained PAT (github_pat_) | github_pat_[A-Za-z0-9_]{10,} | | PEM 私钥 | -----BEGIN (RSA\|OPENSSH\|EC\|PGP) PRIVATE KEY----- | | Slack Token (xox-) | xox[baprs]-... |

> eyJ 开头的长 JWT 不拦截(模式太宽,误报率高)。

配置项

在 profile 的 cordis.patch.yml(或 bundle 配置)中覆盖:

- insert:
    - id: guard
      name: dsh-safeguard
      config:
        enableDanger: true      # 危险命令拦截开关(默认 true)
        enableSecrets: true     # 密钥泄漏拦截开关(默认 true)
        extraPatterns:          # 额外正则字符串(额外危险命令规则)
          - 'curl.*\|.*bash'
        allowList:              # 精确豁免名单(字符串完全一致才豁免)
          - 'rm -rf /tmp/safe-dir'
配置项类型默认说明
enableDangerbooleantrue是否拦截危险命令
enableSecretsbooleantrue是否拦截密钥泄漏
extraPatternsstring[][]额外危险命令正则(非法正则以警告跳过)
allowListstring[][]精确豁免:危险命令按整条命令、密钥按命中片段做完全一致匹配

两个工具的用法

guard_list

无参,列出当前启用的规则类别与条目数:

[dsh-safeguard] 规则清单
危险命令: 启用(12 条规则)
密钥检测: 启用(6 条规则)
额外正则: 0 条
豁免名单: 0 条

guard_check

参数 text(必填 string)。纯检查不拦截,返回命中规则名 / 类别 / 是否豁免:

  • guard_check("rm -rf /") → 命中,类别 danger,规则 rm -rf
  • guard_check("aws key: AKIAIOSFODNN7EXAMPLE") → 命中,类别 secrets,规则 AWS Access Key (AKIA)
  • guard_check("echo hello") → 通过

模型可通过 await tools.guard_check({ text: "..." }) 做程序化自检。

不验签、不做沙箱替代

  • 本插件只做正则模式匹配,不校验密钥真实性,也不校验命令签名。
  • 不是沙箱:不会隔离文件系统、网络或子进程,拦截的是「命中明显高风险模式」的调用。
  • 生产环境仍应配合密钥扫描器(如 gitleaks、trufflehog)、签名校验与操作系统级沙箱(如 dsh-bash-sandbox)使用。

License

MIT