mirror of
https://github.com/morluto/rea
synced 2026-10-26 14:25:49 -04:00
bb154d1067
Inspect bounded offline aioquic1.5.0 JSON qlog0.3 and page retained event/transport facts with explicit trace and stream selectors. Preserve producer coordinates, exact numeric lexemes, global pre-selection fact scope and endpoint declaration uncertainty. Verified four real HTTP/3 recordings with an independent interval oracle, public CLI/MCP/schema parity, auth exclusions, source-deletion views and actual decoder heap exhaustion. Unverified producer platforms and qlog-specific lifecycle induction remain documented. Co-authored-by: LuisTaffelli <86675342+LuisTaffelli@users.noreply.github.com> Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com>
93 lines
3.0 KiB
TypeScript
93 lines
3.0 KiB
TypeScript
import { redactExplicitText } from "./explicitSensitiveValues.js";
|
|
import type { WebNetworkCapture } from "./webNetworkCapture.js";
|
|
|
|
/** Exclude marked source coordinates without inventing a substitute record identity. */
|
|
export const excludeCaptureCoordinates = (
|
|
value: WebNetworkCapture,
|
|
sensitiveValues: readonly string[],
|
|
): WebNetworkCapture => {
|
|
if (sensitiveValues.length === 0) return value;
|
|
let excluded = false;
|
|
const sensitive = (pointer: string): boolean =>
|
|
sensitiveValues.some((literal) => pointer.includes(literal));
|
|
const sidecars = <T extends { readonly pointer: string }>(
|
|
items: readonly T[],
|
|
): T[] =>
|
|
items.filter((item) => {
|
|
if (!sensitive(item.pointer)) return true;
|
|
excluded = true;
|
|
return false;
|
|
});
|
|
const records = value.records.map((record) => {
|
|
const location =
|
|
(record.location.kind === "json-pointer" &&
|
|
sensitive(record.location.pointer)) ||
|
|
(record.location.kind === "archive-members" &&
|
|
record.location.members.some(sensitive)) ||
|
|
(record.location.kind === "byte-range" &&
|
|
(sensitive(String(record.location.offset)) ||
|
|
sensitive(String(record.location.bytes))))
|
|
? {
|
|
kind: "unknown" as const,
|
|
reason: "explicit-sensitive-value" as const,
|
|
}
|
|
: record.location;
|
|
if (location !== record.location) excluded = true;
|
|
return {
|
|
...record,
|
|
location,
|
|
binary_fields: sidecars(record.binary_fields),
|
|
numeric_literals: sidecars(record.numeric_literals),
|
|
redactions: sidecars(record.redactions),
|
|
};
|
|
});
|
|
const recordsPointer = value.container.records_pointer;
|
|
const records_pointer =
|
|
recordsPointer !== null && sensitive(recordsPointer)
|
|
? null
|
|
: recordsPointer;
|
|
if (records_pointer !== recordsPointer) excluded = true;
|
|
const container = {
|
|
...value.container,
|
|
records_pointer,
|
|
numeric_literals: sidecars(value.container.numeric_literals),
|
|
redactions: sidecars(value.container.redactions),
|
|
};
|
|
const qlog =
|
|
value.format === "qlog"
|
|
? {
|
|
...value.qlog,
|
|
traces: value.qlog.traces.map((trace) => {
|
|
if (
|
|
trace.location.kind !== "json-pointer" ||
|
|
!sensitive(trace.location.pointer)
|
|
)
|
|
return trace;
|
|
excluded = true;
|
|
return {
|
|
...trace,
|
|
location: {
|
|
kind: "unknown" as const,
|
|
reason: "explicit-sensitive-value" as const,
|
|
},
|
|
};
|
|
}),
|
|
}
|
|
: undefined;
|
|
return {
|
|
...value,
|
|
...(qlog === undefined ? {} : { qlog }),
|
|
container,
|
|
records,
|
|
limitations: excluded
|
|
? [
|
|
...value.limitations,
|
|
redactExplicitText(
|
|
"Marked source coordinates and their sidecars are excluded; affected record locations remain unknown.",
|
|
sensitiveValues,
|
|
),
|
|
]
|
|
: value.limitations,
|
|
};
|
|
};
|