fix: bound trans stdout and sanitize win ps json

This commit is contained in:
Codex
2026-06-07 07:27:44 +00:00
parent 6144f159ce
commit 33ab2a79a5
5 changed files with 294 additions and 3 deletions
+11 -1
View File
@@ -8,6 +8,7 @@ import { summarizeMicroserviceHealthResponse, summarizeMicroserviceObservation,
import { parseNetworkPerfOptions, runNetworkPerf } from "./network-perf";
import {
buildWindowsPowerShellInvocation,
createSshStdoutForwarder,
formatSshFailureHint,
formatSshRuntimeTimeoutHint,
formatSshRuntimeTimingHint,
@@ -985,6 +986,10 @@ async function runRemoteSshWebSocket(
return await new Promise<number>((resolve) => {
const rawMode = parsed.remoteCommand === null && process.stdin.isTTY && typeof process.stdin.setRawMode === "function";
const stdoutForwarder = parsed.remoteCommand === null ? null : createSshStdoutForwarder({
invocation,
transport: "frontend-websocket",
});
let timedOut = false;
const openTimer = setTimeout(() => {
if (sessionReady || settled) return;
@@ -1068,7 +1073,12 @@ async function runRemoteSshWebSocket(
if (message.type === "ssh.data") {
const chunk = Buffer.from(String(message.data ?? ""), message.encoding === "base64" ? "base64" : "utf8");
if (message.stream === "stderr") process.stderr.write(chunk);
else process.stdout.write(chunk);
else if (stdoutForwarder === null) {
process.stdout.write(chunk);
} else {
const hint = stdoutForwarder.write(chunk);
if (hint !== null) process.stderr.write(hint);
}
return;
}
if (message.type === "ssh.error") {