Introduction¶
When using agents in DSH (DeepSeek Harness) to modify code or package releases, .env files, API keys, and hosting platform tokens are easily mistaken for “project files” and accidentally included in a git push or npm publish. Remediating via public repository scanning after the fact is far more costly than blocking the issue before release.
Below is the community plugin dsh-leak-guard (maintainer 7gzgn): it performs a local scan of the workspace before pushing, publishing, or packaging to check for credentials that should not be exposed. It is categorized as admin-security; the repository and documentation can be found at the SkillHub directory page and on GitHub.
What is this¶
dsh-leak-guard is a pre-release credential auditing plugin for DSH (current package version 0.1.1, MIT License). It scans files under a specified path to find API keys, tokens, private keys, database connection strings, plaintext passwords, etc. It is zero-dependency, purely local, offline, and uploads no content. Matched results are redacted before returning (preview shows only the first 6 characters).
The design goal can be summarized as: run the scan before the release action, and do not release if ok = false.
Detection Scope¶
The README summarizes the main categories in a table; the complete rules can be printed via the tool (currently 23 content rules + 11 filename rules).
| Category | Examples |
|---|---|
| LLM Keys | sk-…, sk-ant-…, hf_… |
| Code Hosting Tokens | ghp_/gho_/ghu_/ghs_/ghr_, github_pat_…, glpat-… |
| Cloud Providers | AKIA…/ASIA… (AWS), LTAI… (Alibaba Cloud), AKID… (Tencent Cloud), AIza… (Google) |
| Payment / Communication | sk_live_… (Stripe), xox… (Slack), SG.… (SendGrid), Telegram bot tokens |
| Private Keys / Certificates | -----BEGIN … PRIVATE KEY-----, id_rsa, *.pem / *.p12 |
| Connection Strings | postgres://user:pass@…, mongodb://…, redis://…, URLs with embedded credentials |
| Generic Assignments | password = "…", api_key: "…", hardcoded Bearer … |
| Sensitive Files (by filename) | .env*, .credentials.yaml, .npmrc, .netrc, .git-credentials, service-account*.json, .gh-token |
The rule strategy emphasizes “prefer false negatives over false positives”: it requires specific prefixes and sufficiently long random bodies, and allows placeholders such as sk-xxxx, <YOUR_KEY>, ${TOKEN}, change-me via a whitelist.
Invocation in DSH¶
The plugin registers as the DSH tool leak_guard. Example for scanning a specified directory:
leak_guard({ action: "scan", path: "D:\\dsh\\projects\\my-thing" })
In the returned JSON, ok: true indicates no items requiring attention were found; when ok: false, check findings and prioritize handling critical / high level issues. counts summarizes the number of findings per level, and stats provides scanned file count, skipped count, and byte count.
To view the complete list of rules:
leak_guard({ action: "rules" })
Usage as a Node Library¶
In addition to the DSH tool, the package exports a pure ESM scanner (Node >= 18) that can be referenced directly in scripts or CI:
import { scanPath } from 'dsh-leak-guard/scanner'
const result = await scanPath('/path/to/repo')
if (!result.ok) {
console.error('Do not publish, handle first:', result.findings)
process.exit(1)
}
package.json also provides subpath exports such as ./patterns for easy reuse of rule definitions.
Implementation Trade-offs¶
- Coarse filtering followed by fine inspection: Joint regex filters out irrelevant lines, and suspected lines are then run against full rules. A medium-sized project can be scanned in seconds.
- No duplicate reporting for the same leak: If a specific rule hits, the generic
assignment-secretrule is not stacked on top. - Offline boundary: No networking, no disk writing, no reading unspecified paths, no following symbolic links; binary files are skipped by default; the default limit for a single file is 1MB, beyond which it only prompts but does not scan.
- High-entropy detection disabled by default: When
entropy: trueis enabled, it becomes more sensitive to long random strings, but only reports if context words like key/token/secret appear on the same line; noise levels may still be high.
Limitations & DSH Compatibility¶
Make sure to recognize the boundaries first, and treat this as a habitual action rather than an absolute insurance policy:
- It is not a git history scanner: It only looks at existing files in the workspace, not committed history.
- It will miss: Rules are finite; new service prefixes or custom encodings may be missed. Its positioning is a fallback safety net.
- The declared DSH compatibility range is
>=0.2.0-rc.2 <0.3.0-0(covering the entire 0.2 line). At runtime, if it cannot obtaindefineToolfrom@deepseek-ai/dsh-tools, it will degrade gracefully to avoid crashing the host.
Installation & Notes¶
The DSH ecosystem adopts an “everything is a plugin” approach; SkillHub is a community directory site and has no official affiliation with DeepSeek or Quant立柱 (HiWalla). Before installing, please read the source code and MIT License on the GitHub repository to ensure it meets your security policy.
The plugin reads the path you pass with the current DSH process permissions, scanning only the directory you specify. In agent automatic git push or packaging flows, fixing leak_guard as the step immediately before release is easier than fighting fires in public repositories afterward.
Conclusion¶
dsh-leak-guard solves the question “Are there credentials in the workspace before sending it out?”: it is local, redacted, and scriptable. Use action: "rules" for detailed rule specifications; use action: "scan" for daily pre-release checks, and use ok as the standard to decide whether to continue.
- Directory Page: https://www.skillhub.cn/plugins/7gzgn/dsh-leak-guard
- Source Code & Docs: https://github.com/7gzgn/dsh-leak-guard