Skip to content

🔒 修复 pnpm audit 全部安全警告 (20260921) - #1760

Open
cyfung1031 wants to merge 3 commits into
mainfrom
fix-npm-package-vulnerability-20260921
Open

cyfung1031 wants to merge 3 commits into
mainfrom
fix-npm-package-vulnerability-20260921

Conversation

@cyfung1031

@cyfung1031 cyfung1031 commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

pnpm audit reported 1 critical, 26 high, 20 moderate, 3 low vulnerabilities (websocket-driver, brace-expansion, js-yaml, shell-quote, body-parser, dompurify, fast-uri, react-router, postcss, hono, nanoid, fast-xml-parser, browserslist, @humanfs/node, qs, vitest, webpack-dev-server, and more). This PR resolves all of them — pnpm audit now reports 0 critical / 0 high / 0 moderate / 0 low.

  • Refreshed the locked resolution for direct dependencies already permitted by their existing package.json ranges: dompurify, fast-xml-parser, react-router-dom, webdav, postcss, vitest/@vitest/coverage-v8, eslint, postcss-loader, concurrently.
  • Bumped the exactly-pinned @modelcontextprotocol/sdk from 1.29.0 to 1.30.0.
  • Extended this repo's existing pnpm-workspace.yaml overrides table (the precise "parent@version>package": "exact-version" convention from 修复所有 npm vulnerability #1350) to refresh stale entries and add new ones for transitive vulnerabilities whose immediate parent's own semver range already permits the patched version but pnpm won't reach for it without an explicit override: brace-expansion (both the webdav>minimatch and crx>archiver>glob>minimatch chains, covered separately since they resolve to different minimatch majors), js-yaml, hono, browserslist/baseline-browser-mapping, @humanfs/node.
  • The @rspack/cli → @rspack/dev-server → webpack-dev-server chain (websocket-driver, shell-quote, webpack-dev-server itself, body-parser, qs, fast-uri) turned out to be fixable the same way, in-place on the existing @rspack/dev-server@1.1.5 release, by bumping the override targets (webpack-dev-server 5.2.5→5.2.6, shell-quote→1.10.0, fast-uri→3.1.7, qs/body-parser→6.16.0/1.20.8) — all within their respective parents' (webpack-dev-server, launch-editor, ajv, express) own declared compatible ranges. No major-version bump of @rspack/cli/@rspack/core was needed, so there's no separate rspack-migration PR.
  • Every override target was checked against this repo's minimumReleaseAge: 10080 (7-day) cooldown gate; where the newest patched release was too fresh (e.g. brace-expansion 1.1.21/2.1.7, fast-uri 3.1.8, published within the last week), used the next-older release that still clears the vulnerable-version threshold (brace-expansion 1.1.18/2.1.4, fast-uri 3.1.7).

An earlier revision of this PR added a parallel pnpm.overrides block directly in package.json and, based on a stale read of the situation, proposed a separate follow-up PR to bump @rspack/cli/@rspack/core to 2.x as the only way to close the remaining dev-server-chain findings. Neither was correct: the package.json block duplicated (and could drift from) the existing pnpm-workspace.yaml overrides mechanism, and the rspack major bump turned out to be unnecessary once the override targets were refreshed. Both have been corrected in the current revision.

Test plan

  • pnpm audit — 1 critical / 26 high / 20 moderate / 3 low → 0 / 0 / 0 / 0
  • pnpm run typecheck — passes
  • pnpm run build — passes (only pre-existing bundle-size/critical-dependency warnings)
  • pnpm run test:ci — 373 test files / 4837 tests pass
  • pnpm run lint:ci — passes
  • Note: this project's dev/build scripts invoke plain rspack (watch mode), never rspack serve, so the @rspack/dev-server/webpack-dev-server code path isn't exercised by this project's own workflow either way — the fix was still applied for defense in depth and to clear the audit.

🤖 Generated with Claude Code

