全部插件

dsh-defend

dsh-defend · 版本 0.3.16 · 更新于 2026年11月29日

通过 1024 商店安装时,先执行一次 npm i -g dsh1024,再执行 dsh1024 plugin --profile web add dsh-defend(计入 deepseek1024.com 安装排行)。

  • 逐版审核
  • 会话消息
  • MIT
  • 0次下载

说明

以下为插件作者提供的原文。

🛡️ dsh-defend

  • 1024 商店渠道:先 npm i -g dsh1024,再 dsh1024 plugin --profile web add dsh-defend(计入 deepseek1024.com 安装排行)。

DeepSeek Harness 的提示注入、越狱与密钥泄露防护。

规则裁决已知的,拦截裁决其余的——一切都有审计。

License Gitee DSH plugin dsh-doctor DSH Market Node CI Version npm version npm downloads dshfind

English · 简体中文 · Español · Português · हिन्दी


⭐ 如果它帮到了你

这个插件是 DSH 插件家族的一员(40+ 个,全部 Apache-2.0)。如果你在用,给个 star —— 它不会解锁任何功能,但会让下一个人在搜索里更容易找到它。

English: part of a 40+ plugin family for DeepSeek Harness. If it is useful, a star helps the next person find it — nothing is gated behind it.

兼容性

方面状态
HarnessDeepSeek Harness dsh-v0.1.7-rc.2(2026-09-24 核验;peer 范围 >=0.1.2-rc.1 <0.2.0 || >=0.1.5-alpha.1 <0.2.0 || >=0.1.6-0 <0.2.0 || >=0.1.7-0 <0.2.0)。该线上 Session.append 的第三参仅对表面事件类型存在且为 SurfaceIntent,因此非表面的 defend/detection 仍无法盖章 ignorable:会话日志审计保持失败关闭式停用,/defend 显式渲染该状态。会话格式 V4 已无 tool-result 内容块——本插件从不生产它,两个内容 walker 只为退役的 V3 包裹块保留只读回退,使升级前写下的会话仍可被扫描。已于 2026-09-24 核验(双 typecheck 尺子 + 全量测试 + build + self-contained/artifacts 门 + pack;宿主类型图仅一份)。
Node^22.19.0 || >=24.0.0
平台全部(纯 host;无原生代码、无网络)
模型任意(检测发生在内容到达模型之前)

你能得到什么

dsh-defend 在 agent 面前放了两层相互独立的防线:

  1. 危险删除门禁 —— 8·14/8·16 事故教训的可执行形态。在 tools/pre-execute 上,递归删除类 shell 命令被拒绝,除非每个目标都是会话工作区内的显式绝对路径且不触碰受保护前缀(家目录配置、.dsh/.claude、系统目录)。dry-run 标记(-WhatIf、--dry-run、git clean -n)放行——它们正是教训要求的删除前核对。
  2. 检测层 —— 移植自四个上游资产(均为 Apache-2.0,见 THIRD_PARTY_NOTICES.md):25 条 Prompt-Injection-Payloads 规则、25 条 Jailbreak-Detector 模式(纯 TypeScript Aho-Corasick 自动机)、来自 Secret-Key-Leaker-Detect 与各签发方公开文档的 12 条密钥语法、以及原样保留为回归基准的 Prompt-Attack-Dataset。

三个拦截点,同一套决策模型:

拦截点扫描内容决策
agent/pre-step进入模型的消息allow → next();ask → 审批;block → 拒绝本步
tools/pre-execute工具参数allow → next();ask → 审批;block → deny
tools/post-execute工具结果allow → next();ask → 审批;block → 纠正性反馈

默认:每个 family 均为 ask,critical 级密钥一律 block(上游「见即中断」语义)。没有审批应答者即失败关闭。每次放行都调用 next()——下游策略插件永不被短路。

