- Home
- Plugins
- Security & Permissions
- dsh-package-check
dsh-package-check
qinghuidaqzp/dsh-package-check
Looks a package up before the agent installs or runs it: npm, pnpm, yarn, bun, npx and dlx, pip, uv, poetry, pdm and pipx commands are parsed on tools/pre-execute. A name that does not exist on npm or PyPI is denied; packages first published under 30 days ago, with under 100 npm downloads last week, one typo away from a popular package, or deprecated need approval. Uses public read-only registry endpoints, and an unreachable registry never blocks the command.
Install
dsh plugin --profile web add github:qinghuidaqzp/dsh-package-checkREADME
dsh-package-check · 装包安检
English | 中文
DeepSeek Harness(dsh)插件:Agent 装 npm 或 PyPI 包之前,先去官方源查一查这个包。
AI 写代码时偶尔会编出根本不存在的包名。有人专门抢注这些名字,放上恶意代码,等 AI 或照着 AI 建议的人来装,这种攻击叫作 slopsquatting。另外,名字和常用包只差一个字母的仿冒包(typosquatting)也很常见。装包安检在命令真正执行之前把这些情况挡下来。

截图来自测试环境:Agent 要装已经被作者弃用的 left-pad,插件弹出确认框,并写明了原因。
检查什么
| 情况 | 怎么处理 |
|---|---|
| 源上没有这个包(多半是编出来的名字) | 直接拦下,并提醒 Agent 先确认正确的包名,不要换个相近的名字再试 |
| 首次发布不满 30 天 | 先问你 |
| npm 上周下载量不到 100 次 | 先问你 |
名字和常用包只差一个字母,或只差连字符、js/py 前后缀 | 先问你(下载量很大、或在 PyPI 上发布多年的包不算) |
| 已被作者标记为弃用(PyPI 是被撤回) | 先问你,并附上作者写的弃用说明 |
| 一切正常,或者查询失败、连不上源 | 不干预 |
能识别的命令:
- npm 系:
npm、cnpm、pnpm、yarn、bun的install、i、add;以及npx、pnpm dlx、yarn dlx、bunx、npm exec这类"下载后直接运行"的命令 - Python:
pip install、pip3 install、python -m pip install、uv add、uv pip install、uvx、uv tool install、poetry add、pdm add、rye add、pipx install、pipx run
本地路径、git 地址、网址、压缩包不检查;不带包名的 npm install(按锁文件安装)也不检查。
它怎么做
插件挂在 dsh 的 tools/pre-execute 上。每次 Agent 要执行 shell 命令,dsh 自己的规则(沙箱、审批策略、其他插件)先做决定;只有原本会直接执行的命令,插件才会去解析里面的装包动作并查询,再决定是放行、先问你还是拦下。它只会多问或多拦,不会放行 dsh 本来要问或要拒绝的命令。
查询走的是公开、只读的接口,也就是安装本身就会访问的地方:
- npm:
registry.npmjs.org(包信息)和api.npmjs.org(下载量) - PyPI:
pypi.org
查询结果缓存一小时,每次查询最多等 5 秒。
安装
需要 dsh ≥ 0.2.0,在 0.2.2-rc.1 和 0.2.2-rc.5 上实测过。
dsh plugin --profile web add github:qinghuidaqzp/dsh-package-check
装好后重启 dsh 即可生效,没有单独的界面。
配置
| 键 | 默认值 | 说明 |
|---|---|---|
npmRegistry | https://registry.npmjs.org | 查 npm 包的源;国内可以改成 https://registry.npmmirror.com |
npmDownloads | https://api.npmjs.org | 查 npm 下载量的接口;连不上时只是少了下载量这一项 |
pypi | https://pypi.org | 查 PyPI 包的地址 |
minAgeDays | 30 | 首次发布不满这么多天就先问你 |
minWeeklyDownloads | 100 | npm 上周下载量低于这个数就先问你 |
missing | deny | 包不存在时:deny 直接拦下,ask 先问你 |
ignore | [] | 不检查的包名,支持 *,例如 @mycompany/* |
shellTools | bash, pwsh, shell, powershell, terminal, run_code | 参数 command 是 shell 命令的工具 |
timeoutMs | 5000 | 每次查询的超时(毫秒) |
用私有源的话:带作用域的 npm 包(@公司名/xxx)在公共源上查不到时,插件只会先问你,不会直接拦。其他私有包可以加进 ignore,或者把 missing 改成 ask。
局限
- 它按命令文本判断。脚本内部装的包、改了
package.json再npm install、pip install -r requirements.txt里列的包,都看不到。 - "只差一个字母"只和内置的约 300 个常用包比较。
- 它不扫描恶意代码,不能代替安全审查。它只是在装之前多看一眼。
- 在没有审批界面的场景(
dsh headless、CI),"先问你"会被 dsh 当作拒绝。 - 查询失败时它会放行,不会因为网络问题挡住你干活。
开发
npm install
npm test
DSH_BIN=$(which dsh) node test/integration/run.mjs
端到端测试在真实的 dsh 里跑:test/mock-messages.mjs 是本地的 DeepSeek 替身,让 Agent 依次执行几条装包命令,包信息查的是真实的 npm 源。正常包用 --dry-run 安装,不会真的装上。
许可证
MIT
Related plugins
dsh-purge
hunyisage/dsh-purge
dsh-infinite-gen-4
minglink/dsh-infinite-gen-4
dsh-purge
mmparko/dsh-purge
cc-safety-net
kenryu42/cc-safety-net