Depguard

io.github.CloudCorpRecords由 GitHub 账号 CloudCorpRecords 发布v0.4.0更新于 Nov 2, 2026

PR dependency early warning: install scripts, typosquats, downgrades, and lockfile drift.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

Depguard 对仓库依赖变更做分级检查——安装脚本、仿冒包名、降级、锁文件漂移——并给出 CLEAR/REVIEW/HIGH-RISK 结论。

可以做什么
  • 将仓库的清单与锁文件同某个 git 引用或基准目录做差异比较,对每个新增、删除、变更的依赖逐项评级
  • 对单个包名与版本做仿冒名称形态与版本模式检查
  • 分析某个包在注册表中的发布历史,识别分阶段投毒模式、维护者与仓库变更、来源证明缺失
  • 在开启在线或内容模式时,附加注册表检查(版本年龄、发布者变更、来源证明、弃用)或静态 tarball 内容差异
适用场景
适合在审查 npm(部分支持 PyPI)项目的拉取请求或依赖升级时使用,在变更合并前获得自动化预警。它面向新增或变更包的供应链审查,而非通用代码审查。
运行要求
以 stdio 本地运行,可通过 npx 或 Docker 镜像启动;npm 包需要 Node.js 20 或更高版本。未声明任何账号、API 密钥或环境变量。离线核心无需网络;在线注册表检查与内容模式需要访问 npm 或 PyPI 注册表的网络。
安装前请注意
结论只是启发式提示:仿冒检测仅看名称形态,来源证明仅表示注册表元数据中存在证明条目而非已验证,嵌套工作区清单不会被清点。内容模式会从注册表下载 tarball(仅在内存中解压,从不执行),因此包名与版本会发送给注册表。发现的问题并不等于证明代码恶意。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Depguard,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

depguard

PR-time and dependency-change early warning for npm repos. The Shai-Hulud / ChainDrop worm family backdoored 500+ npm packages in 2026, executing at install time through preinstall dropper scripts and propagating through the dependency graph. depguard is the diff-time check: given a repo and a base (a git ref or a second manifest set), it diffs package.json and the lockfiles, and grades every added, removed, and changed dependency with evidence, before the change merges.

The base verdict is fully offline and deterministic. Registry checks (version age, publisher change, provenance, deprecation) run only behind an explicit --online flag or the matching MCP parameter, and a failed lookup never changes the local verdict.

What it checks

SignalSourceRule ids
New install scripts in the repo's own package.json, escalated when the content fetches remote code, reads credentials, or runs the documented setup.mjs dropper namelocalINSTALL-SCRIPT-ADDED, INSTALL-SCRIPT-CHANGED
A changed dependency newly marked as having an install script in the lockfile; install scripts present on added dependencieslocalINSTALL-SCRIPT-ADDED, INSTALL-SCRIPT-PRESENT
Typosquat-shaped added names: edit distance 1 (or 2, longer names) against the repo's own existing dependency set and a bundled popular-names list (about 380 names, shipped in the package)localTYPOSQUAT-SUSPECT, TYPOSQUAT-POSSIBLE
Version anomalies: silent downgrades, stable-to-prerelease jumps, non-semver versions, ranges widened (to * or latest is high), newly added unpinned rangeslocalDOWNGRADE, PRERELEASE-JUMP, VERSION-PATTERN, RANGE-WIDENED, RANGE-UNPINNED
Lockfile drift: manifests changed but the lockfile is identical; lockfile changed with no manifest change; resolved URL host changes for the same version; integrity hash removed or changed at the same versionlocalLOCKFILE-DRIFT, LOCKFILE-ONLY-DRIFT, RESOLVED-HOST-CHANGE, INTEGRITY-REMOVED, INTEGRITY-CHANGED
Manifest dependencies with no lockfile entry (single-snapshot mode)localLOCK-MISSING
Version published under 7 days ago; publisher or maintainer change versus the previous version; missing provenance attestation; deprecation marking; version absent from the registryonline onlyVERSION-AGE, MAINTAINER-CHANGE, NO-PROVENANCE, DEPRECATED, VERSION-NOT-FOUND
Content diff of the two versions' tarballs: a version bump that adds an install script, or adds credential-path strings, network endpoints, binaries, or obfuscation-shaped code in install-reachable files (the script targets plus their relative imports). A quiet bump that adds a preinstall loading credential paths grades HIGH-RISK and names the added signals; a benign build postinstall with no such signals does not grade highcontent mode only (--content)CONTENT-INSTALL-SCRIPT-ADDED, CONTENT-INSTALL-SCRIPT-CHANGED, CONTENT-CRED-SIGNAL-ADDED, CONTENT-NETWORK-ENDPOINT-ADDED, CONTENT-BINARY-ADDED, CONTENT-OBFUSCATED-ADDED
Registry publish history: the staged worm pattern (a 0.0.0-stage stub, a decoy-looking release, then a rapid regressed patch holding dist-tags.latest), stage stubs, latest-version regression, rapid regressed clusters, publisher and maintainer changes, repository slug changes, provenance dropshistory mode (depguard history <name>)HISTORY-STAGED-PATTERN, HISTORY-STAGE-STUB, HISTORY-LATEST-REGRESSION, HISTORY-RAPID-REGRESSION, HISTORY-MAINTAINER-CHANGE, HISTORY-REPO-CHANGE, HISTORY-PROVENANCE-DROP, HISTORY-PACKAGE-NOT-FOUND

