Repository navigation
fix(server): allow Shiki WASM in CSP - #4435
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🦋 Changeset detectedLatest commit: a4377f0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
sailist
previously approved these changes
Oct 26, 2026
sailist
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
修复非回环 Kimi Web 页面中 Shiki 代码高亮因 WebAssembly 被 CSP 拦截而失效的问题。
Bug Reproduction Steps
kimi web,使页面带上服务端 CSP。WebAssembly.instantiate()被default-src 'self'拦截。Root Cause
Shiki 默认使用 Oniguruma 的 WASM 正则引擎。CSP 未声明
script-src,因此脚本策略回退到default-src 'self',不包含 WASM 编译所需的'wasm-unsafe-eval'。本次精确声明 WASM 权限,保留 JavaScripteval和 inline script 的禁止策略,是根本修复。Code Changes
'unsafe-eval'、'unsafe-inline'或其他脚本来源。securityHeaders、securityExposure和hostExposure.e2e的 CSP 契约。eval。Behavior Changes and Affected Users
127.0.0.1Web 用户验证:
securityHeaders.test.ts、securityExposure.test.ts、hostExposure.e2e.test.ts:3 个文件、17 条用例通过。pnpm --filter @moonshot-ai/kap-server run typecheck通过。HighlightedCode生产构建对照:修复前 0 个着色 token 并记录 WASMCompileError;修复后 47 个着色 token,WASM 错误消失。Checklist
gen-changesetsskill and included the approved patch changeset.gen-docsskill, or this PR needs no doc update. (No user documentation change required)Requested by qer via Mira.