Repository navigation
Conversation
inspect_web_network_capture validates request.url with ajv-formats' RFC 3986
`uri` format. Browsers serialize request URLs per WHATWG URL and leave
[ ] { } | ^ and backtick, a `%` that starts no escape, and a backslash in the
query or fragment unescaped, so a HAR that Chrome itself exports for such a
page was rejected whole as a format error.
- A request URL is admitted when the pinned RFC 3986 check accepts it as
written or with only those characters percent-encoded: each [ ] { } | ^ and
backtick, each `%` not followed by two hex digits, and each backslash after
the first `?` or `#`. Spellings that only WHATWG parsing accepts, such as a
backslash before the first `?` or `#` or a tab, stay rejected: browsers
never serialize them, and WHATWG alone reads an authority through them.
- The transport-credential header set moves unchanged from CaptureRedaction
to src/browser/network/TransportCredentials.ts; capture_browser_scenario's
network headers now use it instead of a private copy, and the session
HAR recorder in the next change applies the same set.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
observe_web_session can now record the selected page's in-scope HTTP requests and WebSocket connections across main-frame navigations as one HAR 1.2 log, so a user-driven multi-page flow can be inspected offline with inspect_web_network_capture. Recording is opt-in through a `network` selection (CLI: --network); without it the result and Evidence parameters are unchanged. - Requests, redirects and WebSocket handshakes use the timeline's origin boundary. Excluded traffic is counted in completeness. Recording stops right after the event that ends the timeline, so an out-of-scope document redirect still completes its in-scope hop. - Cross-site iframes that the browser runs out of process, and the page's dedicated, shared and service workers, are separate targets that are not attached, so their traffic is not recorded, and a dedicated worker's script request can appear without its response; a limitation, the tool description and the docs say so. - Without a network selection, the navigation-only limitation now says that network was not selected, rather than that the tool cannot capture headers, bodies or payloads. - Headers are retained only with `header_values`. Authorization, Proxy-Authorization, Cookie and Set-Cookie never are. URL-valued headers (Location, Content-Location, Referer, Origin, Link, Refresh) pointing outside the selected origins, or without a parseable target, are omitted, and userinfo in retained ones is removed; all are counted. Link targets, including `anchor` parameters, are read as RFC 8288 link-values; a Link that does not parse as one, has a `<` inside a target or an anchor value it cannot read is omitted. The Refresh delay is matched without backtracking, so a page-controlled digit run stays linear. A quoted Refresh URL whose quote appears again after its closing quote is omitted, since Chromium reads it to the last matching quote. - har_bytes reports the log's serialized size. REA does not check it against inspect_web_network_capture's 32 MiB input budget or 96 MiB reply limit, which a log dominated by WebSocket frames can exceed below 32 MiB; the tool description and docs say so. - Timings follow HAR 1.2 (non-negative send/wait/receive, time is their sum); a response still loading when recording stopped says so. A request that carried an unretained body reports bodySize -1. - coverage_started_at is taken once the browser has processed Network.enable, the earliest instant coverage is guaranteed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fba05f5e12
ℹ️ 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".
| const payload = cdpStringValue(response?.payloadData) ?? ""; | ||
| const opcode = Math.max(0, Math.trunc(numberValue(response?.opcode) ?? 0)); | ||
| const timestamp = numberValue(params?.timestamp); | ||
| socket.messages.push({ |
There was a problem hiding this comment.
Bound retained WebSocket frame metadata
When observe_web_session runs with network capture on a page that emits many WebSocket frames, especially with the uncapped observation_ms input, every event is appended here with no aggregate item or byte limit. A high-rate or long-lived socket can therefore grow memory without bound and the later HAR/Evidence serialization expands it again, potentially failing the observation instead of returning explicit truncated or resource-constraint completeness; enforce an aggregate budget before retaining each frame.
AGENTS.md reference: AGENTS.md:L46-L46
Useful? React with 👍 / 👎.
| return ( | ||
| rfc3986( | ||
| value.replace( | ||
| /[[\]{}|^`\\]|%(?![0-9A-Fa-f]{2})/gu, |
There was a problem hiding this comment.
Preserve IPv6 delimiters in the URI fallback
For a recorded request to a supported IPv6 origin with any character that triggers this fallback, such as http://[::1]/?q=% or http://[::1]/?filter[x]=1, the initial RFC check fails and this replacement percent-encodes the authority's structural [ and ] as well as the query character. The validator then checks an invalid host spelling such as http://%5B::1%5D/..., so a HAR that observe_web_session just produced cannot round-trip through inspect_web_network_capture; restrict bracket encoding so IP-literal delimiters are preserved.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
| return raws?.map(({ raw, start }) => ({ | ||
| raw, | ||
| start, | ||
| url: URL.canParse(raw, requestUrl) ? new URL(raw, requestUrl).href : raw, |
There was a problem hiding this comment.
Reject relative Origin header values
With header_values enabled, a server response can contain a malformed value such as Origin: not-a-url; resolving every URL-valued header against the request turns that into an in-scope path, so the raw malformed text is retained and the out-of-scope counter is unchanged even though unparseable Origin targets are supposed to be omitted. Origin permits an absolute serialized origin or null, so validate it as absolute instead of treating unresolved applicability as aligned with the request origin.
AGENTS.md reference: AGENTS.md:L19-L19
Useful? React with 👍 / 👎.
Summary
Refs #774 (batch 1, "Network transaction identity and selected content evidence").
observe_web_sessioncan now record the selected page's in-scope HTTP requests and WebSocket connections as one HAR 1.2 log, across main-frame navigations.inspect_web_network_capturecan then inspect that log offline.Recording is opt-in through
network(CLI--network, with--header-values). Without it, the result and the Evidence parameters are unchanged.Problem and expected behavior
inspect_web_pagefails closed withtarget_changedwhen the page navigates during its window, andobserve_web_sessionkeeps navigation metadata only. Login, checkout and other multi-page flows therefore had no network evidence. Withnetworkselected, the session result gainsnetwork.har: every in-scope request, redirect hop, failure, WebSocket handshake and frame, with completeness and limitations reported.Change and scope
CdpSessionNetworkrecords requests, redirect hops, failures, WebSocket handshakes and frames. CDP reports a hop's response together with the next request. Entries are keyed by target and request ID.header_values:Authorization,Proxy-Authorization,CookieandSet-Cookienever are, by the shared rules from fix(browser): admit browser-serialized HAR request URLs #2044.Location,Content-Location,Referer,Origin,LinkandRefresh. One that points outside the selected origins, or whose target cannot be parsed, is omitted and counted.Linkis read as RFC 8288 link-values, includinganchorparameters. A Link is omitted when it does not parse, has a<inside a target, or has an anchor value REA cannot read.Refreshfollows the HTML declarative-refresh steps, with or withouturl=. Its delay is matched without backtracking. A quoted URL whose quote appears again after its closing quote is omitted, because Chromium reads to the last matching quote.src/domain/recordedTransportUrl.ts, the repository's transport-URL parser, and cut at its parsed offset only when the cut leaves exactly the same target. A spelling the parser reads as ambiguous, such ashttp:user:pass@host/, or a cut that would change the target, omits the header.send,waitandreceiveare non-negative, andtimeis their sum;bodySize-1.coverage_started_atis taken once the browser has processedNetwork.enable.har_bytesreports the log's size. This PR does not check it againstinspect_web_network_capture's limits; feat(browser): retain selected bodies and payloads in session HAR #2047 adds the input-budget limitation. The decoder's 96 MiB reply limit is documented, not estimated: a log dominated by WebSocket frames can exceed it below 32 MiB.network, the navigation-only limitation says network was not selected.Contract and boundary impact
src/browser/CdpSessionNetwork.ts(recorder) andsrc/browser/CdpSessionHar.ts(projection).networkinput and anetworkoutput, plus one new contract example.inspect_web_network_capture.observe_web_sessionEvidence parameters gainnetworkonly when it is selected.Network.enableon the page session, which was already sent.docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
tests/boundary/browser/cdpObservationSessionNetwork.test.tscovers:RefererandOrigin, bare and malformedLink, quoted<and quoted-pairs,anchorparams, aRefreshwith and withouturl=, scheme-relative and backslash userinfo, a backslash retarget, two credentialed targets in one header, and a 200,000-digitRefreshdelay;%and a query backslash, accepted by the decoder;--networkalone keeping every header out, and MCP Evidence:browserCli.test.tsandbrowserMcp.test.ts.loadingFinishedon the iframe's own target, so with the iframe's origin selected that entry says it had not finished loading.For evidence-bearing changes:
Validation performed
Host: macOS 27.0.1, Node 24.20.0, Chrome 154 (headless, isolated profile).
turbo run typecheck lint format:check knip metadata:check docs:check:built mcp-catalog:check:built,npm run verify:architecture-guards,npm run verify:test-discoveryandnpx jscpd src/ tests/all pass.npx vitest runon 11 browser, CLI, MCP and process boundary files: 74 passed, 2 skipped.exposes CLI-equivalent Evidence results and session tools, an existing MCP test, times out only under heavy machine load. It fails the same way on unmodifiedmain.Compatibility, safety, and release
🤖 Generated with Claude Code