cyfung1031 and others added 2 commits September 21, 2026 07:43
pnpm audit 报告 1 项 critical、26 项 high、20 项 moderate、3 项 low 漏洞(websocket-driver、
brace-expansion、js-yaml、shell-quote、body-parser、dompurify、fast-uri、react-router、
postcss、hono、nanoid、fast-xml-parser、browserslist、@humanfs/node、qs、vitest 等)。

多数漏洞源于 pnpm-lock.yaml 落后于 package.json 中已允许的 semver 范围,通过刷新以下直接依赖的
锁定版本即可在现有 range 内修复: dompurify、fast-xml-parser、react-router-dom、webdav、
postcss、vitest/@vitest/coverage-v8、eslint、postcss-loader,以及将 @modelcontextprotocol/sdk
从精确锁定的 1.29.0 升至 1.30.0。

其余漏洞位于传递依赖(brace-expansion、js-yaml、hono、browserslist、baseline-browser-mapping、
@humanfs/node、qs),其父包自身的 semver range 已允许修复版本,但 pnpm 不会在未显式指定时跳到该
版本,故通过 pnpm.overrides 显式钉住这些包的最低安全版本,均在各自父包声明的兼容范围内。

剩余 1 项 moderate、7 项 high、1 项 low 均集中在 @rspack/cli > @rspack/dev-server >
webpack-dev-server 链路: @rspack/dev-server 在 1.x 全系列中硬编码精确版本
webpack-dev-server@5.2.2(不可通过 range 修复),需要升级到 @rspack/cli 2.x(已改用
@rspack/dev-middleware,不再依赖 webpack-dev-server)才能修复,属于构建工具的破坏性大版本升级,
放到单独的 PR 处理。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
复用上个提交遗留的 pnpm.overrides(package.json)方式与本仓库既有的
pnpm-workspace.yaml 精确父版本覆盖表(见 #1350)并不一致,且未覆盖
@rspack/cli > @rspack/dev-server > webpack-dev-server 链路的剩余漏洞。

改为在 pnpm-workspace.yaml 现有覆盖表内就地刷新,遵循同一套
"parent@version>package": "exact-version" 约定:
- webpack-dev-server 5.2.5→5.2.6、shell-quote→1.10.0、fast-uri→3.1.7、
  qs/body-parser→6.16.0/1.20.8,均在各自父包(webpack-dev-server、
  launch-editor、ajv、express)自身声明的兼容范围内,且都是 rspack 1.x
  全系列可达的版本,无需迁移到 rspack 2.x。
- 新增 @modelcontextprotocol/sdk>hono、eslint>@humanfs/node、
  minimatch>brace-expansion(webdav 与 crx/archiver 两条链路分别覆盖)、
  @babel/helper-compilation-targets>browserslist>baseline-browser-mapping
  的父版本精确覆盖项。
- 删除上个提交在 package.json 引入的 "pnpm.overrides" 块,避免与
  pnpm-workspace.yaml 的覆盖表并存造成后续维护混乱。
- concurrently 升至 10.0.5(仍在既有 ^10.0.3 range 内),其自带的
  shell-quote 依赖已原生修复,无需额外覆盖项。

所有候选版本均通过 minimumReleaseAge(7 日冷却期)校验。

pnpm audit: 0 critical / 0 high / 0 moderate / 0 low(先前提交后仍剩
1 moderate、7 high、1 low 均集中于 rspack dev-server 链路)。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@cyfung1031 cyfung1031 changed the title ⬆️ 升级依赖并修复 pnpm audit 安全警告 🔒 修复 pnpm audit 全部安全警告 Sep 20, 2026
@cyfung1031 cyfung1031 changed the title 🔒 修复 pnpm audit 全部安全警告 🔒 修复 pnpm audit 全部安全警告 (20260921) Sep 21, 2026
@cyfung1031 cyfung1031 added the P2 🐌 非重要也不紧急的内容 label Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 🐌 非重要也不紧急的内容

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant