mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 22:45:47 +00:00
* test(limits): check documented limit defaults against code instead of per-file pins The numeric-limit script now reads every default, floor, and maximum in docs/design/rea-limit-inventory.md and compares it with ANALYSIS_SETTINGS or the owner constant the parser enforces. A mismatch names the limit and both values. Pins that only restated a covered value are removed. Pwntools input bytes and the Kuna timeouts now use the shared exports, so the registry value is the one the parser applies. * fix(limits): reject a fractional documented limit cell The cell parser treated a dot as the end of the integer, so 5000.5 compared equal to 5000. A documented number is now one complete integer, with prose only after whitespace. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { MAXIMUM_PWNTOOLS_MAX_INPUT_BYTES } from "../domain/analysisResourceLimits.js";
|
|
import { currentAnalysisOperationSnapshot } from "../domain/analysisOperationSnapshot.js";
|
|
import { PWNTOOLS_LIMITS } from "../domain/native/pwntoolsResourceLimits.js";
|
|
|
|
// The artifact is read into one in-memory buffer and staged again as a private
|
|
// snapshot before the owned bridge parses it under a 3 GiB address-space
|
|
// reservation, so an override stays within a third of that reservation.
|
|
|
|
/** Optional caller-supplied input bound, in bytes, without a decimal point. */
|
|
export const pwntoolsInputBytesSchema = z
|
|
.string()
|
|
.regex(/^[1-9]\d*$/u, "must be a positive decimal integer")
|
|
.transform(Number)
|
|
.pipe(z.int().safe().max(MAXIMUM_PWNTOOLS_MAX_INPUT_BYTES));
|
|
|
|
const CONSTRAINT =
|
|
`REA_PWNTOOLS_MAX_INPUT_BYTES must be a decimal integer from 1 to ` +
|
|
`${String(MAXIMUM_PWNTOOLS_MAX_INPUT_BYTES)} bytes, and REA never installs Python or packages.`;
|
|
|
|
/** Resolved input bound, or the reason the caller's override cannot be used. */
|
|
export type PwntoolsInputBytes =
|
|
| {
|
|
readonly configured: true;
|
|
readonly bytes: number;
|
|
readonly source: "default" | "setting" | "runtime" | "request";
|
|
}
|
|
| { readonly configured: false; readonly error: string };
|
|
|
|
/**
|
|
* Resolve the admitted artifact size for the pwntools adapters. An unset value
|
|
* keeps the shipped default, so the bound is only ever widened deliberately.
|
|
*/
|
|
export const pwntoolsInputBytes = (
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
): PwntoolsInputBytes => {
|
|
const override =
|
|
currentAnalysisOperationSnapshot()?.overrides["pwntools.max_input_bytes"];
|
|
if (override !== undefined)
|
|
return { configured: true, bytes: override, source: "runtime" };
|
|
const value = environment.REA_PWNTOOLS_MAX_INPUT_BYTES;
|
|
if (value === undefined)
|
|
return {
|
|
configured: true,
|
|
bytes: PWNTOOLS_LIMITS.input_bytes,
|
|
source: "default",
|
|
};
|
|
const parsed = pwntoolsInputBytesSchema.safeParse(value);
|
|
return parsed.success
|
|
? { configured: true, bytes: parsed.data, source: "setting" }
|
|
: { configured: false, error: CONSTRAINT };
|
|
};
|