Files
reverse-engineering-anything/src/hopper/bridgeBootstrapLimit.test.ts
T
Cursor Agent 57dd7f26b1 fix(limits): carry runtime ceilings into Hopper and pwntools recovery
A runtime bridge ceiling is injected into the Hopper bootstrap. Pwntools input-limit guidance names the layer that selected the ceiling.
2026-11-11 20:16:24 +08:00

55 lines
1.6 KiB
TypeScript

import { expect, it } from "vitest";
import { bridgeBootstrapSource } from "./BridgeLauncher.js";
const session = {
directory: "/tmp/rea-bootstrap",
socketPath: "/tmp/rea-bootstrap/bridge.sock",
token: "token",
runId: "run",
};
const options = {
environment: {},
launcherPath: "/hopper",
targetPath: "/target",
targetKind: "executable" as const,
loaderArgs: [],
bridgeScriptPath: "/bridge.py",
};
it("leaves an unset ceiling out of the Hopper bootstrap", () => {
const source = bridgeBootstrapSource(session, options, true, "/target");
expect(source).not.toContain("REA_BRIDGE_MAX_REQUEST_BYTES");
// The reconnect control is a fixed 30-second bridge value, not a launch setting.
expect(source).toContain("REA_RECONNECT_TIMEOUT_SECONDS = 30\n");
expect(source).toContain("exec(compile");
});
it("injects a caller-selected ceiling before the bridge is executed", () => {
const source = bridgeBootstrapSource(
session,
{
...options,
bridgeMaxRequestBytes: { maximumBytes: 8192, source: "setting" },
},
true,
"/target",
);
const injected = source.indexOf("REA_BRIDGE_MAX_REQUEST_BYTES = 8192");
expect(injected).toBeGreaterThanOrEqual(0);
expect(injected).toBeLessThan(source.indexOf("exec(compile"));
});
it("injects a runtime ceiling before the bridge is executed", () => {
const source = bridgeBootstrapSource(
session,
{
...options,
bridgeMaxRequestBytes: { maximumBytes: 65_536, source: "runtime" },
},
true,
"/target",
);
expect(source).toContain("REA_BRIDGE_MAX_REQUEST_BYTES = 65536");
});