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

Aperta
#6,772 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
playwright, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TSQL
Stelle
32
Fork
7
Merge medio
1g 16h
PR unite (30g)
504

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MemberJunction/MJ

Tutte le issue di MemberJunction/MJ

Issue simili

Altre issue su DevOps

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.