入站消息 ── agent/pre-step ── 扫描 ── 干净 → next()/enter
工具参数 ── tools/pre-execute ── 扫描 ── 放行 → next()
工具结果 ── tools/post-execute ── 扫描 ── 拦截 → 反馈
                              │
                              └─ defend/detection 审计(规则 id/类别/
                                 严重度/决策——从不含匹配文本)

快速开始

# 1. 把 bundle 装进你的 profile
sole plugin --profile web add "github:PerryLink/dsh-defend#main"

# 或从 npm 安装(正式发布版)
sole plugin --profile web add dsh-defend

# 2. 重启并核实行
dsh --profile web --dump-config | grep -A3 'id: dsh-defend'

安装与卸载

  • git 通道(最新 main):sole plugin --profile web add "github:PerryLink/dsh-defend#main" —— prepare 脚本仅用生产依赖构建。
  • npm 通道(正式发布版):sole plugin --profile web add dsh-defend。
  • tarball 通道:在本仓库执行 pnpm pack,然后 sole plugin --profile web add ./dsh-defend-<version>.tgz。
  • 卸载:sole plugin --profile web remove dsh-defend(或从 profile patch 中删除该行)。

配置

所有可调项都是 Schemastery Config 字段(可在 cordis.yml 中修改)。按 id 定向覆盖会替换整行——需要重新声明每个键。cordis.patch.yml 内联说明了每个键。

键默认值含义
enabledtrue两层防线总开关
actiondeny危险删除门禁动作(deny / ask)
toolNames['bash','persistent-bash','terminal-bash']门禁评审命令参数的工具注册名
detection.enabledtrue检测层开关
detection.maxScanChars10000每次拦截的扫描字符上限(只扫头部)
detection.normalizeUnicodetrue扫描前 NFKC/Unicode 归一化(堵 lookalike-Unicode 绕过)
detection.secretMinEntropy3.0密钥命中后的最小 Shannon 熵(bits/字符),低于阈值视为误报丢弃;0 关闭
detection.injectionActionask注入类:allow / ask / block
detection.jailbreakActionask越狱类:allow / ask / block
detection.secretActionask密钥类:allow / ask / block
detection.secretBlockCriticaltruecritical 密钥无视 secretAction 一律 block
detection.audittrue写 defend/detection 会话审计事件
detection.allowUnmarkedAuditfalse宿主不识别 ignorable 标记(截至目前所有已发布线)或对未知事件类型 fail-closed(宿主 0.1.2-rc.1 及以后)时是否仍写会话日志审计(接受会话无法恢复的风险)
detection.maxReportEntries200内存环形缓冲条数上限
registerCommandtrue注册 /defend 命令
registerTooltrue注册 defend_report 工具

工具与界面

界面类型说明
defend_report工具汇总(记录/拦截/询问数)、按 family 计数、最近 20 条——从不含匹配文本
/defend命令同样的汇总文本
agent/pre-step监听入站消息扫描(enter/reject)
tools/pre-execute监听工具参数扫描(deny/ask)+ 危险删除门禁
tools/post-execute监听工具结果扫描(block 反馈)

权限与数据

  • 权限:ask 决策走官方审批接缝;绝不重实现或绕过。workshop manifest 声明 session:append 与 network:none。
  • 数据:不落盘任何东西;报告环形缓冲仅在内存且有界。无网络请求、无子进程。
  • 会话日志:defend/detection 事件只带规则 id、family、类别、严重度、密钥类型、决策与扫描事实——匹配文本从不入日志,密钥匹配在构造上只留类型。

安全边界

  • 检测,而非执法。 门禁与检测层只在官方 seam 上产出 deny/ask/block 决策;沙箱与审批系统仍是执行权威。
  • 失败关闭。 审批应答者缺失、会话缺失或服务面缺失时,一律退化为最严格决策——绝不静默放行。
  • 内容不出进程。 扫描在本地完成;审计事件已脱敏;密钥绝不入日志、展示或报告。
  • 有界工作。 扫描上限、每规则至多一条匹配、环形缓冲上限,恶意输入无法消耗无界资源。

