dsh-guard
Manifest validDSH (DeepSeek Harness) security guard plugin: blocks/asks on dangerous commands & sensitive paths, redacts secrets in tool output, local JSONL audit log + guard_report. DSH 安全护栏插件。
dsh-guardrail · DSH 安全护栏
中文 | English
让 AI 删库之前先问你一声。 给 DeepSeek Harness (DSH) 加一道护栏:拦截危险命令和敏感文件访问,给工具输出里的密钥、手机号打码,并留下本地审计日志。

功能
- 🛑 危险命令拦截:内置 22 条规则,覆盖递归删除、格式化磁盘、fork 炸弹、
git push --force、curl | sh、删注册表等。每条规则可以设为deny(直接拒绝)或ask(在网页里弹审批,你点批准才执行)。 - 🔑 敏感路径保护:
.env、SSH 私钥、云厂商凭据、浏览器 Cookie / 密码库、DSH 自己的凭据文件。 - 🙈 输出脱敏:工具返回的内容在交给模型之前会先打码,内置 13 条规则(私钥、JWT、
sk-key、GitHub / AWS / Slack / Google / Stripe token、Bearer、password=一类键值、身份证号、中国和智利手机号),邮箱和智利 RUT 可选开启。 - 📒 本地审计日志:按天追加写 JSONL,存在
$DSH_HOME/dsh-guard/。写入前先脱敏再截断,不会把密钥原文落盘。 - 📋
guard_report工具:问 AI“今天都干了啥”,它会返回一份中文日报。 - 🧪
dryRun演练模式:只记录、不拦截,方便先观察会误拦哪些命令。 - 🪶 零侵入:通过
cordis.patch.yml挂载,不用改 DSH 源码。
安装
建议先装到一个单独的测试 profile 里试用:
# 从 npm 安装
dsh plugin --profile <profile> add dsh-guardrail
# 或者用离线安装包
dsh plugin --profile <profile> add ./dsh-guardrail-0.1.2.tgz
启动后日志里出现 [dsh-guard] 已加载… 就说明装好了。
要重装同一个版本,先运行
dsh plugin --profile <p> remove dsh-guardrail再add,不然可能用到旧缓存。
要求:DSH ≥ 0.2.1-rc.5,Node ≥ 22。已在 Linux 和 Windows(PowerShell)上验证。
配置
在网页 Plugins → dsh-guardrail 里改,或者写进 profile 配置。
| 配置项 | 默认值 | 说明 |
|---|---|---|
enabled | true | 总开关 |
dryRun | false | 演练模式:只写审计日志,不拦截、不脱敏 |
announce | true | 往系统提示里加一小段护栏说明(约 60 token) |
ignoreTools | ["guard_report"] | 这些工具不做拦截检查 |
commandArgKeys | 内置列表 | 哪些参数名算“命令文本” |
pathArgKeys | 内置列表 | 哪些参数名算“路径” |
disabledRules | [] | 要关掉的内置规则 id |
rules | [] | 自定义规则:{ id, kind: command|path, pattern, flags="i", action="ask", reason } |
allow | [] | 白名单正则,命中的参数不会触发拦截 |
redact.enabled | true | 是否给工具输出打码 |
redact.mode | content | content 只改模型看到的文本;value 改规范化后的 value(PTC 场景用) |
redact.disabled | [] | 要关掉的内置脱敏规则名 |
redact.emails | false | 给邮箱打码 |
redact.chileRut | false | 给智利 RUT 打码 |
redact.extra | [] | 自定义脱敏:{ name, pattern, flags="g", replacement="[REDACTED]" } |
audit.enabled | true | 写审计日志 |
audit.dir | "" | 日志目录,留空就用 $DSH_HOME/dsh-guard |
audit.logAllowed | true | 放行的调用也记下来 |
audit.logArgs | true | 记录参数预览(先脱敏再截断) |
audit.maxArgChars | 200 | 参数预览最多保留几个字符 |
没有审批通道时(比如 headless 运行),
ask会退化成拒绝,审计里记为unavailable。
内置拦截规则
| id | 类型 | 动作 | 说明 |
|---|---|---|---|
rm-rf-root-home | command | deny | 递归删除根目录/用户目录/盘符 |
rm-rf | command | ask | 递归强制删除 (rm -rf) |
win-del-recursive | command | ask | Windows 递归删除 (del /s、rd /s、rmdir /s) |
remove-item-root-home | command | deny | PowerShell 递归删除根目录/用户目录/盘符 |
remove-item-recurse | command | ask | PowerShell 递归删除 (Remove-Item -Recurse) |
format-disk | command | deny | 格式化磁盘/分区 |
diskpart-bcdedit | command | ask | 磁盘/启动项管理工具 (diskpart/bcdedit/vssadmin) |
fork-bomb | command | deny | fork 炸弹 |
shutdown | command | ask | 关机/重启 |
reg-delete | command | ask | 删除注册表项 (reg delete / Remove-ItemProperty on registry) |
net-user-add | command | ask | 新增系统用户/提权 (net user /add、net localgroup administrators) |
git-push-force | command | ask | git 强制推送 (--force / -f / --force-with-lease) |
git-destructive | command | ask | git 破坏性操作 (reset --hard / clean -fd / branch -D 远端删除) |
pipe-to-shell | command | ask | 下载内容直接交给 shell 执行 (curl |
env-file | path | ask | .env 环境变量/密钥文件 |
ssh-private-key | path | deny | SSH 私钥 |
ssh-dir | path | ask | ~/.ssh 目录 |
dsh-credentials | path | deny | DSH 凭据文件 (.credentials.yaml) |
key-cert-files | path | ask | 证书/私钥文件 (*.pem, *.p12, *.pfx, *.ppk, *.key) |
browser-secrets | path | deny | 浏览器 Cookie / 登录数据库 |
cloud-credentials | path | ask | 云/CLI 凭据文件 (.aws/credentials, .git-credentials, .netrc, .kube/config, .docker/config.json) |
system-secrets | path | deny | 系统密码库 (/etc/shadow, Windows SAM) |
guard_report 示例
📋 dsh-guard 日报 2026-11-04
工具调用共 4 次;拦截 1 次,询问 2 次(批准 1 / 拒绝 1)。
输出脱敏共 3 处(github-token×1、cn-phone×1、cl-phone×1)。
调用最多的工具:powershell×3、read_file×1
被拦截/询问的记录(最近 3 条,共 3 条):
- 23:21:05 [powershell] 已拒绝 · 规则 ssh-private-key · type C:\temp\id_rsa
- 23:21:40 [powershell] 询问→被拒绝 · 规则 reg-delete · reg delete HKCU\Software\DshGuardTest /f
- 23:22:10 [powershell] 询问→已批准 · 规则 remove-item-recurse · Remove-Item -Recurse X:\demo
日志文件:~/.dsh/profiles/<p>/dsh-guard/audit-2026-11-04.jsonl
局限(请务必读)
- 这是基于正则的护栏,不是沙箱。 命令经过 base64 编码、变量拼接、写成脚本再执行,或者交给别的解释器跑,都可能绕过去。它防的是“AI 手滑”,防不了有意的对抗。
- 只检查配置里指定的参数名,非标准工具的参数可能看不到。
- 脱敏也是模式匹配,格式不常见的密钥可能漏掉,偶尔也会误打码。
- 想要真正的隔离,请配合 DSH 的沙箱 / 容器、最小权限账号和只读挂载一起用。
- 请不要把它宣传成“绝对安全”。
FAQ
会拖慢 DSH 吗? 不会。每次工具调用只多跑几次正则匹配,可以忽略。
误拦了怎么办? 把规则 id 加进 disabledRules,或者把对应命令写进 allow 白名单。也可以先开 dryRun 观察一天。
被拦之后 AI 会换个写法绕过吗? 拒绝消息里明确要求它不要绕。实测时 DeepSeek 都如实告诉了用户。但这只是约束,不是保证,见上面的局限。
审计日志会上传吗? 不会。日志只写在本地,插件不发起任何网络请求。
和 Windows 兼容吗? 兼容。规则覆盖了 del /s、Remove-Item -Recurse、reg delete、diskpart 这些命令,也已经在 Windows 真机上测过。
许可证
English
Make the AI ask before it nukes your repo. A guardrail plugin for DeepSeek Harness (DSH): blocks or asks before dangerous commands and sensitive file access, redacts secrets in tool output, and keeps a local audit log.

Features
- 🛑 Dangerous-command guard: 22 built-in rules covering recursive delete, disk format, fork bombs,
git push --force,curl | sh, registry deletes and more. Each rule either usesdenyorask(an approval prompt in the web UI). - 🔑 Sensitive paths:
.env, SSH keys, cloud credentials, browser cookies and password stores, and DSH's own credential files. - 🙈 Output redaction: 13 built-in patterns, including private keys, JWTs,
sk-keys, GitHub/AWS/Slack/Google/Stripe tokens, Bearer tokens,password=-style pairs, CN ID cards, and CN and Chile phone numbers. Email and Chile RUT redaction are optional. - 📒 Local JSONL audit log in
$DSH_HOME/dsh-guard/. Previews are redacted and then truncated before they are written. - 📋
guard_reporttool: returns a daily summary in Chinese. - 🧪
dryRun: logs what would be blocked without blocking anything. - 🪶 Mounted via
cordis.patch.yml, with no changes to DSH source.
Install
dsh plugin --profile <profile> add dsh-guardrail
# or offline
dsh plugin --profile <profile> add ./dsh-guardrail-0.1.2.tgz
Look for [dsh-guard] 已加载… in the startup log. Requires DSH ≥ 0.2.1-rc.5 and Node ≥ 22. Tested on Linux and Windows (PowerShell).
Configuration
The keys and defaults are the same as in the Chinese table above. The ones you'll use most are dryRun (false), disabledRules ([]), allow ([]), rules ([]), redact.mode ("content"), redact.emails (false), audit.dir ("" → $DSH_HOME/dsh-guard) and audit.maxArgChars (200). Without an approval channel (headless), ask falls back to deny and is logged as unavailable.
Rules
See the rule table above. Each rule has an id, a type (command or path) and an action (deny or ask).
Limitations
This is a regex guardrail, not a sandbox. Encoded commands, variable concatenation, scripts written and then executed, or other interpreters can bypass it. It catches accidents, not adversaries. Redaction is pattern-based too, so it can miss secrets or redact the wrong text. If you need real isolation, use it together with sandboxes or containers and least-privilege accounts. Please don't market it as "absolutely safe".
FAQ
- Overhead? Negligible: a few regex matches per tool call.
- False positive? Add the rule id to
disabledRulesor a pattern toallow, or start withdryRun. - Does anything leave my machine? No. The plugin makes no network requests.
License
Comments
Loading…
Similar plugins
by ZhijiangTang
DSH plugin: block dangerous shell commands and secret leakage before execution (tools/pre-execute veto)
★ 0
↓ 58/wk
MIT
JavaScript
Aug 16, 2026
dsh plugin --profile web add dsh-safeguardby jkrandom-sudo
Security audit for DeepSeek Harness plugins: static permission profile with file/line evidence + a runtime sentinel gating credential access and unknown-host egress · DSH 插件安全审计:静态权限画像(附文件/行号证据)+ 运行时哨
★ 4
↓ 85/wk
MIT
TypeScript
Sep 11, 2026
dsh plugin --profile web add dsh-plugin-auditby zhaoxuejie
DeepSeek Harness 工具调用安全守卫(防火墙)插件:危险命令拦截、路径白名单、敏感文件黑名单、人工审批与审计
★ 0
MIT
TypeScript
Sep 8, 2026
dsh plugin --profile web add dsh-plugin-tool-guardby Yazzyk
DeepSeek Harness (dsh) 插件:在 Web GUI 里手动点选文件或目录,屏蔽 agent 对它们的读取、搜索、写入与编辑。A dsh plugin that denies an agent read/search/write/edit access to chosen files and directories, picked from the plugin's own We
★ 2
MIT
JavaScript
Oct 10, 2026
dsh plugin --profile web add dsh-file-shieldby ChenChen913
One-click local security checkup button for the DeepSeek Harness (DSH) Web UI: read-only checks (!!js config, third-party plugins, credential file perms, instruction files), severity-graded report, pl
★ 0
MIT
JavaScript
Sep 11, 2026
dsh plugin --profile web add dsh-security-doctorby 863683348
Installation safety gate for DSH plugins: antivirus-style scan of install scripts, permissions, secrets and network callbacks on local directories or npm tarballs, returning a BLOCK/WARN/PASS verdict
★ 0
MIT
JavaScript
Sep 11, 2026
dsh plugin --profile web add dsh-plugin-gate