id7869/dsh-security:DeepSeek Harness 安全审计插件

前言

DeepSeek Harness (DSH) 的核心理念是「一切皆插件」。对于开发者而言,在本地或 CI 环境中复现类似 OpenAI codex-security 的安全审计能力,通常需要引入额外的 Python 环境、向量数据库或复杂的依赖链。id7869/dsh-security 是一个独立插件,它仅借鉴 codex-security 的方法论,在 DSH 原生能力范围内重建了「发现 → 验证 → 报告」的完整审计流程。

核心功能

该插件以独立 DSH 插件的形式存在(包含 skills 和 workflow),不依赖外部 Python 或 Docker 环境。

  1. 完整审计流程:覆盖代码盘点、威胁建模、发现候选漏洞、独立验证、去重、严重度重分级、生成报告及固化。
  2. 去重机制:基于指纹(djb2/FNV-1a)和历史记录进行两阶段评审(粗筛 SAME/DISTINCT,深度确认 canonical+merged),避免重复告警。
  3. 本地持久化:仅使用本地 JSONL 文件存储状态(state/ 目录),不依赖 SQLite 或 Mnemon。
  4. 零静态依赖:lib/index.js 仅引用 Node.js 内建模块,无 @deepseek-ai/dsh-skill 等静态 peer 依赖,安装后无需构建 node_modules。

安装与启用

在安装前,请确保环境满足以下要求:
* DSH 版本 ≥ 0.1.5-rc.1
* Node.js ≥ 22

推荐使用本地 clone + link 的方式安装:

# 1) clone 到本地工作区
git clone https://github.com/id7869/dsh-security.git C:\gh-workspace\dsh-security

# 2) link 到 DSH profile(以 web 为例)
dsh plugin --profile web add "C:\gh-workspace\dsh-security"

# 3) 重新启动该 profile 使插件生效
dsh --profile web

安装完成后,在 DSH 会话中输入「列出 dsh-security 的可用 skill」,应能看到入口 skill dsh-security-run。

使用方式

自然语言(推荐)

在会话中直接使用自然语言触发。插件会根据意图自动选择对应的 workflow 或 skill。支持的操作包括:
* 「扫描这个仓库」
* 「修复这个漏洞」
* 「把这个告警入库」

手动执行 Workflow

也可以直接在会话中调用原生 workflow 工具,传入参数执行插件内置脚本。

扫描(workflow/scan.js)

{
  "repo": "C:/path/to/your/repo",
  "skillDir": "C:/path/to/dsh-security/skills",
  "outputDir": "C:/path/to/output",
  "stateDir": "C:/path/to/dsh-security/state",
  "mode": "standard",
  "maxDiscoveryRuns": 5,
  "stopAfterNoNew": 2,
  "classify": false
}

Diff 扫描(workflow/diff.js)

仅审计变更文件,用于代码审查。

{
  "repo": "C:/path/to/your/repo",
  "skillDir": "C:/path/to/dsh-security/skills",
  "outputDir": "C:/path/to/output",
  "stateDir": "C:/path/to/dsh-security/state",
  "baseRef": "main",
  "headRef": "HEAD"
}

修复(workflow/fix.js)

对指定 finding 进行修复并复验。

{
  "repo": "C:/path/to/your/repo",
  "skillDir": "C:/path/to/dsh-security/skills",
  "outputDir": "C:/path/to/output",
  "stateDir": "C:/path/to/dsh-security/state",
  "verify": true,
  "findings": [{ "title": "SQL injection in POST /login handler", "location": {"file": "src/index.js", "line": 17}, "category": "SQL injection", "severity": "high", "remediation": "改用参数化查询" }]
}

已有 Finding 入库(workflow/triage.js)

将外部发现(如外部扫描器)的漏洞导入 DSH 的审计体系。

{
  "repo": "C:/path/to/your/repo",
  "skillDir": "C:/path/to/dsh-security/skills",
  "outputDir": "C:/path/to/output",
  "stateDir": "C:/path/to/dsh-security/state",
  "findings": [{ "title": "Possible XSS in search", "location": {"file": "src/index.js"}, "category": "XSS" }]
}

跟踪(workflow/track.js)

将 finding 导出至外部工单系统或本地导出。

{
  "repo": "C:/path/to/your/repo",
  "skillDir": "C:/path/to/dsh-security/skills",
  "outputDir": "C:/path/to/output",
  "stateDir": "C:/path/to/dsh-security/state",
  "destination": "auto",
  "findings": [{ "id": "csf_1234567890abcdef", "title": "XSS" }]
}

产物与目录结构

插件运行后,会在 outputDir 和 stateDir 生成以下核心文件:

  • 状态文件:findings.jsonl(reportable finding)、findings-index.jsonl(索引)、scans.jsonl(扫描汇总)、dedupe-groups.jsonl(去重组)。
  • 审计报告:findings.json、report.md、exports/results.sarif(SARIF 格式)、coverage.json(代码覆盖率快照)。
  • 元数据:scan-manifest.json(seal 阶段生成,包含哈希校验)。
  • 目录结构:
    • skills/:包含 inventory, discover, validate, dedupe, report, seal 等各阶段 skill。
    • workflow/:scan.js, diff.js, fix.js, triage.js, track.js 等编排脚本。
    • state/:本地 JSONL workbench,用于跨扫描去重和历史召回。

注意事项

  • 运行权限:插件在 DSH 进程权限下运行,请确保 DSH 进程对目标仓库有读/写权限。
  • 生态归属:该插件为社区项目,由用户 id7869 维护,与 DeepSeek 或官方应用商店无官方从属关系。
  • 许可证:MIT License。

总结

id7869/dsh-security 提供了一套在 DSH 内部即可完成全流程安全审计的方案。通过复用 DSH 自身的模型能力,结合本地 JSONL 去重与持久化,它在不增加额外环境负担的前提下,实现了从发现到修复的闭环。相关源码与文档可访问 GitHub 仓库。

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

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

小夜