Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Opt-out for the module-load eval probe (strict CSP reports a violation on import)

Đang mở Phù hợp với người mới
#3,276 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
70/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, typescript

Hướng nghiên cứu

Bắt đầu từ packages/typegpu/src/data/compiledIO.ts, nơi chứa probe EVAL_ALLOWED_IN_ENV chạy khi tải module. Đọc ba phương án opt-out được đề xuất trong issue và kiểm tra cách typegpu đã xử lý các tùy chọn root/init để chọn phương án phù hợp. Hoàn thành khi: import typegpu dưới script-src 'self' không tạo ra báo cáo securitypolicyviolation nào, và plain writer vẫn được dùng với cảnh báo hiện có khi eval không khả dụng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

packages/typegpu/src/data/compiledIO.ts probes for eval support when the module loads:

export const EVAL_ALLOWED_IN_ENV: boolean = (() => {
  try {
    new Function('return true');
    return true;
  } catch {
    return false;
  }
})();

Under a strict Content Security Policy without 'unsafe-eval', the try/catch keeps this from breaking anything: typegpu falls back to the plain writer, and since #2758/#2771 it warns once. But the browser still files a securitypolicyviolation (script-src, eval) the moment typegpu is imported, before any buffer is written.

Hosts that embed apps in sandboxed iframes with a strict CSP (MCP Apps / ChatGPT apps, browser extensions, enterprise pages with CSP reporting) treat any such report as a policy failure. An app that never wants compiled writers can't avoid the report today short of patching the package.

Request

An opt-out that skips the probe, so the plain writer is used without ever calling new Function. Any of these would work for us:

  • a global flag read before the probe, like zod's globalThis.__zod_globalConfig = { jitless: true };
  • a lazy probe that runs only the first time a compiled writer is actually requested, plus a root or init option to disable compiled writers;
  • a build-time define (TYPEGPU_NO_EVAL) that tree-shakes the probe.
Repro
  1. Serve a page with Content-Security-Policy: script-src 'self'.
  2. Add document.addEventListener('securitypolicyviolation', e => console.log(e.violatedDirective, e.blockedURI)).
  3. Import typegpu. One script-src / eval violation is logged at import, with no GPU work done.

Seen on typegpu 0.12.8. We currently carry a patch-package-style patch that hard-codes the plain writer and would drop it as soon as an opt-out exists. Thanks for TypeGPU!

Ngôn ngữ chính
TypeScript
Star
3.3k
Fork
141
Merge trung bình
3 ngày 8 giờ
Pull request đã merge (30 ngày)
72

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của software-mansion/TypeGPU

Tất cả issue của software-mansion/TypeGPU

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.