Skip to content

fix(deps): close the last high advisories, sanitize rich-text echo, env-scoped amap key - #15

Merged
Jerry-CodeHub merged 2 commits into
masterfrom
fix/deps-cleanup
Sep 23, 2026
Merged

Jerry-CodeHub merged 2 commits into
masterfrom
fix/deps-cleanup

Conversation

@Jerry-CodeHub

@Jerry-CodeHub Jerry-CodeHub commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

背景

审计 2026-09-22 M-9 + M-7 + M-6 + M-8 + L-4。审查时官方源 audit 为 14 条(2 high 均为构建期 image-size),另有数项遗留 medium。

改动与结果

依赖治理(M-9)

  • overrides:less@<4.9.1 → 4.9.1(4.9.1 起改用 probe-image-size,一次消掉仅存 2 条 high)、hono 刷新至 4.13.5、yaml 2.x 与 @hono/node-server 补覆盖
  • audit 结果:0 high / 4 moderate / 3 low,全部在 THIRD-PARTY-NOTICES「已知接受风险」登记并写明逐项理由(react-router 6.x 无补丁且本项目不可利用、uuid/decode-uri-component 触发条件不满足等)
  • ci.yml audit 步骤离开观察期:--prod --audit-level=high 阻断
  • notices 新增 @stagewise/toolbar(AGPL,umi 4.7 传递、未激活不分发无义务)备注:勿开启 umi stagewise 配置

富文本回显消毒(M-7)

  • dompurify 显式声明为直接依赖(此前仅 tinymce 传递依赖),回显前 DOMPurify.sanitize
  • headless 实测:向编辑器注入 <img onerror> 与 javascript: 链接,回显区均被剥除(<img src="x"><a>link</a>),零执行——此回显是下游「存库再展示」最易复制的模式,消毒即存储型 XSS 防线

高德 key 环境化(M-6)

  • AMAP_KEY / AMAP_SECURITY_CODE 经 define 注入;window._AMapSecurityConfig 在 loader 加载前设置;未配置保持组件库默认公共 key(注释与 README 说明申请路径与配额影响)

其他

  • lyrics.ts 文件头警告:xgplayer-music 的 Lyric 插件以零转义 innerHTML 渲染歌词,远程化 LRC 前必须逐行转义(M-8)
  • xgplayer 演示视频/海报 URL 定死 https://(协议相对在 http 源会降级明文;ffmpeg 不可用,自制媒体降级为定协议方案,L-4)
  • README 环境变量表补 AMAP 条目;.env.example 同步

验证

pnpm check 全绿;pnpm audit --prod high=0;主产线构建 + 浏览器消毒实测通过。

Summary by CodeRabbit

  • New Features

    • Added optional configuration for AMap API credentials, with fallback support when credentials are not provided.
    • Added documentation for configuring AMap credentials in deployments.
  • Bug Fixes

    • Improved rich-text rendering safety by sanitizing displayed editor content.
    • Updated media URLs to use secure HTTPS connections.
  • Security

    • Strengthened dependency auditing by enforcing checks for high-severity vulnerabilities.
    • Documented accepted third-party security risks and applied vulnerability updates.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f0a79143-ec5a-49ed-ae5f-b7d3d2eb1296

📥 Commits

Reviewing files that changed from the base of the PR and between 8832854 and 32a5a4f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • .env.example
  • .github/workflows/ci.yml
  • README.md
  • THIRD-PARTY-NOTICES.md
  • config/config.github.ts
  • config/config.ts
  • package.json
  • src/pages/Feature/AudioFeature/AudioPlayer/lyrics.ts
  • src/pages/Feature/Map/AutonaviMap/index.tsx
  • src/pages/Feature/RichTextEditing/index.tsx
  • src/pages/Feature/VideoPlayer/xgplayer/index.tsx
  • src/typings.d.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The pull request strengthens dependency auditing, sanitizes rich-text output, adds configurable AMap credentials, documents fallback settings, and changes video asset URLs to explicit HTTPS URLs.

Changes

Security and Runtime Updates

Layer / File(s) Summary
Dependency and content security
package.json, src/pages/Feature/RichTextEditing/index.tsx, src/pages/Feature/AudioFeature/AudioPlayer/lyrics.ts, .github/workflows/ci.yml, THIRD-PARTY-NOTICES.md
Adds DOMPurify, updates dependency overrides, enforces high-severity production audit failures, documents accepted advisories, and sanitizes editor content before rendering.
AMap credential configuration
src/typings.d.ts, config/config.ts, config/config.github.ts, .env.example, README.md, src/pages/Feature/Map/AutonaviMap/index.tsx
Passes optional AMap credentials from environment variables to the map component and sets the security code before asynchronous API loading. Documentation describes the public-key fallback.
Media URL hardening
src/pages/Feature/VideoPlayer/xgplayer/index.tsx
Replaces protocol-relative video and poster URLs with explicit HTTPS URLs.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Environment
  participant UmiConfig
  participant AutonaviMap
  participant AMapLoader
  Environment->>UmiConfig: Provide AMAP_KEY and AMAP_SECURITY_CODE
  UmiConfig->>AutonaviMap: Inject compile-time values
  AutonaviMap->>AutonaviMap: Set window._AMapSecurityConfig when configured
  AutonaviMap->>AMapLoader: Load the JS API with mapKey
Loading

Merge Risk: ⚪ Minimal · up to 32a5a

The security and configuration changes have no remaining concrete merge-blocking risk in the supplied evidence.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. (5 skipped: 5 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: dependency fixes, rich-text sanitization, and environment-scoped AMap credentials. It is specific and concise enough for the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

config/config.github.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

config/config.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

package.json

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

  • 5 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Deploying umi-react-admin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 32a5a4f
Status: ✅  Deploy successful!
Preview URL: https://d1168002.umi-react-admin.pages.dev
Branch Preview URL: https://fix-deps-cleanup.umi-react-admin.pages.dev

View logs

@Jerry-CodeHub
Jerry-CodeHub merged commit 4657f95 into master Sep 23, 2026
6 checks passed
@Jerry-CodeHub
Jerry-CodeHub deleted the fix/deps-cleanup branch September 23, 2026 02:35
…nv-scoped amap key

- overrides: less <4.9.1 (drops image-size, the only remaining high),
  hono refreshed to 4.13.5, yaml 2.x and @hono/node-server covered;
  audit now 0 high / 4 moderate / 3 low, all registered as accepted
  risks in THIRD-PARTY-NOTICES with per-item rationale
- ci audit step leaves observation mode: blocks on --audit-level=high
- dompurify declared as a direct dependency and wired into the
  rich-text echo; verified headless that onerror/javascript: injected
  into the editor are stripped from the rendered preview - the echo is
  the pattern downstream projects copy when they persist content
- amap key and security code move to AMAP_KEY/AMAP_SECURITY_CODE env
  defines (window._AMapSecurityConfig set before the loader fetches);
  unset keeps the loader's shared public key, README documents applying
  for a dedicated key
- lyrics.ts documents that xgplayer-music renders LRC lines via
  unescaped innerHTML: remote lyrics must be escaped upstream
- xgplayer demo media URLs pinned to https (protocol-relative would
  downgrade on http origins); notices gains the AGPL @stagewise/toolbar
  entry (inert unless umi stagewise is enabled)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant