react-test-harness: network allowlist follow-ups from #6758

Đang mở
#6,772 0 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 1 ngày

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
playwright, typescript
Lĩnh vực
ci-cd, security, testing

Hướng nghiên cứu

Start in packages/React/test-harness, reading component-runner.ts, network-guard.integration.test.ts, and connect.integration.test.ts; first check how ComponentRunner derives declared libraries and how the integration suites are gated by RUN_BROWSER_INTEGRATION=1. The issue describes four separate follow-ups, from allowlist tests to CI and attached-browser handling, so choose one and confirm its scope with maintainers. Done means the selected behavior has a focused test or CI job that covers the case described.

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

Mô tả

Follow-ups from #6758, which added a network allowlist and an allowlisting proxy to @memberjunction/react-test-harness. Reviewers raised these as non-blocking, and they were split out of that PR.

1. Allow only the libraries a component declares

ComponentRunner allows the origin of every registered Component Library (CDNUrl, CDNCssUrl) on every page, whatever libraries the component under test declares. Not every one of those origins is a static CDN: at least one is an authenticated API host. A component can therefore send requests to any registered library's origin.

Proposed: build the allowlist from the component's declared libraries, including those of its child components, plus the core runtime. Check that the runtime's ComponentCompiler never needs an undeclared library before narrowing.

2. Pin the AllowNetworkUrls calls in ComponentRunner

Removing either AllowNetworkUrls(...) call in component-runner.ts passes every test: the library URLs in ExecuteComponent, and the core runtime URLs in loadRuntimeLibraries. The failure mode is fail-closed (every component run fails to load React or its libraries), but nothing catches it.

Proposed: a test that runs ComponentRunner with a mocked BrowserManager and asserts both calls are made with the expected URLs, fallback CDN URLs included.

3. WebRTC over UDP in attached browsers

When the harness launches the browser, it passes flags (BROWSER_LAUNCH_ARGS) that keep WebRTC on the allowlisting proxy and turn its UDP off. An attached browser (connect / MJ_REACT_TEST_HARNESS_CONNECT) keeps the flags it was started with. There, only the init script that removes the WebRTC constructors stands in the way of UDP STUN/TURN traffic, and a script can be raced. TCP is still refused at the proxy.

Options: document the flags an attached browser must be started with and warn when they can't be confirmed, or refuse allowlist mode on an attached browser unless the caller confirms the flags.

4. Run the real-browser suite in CI

network-guard.integration.test.ts (and connect.integration.test.ts) run only with RUN_BROWSER_INTEGRATION=1, so CI runs none of them. They are the only tests that prove the guard in a real browser. The proxy's socket-level tests (network-proxy.test.ts) do run in CI.

Proposed: a CI job that installs Playwright's Chromium and runs these suites, at least when packages/React/test-harness changes.

Package: packages/React/test-harness.

🤖 Generated with Claude Code

Ngôn ngữ chính
TSQL
Star
32
Fork
7
Merge trung bình
1 ngày 16 giờ
Pull request đã merge (30 ngày)
504

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 MemberJunction/MJ

Tất cả issue của MemberJunction/MJ

Issue tương tự

Thêm issue về DevOps

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.