Skip to content

fix: 修正 CodeQL js/redos 與 js/double-escaping 兩個真問題 - #12

Merged
SanHsien merged 4 commits into
mainfrom
claude/youthful-bell-8s7pmz
Oct 24, 2026
Merged

SanHsien merged 4 commits into
mainfrom
claude/youthful-bell-8s7pmz

Conversation

@SanHsien

@SanHsien SanHsien commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

修正

  1. packages/markup/src/syntax.ts:14(js/redos):REFERENCE 的字元類已含 .,X*(\.X*)* 會指數級回溯。改為 /^[A-Za-z_][A-Za-z0-9_.:-]*$/u。
    • 等價性:用字母表 A z _ 0 9 . : - ! 窮舉所有長度 ≤6 的字串(597,871 個)比對新舊兩式,0 筆不一致。
  2. packages/provider-hyperframes-local/src/sampling.ts:25(js/double-escaping):&amp; 改成最後還原,&amp;lt; 現在得到 &lt;,不再是 <。
  3. docs/fork/DECISIONS.md 加 2026-10-24 條目。CodeQL alert 編號在這個環境查不到(gh api .../code-scanning/alerts 回 403),條目裡註明待補。

測試

  • packages/markup/test/reference.test.ts:以原正則接受的語言(不用正則的逐字元判斷,避免測試本身再觸發 js/redos,見 99b4c4c)為對照,合法/不合法參考的結果不變(含長度 ≤4 的窮舉);"A.".repeat(30) + "!" 要在 50ms 內被拒絕。
  • packages/provider-hyperframes-local/test/sampling.test.ts:&amp;lt; 得 &lt;、&amp;amp; 得 &amp;,一般實體照常還原。
  • 拿掉修正後:ReDoS 測試失敗(rejecting 61 characters took 13027.5ms),解碼測試失敗(expected: 'a&lt;b'、actual: 'a<b')。

閘門(Linux 容器)

tests pass fail skipped
main(c261677) 1069 1049 0 20
本分支 1072 1052 0 20

pnpm install --frozen-lockfile --ignore-scripts、pnpm check 前後都通過。Windows 的 tools/dev_check.ps1 沒有在這裡跑。

🤖 Generated with Claude Code

https://claude.ai/code/session_01LzPwoJBKJ97mwPJq3Uohmv

… attributes

- markup: REFERENCE's character class already contains ".", so the
  trailing (\.X*)* group only added exponential backtracking. The
  simplified pattern accepts exactly the same strings (exhaustively
  checked for all strings up to length 6 over a small alphabet).
- provider-hyperframes-local: decode &amp; last so "&amp;lt;" yields
  "&lt;" instead of "<".
- Record both fixes in docs/fork/DECISIONS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LzPwoJBKJ97mwPJq3Uohmv
Copilot AI balanced review requested due to automatic review settings October 24, 2026 05:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T05:47:50.780993Z 99b4c4c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

claude and others added 3 commits October 24, 2026 05:47
The oracle regex in the test reintroduced the js/redos pattern that
CodeQL flags; check the same language character by character instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LzPwoJBKJ97mwPJq3Uohmv
@SanHsien
SanHsien merged commit e3d8363 into main Oct 24, 2026
5 checks passed
@SanHsien
SanHsien deleted the claude/youthful-bell-8s7pmz branch October 24, 2026 16:32
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.

4 participants