refactor(browser): clarify inspector capture identifiers

This commit is contained in:
morluto
2026-07-24 13:34:07 +00:00
parent fd25a7e15a
commit ca035a75eb
3 changed files with 17 additions and 12 deletions
+8 -5
View File
@@ -16,14 +16,17 @@ type ExclusionReason =
| "unsupported_location"; | "unsupported_location";
/** Empty durable-location exclusion counters. */ /** Empty durable-location exclusion counters. */
export const v8ExclusionCounts = (): Record<ExclusionReason, number> => ({ export const createInspectorExclusionCounts = (): Record<
ExclusionReason,
number
> => ({
outside_file_roots: 0, outside_file_roots: 0,
outside_origins: 0, outside_origins: 0,
unsupported_location: 0, unsupported_location: 0,
}); });
/** Stable safety and protocol limitations shared by target-list Evidence. */ /** Stable safety and protocol limitations shared by target-list Evidence. */
export const v8TargetLimitations = (): string[] => [ export const describeInspectorTargetLimitations = (): string[] => [
"REA attaches to an already-running exact target and never launches, resumes, evaluates, pauses, or mutates it.", "REA attaches to an already-running exact target and never launches, resumes, evaluates, pauses, or mutates it.",
"Only Runtime.enable and Debugger.enable are sent; source text, object values, EventEmitter activity, and Electron IPC are not inspected.", "Only Runtime.enable and Debugger.enable are sent; source text, object values, EventEmitter activity, and Electron IPC are not inspected.",
"Target IDs and locations are authorized, but the Inspector protocol does not authenticate an operating-system process ID or Electron role.", "Target IDs and locations are authorized, but the Inspector protocol does not authenticate an operating-system process ID or Electron role.",
@@ -39,14 +42,14 @@ interface FinalizeCaptureInput {
} }
/** Canonically authorize, deduplicate, and sort one bounded raw capture. */ /** Canonically authorize, deduplicate, and sort one bounded raw capture. */
export const finalizeV8InspectorCapture = async ({ export const finalizeInspectorCapture = async ({
input, input,
runtime, runtime,
target, target,
roots, roots,
state, state,
}: FinalizeCaptureInput): Promise<JavaScriptRuntimeObservation> => { }: FinalizeCaptureInput): Promise<JavaScriptRuntimeObservation> => {
const exclusions = v8ExclusionCounts(); const exclusions = createInspectorExclusionCounts();
const scripts = new Map< const scripts = new Map<
string, string,
JavaScriptRuntimeObservation["scripts"]["items"][number] JavaScriptRuntimeObservation["scripts"]["items"][number]
@@ -119,7 +122,7 @@ export const finalizeV8InspectorCapture = async ({
"A bounded observation window cannot establish that an unobserved script or behavior never occurs.", "A bounded observation window cannot establish that an unobserved script or behavior never occurs.",
"The declared Node/Electron process role is not authenticated by the Inspector protocol.", "The declared Node/Electron process role is not authenticated by the Inspector protocol.",
], ],
limitations: v8TargetLimitations(), limitations: describeInspectorTargetLimitations(),
}; };
}; };
+6 -6
View File
@@ -31,9 +31,9 @@ import {
canonicalRuntimeRoots, canonicalRuntimeRoots,
} from "./JavaScriptRuntimeScope.js"; } from "./JavaScriptRuntimeScope.js";
import { import {
finalizeV8InspectorCapture, createInspectorExclusionCounts,
v8ExclusionCounts, describeInspectorTargetLimitations,
v8TargetLimitations, finalizeInspectorCapture,
} from "./V8InspectorCaptureProjection.js"; } from "./V8InspectorCaptureProjection.js";
import { import {
discoverV8Inspector, discoverV8Inspector,
@@ -93,7 +93,7 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
options.signal, options.signal,
); );
const allowed: AuthorizedV8InspectorTarget[] = []; const allowed: AuthorizedV8InspectorTarget[] = [];
const excluded = v8ExclusionCounts(); const excluded = createInspectorExclusionCounts();
for (const target of discovery.targets) { for (const target of discovery.targets) {
const decision = await authorizeRuntimeLocation( const decision = await authorizeRuntimeLocation(
target.url, target.url,
@@ -128,7 +128,7 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
has_more: nextOffset < allowed.length, has_more: nextOffset < allowed.length,
}, },
excluded: { ...excluded, unconnectable: 0 }, excluded: { ...excluded, unconnectable: 0 },
limitations: v8TargetLimitations(), limitations: describeInspectorTargetLimitations(),
}), }),
); );
} catch (cause: unknown) { } catch (cause: unknown) {
@@ -166,7 +166,7 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
} finally { } finally {
removeListener(); removeListener();
} }
const result = await finalizeV8InspectorCapture({ const result = await finalizeInspectorCapture({
input, input,
runtime: discovery.runtime, runtime: discovery.runtime,
target, target,
+3 -1
View File
@@ -256,8 +256,10 @@ describe("browserScenarioSchema", () => {
}); });
it("rejects embedded URL credentials and query values", () => { it("rejects embedded URL credentials and query values", () => {
const credentialedUrl = new URL("https://app.example.test/");
credentialedUrl.username = String.fromCodePoint(120);
for (const url of [ for (const url of [
"https://user@app.example.test/", credentialedUrl.href,
"https://app.example.test/?token=raw", "https://app.example.test/?token=raw",
]) { ]) {
const scenario = baseScenario(); const scenario = baseScenario();