Semantic risk grading and progressive authorization: classifies tool calls into safe/risky/redline, asks before irreversible actions, auto-allows only approved-and-succeeded signatures.
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:leetom314/dsh-risk-gate
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
Semantic risk grading + progressive authorization for DeepSeek Harness. 按操作语义自动分级,不要求用户写规则——把 Hermes Agent 的可逆性决策链移植成 dsh 插件。
What it does
Hooks tools/pre-execute and classifies every tool call by operation semantics:
| Level | Meaning | Action |
|---|---|---|
safe |
reversible / read-only (read, search, web, benign bash) | pass through (next()) |
risky |
irreversible but low-risk (write, edit, install, git commit) | ask via approval seam |
redline |
one of four red lines: remote-state change / outbound message / delete / paid quota | ask with explicit redline type; fail-closed deny when no answerer |
Classification is local and deterministic — no network, no LLM call. Unknown tools default to risky (fail-closed).
Progressive authorization (渐进授权)
Same operation signature approved-and-succeeded N times → auto-allowed afterward; a single failure/rejection zeroes the signature back to ask.
- Signature = tool name + normalized arguments (large text payloads truncated)
- Redline ops never auto-allow by default (
alwaysAskRedline: true) - State is per-process (in-memory); HMR dispose clears it
Install
# from GitHub (requires dsh CLI; git-based install)
dsh plugin --profile web add "github:leetom314/dsh-risk-gate#main"
# or clone and verify locally first
git clone https://github.com/leetom314/dsh-risk-gate.git
cd dsh-risk-gate && ./setup.sh && npm test && ./verify.sh
Config
- id: dsh-risk-gate
name: dsh-risk-gate
config:
autoAllowThreshold: 3 # 0 = disable progressive auth, always ask
alwaysAskRedline: true # redline ops never auto-allow
verbose: false
overrides: # optional per-tool override
some_tool: deny # 'safe' | 'deny'
Test
npm test # node --test (classifier + host-level progressive auth)
E2E (real model + headless profile, isolated DSH_HOME):
./setup.sh
DEEPSEEK_API_KEY=... ./verify.sh
# expect: read-only pass / rm single-file blocked / rm -rf redline blocked /
# quoted echo string not blocked / git push + scp + ssh remote blocked
verify.sh 动态生成临时 overlay($HERE/index.js 路径),不需要仓库内 overlay 文件——overlay*.yml 已 gitignore(含本机绝对路径,不随版本库分发)。
How the semantics map (red lines)
Shell-command inspection (bash/pwsh only, conservative regex):
- DELETE —
rm -rf,shred,mkfs,dd ... of=/dev/... - REMOTE —
git push(incl.git -C dir pushvariants),git reset --hard,rsync user@host:,ssh user@host,curl/wget -X POST/PUT/DELETE, data uploads - PAY — cloud provisioning (
aws ec2 run-instances,gcloud compute, ...) - MESSAGE — outbound message tools (
send_message,im_send, ...)
Tool-name mapping: read/glob/grep/web_*/skill/job_* safe · write/edit/str_replace_editor/todo_write/create_goal risky.
Limitations
- Shell inspection is regex-based (no full shell parsing): designed to be conservative (false positives over misses), but a determined prompt can still smuggle commands through obfuscation. It is a safety gate, not a sandbox — pair with
dsh-permission-rules/ sandbox executors for defense in depth. - Learning state is in-memory only (no persistence across restarts yet).
- Approval UI is channel-provided; headless with no answerer fails closed (deny).
链接
同类插件
toby-bridges/api-relay-audit★ 832
从 DeepSeek Harness 对 AI API 中转站和 LLM 代理运行本地安全审计,生成 Markdown 报告,覆盖提示词注入、模型替换信号、工具调用改写、错误泄漏、流完整性和按 profile 启用的 Web3 风险。
howmp/dsh-pentest★ 451
面向 DeepSeek Harness 的授权渗透模式:以探索链路记录目标、线索、资产与漏洞,并在 Web 中可视化展示。
SeaOf0/dsh-redteam-model★ 417
面向授权安全研究的 DSH 合集:九个工作模式(redteam 总控、渗透测试、代码审计、二进制分析、攻防评估、免杀对抗、应急溯源、云安全攻防、CTF 解题)与十五个运行时插件,设置页管理台支持一键部署、安装、更新与卸载。
PerryLink/dsh-auto-review★ 164
审批链上的第二模型自动审查:只读审查子代理返回带理由的 allow/deny 结构化裁决,默认 fail-closed。
PerryLink/dsh-permission-rules★ 114
Claude Code 风格的声明式权限规则:按序 allow/deny/ask 的 YAML 规则,在 tools/pre-execute 瀑布上匹配工具名、参数、工作区路径与 agent 身份,带完整会话日志审计、干跑模式与热重载。
PensiveFei/dsh-secure-audit★ 85
DSH 只读安全合规插件:提示注入检测、中文 PII 脱敏、本机配置安全审计,输出脱敏且可复现的报告。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。