fix(providers): preserve reply bytes and structured JSON ownership

Share strict UTF-8 JSON admission across bounded worker reports. Preserve IDA/JEB structured dictionaries through negotiated SDK validation and adapter decoding, retaining inherited tool validation and protocol handling.

Validated 240 tests, including real SDK/HTTP exchanges and firmware file reads; 83 host-specific cases skipped. Typecheck, lint, and discovery passed. Real-provider execution and modern MCP protocol behavior remain unverified.
This commit is contained in:
morluto committed 2026-10-26 17:52:32 +08:00
1 parent 721dd3d1aa
commit da526fc014
18 files changed
+508 -95

No files matched your search

+4 -1
View File
@@ -1,3 +1,4 @@
import { safeParseUtf8Json } from "../../domain/safeJson.js";
import {
AnalysisCleanupLease,
AnalysisCleanupLeaseGroup,
@@ -387,7 +388,9 @@ export class PwntoolsDecoder<
undefined,
this.#resources,
);
reply = replySchema.parse(JSON.parse(file.bytes.toString("utf8")));
const decoded = safeParseUtf8Json(file.bytes);
if (!decoded.ok) throw decoded.cause;
reply = replySchema.parse(decoded.value);
} catch (cause: unknown) {
if (
cause instanceof ArtifactReaderFailure &&
@@ -1,12 +1,13 @@
import { safeParseUtf8Json } from "../../domain/safeJson.js";
import { join } from "node:path";
import { readStableArtifact } from "../../artifacts/readStableArtifact.js";
import { OwnedCommandFailure } from "../../process/OwnedCommand.js";
import {
PWNTOOLS_MEMORY_FAILURE_EXIT,
PWNTOOLS_FILE_SIZE_FAILURE_EXIT,
PWNTOOLS_LIMITS,
} from "./PwntoolsRelease.js";
import { z } from "zod";
import { PWNTOOLS_LIMITS } from "./PwntoolsRelease.js";
import type { ArtifactResourceScope } from "../../artifacts/ArtifactResourceScope.js";
/** Actual limits reported by the owned bridge after lowering inherited soft limits. */
@@ -94,10 +95,10 @@ export const readPwntoolsFailureEvidence = async (
undefined,
resources,
);
const decoded = safeParseUtf8Json(reported.bytes);
if (!decoded.ok) throw decoded.cause;
limitReport = {
limits: pwntoolsResourceLimitsSchema.parse(
JSON.parse(reported.bytes.toString("utf8")),
),
limits: pwntoolsResourceLimitsSchema.parse(decoded.value),
failure: null,
};
} catch (reportFailure: unknown) {