已知限制

  • 检测缺口。 规则库覆盖已移植词汇及其容错变体;新式措辞、形近 Unicode 编码(NFKC 归一化列为后续工作)与多步攻击可能绕过。基准把实测下限(上游数据集 27/28)钉进测试,回归可见。
  • 无模型级判定。 dsh-defend 是确定性的,绝不调用模型,无法判断全新意图。
  • 消息拒绝是静默的。 agent/pre-step 的 reject 不给模型理由(seam 没有理由字段);审计事件记录规则事实。
  • 会话审计与 ignorable 标记。 审计追加请求 envelope 的 ignorable: true 标记,任何 harness 构建都能加载日志。截至目前所有已发布线(0.1.0-rc.1–0.1.0-rc.8、0.1.1-rc.1–0.1.1-rc.2)都会静默丢弃它——事件未标记落盘,更严格构建上会话将无法恢复;宿主 0.1.2-rc.1 保留信封字段但仅用于存量日志读取兼容、Session.append 仍无法盖章,且读取路径对未标记未知事件类型 fail-closed(defend/detection 未注册),写入同样会让会话无法加载。因此 dsh-defend 在第一次追加前即判定(peer 版本预判;版本不可解析时同样 fail closed)并以一次性告警停用会话日志审计。设 detection.allowUnmarkedAudit: true 可重新开启。见 issue #2。

开发

pnpm install        # node ^22.19 || >=24
pnpm run typecheck  # tsc:src + tests,对照本地 harness checkout
pnpm run typecheck:ci  # tsc:对照已发布的 0.1.7-rc.2 类型(无 paths)
pnpm test           # vitest:96 个测试、9 个套件(含检测基准)
pnpm run build      # tsdown bundle + tsc 声明(lib/)
pnpm run verify:self-contained  # 依赖声明全部来自 registry
pnpm run verify:artifacts       # 构建产物 ESM 面 + 发布文件齐全
pnpm pack           # 发布用 tarball

Benchmark

红队基准(105 个样本的逐类 P/R/F1 + 27/28 fixture 下限)见 benchmark/RESULTS.md;用 node --experimental-strip-types benchmark/run.mjs 复现(零新依赖、无需构建)。

Topics

dsh, dsh-plugin, deepseek-harness, deepseek, cordis, security, prompt-injection, jailbreak, secret-scanning, ai-safety

