LeslieWylie/dsh-fleet-audit

DSH agent-fleet 卫生审计插件:凭据文件权限、嵌入的 git 远程凭据(已掩码)、提供商令牌字面量。只读、零依赖、确定性。

项目介绍Project Overview

DSH 舰队卫生审计插件,只读、零依赖、确定性。检测三类风险:凭据文件权限过宽(如 ~/.gitconfig、~/.netrc 应为 600/700)、git remote 中内嵌的 https://user:pass@host 凭据、以及常见 provider token 字面量前缀;输出全程脱敏,逐字节保证不泄露原文。适用于多 agent 机器上线前或定期安全基线体检。需注意:仅扫描文本配置,token 识别为启发式,可能漏报或误报,发现泄漏需自行 chmod 与轮换。

DSH fleet hygiene audit plugin: read-only, zero-dependency, deterministic. It checks three risks: overly permissive credential files (~/.gitconfig, ~/.netrc should be 600/700), embedded credentials in git remote URLs, and common provider token prefixes. Output is fully masked byte-by-byte to guarantee no plaintext leakage. Use for baseline security checks on multi-agent machines. Caveat: scans only text configs, and token prefix detection is heuristic, so false negatives or false positives are possible. Any leaks found must be remediated manually via chmod and credential rotation.

或使用命令行安装(适合开发者)Or use CLI install (for developers)

命令行安装CLI Install

dsh plugin --profile web add dsh-fleet-audit

LeslieWylie/dsh-fleet-audit 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

🔎 dsh-fleet-audit

English

DSH agent 舰队卫生审计插件:只读、零依赖、确定性。检查三件事,输出全程脱敏:

  1. 凭据文件权限 —— 常用凭据文件(~/.gitconfig~/.netrc~/.npmrc~/.env~/.ssh/)应收紧为 600/《700,组/其他可读一律标记为 tooOpen`
  2. git remote 内嵌凭据 —— 扫描 ~/.gitconfig 与给定目录下的 .git/config,识别 https://user:pass@hosthttps://oauth2:TOKEN@host、token 型用户名等;输出 URL 中凭据以 *** 掩码,逐字节保证不泄露原文
  3. provider token 前缀字面量(可关)—— github / github-fine-grained / gitlab / gitlab-ci / slack / aws / openai / jwt 常见前缀,只报「类型 × 出现次数」

为什么

多 agent 时代的机器上,凭据散落在 ~/.gitconfig、agent 配置、.git/config 与各种 .env 里。git 的 url.*.insteadofpushurl 一旦嵌了 token(例如 https://oauth2:<token>@gitlab.example.com/...),任何 git remote -v 都会把密钥打印进日志/对话/CI。一键只读审计 + 脱敏输出,是安全基线体检的第一道。

安装

# 本地验证
dsh plugin --profile web add /path/to/dsh-fleet-audit

# 发布后(npm / GitHub)
dsh plugin --profile web add dsh-fleet-audit
# 或
dsh plugin --profile web add github:LeslieWylie/dsh-fleet-audit

安装后重启 dsh web,直接说「审计一下本机凭据卫生 / run fleet_audit」。

用法(工具参数)

参数 类型 说明
roots string[] 递归扫描 .git/config 的目录(可选;默认只查 ~/.gitconfig
files string[] 额外要查权限的凭据文件绝对路径
scanSecrets boolean 是否扫描 token 前缀字面量(默认 true
maxGitConfigs number git config 扫描上限(默认 200,上限 2000)
maxDepth number 目录递归深度(默认 5,上限 20)

输出示例(脱敏)

{
  "ok": true,
  "summary": { "files": 5, "tooOpen": 1, "gitLeaks": 2, "secretFiles": 1, "issues": 4, "scannedGitConfigs": 12 },
  "checks": {
    "credentialFiles": [
      { "path": "/Users/alice/.gitconfig", "exists": true, "mode": "644", "tooOpen": true }
    ],
    "gitRemoteLeaks": [
      { "file": "/Users/alice/code/proj/.git/config", "host": "gitlab.example.com", "maskedUrl": "https://***:***@gitlab.example.com/group/proj.git" }
    ],
    "secrets": [
      { "file": "/Users/alice/.gitconfig", "providers": [ { "provider": "github", "count": 1 } ] }
    ]
  },
  "note": "Read-only audit; secret-like values are masked in the output. Fix permissions with chmod 600 and rotate any exposed credentials."
}

安全边界

  • 只读:不写文件、不启进程、不访问网络、不保存状态
  • 脱敏:所有疑似凭据一律掩码;测试同时断言「输出 JSON 不含原始密钥」
  • 有界:git config 数量与递归深度均设上限,可防扫描失控

开发

npm install
npm run check   # typecheck + vitest + build

已知局限

  • 仅扫描文本类配置文件(不会解析加密存储、系统钥匙串、二进制文件)
  • token 前缀识别为启发式规则:可能漏报(非常规前缀)或误报(需人工复核)
  • 默认只检查固定凭据列表;任意路径凭据请通过 roots / files 显式指定
  • 不主动修改任何文件;发现泄漏后请自行 chmod 600 并轮换密钥

回滚

dsh plugin --profile <p> remove dsh-fleet-audit   # 或从 dsh.profile.bundles 删除该行

插件只读、无状态,卸载不影响任何用户数据。

独立社区插件

本项目为独立社区插件,与 DeepSeek 官方或其 DSH 仓库无隶属关系;"official" 身份仅通过官方渠道授予。发布时会给仓库添加 dsh-plugin topic 以便发现。

许可

MIT © LeslieWylie

上一个 Prev dsh-chat-continue 下一个 Next dsh-rules