Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(artifacts): preserve input size refusals and recovery
morluto8451d283920e
diff --git a/docs/go-binaries.md b/docs/go-binaries.mdindex 6088141c5..038eff78d 100644--- a/docs/go-binaries.md+++ b/docs/go-binaries.md@@ -91,6 +91,10 @@ host permission denial, changed artifacts and cancellation retain distincterrors. The selected file is never modified; this inspection creates notemporary files, starts no subprocesses and accesses no network endpoint.+An input above 256 MiB returns `resource_constraint` with resource `file-size`+and `reported_limits.maximum_input_bytes`. Select a suitable input within that+fixed allowance; changing an output-write or transport budget does not admit it.+Resource guards bound the selected file and cumulative header searches to 256 MiBeach, aggregate embedded stringsto 1 MiB, structural table decoding to 16 MiB and the complete normalized metadatadiff --git a/docs/wasm-artifacts.md b/docs/wasm-artifacts.mdindex 12d4da85b..7093df0a0 100644--- a/docs/wasm-artifacts.md+++ b/docs/wasm-artifacts.md@@ -46,7 +46,10 @@ Equivalent MCP input:```Each selected regular file is read through the existing stable artifact reader;-symlinks, changing files and files over 8 MiB fail closed. WASM bytes are copied+symlinks, changing files and files over 8 MiB fail closed. An oversized input+returns `resource_constraint` with resource `file-size` and its fixed byte+allowance in `reported_limits.maximum_input_bytes`; retrying the unchanged file+does not raise that allowance. WASM bytes are copiedinto a private workspace as read-only `module.wasm`; its digest is recheckedbefore and after each tool. WABT validates with `--enable-all`,reports sections through `wasm-objdump -h -x`, and decodes throughdiff --git a/src/go/GoBinaryProvider.ts b/src/go/GoBinaryProvider.tsindex efc2f21dd..0703bf590 100644--- a/src/go/GoBinaryProvider.ts+++ b/src/go/GoBinaryProvider.ts@@ -83,7 +83,11 @@ const failureForPrimary = (cause: unknown, path: string): AnalysisError => {"file-size",cause.message,{ maximum_input_bytes: INPUT_BYTES },- { cause },+ {+ cause,+ remediationAction:+ "Select a suitable stable artifact within the reported input byte allowance. Do not truncate required bytes; retrying the unchanged oversized input will fail again.",+ },);if (cause.reason === "path")return new AnalysisInputError(OPERATION, { cause }, [diff --git a/src/wasm/WabtFailures.test.ts b/src/wasm/WabtFailures.test.tsnew file mode 100644index 000000000..e7c8b09cd--- /dev/null+++ b/src/wasm/WabtFailures.test.ts@@ -0,0 +1,54 @@+import { expect, it } from "vitest";+import { ArtifactReaderFailure } from "../artifacts/ArtifactReader.js";+import { projectAnalysisError } from "../domain/analysisErrorProjection.js";+import { wabtFailure } from "./WabtFailures.js";+import { WABT_LIMITS } from "./WabtRelease.js";++it.each([false, true])(+ "preserves the file-size boundary with cleanup=%s when an input exceeds its fixed allowance",+ (cleanup) => {+ const cause = new ArtifactReaderFailure(+ "limit",+ "Selected artifact exceeds its byte allowance",+ {+ boundary: "file-size",+ ...(cleanup+ ? {+ cleanup: { reason: "close denied", resources: ["selected.wasm"] },+ }+ : {}),+ },+ );+ const projected = projectAnalysisError(+ wabtFailure(cause, "artifact", "selected.wasm"),+ );+ expect(projected).toMatchObject({+ code: cleanup ? "cleanup_incomplete" : "resource_constraint",+ category: "resource_constraint",+ retryable: false,+ details: {+ resource: "file-size",+ reported_limits: { maximum_input_bytes: WABT_LIMITS.inputBytes },+ },+ });+ if (!cleanup) {+ expect(projected.remediation.action).toContain("input byte allowance");+ expect(projected.remediation.action).not.toContain("evidence reply");+ }+ expect(+ wabtFailure(cause, "artifact", "selected.wasm").cleanupResources,+ ).toEqual(cleanup ? ["selected.wasm"] : []);+ },+);++it("keeps oversized tool admission distinct from selected artifact size", () => {+ const cause = new ArtifactReaderFailure(+ "limit",+ "Configured tool exceeds its byte allowance",+ { boundary: "file-size" },+ );+ expect(+ projectAnalysisError(wabtFailure(cause, "configuration", "selected.wasm"))+ .code,+ ).toBe("capability_unavailable");+});diff --git a/src/wasm/WabtFailures.ts b/src/wasm/WabtFailures.tsindex 54ee98d79..e737163c7 100644--- a/src/wasm/WabtFailures.ts+++ b/src/wasm/WabtFailures.ts@@ -139,6 +139,25 @@ export const wabtFailure = (userMessage: `${reason} Supply WABT 1.0.42 via absolute REA_WABT_BIN_DIRECTORY; REA does not install tools.`,},);+ if (+ phase === "artifact" &&+ cause instanceof ArtifactReaderFailure &&+ cause.reason === "limit" &&+ cause.boundary === "file-size"+ )+ return new AnalysisResourceConstraintError(+ "inspect_wasm_artifact",+ "file-size",+ reason,+ { maximum_input_bytes: WABT_LIMITS.inputBytes },+ {+ cause,+ ...cleanupOptions,+ retryable: false,+ remediationAction:+ "Select a suitable stable artifact within the reported input byte allowance. Do not truncate required bytes; retrying the unchanged oversized input will fail again.",+ },+ );if (phase === "artifact" &&cause instanceof ArtifactReaderFailure &&diff --git a/tests/boundary/cli/artifactInputLimits.test.ts b/tests/boundary/cli/artifactInputLimits.test.tsnew file mode 100644index 000000000..2a98ec044--- /dev/null+++ b/tests/boundary/cli/artifactInputLimits.test.ts@@ -0,0 +1,58 @@+import { mkdir, open, writeFile } from "node:fs/promises";+import { join } from "node:path";+import { expect } from "vitest";+import { z } from "zod";+import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";+import { cliTest } from "../../support/cli/cliFixture.js";++for (const { command, limit } of [+ { command: "inspect-go-binary", limit: 256 * 1024 * 1024 },+ { command: "inspect-wasm-artifact", limit: 8 * 1024 * 1024 },+]) {+ cliTest.skipIf(process.platform === "win32")(+ `${command} identifies fixed input-size refusal and recovery`,+ async ({ cli }) => {+ const root = await createTestTempDirectory("rea-artifact-input-limit-");+ const selected = join(root, "oversized.bin");+ const handle = await open(selected, "wx");+ try {+ await handle.truncate(limit + 1);+ } finally {+ await handle.close();+ }+ const tools = join(root, "tools");+ await mkdir(tools);+ for (const tool of ["wasm-validate", "wasm-objdump", "wasm2wat"])+ await writeFile(+ join(tools, tool),+ `#!/bin/sh+if [ "$1" = --version ]; then printf '1.0.42\\n'; exit 0; fi+printf 'Unexpected analysis command\\n' >&2+exit 1+`,+ { mode: 0o700 },+ );+ const output = await cli.run({+ arguments: [command, selected, "--json"],+ environment: { REA_WABT_BIN_DIRECTORY: tools },+ });+ expect(output.exitCode).toBe(1);+ const refusal = z+ .object({+ code: z.literal("resource_constraint"),+ category: z.literal("resource_constraint"),+ retryable: z.literal(false),+ details: z.object({+ resource: z.literal("file-size"),+ reported_limits: z.object({+ maximum_input_bytes: z.literal(limit),+ }),+ }),+ remediation: z.object({ action: z.string() }),+ })+ .parse(output.json);+ expect(refusal.remediation.action).toContain("input byte allowance");+ expect(refusal.remediation.action).not.toContain("evidence reply");+ },+ );+}