前言¶
DeepSeek Harness (DSH) 的核心理念是「一切皆插件」。對於開發者而言,在本地或 CI 環境中復現類似 OpenAI codex-security 的安全審計能力,通常需要引入額外的 Python 環境、向量數據庫或複雜的依賴鏈。id7869/dsh-security 是一個獨立插件,它僅借鑑 codex-security 的方法論,在 DSH 原生能力範圍內重建了「發現 → 驗證 → 報告」的完整審計流程。
核心功能¶
該插件以獨立 DSH 插件的形式存在(包含 skills 和 workflow),不依賴外部 Python 或 Docker 環境。
- 完整審計流程:覆蓋代碼盤點、威脅建模、發現候選漏洞、獨立驗證、去重、嚴重度重分級、生成報告及固化。
- 去重機制:基於指紋(djb2/FNV-1a)和歷史記錄進行兩階段評審(粗篩 SAME/DISTINCT,深度確認 canonical+merged),避免重複告警。
- 本地持久化:僅使用本地 JSONL 文件存儲狀態(
state/目錄),不依賴 SQLite 或 Mnemon。 - 零靜態依賴:
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 倉庫。