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 分