Saltar al contenido principal
S

dsh-secret-shield

shanwenzhe/dsh-secret-shield

Local-first secret scanner and one-click redactor for API keys, cloud credentials, DB passwords, private keys, and PII without exposing plaintext to the LLM.

Instalar

dsh plugin --profile web add github:shanwenzhe/dsh-secret-shield

README

dsh-secret-shield

DeepSeek Harness (DSH) 本地敏感凭据扫描与一键脱敏插件。

把项目交给 AI 或提交 Git 前,最怕把 .env、API Key、云厂商 AccessKey、数据库密码或私钥漏出去;而让大模型直接读文件查密钥,反而会把明文密钥发给云端模型。

dsh-secret-shield 在本地进程内完成扫描与脱敏,只向模型返回文件路径、行号、规则类型和打码预览(例如 sk-9...3210),零明文泄漏。


安装

方式一:通过 DSH 命令行 / 插件市场直接安装(推荐)

dsh plugin --profile web add github:Shanwenzhe/dsh-secret-shield

或在 DSH Desktop 的 设置 -> 插件市场 (dshmarket) 中搜索 dsh-secret-shield 一键安装。

方式二:本地源码热挂载调试

在 DSH Desktop 的 cordis.patch.yml 末尾追加:

- insert:
    - id: secret-shield
      name: 'file:///e:/antigravity%E9%A1%B9%E7%9B%AE/dsh-secret-shield/src/index.js'

核心功能

  1. secret_scan(本地零泄漏扫描)
    • 递归扫描指定文件或目录,自动跳过 node_modules、.git、lockfile 和二进制文件。
    • 内置 4 大类检测规则:
      • AI 密钥:DeepSeek / OpenAI、Anthropic、Gemini、HuggingFace、Groq
      • 云与开发凭据:GitHub PAT、AWS、阿里云 (LTAI...)、腾讯云 (AKID...)、Slack、Stripe、带密码的数据库连接串、常见 .env 密钥赋值
      • 私钥与令牌:PEM 私钥、JWT Token
      • 个人隐私(默认关闭,可按需开启):中国大陆手机号、18 位身份证号
    • 内置误报过滤(自动忽略 your-key、changeme、xxxx、<token> 等文档占位符)。
  2. secret_redact_text(文本一键脱敏)
    • 对日志、报错栈、配置片段做本地脱敏,替换为 [REDACTED:LLM_API_KEY_1] 等确定性占位符。
  3. secret_redact_file(文件一键脱敏 / 生成 .env.example)
    • 默认 dryRun: true 仅预览,不会误改文件;传入 outputPath: ".env.example" 且 dryRun: false 可一键生成脱敏模板。
  4. 原生热更新设置
    • 通过 @deepseek-ai/schemastery 的 .volatile() 配置项,可在 DSH 设置中实时开关各类规则、调整体积上限和忽略目录,无需重启。

开发与测试

npm install
npm test
npm run scan:self
npm run pack:check

Plugins relacionados