Lockfiles: package-lock.json is parsed fully (v1 legacy tree and v2/v3 packages map). yarn.lock and pnpm-lock.yaml are parsed best-effort for resolved entries and versions.

Verdicts: per dependency and overall, CLEAR / REVIEW / HIGH-RISK, with one evidence line per finding naming the dep, the change, the rule id, the severity, and whether the signal is local or online. Exit code is 0 for CLEAR and 1 for REVIEW or HIGH-RISK.

CLI

bash
depguard check [path] [--json] [--offline] [--online] [--content] [--base <ref>] [--base-path <dir>]depguard package <name> [version] [--json] [--online] [--content]depguard history <name> [--json] [--registry npm|pypi]depguard mcp

history (v0.3.0, ledger P-159) analyzes one package's registry publish history for the staged worm pattern and related signals. It reads registry metadata only and downloads no tarballs. Since v0.4.0, --registry pypi (or the registry parameter on check_history) reads PyPI history through its JSON API instead: the same timeline checks (staged pattern, stage stub, latest regression, rapid regression) run on per-version upload times, plus a PyPI-specific HISTORY-YANKED-VERSION finding for releases whose files are all yanked. PyPI publishes no per-version publisher, maintainer, repository, or provenance data through that API, so those npm checks do not fire on PyPI histories.

check defaults to the offline core against the current directory, as a single snapshot (every manifest dependency graded on what is here now). Pass --base HEAD~1 (any git ref) or --base-path <dir> to diff against a base. package grades one name without a repo. There are no timestamps in the JSON report, so identical inputs produce byte-identical output.

--content adds content-based update vetting (v0.2.0, ledger P-158): for every changed or added dependency, and for snapshot pins with a prior published version, depguard fetches both versions' tarballs from the npm registry and diffs the install-time surface statically. Tarballs are extracted in memory only: depguard never installs or executes anything from a tarball. In package mode with --content, the named version is diffed against the greatest lower published version.

MCP

One bin serves the CLI and a stdio MCP server (depguard mcp). Tools:

  • guard_path(path, base?, base_path?, online?, content?): the full diff report as JSON.
  • check_package(name, version?, online?, content?): grade a single package name and version.
  • check_history(name): analyze a package's registry publish history for staged-pattern and related signals.

Limits

  • Root manifests only: nested workspace package.json files and nested lockfiles are not inventoried in v0.1.0. (Ledger P-132, documented limit.)
  • pnpm-lock.yaml parsing is key-based and best-effort: resolved tarball URLs are captured only where the lockfile layout exposes them inline, so resolved-host drift detection is strongest on package-lock.json, then yarn.lock, then pnpm-lock.yaml.
  • Install scripts of dependencies themselves are known only where the lockfile records them (package-lock hasInstallScript) or, online, where registry metadata declares them. Content mode (--content, v0.2.0) goes one step further and downloads the two versions' tarballs to diff their install-time surface, but the inspection is static only: tarballs are extracted in memory, nothing is installed, and no tarball code is ever executed. Offline and online modes download nothing.
  • Content mode follows install script targets and their relative imports to depth 3; signals buried deeper in a dependency's own internal graph, or generated at install time, are out of reach of this signal.
  • Typosquat detection is name-shape only. A name that is itself a bundled popular name is never flagged (ledger P-130), and a well-chosen name at edit distance 3 or more is out of reach of this signal by design.
  • Online signals are only as good as the registry packument: publisher comparison uses the recorded publisher of the greatest lower version, and provenance means an attestation entry exists in registry metadata, not that it was verified.
  • Caps are explicit, never silent: lockfile parsing stops at 50,000 entries and any manifest file over 64 MiB is skipped, both reported in the output (caps in JSON, a cap line in human output, plus warnings).

Development

bash
npm installnpm run buildnpm test

TypeScript, Node >= 20, tests with tsx --test, no network in unit tests (registry responses are injected fixtures).

来源:README.md,提交 e1d357f

工具

3

guard_path

Diff a repo's dependency manifests and lockfiles against a base (git ref or directory) and grade every added, removed, and changed dependency: install scripts, typosquat-shaped names, downgrades, prerelease jumps, widened ranges, and lockfile drift. Fully offline unless online is true, which adds npm registry checks (version age, publisher change, provenance, deprecation).

输入参数basepath必填onlinecontentbase_path

check_package

Grade a single package name (and optional version): typosquat distance against a bundled popular-names list and version pattern checks offline; with online true, registry checks for version age under 7 days, publisher change versus the previous version, provenance attestation, and deprecation.

输入参数name必填onlinecontentversion

check_history

Analyze a package's registry publish history for the staged worm pattern (a 0.0.0-stage stub, a decoy release, then a rapid regressed patch holding dist-tags.latest), plus publisher and maintainer changes, repository slug changes, and provenance drops between consecutive versions. The registry defaults to npm; with registry pypi it reads PyPI history instead (the same timeline checks, plus yanked-version findings, since PyPI publishes no per-version publisher data). Registry metadata only; no tarballs are downloaded.

输入参数name必填registry

版本历史

3
  1. v0.4.0最新Oct 26, 2026
  2. v0.3.0Oct 23, 2026
  3. v0.1.0Oct 22, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分