Support Trusted Types (require-trusted-types-for 'script')
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 活跃
- 技术栈
- react, typescript
调研方向
Start with the shared policy helper in #24738 and trace its use from showReportDialog. Then inspect the Replay compression worker, Feedback form, lazyLoadIntegration, loader script, and error-page-embed.js paths named in the report. Done means the affected sinks work under require-trusted-types-for 'script', with the policy and CSP requirements documented.
由索引模型根据 Issue 内容生成。
描述
Problem Statement
Apps that enforce Trusted Types (Content-Security-Policy: require-trusted-types-for 'script') can't use several SDK features without a pass-through default policy, which disables Trusted Types for the whole page.
Repro: https://github.com/oioki/trusted-types-sentry-js-sdk. It's a minimal Vite + React app with @sentry/react 11.0.0 and no Trusted Types policies of its own, so every violation comes from the SDK.
| Sink | Where | Enforced result | Workaround |
|---|---|---|---|
new Worker(url) |
Replay compression worker | Caught; replay continues | useCompression: false (larger payloads) |
innerHTML |
Feedback form (dangerouslySetInnerHTML: logo, success icon, screenshot styles) |
Form doesn't render | showBranding: false covers the logo only |
script.src |
showReportDialog() |
Throws, no dialog | None |
innerHTML |
error-page-embed.js (served by Sentry) |
Blocked once the dialog loads | None |
script.src |
lazyLoadIntegration() |
Throws | None |
script.src |
Loader Script | Throws | None |
The workaround in #15913 (workerUrl) doesn't help: new Worker(url) requires a TrustedScriptURL for any string URL, not just blob: URLs, so a self-hosted worker still violates.
Teams with a strict CSP (enterprise, fintech, public sector, Angular and Lit users) currently have to choose between Sentry's Replay, Feedback and User Feedback dialog and enforcing Trusted Types. Teams in report-only rollout also get SDK noise in their violation reports, with no policy name they can allow.
Solution Brainstorm
- The SDK creates one named policy, e.g.
sentry-sdk, that validates rather than passes values through. It would allow only script URLs the SDK builds itself (DSN host plus the known paths, the CDN) and only static HTML. Apps allow it withtrusted-types sentry-sdk. - Remove the
innerHTMLuses in feedback by building the SVG and styles with DOM APIs. - Document the CSP needed (
trusted-types sentry-sdk, and'allow-duplicates'when more than one SDK copy is on the page).
Additional Context
#24738 is a first step: a shared sentry-sdk policy helper, used by showReportDialog.
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
- 主要语言
- TypeScript
- 星标
- 8.7k
- 派生
- 1.9k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 523
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/sentry-javascript 的其他 Issue
-
Next.js: basePath is concatenated onto absolute router.push hrefs, corrupting navigation transaction names可能已有人在做 @Lms24 于 3 天前认领。 未关闭Browser Bug Next.js Traces
难度 2/5 1-3 小时 新手友好度 75/100
getsentry/sentry-javascript#24672 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
javascript
难度 2/5 1-3 小时 新手友好度 75/100
getsentry/sentry-javascript#24200 · 2 条评论 ·
维护者通常 1 天内回复
-
javascript Task
难度 2/5 1-3 小时 新手友好度 82/100
getsentry/sentry-javascript#24134 · 1 条评论 ·
维护者通常 1 天内回复
-
Cloudflare Workers javascript Tests
难度 2/5 1-3 小时 新手友好度 78/100
getsentry/sentry-javascript#24051 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug Bun javascript
难度 2/5 1-3 小时 新手友好度 92/100
getsentry/sentry-javascript#24045 · 1 条评论 ·
维护者通常 1 天内回复
查看 getsentry/sentry-javascript 的全部 Issue
相似的 Issue
-
check:passed streams:add
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
Fission-AI/OpenSpec#1986 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
nestjs/docs.nestjs.com#3554 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
publicodes/publicodes#868 ·
-
namespace operations
难度 1/5 1 小时以内 新手友好度 78/100
EclipseFdn/open-vsx.org#13488 ·
维护者通常 2 天内回复