Files
beads-group/docs/dependency-report.md

40 lines
3.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 小程序依赖审计与修复
2026-10-03:仅修改 `perler-beads-applet/package.json` / `package-lock.json`,没有修改业务源码或配置。
## 官方版本核查
npm 官方注册表的 `@dcloudio/vite-plugin-uni` 最新稳定匹配套件为 `3.0.0-5020620260917001`(版本日期 2026-09-17),已统一更新 uni-app、uni-components、uni-h5、uni-mp-weixin、vite-plugin-uni、uni-cli-shared 六个直接依赖。npm `vue3` 标签实际是 `3.0.0-alpha-5030120260930001`,未采用 alpha;`latest` 标签也是旧 alpha,不能直接作为稳定选型依据。
当前稳定 uni 插件仍声明精确 peer Vite 5.2.8。通过 package overrides 显式采用同主版本 Vite 5.4.21,未使用忽略 peer 的强制安装,也未跨主版本替换 uni/Vite。保持 Vue 3.4.38 与现有工具链一致。
## 已修复的依赖链
覆盖依赖固定版本:Vite 5.4.21、ws 8.22.0、jpeg-js 0.4.4、PostCSS 8.5.28、postcss-selector-parser 6.1.4、Express 4.22.3、adm-zip 0.6.1、phin 3.7.1、Babel core 7.29.7,以及 intlify 9.14.5 的 core-base/shared/message-compiler/message-resolver/vue-devtools。同主版本升级;adm-zip/jpeg-js 属 0.x 补丁套件,其使用由生产构建验证。没有接受 `npm audit fix --force` 建议的 DCloud 0.x 降级。
清除了旧 i18n 原型污染/XSS、ws 内存泄漏/DoS、JPEG 解码无限循环、PostCSS 源映射读文件/输出 XSS、ZIP 解压相关问题以及 Express 路由链问题;Vite 5 的历史漏洞大部分修复。
最后一次 `npm audit --json`:24 项(9 high、15 moderate、0 critical、0 low)。审计统计包含传播至 DCloud 上层包的重复节点,不等于 24 个独立攻击入口。安装时统计曾为 22 项,最终以上述显式重新审计结果为准。原始报告约 45 项 / 20 high,明显降低但没有达到零风险。
## 残留与实际可达性
- **braces 3.0.3(high)**:npm 官方已发布最新仍为 3.0.3,审计范围 `<=3.0.3`,没有可选修复版本。传播经过 micromatch→fast-glob、chokidar、unimport→DCloud。实际使用用于源码/目录 glob 和本地文件监听;项目没有把顾客输入交给这些 Node glob API。构建开发工具在不可信源码或极深 glob 输入下仍可能被耗尽栈。不能把它简单报告成“已修复”;待上游发布补丁。
- **Vite 5.4.21(high)**:残留优化依赖 `.map` 路径穿越,以及 Windows UNC/替代路径相关开发服务器漏洞。DCloud CLI `dist/cli/server.js` 明确调用 Vite createServer,因此 dev:h5 使用时实际可达。监听 127.0.0.1 限制远程直接访问,但不是对恶意页面/开发请求的完整免疫。生产交付是静态 H5 文件/微信构建,不运行 Vite 开发服务;不应将 dev:h5 暴露公网或用作生产服务。真正彻底修复需要上游支持新版 Vite,未经确认不强制跨主版本覆盖。
- **esbuild 0.20.2(moderate)**:残留为 esbuild 内置开发服务器跨来源请求问题。DCloud `uni-cli-shared/dist/esbuild.js` 使用 esbuild.build;检查未发现项目调用 esbuild.serve。Vite 工具链也持有 esbuild,但本次生产构建不运行其内置服务。保留上游版本,避免未经兼容验证的 0.x 次版本强制升级。
这些依赖仍由 uni 包传递,`npm audit --omit=dev` 不能简单证明产物安全;应按具体 Node API 与生产打包内容判断。未声称实际扫描微信运行时或完整源到汇的数据流。
## 验证
依赖安装成功。实际执行通过:
```sh
npm test # 当前 12 项测试
npm run typecheck
npm run build:h5 # Compiler 5.26
npm run build:mp-weixin # Compiler 5.26
npm audit --json --cache /tmp/perler-npm-cache
```
审计仍返回非零结果为上述残留;测试与构建通过不等价于清除这些风险。业务源代码当时由根任务继续修改,最终交付前根任务应在最终源码快照重跑。