dsh-auto-approve: Auditable Auto-Approval for Plugin Directory Writes

前言

在 DSH 的 workspace-write 沙箱下,任何向工作区外写入文件的 Shell 命令都会触发审批弹窗。维护者在一套真实环境里统计过 15 份会话日志:69 次 Shell 审批请求中,已决的 67 次全部是 allowed-once,且每一次都是为了写入 ~/.dsh/plugins/... 或 ~/.dsh/profiles/*/node_modules/...。这类弹窗几乎不携带有用信息,却需要反复点击「允许」。

下面介绍社区插件 dsh-auto-approve(维护者 Genesis-ly),它用确定性规则引擎替代上述一类点击,其余审批仍走原有界面或 Auto review。

这是什么

dsh-auto-approve 是 DeepSeek Harness(DSH)上的一个 admin-security 类插件:对「仅为向用户自有插件目录写入文件」的沙箱升级请求做自动 allowed-once 放行;命中硬拒绝列表、或涉及 profile 核心配置文件的写入时,一律交还人工。决策过程写入本地审计日志,不向外部发送数据。

插件版本 0.1.0,许可证 MIT,依赖 Node >= 20,README 写明在 DSH 0.2.2-rc.5、Windows 10/11 上验证;package.json 中 DSH 引擎范围为 >=0.2.1-rc.3 <0.3.0。

核心功能

挂载方式

审批请求本身不带工具参数,因此插件注册两个钩子:

钩子 作用
tools/pre-execute 记录 callId → { name, arguments },再原样调用 next()
approval/request(prepend: true) 规则通过则返回 allowed-once,否则 next() 由正常 UI 决定

规则链路

每个请求先过硬拒绝列表。匹配删除类命令(rm、del、Remove-Item、dd、format)、网络工具(curl、wget、ssh、scp)、提权(sudo、runas)、系统变更(reg、sc delete、schtasks、shutdown、taskkill)、包管理器(pip、npm、pnpm install/publish)、容器、嵌套 Shell(bash -c、pwsh -c)、node -e、python -c、eval、exec、xargs、find -delete/-exec、原始设备写入等,一律交还人工。

对 profile 配置的写入(profiles/*/package.json、cordis.yml、cordis.patch.yml)也始终交还人工:这些文件决定下次启动加载哪些代码。

通过硬拒绝列表后,由 mode 选择策略:

mode 何时自动放行
strict 每个写入目标可静态证明落在 allowRoots 内
window 在 grantMinutes 滑动窗口内曾有人工批准
denylist(默认) 命令未命中硬拒绝列表,且非 profile 配置写入
both 满足 strict 或 window 任一

pass 表示不拒绝,请求交给下一个处理器,UI 正常展示。

审计

每次审批在 ~/.dsh/dsh-auto-approve/audit.jsonl 追加一行 JSON,例如:

{"at":"…","tool":"ops_bash","callId":"…","session":"…","decided":"allowed-once","via":"denylist","code":"denylist","reason":"no denied construct and no profile-config write","targets":[]}

decided 为 allowed-once 或 pass-to-human;via 标明决策路径。

安装与启用

官方安装不通过 dsh plugin add 拼接仓库名,而是使用仓库内 PowerShell 脚本。安装前请完全退出 DSH(含托盘),并在本机查看源码与 MIT 许可证;插件以当前 DSH 进程权限运行。

# Quit DSH completely (including the tray) first.
pwsh -NoProfile -File .\scripts\install.ps1

脚本会把包复制到 %USERPROFILE%\.dsh\plugins\dsh-auto-approve,添加 link: 依赖,将包写入 dsh.profile.bundles,并先备份 package.json。完成后需重启 DSH。

配置示例

在 profile 中增加插件项,建议首次使用 dryRun: true,仅决策与审计、不实际放行:

- id: dsh-auto-approve
  config:
    mode: denylist        # strict | window | denylist | both
    grantMinutes: 10      # window / both only
    dryRun: true          # decide + audit, never grant; use this first
    allowRoots: ['~/.dsh/plugins', '~/.dsh/profiles/*/node_modules']

README 建议:启用真实放行前,用 dryRun: true 观察 audit.jsonl 约一天。默认 denylist 仅在无危险构造时放行,且从不自动放行 profile 配置写入。

测试与兼容说明

npm test        # 17 cases: rules 12 + plugin wiring 5

README 说明不修改厂商文件,DSH 与插件更新后仍可继续使用。安全说明见仓库 SECURITY.md。

适用场景与注意

适合长期在 Windows 上使用 DSH、频繁安装或更新自有插件、且希望减少「仅为写插件目录」重复审批的开发者。不适合把自动放行当作通用 Shell 白名单:硬拒绝列表外的复杂命令仍会弹窗,涉及 profile 与网络、提权、删除的操作不应期望被自动批准。

DSH 生态奉行「一切皆插件」;目录站点 SkillHub 插件页 与 GitHub 仓库由社区维护,与 DeepSeek / 幻方无官方从属关系。核实功能与安装步骤请以 GitHub README 为准。

结尾

dsh-auto-approve 把一类高重复、低信息的沙箱审批换成可配置、可审计的确定性规则,默认保守,其余仍问人。目录:SkillHub;源码与文档:github.com/Genesis-ly/dsh-auto-approve。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye