@shaoshi/dshscan:DSH 插件安全掃描器

前言

DSH 的理念是「一切皆插件」。插件進入 dsh 進程後,會運行在當前的 dsh 進程權限下,因此安裝前需要檢查源碼、依賴、manifest 與可能的外連行爲。社區目錄是獨立站點,與 DeepSeek / 幻方無官方從屬關係;目錄頁中的 verified=true 也只表示 dshbase CI 可安裝,不等於安全審計結論。

@shaoshi/dshscan 解決的是這類問題:把插件源碼、依賴、DSH manifest 和 DSH 特有攻擊面放到一次掃描裏,輸出帶嚴重等級和證據的報告,便於安裝前判斷或批量巡檢。

這是什麼

@shaoshi/dshscan 是 DSH 插件安全掃描器,由 shaoshi20 維護,許可證爲 MIT。

它支持靜態與語義雙通道檢查,內置 DSH 特有攻擊面規則,集成 npm audit,支持批量掃描,並輸出帶嚴重等級與證據的 HTML 報告。

核心功能

  • 輸入形式:插件名、GitHub 倉庫地址、本地目錄、zip、Markdown 文件。
  • 輸出報告:JSON 報告包含 risk_scoreseveritysafe_to_installrecommendationfindings
  • 雙通道掃描:靜態規則掃描可完全離線;可選 LLM 語義掃描,需要設置 DSCAN_LLM_API_KEYOPENAI_API_KEY
  • dshbase 集成:輸入插件名時自動讀取本地索引元數據。
  • npm 源碼掃描:npm 插件可自動 npm pack 下載並掃描包內容。
  • 依賴審計:檢查未鎖定版本、遠程依賴源、依賴包名仿冒,並集成 npm audit。
  • DSH manifest 校驗:檢查 dsh.bundlecordis.patch.yml、LICENSE、README。
  • DSH 攻擊面規則:R010 插件樹注入、R011 瀏覽器側惡意代碼、R012 profile 篡改、R013 manifest 混淆、R014 遠程動態加載、R015 內置工具影子劫持。
  • Benchmark 評估集:內置惡意/良性樣例,可輸出查全率、誤報率、F1 與逐規則指標。
  • 自定義規則:支持 --rules <file>
  • 策略文件:支持 --policy <file>
  • 審計日誌:支持 --audit-log <file>
  • Web Dashboard:支持 --serve 啓動本地可視化面板,可用 --history 指定歷史文件。
  • HTML 報告:支持 --html 輸出獨立網頁報告。
  • 誤報處理:每條 finding 帶證據和修復建議。
  • 批量掃描:支持掃描 dshbase 插件目錄並輸出彙總 JSON / HTML。
  • 定時巡檢:可結合 GitHub Actions 每日自動拉取 dshbase 目錄並批量掃描。

安裝與啓用

作爲 DSH 插件安裝:

dsh plugin add @shaoshi/dshscan

package.json 中聲明:

peerDependencies: @deepseek-ai/dsh-tools 0.1.0-rc.6
dependencies: adm-zip ^0.5.16, yaml ^2.9.0

典型用法

掃描單個插件

dshscan <plugin-name>

輸入插件名時,會讀取本地索引元數據。

掃描倉庫、本地目錄、zip、Markdown

dshscan github:owner/repo
dshscan https://github.com/owner/repo
dshscan /path/to/plugin
dshscan plugin.zip
dshscan README.md

離線掃描與語義掃描

dshscan <plugin-name> --offline
dshscan <plugin-name> --semantic

靜態掃描無需網絡。掃描 GitHub 倉庫獲取源碼需要網絡,可用 --offline 跳過。啓用 LLM 語義掃描需設置 DSCAN_LLM_API_KEYOPENAI_API_KEY

輸出報告

dshscan <plugin-name> --output report.json --pretty
dshscan <plugin-name> --summary
dshscan <plugin-name> --html --output report.html

依賴審計、自定義規則與策略

dshscan <plugin-name> --audit
dshscan <plugin-name> --rules custom-rules.json
dshscan <plugin-name> --policy policy.json --audit-log audit.jsonl

Web Dashboard

dshscan --serve --port 8787
dshscan --serve --port 8787 --history /path/to/history.json

Benchmark 評估

dshscan --benchmark --summary
dshscan --benchmark --pretty

批量掃描

dshscan --batch --limit 50 --index /path/to/dshbase-directory.json --output batch.json --pretty
dshscan --batch --all --html --output batch.html
dshscan --batch --all --offline --output all.json

報告判定說明

JSON 報告中的 safe_to_installtrue 僅當沒有 high/critical finding,且 risk_score < 40

未啓用語義掃描時,報告會標註 scan_mode: static 和“僅靜態掃描,非完整掃描”。

報告超過 100 條 finding 時,只展示按嚴重級排序的前 100 條,並置 findings_truncated: true;計分與安裝建議仍基於全量。

索引文件缺失或損壞不會導致崩潰,會自動降級爲無元數據通道並提示。可用 DSCAN_INDEX 指向索引文件。

掃描範圍與排除

以下目錄完全不掃描:

  • .github.circleci.gitlab
  • third_partyvendor
  • node_modulesdistbuild

適用場景與注意

@shaoshi/dshscan 適合:

  1. 安裝第三方 DSH 插件前,檢查插件源碼、依賴、manifest 和 DSH 相關攻擊面。
  2. 對插件目錄做批量巡檢,並輸出彙總 JSON / HTML。
  3. 對掃描規則做 Benchmark 評估,查看查全率、誤報率、F1 與逐規則指標。
  4. 在 GitHub Actions 中做定時掃描。

注意:DSH 插件會以當前 dsh 進程權限運行。安裝前應檢查源碼、許可證、依賴與實際行爲。verified=true 僅表示 dshbase CI 可安裝,不等於安全審計。未啓用語義掃描時,結果不是完整掃描。

鏈接

目錄頁:

https://dshbase.com/zh/plugins/shaoshi-dshscan/

GitHub:

https://github.com/shaoshi20/dshscan
羽毛球分组比赛记分
小程序二维码

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

小夜