Contributors

  • @PerryLink —— 创建者与维护者:危险删除门禁、四资产检测移植、拦截接线、审计面与五语文档。
  • @cuohua —— 关于 defend/detection 事件未标记落盘导致会话在更严格构建上无法恢复的精准报告(#2);运行时的宿主能力检测与 ignorable 标记纪律直接源自该分析。

PerryLink DSH Plugin Family

This project is one of the 45 DeepSeek Harness plugins maintained by PerryLink. If this one helps you, the others likely will too:

PluginOne-liner
dsh-auto-reviewSecond-model auto-review on the approval chain, fail-closed by default
dsh-autotierAutomatic strong/cheap model-tier routing with deterministic risk guards and a /tier command
dsh-background-agentsDurable background child agents with a Web UI sidebar, messaging and interrupt
dsh-budgetCost governance for DeepSeek Harness: budgets, carbon, and latency in one panel.
dsh-catalogDSH Desktop Market standard catalog source for the PerryLink family
dsh-cert-mcpRead-only MCP server exposing the certification registry: grades, snapshots and five-dimension evidence
dsh-checkpoint-rewindClaude Code /rewind-equivalent: snapshots, session forks, one-shot restore
dsh-claude-moveMigrate Claude Code sessions, memory, skills and CLAUDE.md into DSH
dsh-clickCross-platform native desktop control for DeepSeek Harness — Windows first.
dsh-composer-historyTerminal-style input history for the web composer: arrows, Ctrl+R search
dsh-data-qualityDataset quality checks and citation cross-checks (the optional numeric bridge consumed here)
dsh-defendPrompt-injection, jailbreak, and secret-leak defense for DeepSeek Harness.
dsh-doublecheckEngineering-discipline guard: requirements grill, test gates, adversary review
dsh-drawUnified static-image generation routing for DeepSeek Harness.
dsh-fastRead-only performance diagnostics for DeepSeek Harness.
dsh-fund-researchDeterministic research reports for Chinese public mutual funds
dsh-githubGitHub PR/issues integration for DSH, every write gated by approval
dsh-industry-researchIndustry research orchestration that seals its deliverables through this plugin's ctx.researchReport.assemble
dsh-layaLaya typed decisions (noul/choice/score) as a first-class Cordis service and model-visible tools
dsh-libraryLocal document knowledge base for DeepSeek Harness.
dsh-local-aiLocal-model (Ollama) integration for DeepSeek Harness.
dsh-lsp-actionsLSP diagnostics, formatting, completion, code actions and rename over language servers
dsh-maskPII masking middleware: anonymize at the model boundary, restore at the display layer
dsh-mcp-panelRead-only MCP runtime panel: /mcp command + Settings tab with status, tools and errors
dsh-mementoApproval-gated cross-session memory: ctx.memory seam + SQLite + memory tool
dsh-observeOpenTelemetry and Langfuse observability exporter for DeepSeek Harness.
dsh-output-stylesClaude Code outputStyles-equivalent runtime style switching
dsh-permission-rulesClaude Code-style declarative allow/deny/ask permission rules with audit
dsh-plugin-certificationCommunity certification registry with repro-checkable grades and badges
dsh-plugin-doctorZero-dependency static + sandbox smoke detector for DSH plugins
dsh-plugin-guidePlugin-development knowledge base as an on-demand agent skill
dsh-plugin-kitShared zero-runtime-dependency toolkit for the PerryLink DSH plugins
dsh-plugin-upgradeOne-package, one-corridor-index plugin upgrade skill: routes a repository to the matching closed corridor card
dsh-plugin-upgrade-015Merged 0.1.3-alpha.1 → 0.1.5-rc.1 upgrade corridor card plus a zero-dependency seam scanner
dsh-reachMulti-channel approval/question bridge: WeChat/Telegram/Feishu, session console
dsh-research-reportVerifiable research-report engine: content-addressed evidence ledger and sealed versions
dsh-scoreMulti-dimensional quality scoring for DeepSeek Harness plugins.
dsh-session-pinPin sessions in the Web sidebar with durable ordering
dsh-session-syncCross-device session sync for DeepSeek Harness — a dedicated git mirror of your session store.
dsh-skill-pack-securitySecurity-audit skill pack: secret scan, dependency and supply-chain review
dsh-talkVoice-first session loop for DeepSeek Harness: talk to it, hear it answer.
dsh-team-roomsCross-session team rooms: shared message bus, task board and timeline
dsh-test-driveIsolated install-and-smoke test drives for DeepSeek Harness plugins.
dsh-ticktickTickTick/Dida365 task bridge: session-header panel + 11 tools
dsh-translateVendor parameter translation and deterministic JSON repair for DeepSeek Harness.

License

Apache License 2.0 © 2026 dsh-defend contributors

从 DSH Desktop 市场安装

所有 PerryLink 插件均可在 DSH Desktop 内置市场中浏览:市场 → 来源 → 添加来源 → 粘贴 https://perrylink-dsh-catalog.perrylink.workers.dev/catalog-source.json → 选中。安装仍需通过市场的 npm 身份校验与你的确认。

版本历史

  • 0.3.162026年11月29日 · 139 KB
dsh-defend · SoleAPI Agent 插件 | SoleAPI