🎁 福利专区全网大模型免费应用 + 新用户福利 + 注册活动入口,低成本玩转 AI

测试防弱化 acus9345/dsh-protect-tests

DeepSeek Harness
acus93457 天前有提交已提供中文文档扫描:未发现敏感能力

你让智能体「把测试跑通」,有时它确实照做了,只是方式不是你想要的。失败的测试被加上…

32.2/100
综合分
3
GitHub 星标
—
npm 周下载
—/5
用户评分

数据截至 2026/10/25 · 周下载取自 npm 全网(含 CI / 镜像),非本站安装数;综合分由星标、活跃度与兼容性检查合成。

安装命令 · 需先装 dsh CLI 引擎
dsh plugin --profile web add acus9345/dsh-protect-tests
该包不可直接 npm 安装,改从 GitHub 源安装(明细见下方安装检查)

状态速览

判定依据:实装验证 · 静态安装检查 · 自动扫描 · 仓库维护状态
信任档位:需留意
是什么
dsh 原生插件 · security
装得上吗
实装验证未通过(unknown),装前请到仓库确认最近更新与 issue
L4 · 真实安装等级说明 →
安全吗
本站尚未对该插件做风险分级
暂未覆盖,不等同于无风险
还在维护吗
活跃:最近一次提交在 7 天前
档位由哪些信号合成

本站实装验证(真实安装 L4 覆盖全站;L5 为运行时冒烟或实机截图,覆盖范围小于 L4) · 验证所用 dsh 版本 · 静态安装检查 · 风险分级 · 仓库维护状态。 下方各区块是它的证据明细。

验证判据与等级说明 →
⚠︎ 实装验证未通过(unknown · 2026/10/29) ——可能是验证环境差异,装前建议到 GitHub 仓库确认最近更新与 issue。
社区实装还没有人打卡 · 装过的第一个就是你
安全扫描自动 · 静态分析源码
v2.7.0
🟢 扫描:未发现敏感能力尚无人工评估
展开查看扫描说明与证据 ↓

静态扫描未发现敏感能力:最多只发网络请求、读取自身元数据或只读文件,未发现执行命令、文件写入或敏感信息读取。

扫描于 2026/10/31(1 天前) · 范围 入口闭包 + 发布文件清单 · 来源 GitHub 仓库

静态扫描只反映源码中出现的调用,不构成安全背书;人工评估与自动扫描相互独立、互不覆盖。

依赖的 DSH / Cordis 模块
@deepseek-ai/cordis@deepseek-ai/dsh@deepseek-ai/dsh-agent@deepseek-ai/dsh-fs@deepseek-ai/dsh-llm@deepseek-ai/dsh-session@deepseek-ai/dsh-tools@deepseek-ai/schemastery
给这个插件打分还没有人投票↓
用户评分
还没有人投票,来当第一个

DeepSeek Harness 插件,拦截智能体削弱测试的改动,比如加 .skip、删掉或弱化断言。

README

由 DeepSeek 最新模型翻译生成
dsh-protect-tests 你让智能体「把测试跑通」,有时它确实照做了,只是方式不是你想要的。失败的测试被加上 .skip。断言被注释掉。expect(total).toBe(42) 变成 expect(total).toBeDefined()。测试全绿,bug 还在。 这个 DeepSeek Harness 插件会在每次改动测试文件之前先看一眼,把旧文本和新文本对比。如果改动让测试检查得更少,编辑就会被拒绝,并告诉模型它做了什么:(哈哈 claude 太好用了,我是说真的,我也不知道) dsh-protect-tests blocked this change to src/sum.test.ts because it makes the tests check less: - replaces specific assertions with existence/truthiness checks (0 → 1): expect(sum(1, 2)).toBeDefined() Tests should keep failing until the code is fixed. Fix the implementation instead, or make
展开完整文档(README 剩余 1 节)
dsh-protect-tests

你让智能体「把测试跑通」,有时它确实照做了,只是方式不是你想要的。失败的测试被加上 .skip。断言被注释掉。expect(total).toBe(42) 变成 expect(total).toBeDefined()。测试全绿,bug 还在。

这个 DeepSeek Harness 插件会在每次改动测试文件之前先看一眼,把旧文本和新文本对比。如果改动让测试检查得更少,编辑就会被拒绝,并告诉模型它做了什么:(哈哈 claude 太好用了,我是说真的,我也不知道) dsh-protect-tests blocked this change to src/sum.test.ts because it makes the tests check less:
- replaces specific assertions with existence/truthiness checks (0 → 1): expect(sum(1, 2)).toBeDefined()
Tests should keep failing until the code is fixed. Fix the implementation instead, or make
the test more accurate without weakening it. If the test itself is wrong (the requirement
changed, or it tested a bug), tell the user which test you are changing and why, then
repeat the identical call once to confirm.

