Skip to content

feat(drivers): deny list of request globs for web, Electron and proxies - #216

Open
cjber wants to merge 4 commits into
mainfrom
cb/request-deny
Open

cjber wants to merge 4 commits into
mainfrom
cb/request-deny

Conversation

@cjber

@cjber cjber commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor
flowchart LR
  cfg["app.connect.deny globs"] --> rule["denyRule (core): validated at config load"]
  rule --> dl["denyList (contract)"]
  dl --> pol["api request policy"]
  dl --> gb["guardBrowser: web, Electron requests and WebSockets"]
  dl --> px["read-only proxy: CLI, desktop, mobile requests and upgrades"]
  gb -->|match| ab["abort + WriteLog line with the glob"]
  px -->|match| f403["403 + WriteLog line with the glob"]
  ab --> ex["explorer sees it after its step, write-blocked event, run summary"]
  f403 --> ex
Loading

Why

A web or Electron review could start a payment the app guide forbids: in a Nebula Desktop review the explorer clicked the Billing page's top-up preset, which starts a Stripe checkout. The guide's never-do list is prose for the model, app.readOnly blocks every write the app needs, and app.connect.deny only reached the API request policy.

Scope

  • denyRule(glob) in @bugpatrol/core parses one [METHOD] /path glob; the config schema uses it, so a glob of another shape or with an empty segment (POST //billing/**) is rejected at load, before setup runs.
  • denyList(globs) in @bugpatrol/contract tests a request against the globs and names the matching one. It tests both the encoded and the decoded path, so a%2Fb cannot slip past a single-segment *. requestPolicy uses it, so there is one matcher.
  • Web and Electron: guardBrowser aborts a request whose method and path match a deny glob (on any host), refuses a WebSocket whose handshake matches (as a GET), and logs both with the glob; every other request, writes included, goes out unless app.readOnly is on. A web context blocks service workers whenever the guard is on, as read-only mode already did.
  • Read-only proxies (CLI, desktop, mobile): a matching request gets a 403, a matching upgrade is refused, and both are logged. The config rejects connect.deny on those platforms without app.readOnly.proxy, since Bugpatrol cannot see their requests otherwise.
  • readOnlyOptions(app) builds the options for both drivers and proxies. startApp creates one blocked-request log for a read-only or a deny-only run, so the run summary reports it and a driver recreated for review or retest keeps it.
  • Blocked lines read POST <url> at <time>: app.connect.deny has POST /billing/**; the explorer's tool output, the write-blocked event and the session summary (Bugpatrol blocked N request(s).) cover both read-only and deny blocks.
  • Docs: Deny list section in docs/configuration.md, schema comment, full-file example.

Electron launch/cdp diffs are kept off electron.ts entirely and to one comment line in web.ts, since #213 edits those files.

Verification

  • Each fix reproduced first: the browser, proxy, WebSocket, encoded-path, config-load and run-log tests fail on the code before the change and pass with it.
  • Focused: vitest run on policy, readonly, factory, load, lifecycle, read-only, native-readonly-events and readonly-routine-events tests: 53 passed.
  • tsc --build, biome on changed files, knip: clean. CI green on 6caabcf.

Reviews

Codex (gpt-reserve, xhigh) and Muse reviewed origin/main...HEAD blind, then exchanged exclusive findings once.

  • Fixed: WebSocket handshakes to a denied path bypassed both the browser guard and the proxy (both reviewers); deny-only runs had no shared blocked-request log (Muse; Codex confirmed fixed); globs were validated only after setup ran, and // typos never matched (Muse; Codex confirmed fixed); docs overstated API reporting (Codex; Muse confirmed); codex-connector: encoded path before decoding.
  • Documented, not fixed here: an Electron driver sees only its windows' requests after attach, so main-process, service-worker and pre-attach requests reach the backend (both reviewers, Codex adjusted to medium once documented). On CLI, desktop and mobile the proxy is always read-only, so the deny list adds to read-only mode there (Muse, Codex confirmed medium). Both need a proxy that is not read-only, which is a config design choice (where that proxy is configured), left for a follow-up.

Risks

  • A glob without a method blocks reads too, including page navigations and WebSockets to that path; this is the documented API semantics carried over.
  • Electron coverage is the renderer after attach, as above.

Closes #214

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bugpatrol Ready Ready Preview Nov 19, 2026 8:24pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T02:19:19.439997Z dd5b949 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Bugpatrol review: dashboard

No problem introduced · tested 60c2e7d against main 2c57911

Tested

  • Overview loads
  • Issue detail (Save button overlaps account text) loads

Not tested

  • The rest of the change: outside the dashboard

Updated on each push. Tests only what the diff can affect. Does not block the merge.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Bugpatrol review: fixture-app

No problem introduced · tested 60c2e7d against main 2c57911

Tested

  • Home (index.html) loads
  • Settings (/settings) loads via the Home link

Not tested

  • The rest of the change (deny list, request policy, drivers, proxies, docs): outside the fixture app

Updated on each push. Tests only what the diff can affect. Does not block the merge.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd5b949833

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/contract/src/policy.ts Resolved
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Bugpatrol review: cli

No problem introduced · tested 60c2e7d against main 2c57911

Tested

  • denyRule config validation: FETCH method, // segment, missing leading /, 3-word glob all rejected; lowercase method accepted
  • Platform gate: cli with deny but no proxy rejected with message; with proxy accepted; web/electron/api accepted
  • sweep --dry-run: denied endpoints skipped, reason 'app.connect.deny has POST /billing/**', skip counts right
  • Live sweep vs local server: denied endpoint never sent (server hit log); run summary 'Bugpatrol blocked 0 request(s) in this run'
  • Web replay with deny-only config: driver guard recreated, replay ran, new run-summary line shown
  • CLI readOnly.proxy + connect.deny config accepted (doctor)
  • Replay exit code 4 on fixture's pre-existing electron routine failure (recorded in fixture state)

Not tested

  • guardBrowser abort / WebSocket refusal at runtime (web, Electron): no Playwright browser or Electron binary in sandbox; PR vitest suite covers it
  • Proxy 403 and blocked-line format at runtime for deny matches: live CLI session not startable in fixture (routines resolve per profile); PR tests cover it
  • Encoded-path (%2F) matching and WebSocket handshake matching at runtime: needs driver/proxy runtime the sandbox lacks
  • write-blocked event and 'Bugpatrol blocked N request(s).' summary in a live session: fixture app makes no HTTP requests, so no block could occur in replay
  • Dashboard rendering of renamed blocked-request strings: outside the CLI; another job reviews it

Updated on each push. Tests only what the diff can affect. Does not block the merge.

@cjber

cjber commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex and Muse review of origin/main...HEAD, with one exchange of exclusive findings:

  • WebSocket handshake to a denied path passed the browser guard and the proxy (Codex major, Muse medium): fixed in 6caabcf, tests for both paths.
  • Deny-only runs had no shared blocked-request log (Muse low): fixed in 6caabcf; Codex confirmed in the exchange.
  • Invalid or // globs accepted until a driver was built (Muse low): fixed in 6caabcf, denyRule in core validates at config load; Codex confirmed.
  • Docs overstated API reporting (Codex minor, Muse confirmed): fixed in 6caabcf.
  • Electron main-process, service-worker and pre-attach requests are outside the CDP route (both; Codex medium after the docs change): documented in 6caabcf. Covering them needs a proxy that is not read-only.
  • On CLI, desktop and mobile the proxy is read-only, so the deny list adds to read-only mode (Muse medium, Codex confirmed): documented in 6caabcf and 0224bea; a deny-only proxy is the same follow-up design choice.

@joaquim-verges joaquim-verges added the mergepatrol Queue this PR: Mergepatrol rebases, tests and merges it label Nov 19, 2026 — with Nebula AI Agent
@merge-loop

merge-loop Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Getting ready to merge: MergeLoop settles any conflict and sees its checks pass, fixing them if it can. It keeps its place in the queue.

@merge-loop merge-loop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MergeLoop's review

The PR shares deny matching across policies, drivers and proxies and adds config validation and reporting. All required checks and 53 existing focused tests pass, but two reproduced browser bypasses still let denied requests reach the backend.

It sent 2 back to the author, each in a thread on its line. For each, fix it and push, or reply with why it doesn't apply, then resolve the thread. To have the agent look again before you push, reply in the thread with @merge-loop and why. Once every thread is resolved, the PR goes on to the merge queue with no human approval.

What it cleared
  • Config validation and request matching share the same glob parser (100%)
  • The proxy checks denied requests and upgrades before forwarding (100%)
  • Deny-only runs retain a shared blocked-request log (100%)

if (SAFE.has(request.method())) return route.continue();
options.log.record(request.method(), request.url());
const rule = options.deny?.(request.method(), request.url());
if (!rule && (options.allowWrites || SAFE.has(request.method()))) return route.continue();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent back to the author · f1 · other · 100% sure

Redirected requests bypass the browser deny list

Playwright invokes this route handler only for the first request in a redirect chain. An allowed POST to /start returning a 307 to /billing/checkout therefore reaches that backend endpoint despite POST /billing/** being denied, without recording a block. This shared guard affects both web and Electron.

Shows it: MergeLoop ran pnpm install --frozen-lockfile && pnpm build && npm install --prefix /tmp/bugpatrol-review-browser --no-save --no-package-lock @sparticuz/chromium@153.0.0 && node --input-type=module -e 'import Chromium, { inflate } from "/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/build/index.js"; await Chromium.executablePath(); await inflate("/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/bin/al2023.tar.br");' && LD_LIBRARY_PATH=/tmp/al2023/lib REVIEW_CHROMIUM=/tmp/chromium pnpm vitest run packages/drivers/src/deny-redirect.review.test.ts on 0224bea and it failed:

      Tests  1 failed (1)
   Start at  20:13:56
   Duration  2.53s (transform 479ms, setup 0ms, collect 1.46s, tests 528ms, environment 0ms, prepare 152ms)

$ tsc --build
�[33mThe CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.�[39m
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  packages/drivers/src/deny-redirect.review.test.ts > checks a deny glob again after a 307 redirect
AssertionError: expected [ 'GET /', 'POST /start', …(1) ] to not include 'POST /billing/checkout'
 ❯ packages/drivers/src/deny-redirect.review.test.ts:37:22
     35|     await page.evaluate(() => fetch('/start', { method: 'POST', body: …
     36|     expect(seen).toContain('POST /start');
     37|     expect(seen).not.toContain('POST /billing/checkout');
       |                      ^
     38|     expect(log.drain()).toEqual([expect.stringContaining('app.connect.…
     39|   } finally {

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
With the test it wrote, in packages/drivers/src/deny-redirect.review.test.ts
diff --git a/packages/drivers/src/deny-redirect.review.test.ts b/packages/drivers/src/deny-redirect.review.test.ts
new file mode 100644
index 0000000..ad9e7d5
--- /dev/null
+++ b/packages/drivers/src/deny-redirect.review.test.ts
@@ -0,0 +1,44 @@
+import { createServer } from 'node:http';
+import type { AddressInfo } from 'node:net';
+import { denyList } from '@bugpatrol/contract';
+import { chromium } from 'playwright';
+import { expect, it } from 'vitest';
+import { guardBrowser, WriteLog } from './readonly.js';
+
+it('checks a deny glob again after a 307 redirect', { timeout: 30_000 }, async () => {
+  const seen: string[] = [];
+  const server = createServer((request, response) => {
+    seen.push(`${request.method} ${request.url}`);
+    if (request.url === '/start') {
+      response.writeHead(307, { location: '/billing/checkout' });
+      response.end();
+    } else {
+      response.setHeader('content-type', 'text/html');
+      response.end('<title>App</title>');
+    }
+  });
+  await new Promise<void>((done) => server.listen(0, '127.0.0.1', done));
+  const origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
+  const browser = await chromium.launch({ headless: true, executablePath: process.env.REVIEW_CHROMIUM });
+  try {
+    const context = await browser.newContext();
+    const log = new WriteLog();
+    await guardBrowser(context, {
+      log,
+      allowWrites: true,
+      websockets: 'pass',
+      dropFrames: [],
+      deny: denyList(['POST /billing/**']),
+    });
+    const page = await context.newPage();
+    await page.goto(origin);
+    await page.evaluate(() => fetch('/start', { method: 'POST', body: 'checkout' }).catch(() => undefined));
+    expect(seen).toContain('POST /start');
+    expect(seen).not.toContain('POST /billing/checkout');
+    expect(log.drain()).toEqual([expect.stringContaining('app.connect.deny has POST /billing/**')]);
+  } finally {
+    await browser.close();
+    server.closeAllConnections();
+    await new Promise<void>((done) => server.close(() => done()));
+  }
+});

Change: Enforce the deny policy on every redirect hop and log a matching destination before aborting it.

Fix it and push, or reply with why it doesn't apply. Then resolve this thread.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still holds on 60c2e7d: This remains unfixed: route.continue() follows redirects without running this handler for subsequent hops. With POST /billing/** denied, an allowed POST /start returning a 307 to /billing/checkout sends the payment request to the backend without logging it; this affects the shared web and Electron guard.

Still at: packages/drivers/src/readonly.ts:88.

Shows it: MergeLoop ran pnpm install --frozen-lockfile && pnpm build && npm install --prefix /tmp/bugpatrol-review-browser --no-save --no-package-lock @sparticuz/chromium@153.0.0 && node --input-type=module -e 'import Chromium, { inflate } from "/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/build/index.js"; await Chromium.executablePath(); await inflate("/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/bin/al2023.tar.br");' && LD_LIBRARY_PATH=/tmp/al2023/lib REVIEW_CHROMIUM=/tmp/chromium pnpm vitest run packages/drivers/src/deny-redirect.review.test.ts on 60c2e7d and it failed:

AssertionError: expected [ Array(1) ] to deeply equal [ StringContaining{…}, …(1) ]

- Expected
+ Received

  Array [
    StringContaining "app.connect.deny has POST /billing/**",
-   StringMatching /POST .*\/billing\/checkout at .*: app.connect.deny has POST \/billing\/\*\*$/,
  ]

 ❯ packages/drivers/src/deny-redirect.review.test.ts:48:27
     46|       });
     47|       expect.soft(seen.filter((line) => line.includes('/billing/'))).t…
     48|       expect(log.drain()).toEqual([
       |                           ^
     49|         expect.stringContaining('app.connect.deny has POST /billing/**…
     50|         expect.stringMatching(/POST .*\/billing\/checkout at .*: app.c…

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/4]⎯
With the test it wrote, in packages/drivers/src/deny-redirect.review.test.ts
diff --git a/packages/drivers/src/deny-redirect.review.test.ts b/packages/drivers/src/deny-redirect.review.test.ts
new file mode 100644
index 0000000..02a9a40
--- /dev/null
+++ b/packages/drivers/src/deny-redirect.review.test.ts
@@ -0,0 +1,58 @@
+import { createServer } from 'node:http';
+import type { AddressInfo } from 'node:net';
+import { denyList } from '@bugpatrol/contract';
+import { chromium } from 'playwright';
+import { expect, it } from 'vitest';
+import { guardBrowser, WriteLog } from './readonly.js';
+
+it.each(['web', 'electron'] as const)(
+  '%s denies and logs a redirected POST before it reaches billing',
+  async (platform) => {
+    const seen: string[] = [];
+    const server = createServer((request, response) => {
+      seen.push(`${request.method} ${request.url}`);
+      if (request.url === '/start') {
+        response.writeHead(307, { location: '/billing/checkout' });
+        response.end();
+      } else {
+        response.setHeader('content-type', 'text/html');
+        response.end('<title>App</title>');
+      }
+    });
+    await new Promise<void>((done) => server.listen(0, '127.0.0.1', done));
+    const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
+    const browser = await chromium.launch({
+      headless: true,
+      executablePath: process.env.REVIEW_CHROMIUM,
+      args: ['--no-sandbox', '--disable-gpu'],
+    });
+    try {
+      const context = await browser.newContext({ serviceWorkers: 'block' });
+      const page = await context.newPage();
+      // Electron attaches to an already loaded renderer; web installs the guard first.
+      if (platform === 'electron') await page.goto(url);
+      const log = new WriteLog();
+      await guardBrowser(context, {
+        log,
+        allowWrites: true,
+        websockets: 'pass',
+        dropFrames: [],
+        deny: denyList(['POST /billing/**']),
+      });
+      if (platform === 'web') await page.goto(url);
+      await page.evaluate(async () => {
+        await fetch('/billing/direct', { method: 'POST' }).catch(() => undefined);
+        await fetch('/start', { method: 'POST', body: 'payment' }).catch(() => undefined);
+      });
+      expect.soft(seen.filter((line) => line.includes('/billing/'))).toEqual([]);
+      expect(log.drain()).toEqual([
+        expect.stringContaining('app.connect.deny has POST /billing/**'),
+        expect.stringMatching(/POST .*\/billing\/checkout at .*: app.connect.deny has POST \/billing\/\*\*$/),
+      ]);
+    } finally {
+      await browser.close();
+      server.closeAllConnections();
+      await new Promise<void>((done) => server.close(() => done()));
+    }
+  },
+);

Change: Enforce the deny policy before dispatching every redirect hop, logging a matching destination before aborting it.

Fix it and push, or reply with why it doesn't apply. Then resolve this thread.

await context.addInitScript(refuseWorkers);
const readOnlySockets = options.websockets === 'block' || options.dropFrames.length > 0;
if (!readOnlySockets && !options.deny) return;
if (readOnlySockets) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent back to the author · f2 · other · 100% sure

Workers can open WebSockets to denied paths

Deny-only options set websockets to pass with no frame filters, so this branch leaves workers enabled. WebSocket routing does not intercept worker sockets: a dedicated worker can open /billing/checkout despite /billing/** being denied, and the backend receives the handshake without a blocked-request log. The shared guard leaves this gap on web and Electron.

Shows it: MergeLoop ran pnpm install --frozen-lockfile && pnpm build && npm install --prefix /tmp/bugpatrol-review-browser --no-save --no-package-lock @sparticuz/chromium@153.0.0 && node --input-type=module -e 'import Chromium, { inflate } from "/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/build/index.js"; await Chromium.executablePath(); await inflate("/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/bin/al2023.tar.br");' && LD_LIBRARY_PATH=/tmp/al2023/lib REVIEW_CHROMIUM=/tmp/chromium pnpm vitest run packages/drivers/src/deny-worker-websocket.review.test.ts on 0224bea and it failed:

AssertionError: expected [ '/billing/checkout' ] to deeply equal []

- Expected
+ Received

- Array []
+ Array [
+   "/billing/checkout",
+ ]

 ❯ packages/drivers/src/deny-worker-websocket.review.test.ts:51:22
     49|       `${origin.replace('http:', 'ws:')}/billing/checkout`,
     50|     );
     51|     expect(upgrades).toEqual([]);
       |                      ^
     52|     expect(log.count).toBeGreaterThan(0);
     53|   } finally {

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
With the test it wrote, in packages/drivers/src/deny-worker-websocket.review.test.ts
diff --git a/packages/drivers/src/deny-worker-websocket.review.test.ts b/packages/drivers/src/deny-worker-websocket.review.test.ts
new file mode 100644
index 0000000..3b3862e
--- /dev/null
+++ b/packages/drivers/src/deny-worker-websocket.review.test.ts
@@ -0,0 +1,58 @@
+import { createServer } from 'node:http';
+import type { AddressInfo } from 'node:net';
+import { denyList } from '@bugpatrol/contract';
+import { chromium } from 'playwright';
+import { expect, it } from 'vitest';
+import { guardBrowser, WriteLog } from './readonly.js';
+
+it('holds back a denied WebSocket opened by a dedicated worker', { timeout: 30_000 }, async () => {
+  const upgrades: string[] = [];
+  const server = createServer((_request, response) => {
+    response.setHeader('content-type', 'text/html');
+    response.end('<title>Worker app</title>');
+  });
+  server.on('upgrade', (request, socket) => {
+    upgrades.push(request.url!);
+    socket.end('HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n');
+  });
+  await new Promise<void>((done) => server.listen(0, '127.0.0.1', done));
+  const origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
+  const browser = await chromium.launch({ headless: true, executablePath: process.env.REVIEW_CHROMIUM });
+  try {
+    const context = await browser.newContext({ serviceWorkers: 'block' });
+    const log = new WriteLog();
+    await guardBrowser(context, {
+      log,
+      allowWrites: true,
+      websockets: 'pass',
+      dropFrames: [],
+      deny: denyList(['/billing/**']),
+    });
+    const page = await context.newPage();
+    await page.goto(origin);
+    await page.evaluate(
+      async (url) => {
+        const source = `const socket = new WebSocket(${JSON.stringify(url)});
+        socket.onopen = socket.onerror = socket.onclose = () => postMessage('finished');`;
+        await new Promise<void>((done) => {
+          try {
+            const worker = new Worker(URL.createObjectURL(new Blob([source], { type: 'text/javascript' })));
+            worker.onmessage = () => {
+              worker.terminate();
+              done();
+            };
+          } catch {
+            done();
+          }
+        });
+      },
+      `${origin.replace('http:', 'ws:')}/billing/checkout`,
+    );
+    expect(upgrades).toEqual([]);
+    expect(log.count).toBeGreaterThan(0);
+  } finally {
+    await browser.close();
+    server.closeAllConnections();
+    await new Promise<void>((done) => server.close(() => done()));
+  }
+});

Change: Apply the deny policy to worker WebSockets, or prevent workers from bypassing it while reporting the restriction.

Fix it and push, or reply with why it doesn't apply. Then resolve this thread.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still holds on 60c2e7d: This remains unfixed: worker prevention is installed only for read-only WebSocket rules, while deny-only mode permits workers. Playwright WebSocket routing does not cover their sockets, so both dedicated and shared workers reach /billing/checkout despite GET /billing/** being denied, without recording a blocked request.

Still at: packages/drivers/src/readonly.ts:94.

Shows it: MergeLoop ran pnpm install --frozen-lockfile && pnpm build && npm install --prefix /tmp/bugpatrol-review-browser --no-save --no-package-lock @sparticuz/chromium@153.0.0 && node --input-type=module -e 'import Chromium, { inflate } from "/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/build/index.js"; await Chromium.executablePath(); await inflate("/tmp/bugpatrol-review-browser/node_modules/@sparticuz/chromium/bin/al2023.tar.br");' && LD_LIBRARY_PATH=/tmp/al2023/lib REVIEW_CHROMIUM=/tmp/chromium pnpm vitest run packages/drivers/src/deny-worker-websocket.review.test.ts on 60c2e7d and it failed:

     66|       }, kind);
     67|       expect.soft(upgrades).toEqual([]);
       |                             ^
     68|       expect(log.count).toBeGreaterThan(0);
     69|     } finally {

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/4]⎯

 FAIL  packages/drivers/src/deny-worker-websocket.review.test.ts > SharedWorker cannot open a denied WebSocket without a blocked log
AssertionError: expected 0 to be greater than 0
 ❯ packages/drivers/src/deny-worker-websocket.review.test.ts:68:25
     66|       }, kind);
     67|       expect.soft(upgrades).toEqual([]);
     68|       expect(log.count).toBeGreaterThan(0);
       |                         ^
     69|     } finally {
     70|       await browser.close();

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/4]⎯
With the test it wrote, in packages/drivers/src/deny-worker-websocket.review.test.ts
diff --git a/packages/drivers/src/deny-worker-websocket.review.test.ts b/packages/drivers/src/deny-worker-websocket.review.test.ts
new file mode 100644
index 0000000..61317a7
--- /dev/null
+++ b/packages/drivers/src/deny-worker-websocket.review.test.ts
@@ -0,0 +1,75 @@
+import { createServer } from 'node:http';
+import type { AddressInfo } from 'node:net';
+import { denyList } from '@bugpatrol/contract';
+import { chromium } from 'playwright';
+import { expect, it } from 'vitest';
+import { guardBrowser, WriteLog } from './readonly.js';
+
+it.each(['Worker', 'SharedWorker'] as const)(
+  '%s cannot open a denied WebSocket without a blocked log',
+  async (kind) => {
+    const upgrades: string[] = [];
+    const server = createServer((_request, response) => {
+      response.setHeader('content-type', 'text/html');
+      response.end('<title>App</title>');
+    });
+    server.on('upgrade', (request, socket) => {
+      upgrades.push(request.url ?? '');
+      socket.destroy();
+    });
+    await new Promise<void>((done) => server.listen(0, '127.0.0.1', done));
+    const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
+    const browser = await chromium.launch({
+      headless: true,
+      executablePath: process.env.REVIEW_CHROMIUM,
+      args: ['--no-sandbox', '--disable-gpu'],
+    });
+    try {
+      const context = await browser.newContext({ serviceWorkers: 'block' });
+      const log = new WriteLog();
+      await guardBrowser(context, {
+        log,
+        allowWrites: true,
+        websockets: 'pass',
+        dropFrames: [],
+        deny: denyList(['GET /billing/**']),
+      });
+      const page = await context.newPage();
+      await page.goto(url);
+      await page.evaluate(async (workerKind) => {
+        const ws = `ws://${location.host}/billing/checkout`;
+        const action = `const socket = new WebSocket(${JSON.stringify(ws)}); socket.onerror = () => port.postMessage('closed');`;
+        const source =
+          workerKind === 'Worker'
+            ? `const port = self; ${action}`
+            : `onconnect = (event) => { const port = event.ports[0]; ${action} };`;
+        const blob = URL.createObjectURL(new Blob([source], { type: 'text/javascript' }));
+        try {
+          if (workerKind === 'Worker') {
+            const worker = new Worker(blob);
+            await new Promise<void>((done) => {
+              worker.onmessage = () => done();
+            });
+            worker.terminate();
+          } else {
+            const worker = new SharedWorker(blob);
+            await new Promise<void>((done) => {
+              worker.port.onmessage = () => done();
+            });
+            worker.port.close();
+          }
+        } catch (error) {
+          if (!(error instanceof DOMException) || error.name !== 'SecurityError') throw error;
+        } finally {
+          URL.revokeObjectURL(blob);
+        }
+      }, kind);
+      expect.soft(upgrades).toEqual([]);
+      expect(log.count).toBeGreaterThan(0);
+    } finally {
+      await browser.close();
+      server.closeAllConnections();
+      await new Promise<void>((done) => server.close(() => done()));
+    }
+  },
+);

Change: Apply the deny policy to worker WebSockets, or prevent workers from bypassing it while logging the restriction.

Fix it and push, or reply with why it doesn't apply. Then resolve this thread.

merge-loop Bot and others added 4 commits November 19, 2026 20:23
app.connect.deny applied only to the API request policy, so a web or
Electron review could start a payment that the app guide forbids, and
app.readOnly blocks every write an app needs. The same globs now reach
the web and Electron drivers, which abort a matching request and log it
as blocked for the explorer while every other write goes out, and the
read-only proxies of CLI, desktop and mobile apps, which answer it with
a 403. One matcher, denyList, serves the policy, drivers and proxies.

Closes #214

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolved-by: mergeloop, claude (claude-opus-5-5)
Co-authored-by: Cillian Berragan <cillian@nebula.gg>
A server that splits the path before decoding reads /billing/session/a%2Fb
as one segment, so POST /billing/session/* must deny it. denyList now tests
both the encoded and the decoded path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cillian Berragan <cillian@nebula.gg>
…ig load

- A WebSocket handshake that a deny glob matches is refused, in the browser
  guard and in the read-only proxy, and logged with its glob.
- A deny-only run gets one blocked-request log, so app.stop() reports it and
  a driver recreated for review or retest keeps the same log.
- denyRule moves to core, so the config rejects a glob of another shape, or
  with an empty segment, at load instead of after setup ran.
- Docs: what an Electron driver does not see, the API path's reporting, and
  that a proxy's deny list adds to read-only mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cillian Berragan <cillian@nebula.gg>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cillian Berragan <cillian@nebula.gg>

@merge-loop merge-loop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MergeLoop's review

The PR extends deny rules across drivers and proxies with shared matching and reporting. All five required checks and 56 existing focused tests pass, but both previously reported browser bypasses remain reproducible.

It sent 2 back to the author, each in a thread on its line. For each, fix it and push, or reply with why it doesn't apply, then resolve the thread. To have the agent look again before you push, reply in the thread with @merge-loop and why. Once every thread is resolved, the PR goes on to the merge queue with no human approval.

What it cleared
  • Config validation and request matching share the deny rules (100%)
  • Proxy denials and shared logs preserve blocked-request reporting (100%)
  • All required verification checks pass (100%)

This branch was successfully deployed

1 active deployment
Preview — 60c2e7d3 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergepatrol Queue this PR: Mergepatrol rebases, tests and merges it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web and Electron have no deny list, so a review can start a payment the app guide forbids

2 participants