mirror of
https://github.com/morluto/rea.git
synced 2026-11-06 14:56:32 +00:00
Give Ghidra and Hopper an 8 MiB aggregate retained-output budget while continuing to drain their process pipes. Expose total observed bytes at the supervisor boundary and retained bytes plus explicit truncation in provider diagnostics. Redact known transport tokens even when the retained prefix ends inside one, preserving adjacent caller path/query evidence. Existing partial-launch and cleanup ownership remain intact. Validation: 285 tests across 34 focused suites passed; the final cutoff-fixture refinement passed all 31 Ghidra/Hopper diagnostic tests. check:fast and architecture guards passed. Provider fixtures use real child processes; real Ghidra/Hopper applications were not verified.
32 lines
991 B
TypeScript
32 lines
991 B
TypeScript
import type { ProviderProcessSnapshot } from "./ProviderProcess.js";
|
|
|
|
/** Redact explicit transport credentials from complete and budget-cut output. */
|
|
export const redactCapturedTransportCredential = (
|
|
stream: Pick<
|
|
ProviderProcessSnapshot["stdout"],
|
|
"text" | "bytes" | "observedBytes"
|
|
>,
|
|
token: string | undefined,
|
|
replacement: string,
|
|
): string => {
|
|
if (token === undefined || token.length === 0) return stream.text;
|
|
|
|
const { text } = stream;
|
|
const cutOff = stream.observedBytes > stream.bytes;
|
|
if (cutOff && !text.endsWith(token)) {
|
|
const maximumPrefixLength = Math.min(text.length, token.length - 1);
|
|
for (
|
|
let prefixLength = maximumPrefixLength;
|
|
prefixLength > 0;
|
|
prefixLength -= 1
|
|
) {
|
|
if (text.endsWith(token.slice(0, prefixLength)))
|
|
return `${text
|
|
.slice(0, text.length - prefixLength)
|
|
.replaceAll(token, replacement)}${replacement}`;
|
|
}
|
|
}
|
|
|
|
return text.replaceAll(token, replacement);
|
|
};
|