mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 18:52:48 +00:00
Bind typed service creation, observed availability and retryable cleanup in one composition owner. Reuse selected CLI/MCP factories and canonical contract groups without copying provider operation inventories. Closes #8429. Refs #740. Validated paired real application workflows, actual local Codex CLI Terra/high use, complete Evidence and Unknown checkpoint parity, compiler-backed import boundaries, SDK schemas and final real mixed routing. Automated review findings were fixed at their producing owners. Existing exact-base CodeQL alerts are documented on the PR under the owner-authorized unrelated-check exception; no global alerts or security rules were changed. Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
75 lines
2.7 KiB
TypeScript
75 lines
2.7 KiB
TypeScript
import {
|
|
binaryLayoutPayloadSchema,
|
|
binaryLayoutSchema,
|
|
type BinaryLayout,
|
|
type InspectBinaryLayoutInput,
|
|
} from "../../domain/native/binaryLayout.js";
|
|
import { AnalysisOutputError } from "../../domain/analysisErrorCore.js";
|
|
import { PwntoolsDecoder, type PwntoolsLauncher } from "./PwntoolsDecoder.js";
|
|
import { PWNTOOLS_PROVIDER_IDENTITY } from "./PwntoolsProviderIdentity.js";
|
|
import { PrivateRuntimeRoot } from "../../process/PrivateRuntimeRoot.js";
|
|
import type { BinaryLayoutPort } from "../../application/binaryDiagnostics/BinaryLayoutPort.js";
|
|
import type { z } from "zod";
|
|
|
|
/** ELF-specific projection around the shared owned pwntools decoder boundary. */
|
|
export class PwntoolsLayoutProvider
|
|
extends PwntoolsDecoder<
|
|
InspectBinaryLayoutInput,
|
|
z.output<typeof binaryLayoutPayloadSchema>,
|
|
BinaryLayout
|
|
>
|
|
implements BinaryLayoutPort
|
|
{
|
|
constructor(
|
|
environment: Readonly<NodeJS.ProcessEnv>,
|
|
launcher?: PwntoolsLauncher,
|
|
createRuntime: () => Promise<
|
|
Pick<PrivateRuntimeRoot, "path" | "close">
|
|
> = () => PrivateRuntimeRoot.create({ prefix: "rea-elf-layout-" }),
|
|
) {
|
|
super(
|
|
{
|
|
identity: PWNTOOLS_PROVIDER_IDENTITY,
|
|
operation: "inspect_binary_layout",
|
|
bridge: new URL("../../../bridge/pwntools/layout.py", import.meta.url),
|
|
payloadSchema: binaryLayoutPayloadSchema,
|
|
project: ({ input, payload, snapshot, diagnostics }) => {
|
|
const value = binaryLayoutSchema.safeParse({
|
|
...payload,
|
|
artifact: {
|
|
path: input.path,
|
|
sha256: snapshot.sha256,
|
|
bytes: snapshot.bytes.length,
|
|
},
|
|
diagnostics,
|
|
});
|
|
if (!value.success)
|
|
throw new AnalysisOutputError(
|
|
"inspect_binary_layout",
|
|
`ELF reply contains invalid source ranges or value meanings: ${value.error.issues[0]?.message ?? "schema mismatch"}`,
|
|
{ capturedOutput: diagnostics },
|
|
);
|
|
for (const table of value.data.packed_relative_relocations) {
|
|
const start = Number(BigInt(table.location.offset));
|
|
const length = Number(BigInt(table.location.bytes));
|
|
if (
|
|
!Buffer.from(table.encoded_bytes_base64, "base64").equals(
|
|
snapshot.bytes.subarray(start, start + length),
|
|
)
|
|
)
|
|
throw new AnalysisOutputError(
|
|
"inspect_binary_layout",
|
|
"Reported packed relocation bytes differ from the selected snapshot at their original file range.",
|
|
{ capturedOutput: diagnostics },
|
|
);
|
|
}
|
|
return value.data;
|
|
},
|
|
},
|
|
environment,
|
|
launcher,
|
|
createRuntime,
|
|
);
|
|
}
|
|
}
|