安装

dsh plugin --profile web add dsh-protect-tests

这里用的是 web 配置档,也就是你用 dsh web 启动的浏览器界面。如果你用别的方式运行 DSH,改用 headless(脚本和 CI)或 acp(编辑器集成)。每个配置档各自维护插件列表,所以你用到的每个配置档都要加一遍。装好即生效。卸载用 dsh plugin --profile web remove dsh-protect-tests。

从克隆的仓库安装

想试本地改动,先打包成 tarball 再安装:

git clone https://github.com/acus9345/dsh-protect-tests
cd dsh-protect-tests
npm install
npm pack
dsh plugin --profile web add ./dsh-protect-tests-0.2.0.tgz

它能发现什么

- 新增跳过。 it.skip、test.only、xit、xdescribe、@pytest.mark.skip / xfail、@unittest.skip、t.Skip()、@Disabled、#[ignore],以及 xUnit、RSpec、PHPUnit 和 XCTest 里的同类写法。
- 测试或断言变少。 删掉一个测试用例,或在一次编辑里删掉两个及以上断言。这两个阈值都可配置。
- 不可能失败的断言。 expect(true).toBe(true)、assert True、assertEquals(x, x)、assert!(true)。
- 被注释掉的断言。
- 被吞掉的失败。 把断言包进空的 catch {},或 except AssertionError: pass。
- 被削弱的断言。 把具体检查换成 toBeDefined()、toBeTruthy()、assert.ok(x)、is not None 之类。
- 被删除的测试文件。 在 shell 里对测试文件或测试目录执行 rm、git rm 或 unlink。
- 不可能失败的测试脚本。 把 package.json 里的 "test" 改成 echo、exit 0、... || true,或加上 --passWithNoTests。

在 Windows 上,PowerShell 的删除命令(Remove-Item、del、rd)也算。
测试文件按文件名识别:.test.、.spec.、_test.、test_.py、Test.java、conftest.py,以及 tests/、__tests__/、spec/ 或 e2e/ 下的所有文件,等等。你可以改这份列表。

正常的测试工作不受影响。加测试、加断言、重命名、重构 setup 代码、改测试名里的错别字,全都直接放行。纸面上看起来像删减的重构也放行,比如把五个几乎一样的测试合并成一张 test.each / @pytest.mark.parametrize / t.Run 表,或者把三个 toBe 检查合并成一个 toEqual({...}),或抽成 expectUser(...) 这样的辅助函数。

测试真的写错时

有时候确实是错的。需求变了,或者测试本身就在断言那个 bug。这种情况下,模型要先告诉你它改的是哪个测试、为什么改,然后把同一个调用再执行一次确认。重复的这次会放行。所以这道防线从来不会彻底挡住正当工作,它只是不让被削弱的测试悄无声息地溜过去——必须有人在对话里提到它。如果你更想自己来批准,用 mode: ask。

它抓不到什么

它靠模式匹配,不看语义。如果模型把 toBe(4) 改成 toBe(5) 去迁就一个错误结果,那看起来就是普通编辑,照样放行。重写测试逻辑、让它不再触发那个 bug,也照样放行。它能拦住偷懒的捷径——而大多数情况恰恰就是捷径——但它替代不了你自己读 diff。

配置

最省事的办法:打开 DSH 侧边栏里的 Plugins,点 dsh-protect-tests,改你要改的,按 Save。下一次工具调用就生效,不用重启。

或者往 ~/.dsh/profiles/<profile>/cordis.patch.yml 加一行这样的配置;想对所有配置档生效,就加到 ~/.dsh/cordis.patch.yml。没写的键保持默认值。

- id: protect-tests
config:
mode: deny # or ask for an approval prompt
testFiles: ['.test.', '/tests/', '!tests/fixtures/**'] # replaces the default list
minAssertionsRemoved: 2
minTestsRemoved: 1
disabledSignals: [] # skip, fewer-assertions, fewer-tests, trivial-assert,
commented-assert, swallowed-failure, weaker-assert
guardDeletes: true # watch rm / git rm of test files
guardTestScript: true # watch package.json "test"
allowIdenticalRetry: true # false: a refusal is final
shellTools: [bash, pwsh] # pwsh is the shell DSH uses on Windows

开发

npm install
npm test # detector unit tests
npm run test:e2e # real dsh runs against a scripted local model, no API key needed

安装测试会跑 dsh plugin add,这需要 PATH 里有 pnpm。

MIT 协议。作者 acus9345。欢迎在 issues 里提 bug 和想法。
预览分享卡片长什么样 ↓acus9345/dsh-protect-tests
分享 · DeepSeek Harness Hub
acus9345/dsh-protect-tests

你让智能体「把测试跑通」,有时它确实照做了,只是方式不是你想要的。失败的测试被加上…

回到顶部