Npmpreflight

io.github.CloudCorpRecords由 GitHub 账号 CloudCorpRecords 发布v0.1.0更新于 Oct 25, 2026

Pre-publish npm pack auditor: shipped files, size, secret-pattern leaks, missing fields.

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

概览

AI 生成的概览

一个本地 MCP 服务器,在发布前审计 npm 包目录,检查实际打包文件、体积、密钥特征和 package.json 字段。

可以做什么
发布前审计包目录:根据 files 字段和忽略规则解析实际打包的文件集合,扫描打包文件中的密钥特征,统计体积,并检查 package.json 的必填字段、bin 与 main 入口、许可证以及 publishConfig 访问设置。
适用场景
适合在即将执行 npm publish 时使用,快速预检会打包哪些文件、是否有凭据残留在打包文件中,以及是否缺少必填字段或入口文件。
运行要求
作为本地进程通过 stdio 运行,可用 npx 或已发布的 OCI 镜像启动。需要 Node 20 或更高版本。未声明账号、API 密钥或环境变量。
安装前请注意
它读取本机包文件并输出检查结果,不会发布或修改任何内容。密钥类发现只显示特征编号、文件和行号,不显示匹配到的文本。文件集合是对 npm pack 的静态近似,发布前仍应用 npm pack --dry-run 确认。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

npmpreflight

Audit a package directory before npm publish, while a bad publish is still cheap to undo.

npmpreflight resolves the file set your package would actually ship, scans the shipped files for secret patterns, totals the size, and checks package.json for the fields and entry points a publish depends on. It answers the questions that are embarrassing to discover after a release: is a credential sitting in a shipped file, does the bin target exist in the tarball, is the license field set, and is a scoped package about to publish as restricted.

Install

Run it without installing:

sh
npx @reneturcios/npmpreflight check .

Or install it globally:

sh
npm install -g @reneturcios/npmpreflightnpmpreflight check .

Requires Node 20 or newer.

CLI usage

sh
npmpreflight check [path] [--json]npmpreflight mcpnpmpreflight --version
  • check [path] audits the package directory at path (default: the current directory) and prints a human readable report. Add --json for the machine readable report.
  • mcp starts the MCP server over stdio (see below).
  • --version prints the version.

Exit codes: 0 when the verdict is READY, 1 for any other verdict, 2 for a usage error or an unreadable or invalid package.json, and 141 when the reader closed the output pipe early.

Example output:

text
npmpreflight check .: FIX-FIRST  files: 4, bytes: 603, findings: 2 (high: 2, medium: 0, low: 0, info: 0)  summary: 4 shipped file(s), 603 byte(s), 2 finding(s) (2 high, 0 medium, 0 low, 0 info). High-severity findings must be fixed before publishing.  [HIGH] SECRET-LEAK src/index.js:2 Shipped file matches the secret pattern private-key-block. Remove the credential from the package and rotate it if it was ever real. (evidence: private-key-block)  [HIGH] SECRET-LEAK src/index.js:3 Shipped file matches the secret pattern github-pat-classic. Remove the credential from the package and rotate it if it was ever real. (evidence: github-pat-classic)FIX-FIRST: resolve the high-severity findings before publishing.

Findings never include the matched secret text. The evidence for a secret finding is the pattern id only, plus the file and line, so a report is safe to paste into an issue or a CI log.

MCP

The same audit is available as an MCP tool over stdio:

  • Tool: preflight_package
  • Input: path, the package directory to check
  • Output: the JSON report, identical to check --json

Start it with npmpreflight mcp, or configure an MCP client to run npx @reneturcios/npmpreflight mcp. The server is also published as an OCI image and listed in server.json under the name io.github.CloudCorpRecords/npmpreflight.

Checks

RuleSeverityWhat it flags
MISSING-FIELDhighpackage.json is missing one of name, version, license, or description (one finding per missing field).
BIN-MISSINGhighA bin path in package.json is not in the shipped file set.
MAIN-MISSINGhighThe main entry point is not in the shipped file set.
SECRET-LEAKhighA shipped text file matches a secret pattern: a private key block header, an AWS access key id shape (AKIA plus 16 characters), a classic GitHub token shape (ghp_ plus 36 or more characters), a fine grained GitHub token shape (github_pat_ prefix), an sk- API key shape, or a generic api_key style assignment with a long quoted value. Evidence is the pattern id only.
OVERSIZEmediumTotal shipped size over 10 MiB, or any single shipped file over 1 MiB (one finding per oversize file).
SCOPED-NO-PUBLISHCONFIGmediumThe package name is scoped (starts with @) and publishConfig.access is not public.
NO-READMElowNo README file is in the shipped set.
NO-ENGINESinfopackage.json declares no engines range.

Every report counts the shipped files and their total bytes, plus the finding totals by severity.

Verdict

  • READY when there are no high severity findings. Medium, low, and info findings are reported but do not block the verdict.
  • FIX-FIRST when at least one high severity finding exists.

How the shipped file set is resolved

  • If package.json has a files array, those paths are included: files are added directly and directories are walked recursively. package.json, README, and LICENSE are always included when present, whether or not they are listed, matching npm.
  • If there is no files array, everything in the directory is included except node_modules, .git, and paths matched by .npmignore when one is present. The always included files above are still included even if an ignore rule would match them.
  • The walk is capped at 5000 shipped files. When the cap is reached the report records it in its counts (truncated: 1, with filesSeen and maxFiles) and the render notes that the remaining files were not scanned.

Limits

Read these before trusting a clean verdict:

  • The file set is a static resolution, not a byte-exact npm pack. npm applies more rules (its own always excluded files, lifecycle generated files, and publish time behaviour) that a static pass does not reproduce. Treat npmpreflight as a preflight check, then confirm a release with npm pack --dry-run.
  • .npmignore support is a simple subset: blank lines, # comments, plain lines (a file name at any depth, or an exact relative path), and directory patterns ending in /. Globs, negations, and character classes in .npmignore are not supported and such lines will not match the way npm would match them.
  • files entries support literal files, literal directories, simple * and ** globs, and ! negations of those. Anything more exotic is resolved literally and may differ from npm.
  • Secret scanning reads text files only. A file whose scanned head contains a NUL byte is treated as binary and skipped. Only the first 512 KiB of each file is scanned, so a secret past that offset in a large file will not be found. Patterns are shapes, not proof: a match can be a test fixture or an example, and a real credential in an unrecognized shape will not match.
  • Symlinks are not followed and are not shipped.
  • Output is deterministic: findings are sorted, counts are stable, and no timestamps are emitted.

Development

sh
npm installnpm run buildnpm test

License

MIT

来源:README.md,提交 33914be

工具

1

preflight_package

Audit a package directory before publishing: resolves the shipped file set from the files field and ignore rules, scans shipped files for secret patterns (private keys, token shapes), totals the size, and checks package.json for required fields, a bin target that exists, license, and publishConfig on scoped names. Verdict READY or FIX-FIRST with evidence.

输入参数path必填

版本历史

1
  1. v0.1.0最新Oct 25, 2026

评分

已满足适用检查项的 90%

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

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

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

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