mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 10:04:50 +00:00
* docs: correct, re-verify and prune getting-started, provider and reference pages Re-verify the macOS arm64 native decompiler build, the m68k lane and the RISC-V lane on Ghidra 12.2, check RISC-V language facts against the 12.2 SLEIGH sources, document the verify:ghidra demangler prerequisite, remove duplicated IDA and mcp add paragraphs, prune release-history narratives and the stale 6.4.0 registry checkpoint, clarify Godot carrier classification, correct the packet-summary and SQLite host rows, and say in the inspect-binary-layout CLI description that it is ELF-only on Linux x64. * docs(reference): add a canonical producer_limits section Derive the accepted fields and defaults per operation from the producer limit schemas and describe how an exhausted budget reports its per-call control. * docs(reference): split producer_limits defaults by operation and document the pwntools exceptions Field and decoder discovery reject input_bytes, and packet field search defaults output_bytes to 32 MiB. For pwntools, diagnostic_bytes bounds combined stdout and stderr while output_bytes bounds the reply file, and an oversized input reports the pwntools.max_input_bytes setting limit rather than the producer_limits parameter shape. * fix(pwntools)!: report a per-call input ceiling as its producer_limits parameter When producer_limits.input_bytes set the pwntools admission ceiling for a call, an oversized input reported the registered pwntools.max_input_bytes setting limit with update_mode "parameter" attached. Every other producer budget reports the parameter shape, and AGENTS.md asks for the limit of the control that stopped the work. Report producer_limits.input_bytes with applies_at "next_call" and, as its default, the ceiling that applies when the field is omitted. Setting, launch and built-in ceilings keep the setting shape. Remove the reference exception this made obsolete. BREAKING CHANGE: for a request-sourced pwntools input ceiling, details.limit is now a control_kind "parameter" limit instead of a setting limit carrying setting, source, update_mode and scope fields.
138 lines
4.8 KiB
TypeScript
138 lines
4.8 KiB
TypeScript
import { open } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { expect, it, onTestFinished } from "vitest";
|
|
|
|
import { PwntoolsLayoutProvider } from "../../../src/native/pwntools/PwntoolsLayoutProvider.js";
|
|
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
|
|
import { spawnOwnedProviderProcess } from "../../../src/process/ProviderProcess.js";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
const unsupportedHost = process.platform !== "linux" || process.arch !== "x64";
|
|
const DEFAULT_INPUT_BYTES = 33_554_432;
|
|
// One byte above the shipped bound, so the admission decision is the only
|
|
// difference between the first two cases.
|
|
const ARTIFACT_BYTES = DEFAULT_INPUT_BYTES + 1;
|
|
|
|
/** Sparse regular file just larger than the shipped input bound. */
|
|
const oversizedArtifact = async (): Promise<string> => {
|
|
const root = await createTestTempDirectory("rea-pwntools-input-bound-");
|
|
const path = join(root, "recorded-core");
|
|
const handle = await open(path, "w");
|
|
await handle.truncate(ARTIFACT_BYTES);
|
|
await handle.close();
|
|
return path;
|
|
};
|
|
|
|
/** One admission attempt, reported as the projected caller-visible failure. */
|
|
const inspect = async (override?: string, requestInputBytes?: number) => {
|
|
const path = await oversizedArtifact();
|
|
const provider = new PwntoolsLayoutProvider(
|
|
{
|
|
REA_PWNTOOLS_PYTHON: process.execPath,
|
|
...(override === undefined
|
|
? {}
|
|
: { REA_PWNTOOLS_MAX_INPUT_BYTES: override }),
|
|
},
|
|
async (spawn) =>
|
|
spawnOwnedProviderProcess({
|
|
...spawn,
|
|
command: process.execPath,
|
|
arguments: ["-e", "process.stdout.write('no reply')"],
|
|
}),
|
|
);
|
|
onTestFinished(async () => {
|
|
await provider.close();
|
|
});
|
|
const result = await provider.inspect({
|
|
path,
|
|
...(requestInputBytes === undefined
|
|
? {}
|
|
: { producer_limits: { input_bytes: requestInputBytes } }),
|
|
});
|
|
if (result.ok) throw new Error("Expected the bounded decoder to fail");
|
|
const projected = projectAnalysisError(result.error);
|
|
return { projected, text: JSON.stringify(projected) };
|
|
};
|
|
|
|
it.runIf(!unsupportedHost)(
|
|
"refuses an artifact above the shipped bound when no override is set",
|
|
async () => {
|
|
const { projected, text } = await inspect();
|
|
expect(projected.code).toBe("invalid_request");
|
|
expect(text).toContain(
|
|
`Selected artifact exceeds ${String(DEFAULT_INPUT_BYTES)} bytes`,
|
|
);
|
|
},
|
|
);
|
|
|
|
it.runIf(!unsupportedHost)(
|
|
"admits the same artifact once the override widens the bound",
|
|
async () => {
|
|
const { projected, text } = await inspect(String(ARTIFACT_BYTES));
|
|
// Admission passed, so the only remaining failure is that the owned decoder
|
|
// never wrote a reply, which also proves the process really ran.
|
|
expect(text).not.toContain("Selected artifact exceeds");
|
|
expect(projected.code).toBe("unreadable_output");
|
|
expect(text).toContain("no reply");
|
|
},
|
|
);
|
|
|
|
it.runIf(!unsupportedHost)(
|
|
"refuses an unusable override before reading the artifact",
|
|
async () => {
|
|
const { projected, text } = await inspect("0");
|
|
expect(projected.code).toBe("provider_unavailable");
|
|
expect(projected.details).toMatchObject({
|
|
rejections: [
|
|
{ diagnostics: { configuration_key: "REA_PWNTOOLS_MAX_INPUT_BYTES" } },
|
|
],
|
|
});
|
|
expect(text).toContain("REA_PWNTOOLS_MAX_INPUT_BYTES must be a decimal");
|
|
expect(text).not.toContain("Selected artifact exceeds");
|
|
},
|
|
);
|
|
|
|
it.runIf(!unsupportedHost)(
|
|
"reports a per-call ceiling as its parameter, defaulting to the launch value",
|
|
async () => {
|
|
// The launch value would admit the artifact; the per-call ceiling refuses
|
|
// it, so the limit names the parameter and the ceiling omitting it restores.
|
|
const { projected } = await inspect(String(ARTIFACT_BYTES), 4096);
|
|
expect(projected.details?.limit).toStrictEqual({
|
|
control_kind: "parameter",
|
|
parameter: "producer_limits.input_bytes",
|
|
effective_value: 4096,
|
|
unit: "bytes",
|
|
minimum: 1,
|
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
default_value: ARTIFACT_BYTES,
|
|
applies_at: "next_call",
|
|
});
|
|
},
|
|
);
|
|
|
|
it.runIf(!unsupportedHost)(
|
|
"reports the shipped default when a per-call ceiling refuses without a launch value",
|
|
async () => {
|
|
const { projected } = await inspect(undefined, 4096);
|
|
expect(projected.details?.limit).toMatchObject({
|
|
control_kind: "parameter",
|
|
effective_value: 4096,
|
|
default_value: DEFAULT_INPUT_BYTES,
|
|
});
|
|
},
|
|
);
|
|
|
|
it.runIf(!unsupportedHost)(
|
|
"invents no default when omitting the per-call ceiling would fail configuration",
|
|
async () => {
|
|
const { projected } = await inspect("0", 4096);
|
|
expect(projected.details?.limit).not.toHaveProperty("default_value");
|
|
expect(projected.details?.limit).toMatchObject({
|
|
setting: "pwntools.max_input_bytes",
|
|
effective_value: 4096,
|
|
});
|
|
},
|
|
);
|