chore: merge main into feat/dyld-shared-cache

This commit is contained in:
morluto
2026-10-08 17:02:53 +08:00
85 changed files with 5854 additions and 1121 deletions
@@ -0,0 +1,408 @@
import type { RecordedCrash } from "../../../src/domain/native/recordedCrash.js";
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it, onTestFinished } from "vitest";
import { z } from "zod";
import {
createTestWorkspace,
removeTestWorkspace,
} from "../../support/workspace/workspaceFixture.js";
import { PwntoolsRecordedCrashProvider } from "../../../src/native/pwntools/PwntoolsRecordedCrashProvider.js";
import { PWNTOOLS_PROVIDER_IDENTITY } from "../../../src/native/pwntools/PwntoolsRelease.js";
import { spawnOwnedProviderProcess } from "../../../src/process/ProviderProcess.js";
import { cleanupOwnedProcessGroup } from "../../../src/process/ProcessOwnership.js";
import { waitForProviderProcessReady } from "../../fixtures/providerProcess.js";
import {
recordedCrashFixture,
recordedCrashDebuggerFixture,
recordedCrashFixtureBytes,
recordedCrashSignalFixture,
} from "../../fixtures/binaryDiagnostics/recordedCrash.js";
import { projectAnalysisError } from "../../../src/domain/analysisErrorProjection.js";
import { ProviderCleanupError } from "../../../src/domain/providerCleanupError.js";
const requestSchema = z.object({
snapshot_path: z.string(),
reply_path: z.string(),
});
const host = process.platform === "linux" && process.arch === "x64";
it
.runIf(host)
.each([
"success",
"wrong-register",
"wrong-register-source",
"missing-thread",
"duplicate-thread",
"missing-signal",
"duplicate-signal",
"missing-register",
"duplicated-physical-thread",
"duplicated-physical-signal",
"omitted-physical-note",
"hidden-segment",
"wrong-header-range",
"wrong-note-kind",
"wrong-owner-display",
"wrong-pid",
"wrong-current-signal",
"wrong-signal-number",
"wrong-signal-code",
"wrong-signal-errno",
"wrong-signal-address",
"wrong-raw-note",
"malformed-range",
] as const)(
"validates recorded source bytes and cleanup: %s",
async (scenario) => {
const { path, value, bytes } = await fixture(
true,
scenario === "wrong-owner-display",
);
let owned = "";
const provider = new PwntoolsRecordedCrashProvider(
{ REA_PWNTOOLS_PYTHON: process.execPath },
async (spawn) => {
owned = spawn.cwd ?? "";
const request = requestSchema.parse(
JSON.parse(await readFile(spawn.arguments.at(-1) ?? "", "utf8")),
);
expect(await readFile(request.snapshot_path)).toEqual(bytes);
const payload = structuredClone(value);
alterRecordedCrashReply(payload, scenario);
const {
artifact: _artifact,
diagnostics: _diagnostics,
debugger: _debugger,
decoder_diagnostics: _decoderDiagnostics,
...raw
} = payload;
await writeFile(
request.reply_path,
JSON.stringify({
ok: true,
profile: PWNTOOLS_PROVIDER_IDENTITY.version,
value: raw,
}),
);
return spawnOwnedProviderProcess({
...spawn,
command: process.execPath,
arguments: ["-e", "process.stdout.write('recorded warning')"],
});
},
);
const result = await provider.inspect({
path,
include_debugger_context: false,
});
if (scenario === "success") {
if (!result.ok) throw result.error;
expect(result.value.threads).toEqual(value.threads);
expect(result.value.diagnostics.stdout).toBe("recorded warning");
} else
expect(result).toMatchObject({
ok: false,
error: {
_tag: "AnalysisOutputError",
capturedOutput: { stdout: "recorded warning" },
},
});
expect(await readFile(path)).toEqual(bytes);
await expect(access(owned)).rejects.toMatchObject({ code: "ENOENT" });
},
);
it
.runIf(host)
.each([
"unconfigured",
"success",
"process-failure",
"invalid-context",
"cancelled",
"cleanup-failure",
] as const)(
"owns optional context from the same snapshot: %s",
async (scenario) => {
const { path, value, bytes, root } = await fixture();
const controller = new AbortController();
let owned = "";
let snapshotPath = "";
const venv = join(root, "venv");
const plugin = join(root, "gdbinit.py");
await mkdir(venv);
await writeFile(plugin, "");
const provider = new PwntoolsRecordedCrashProvider(
{
REA_PWNTOOLS_PYTHON: process.execPath,
...(scenario === "unconfigured"
? {}
: {
REA_PWNDBG_GDB: process.execPath,
REA_PWNDBG_GDBINIT: plugin,
REA_PWNDBG_VENV_PATH: venv,
}),
},
async (spawn) => {
const request = requestSchema.parse(
JSON.parse(await readFile(spawn.arguments.at(-1) ?? "", "utf8")),
);
expect(await readFile(request.snapshot_path)).toEqual(bytes);
if (snapshotPath === "") {
snapshotPath = request.snapshot_path;
owned = spawn.cwd ?? "";
const {
artifact: _artifact,
diagnostics: _diagnostics,
debugger: _debugger,
decoder_diagnostics: _decoderDiagnostics,
...raw
} = value;
await writeFile(
request.reply_path,
JSON.stringify({
ok: true,
profile: PWNTOOLS_PROVIDER_IDENTITY.version,
value: raw,
}),
);
return spawnOwnedProviderProcess({
...spawn,
command: process.execPath,
arguments: ["-e", "process.stdout.write('basic stage diagnostic')"],
});
}
expect(request.snapshot_path).toBe(snapshotPath);
const context = recordedCrashDebuggerFixture();
if (scenario === "invalid-context")
context.maps = context.maps.map((map) => ({ ...map, end: "0x0" }));
await writeFile(
request.reply_path,
JSON.stringify({ ok: true, value: context }),
);
const launched = await spawnOwnedProviderProcess({
...spawn,
command: process.execPath,
arguments: [
"-e",
scenario === "process-failure"
? "process.stderr.write('debugger failed',()=>{process.exitCode=9;})"
: scenario === "cancelled"
? "process.stdout.write('ready\\n'); setInterval(() => {}, 1000)"
: "process.stdout.write('debugger stage diagnostic')",
],
});
if (scenario === "cancelled") {
await waitForProviderProcessReady(launched.process);
setImmediate(() => controller.abort());
}
if (scenario === "cleanup-failure")
return {
...launched,
cleanup: async () => {
await cleanupOwnedProcessGroup(launched.ownership);
throw new Error("source-owned post-cleanup reporting failure");
},
};
return launched;
},
);
const result = await provider.inspect(
{
path,
include_debugger_context: true,
},
{ signal: controller.signal },
);
if (scenario === "success") {
if (!result.ok) throw result.error;
expect(result.value.debugger).toMatchObject({
status: "available",
maps: [{ permissions: null }],
diagnostics: { stdout: "debugger stage diagnostic" },
});
} else {
if (result.ok) throw new Error("Expected optional debugger failure");
const projected = projectAnalysisError(result.error);
if (scenario === "unconfigured")
expect(projected).toMatchObject({
details: { captured_output: { stdout: "basic stage diagnostic" } },
});
else if (
scenario === "invalid-context" ||
scenario === "cancelled" ||
scenario === "cleanup-failure"
) {
const serialized = JSON.stringify(projected);
expect(serialized).toContain("basic stage diagnostic");
expect(serialized).toContain(
scenario === "cancelled" ? "ready" : "debugger stage diagnostic",
);
expect(result.error._tag).toBe(
scenario === "invalid-context"
? "AnalysisOutputError"
: scenario === "cancelled"
? "AnalysisCancelledError"
: "ProviderAdapterError",
);
if (scenario === "cleanup-failure")
expect(result.error).toBeInstanceOf(ProviderCleanupError);
} else
expect(projected).toMatchObject({
category: "execution_failure",
details: {
diagnostics: {
preceding_output: { stdout: "basic stage diagnostic" },
stderr: "debugger failed",
},
},
});
}
expect(await readFile(path)).toEqual(bytes);
await expect(access(owned)).rejects.toMatchObject({ code: "ENOENT" });
},
);
const fixture = async (includeSignal = false, opaqueOwner = false) => {
const workspace = await createTestWorkspace("rea-recorded-core-seam-");
onTestFinished(() => removeTestWorkspace(workspace.root));
const path = join(workspace.root, "recorded.core");
const value = includeSignal
? recordedCrashSignalFixture(path)
: recordedCrashFixture(path);
if (opaqueOwner) {
value.notes = value.notes.map((note) =>
note.index === 0
? {
...note,
owner_bytes_base64: Buffer.from("EVIL\0").toString("base64"),
owner_display: "EVIL",
}
: note,
);
value.threads = [];
}
const bytes = recordedCrashFixtureBytes(value);
await writeFile(path, bytes);
return { path, value, bytes, root: workspace.root };
};
const alterRecordedCrashReply = (
payload: RecordedCrash,
scenario: string,
): void => {
if (scenario === "wrong-owner-display")
payload.notes = payload.notes.map((note) =>
note.index === 0 ? { ...note, owner_display: "FORGED" } : note,
);
if (
scenario === "duplicated-physical-thread" ||
scenario === "duplicated-physical-signal"
) {
const noteIndex = scenario === "duplicated-physical-thread" ? 0 : 1;
const note = payload.notes[noteIndex];
if (note === undefined) throw new Error("missing fixture note");
payload.notes.push({ ...note, index: 2 });
if (noteIndex === 0)
payload.threads.push(
...payload.threads.map((thread) => ({
...thread,
note_index: 2,
})),
);
else
payload.signals.push(
...payload.signals.map((signal) => ({
...signal,
note_index: 2,
})),
);
}
if (scenario === "omitted-physical-note") {
payload.notes = payload.notes.filter((note) => note.index === 0);
payload.signals = [];
}
if (scenario === "hidden-segment") {
payload.segments = [];
payload.notes = [];
payload.threads = [];
payload.signals = [];
}
if (scenario === "wrong-header-range")
payload.segments = payload.segments.map((segment) => ({
...segment,
header_location: { offset: "0x0", bytes: "0x38" },
}));
if (scenario === "wrong-note-kind") {
payload.notes = payload.notes.map((note) =>
note.index === 0 ? { ...note, type: "NT_AUXV" } : note,
);
payload.threads = [];
}
if (scenario === "wrong-register-source")
payload.threads = payload.threads.map((thread) => ({
...thread,
registers: thread.registers.map((register) =>
register.name === "rdi"
? {
...register,
value: "0x0",
location: { offset: "0x104", bytes: "0x8" },
}
: register,
),
}));
if (scenario === "missing-thread") payload.threads = [];
if (scenario === "duplicate-thread")
payload.threads = [...payload.threads, ...payload.threads];
if (scenario === "missing-signal") payload.signals = [];
if (scenario === "duplicate-signal")
payload.signals = [...payload.signals, ...payload.signals];
if (scenario === "missing-register")
payload.threads = payload.threads.map((thread) => ({
...thread,
registers: thread.registers.slice(1),
}));
if (scenario === "wrong-register")
payload.threads = payload.threads.map((t) => ({
...t,
registers: t.registers.map((r) => ({ ...r, value: "0x1" })),
}));
if (scenario === "wrong-pid")
payload.threads = payload.threads.map((thread) => ({
...thread,
historical_pid: -2,
}));
if (scenario === "wrong-current-signal")
payload.threads = payload.threads.map((thread) => ({
...thread,
recorded_current_signal: -1,
}));
if (scenario.startsWith("wrong-signal"))
payload.signals = payload.signals.map((signal) => ({
...signal,
...(scenario === "wrong-signal-number"
? {
number: 10,
fault_address: null,
fault_address_meaning: "unknown" as const,
}
: scenario === "wrong-signal-code"
? { code: 2 }
: scenario === "wrong-signal-errno"
? { errno: 0 }
: { fault_address: "0x1" }),
}));
if (scenario === "wrong-raw-note")
payload.notes = payload.notes.map((n) => ({
...n,
descriptor_bytes_base64: Buffer.alloc(336, 1).toString("base64"),
}));
if (scenario === "malformed-range")
payload.notes = payload.notes.map((n) => ({
...n,
descriptor_location: { offset: "0x200", bytes: "0x150" },
}));
};
@@ -0,0 +1,76 @@
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { Ajv2020 } from "ajv/dist/2020.js";
import { expect, it, onTestFinished } from "vitest";
import { RecordedCrashService } from "../../../src/application/binaryDiagnostics/RecordedCrashService.js";
import { toolContract } from "../../../src/contracts/toolContracts.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
import { ok } from "../../../src/domain/result.js";
import { createServer } from "../../../src/server/createServer.js";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import {
recordedCrashFixture,
RECORDED_CRASH_TEST_PROVIDER,
} from "../../fixtures/binaryDiagnostics/recordedCrash.js";
it("advertises exact valid schemas and records inline recorded-core evidence without a binary target", async () => {
const value = recordedCrashFixture();
const service = new RecordedCrashService({
identity: RECORDED_CRASH_TEST_PROVIDER,
inspect: () => Promise.resolve(ok(value)),
});
const session = createTestBinarySession(() => {
throw new Error("deep provider must not start");
});
const server = createServer(session, session, { recordedCrash: service });
const client = new Client({ name: "recorded-crash-contract", version: "1" });
onTestFinished(async () => {
await client.close();
await server.close();
await session.close();
});
const [clientTransport, serverTransport] =
InMemoryTransport.createLinkedPair();
await server.connect(serverTransport);
await client.connect(clientTransport);
const advertised = (await client.listTools()).tools.find(
(tool) => tool.name === "inspect_recorded_crash",
);
if (advertised?.outputSchema === undefined)
throw new Error("recorded crash must publish both schemas");
const ajv = new Ajv2020({ strict: false, validateFormats: false });
const inputSchema: Record<string, unknown> = advertised.inputSchema;
const outputSchema: Record<string, unknown> = advertised.outputSchema;
expect(ajv.validateSchema(inputSchema)).toBe(true);
expect(ajv.validateSchema(outputSchema)).toBe(true);
expect(ajv.validate(inputSchema, { path: value.artifact.path })).toBe(true);
expect(
ajv.validate(inputSchema, {
path: value.artifact.path,
approval: true,
}),
).toBe(false);
const response = await client.callTool({
name: "inspect_recorded_crash",
arguments: { path: value.artifact.path },
});
expect(response.isError).not.toBe(true);
expect(
ajv.validate(outputSchema, response.structuredContent),
JSON.stringify(ajv.errors),
).toBe(true);
const parsed = toolContract("inspect_recorded_crash").outputSchema.parse(
response.structuredContent,
);
const evidence = parseEvidence(parsed.evidence);
expect(parsed.result).toEqual(value);
expect(parsed.result).toEqual(evidence.normalized_result);
expect(session.evidenceById(evidence.evidence_id)).toEqual(evidence);
expect(
(
await client.callTool({
name: "inspect_recorded_crash",
arguments: { path: "relative.elf" },
})
).isError,
).toBe(true);
});
@@ -7,6 +7,18 @@ import { expect, it } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { reconstructJavaScriptArtifact } from "../../../src/application/javascript/JavaScriptArtifactReconstruction.js";
import {
analyzeJavaScriptArtifactFiles,
analyzeAndProjectJavaScriptArtifactFiles,
} from "../../../src/application/javascript/JavaScriptArtifactAnalysis.js";
import { buildJavaScriptArtifactGraph } from "../../../src/application/javascript/JavaScriptArtifactGraphBuilder.js";
import {
buildJavaScriptSemanticGraph,
createJavaScriptSemanticGraphProjection,
} from "../../../src/application/javascript/JavaScriptSemanticGraphBuilder.js";
import { createJavaScriptArtifactReader } from "../../../src/artifacts/javascript/JavaScriptArtifactReader.js";
import { readJavaScriptArtifactFiles } from "../../../src/artifacts/javascript/JavaScriptArtifactFiles.js";
import { scanCanonicalArtifactInventory } from "../../../src/artifacts/inventory/ArtifactInventory.js";
import { scanArtifactInventory } from "../../../src/artifacts/inventory/ArtifactInventory.js";
import { parseJavaScriptApplicationGraph } from "../../../src/domain/javascript/javascriptApplicationGraph.js";
import { javascriptApplicationAnalysisResultSchema } from "../../../src/domain/javascript/javascriptApplicationAnalysis.js";
@@ -14,6 +26,83 @@ import { createJavaScriptSemanticGraph } from "../../../src/domain/javascript/ja
import { parseJavaScriptSemanticGraph } from "../../../src/domain/javascript/javascriptSemanticGraphSerialization.js";
import { writeJavaScriptArtifactFixture } from "../../fixtures/javascriptArtifactApplication.js";
it("reports file progress and honors cancellation before the next source", async () => {
const root = await fixtureDirectory();
const controller = new AbortController();
const progress: string[] = [];
await expect(
reconstructJavaScriptArtifact({ input_path: root }, controller.signal, {
report: async (event) => {
if (event.phase === "parse_javascript_source") {
progress.push(event.message);
if (progress.length === 2) controller.abort();
}
},
}),
).rejects.toMatchObject({ reason: "cancelled" });
expect(progress).toHaveLength(2);
expect(progress[0]).not.toBe(progress[1]);
});
it("preserves graph commitments and export shapes when consuming file-local IR", async () => {
const root = await fixtureDirectory();
await writeFile(
join(root, "exports.mjs"),
`
import { readFile } from "node:fs";
export { readFile as read };
export function create(value) { return { value, nested: { enabled: true } }; }
function unexported() { return "private"; }
`,
);
const snapshot = await scanCanonicalArtifactInventory(root, {});
const reader = createJavaScriptArtifactReader(root, "directory");
try {
const files = await readJavaScriptArtifactFiles(reader, snapshot);
const full = analyzeJavaScriptArtifactFiles(files);
const projection = createJavaScriptSemanticGraphProjection();
const compact = await analyzeAndProjectJavaScriptArtifactFiles(
files,
projection.projectFile,
);
const graph = buildJavaScriptArtifactGraph(snapshot, files, full);
expect(buildJavaScriptArtifactGraph(snapshot, files, compact)).toEqual(
graph,
);
const semantic = projection.finish(
snapshot.manifest.root_sha256,
graph,
compact,
);
expect(semantic).toEqual(
buildJavaScriptSemanticGraph({
rootArtifactSha256: snapshot.manifest.root_sha256,
applicationGraph: graph,
analysis: full,
}),
);
expect(
semantic.nodes.some(
({ application_node_ids }) => application_node_ids.length > 0,
),
).toBe(true);
const exported = compact.files.find(
({ file }) => file.path === "exports.mjs",
);
expect(exported?.semantic?.ir.callables.map(({ name }) => name)).toEqual([
"create",
]);
expect(
full.files
.find(({ file }) => file.path === "exports.mjs")
?.semantic?.ir.callables.map(({ name }) => name),
).toContain("unexported");
expect(parseJavaScriptSemanticGraph(semantic)).toEqual(semantic);
} finally {
await reader.close();
}
});
it("reconstructs package, Electron roles, Webpack/Rspack modules, and cross-layer facts without execution", async () => {
const root = await fixtureDirectory();
Reflect.deleteProperty(globalThis, "__rea_bundle_executed");
+220
View File
@@ -0,0 +1,220 @@
import type { RecordedCrash } from "../../../src/domain/native/recordedCrash.js";
/** Source-owned observation seam; these bytes do not simulate a verified ELF engine. */
export const recordedCrashFixture = (
path = "/artifacts/source-owned.core",
): RecordedCrash => {
const descriptor = Buffer.alloc(336);
descriptor.writeInt32LE(123, 32);
descriptor.writeInt16LE(11, 12);
descriptor.writeBigUInt64LE(0x1122334455667788n, 224);
return {
artifact: { path, sha256: "a".repeat(64), bytes: 512 },
format: "elf-core",
architecture: "x86_64-little-endian",
target_execution: "not-performed",
live_process_identity: "unknown",
segments: [
{
index: 0,
type: "PT_NOTE",
header_location: { offset: "0x40", bytes: "0x38" },
offset: "0x80",
file_size: "0x164",
memory_size: "0x0",
virtual_address: "0x0",
physical_address: "0x0",
alignment: "0x4",
flags: "0x0",
file_backing: "file",
},
],
notes: [
{
index: 0,
segment_index: 0,
type: "NT_PRSTATUS",
location: { offset: "0x80", bytes: "0x164" },
owner_location: { offset: "0x8c", bytes: "0x5" },
owner_bytes_base64: Buffer.from("CORE\0").toString("base64"),
owner_display: "CORE",
descriptor_location: { offset: "0x94", bytes: "0x150" },
descriptor_bytes_base64: descriptor.toString("base64"),
},
],
note_padding: [],
threads: [
{
note_index: 0,
historical_pid: 123,
recorded_current_signal: 11,
registers: [
"r15",
"r14",
"r13",
"r12",
"rbp",
"rbx",
"r11",
"r10",
"r9",
"r8",
"rax",
"rcx",
"rdx",
"rsi",
"rdi",
"orig_rax",
"rip",
"cs",
"eflags",
"rsp",
"ss",
"fs_base",
"gs_base",
"ds",
"es",
"fs",
"gs",
].map((name, index) => ({
name,
value: name === "rdi" ? "0x1122334455667788" : "0x0",
location: {
offset: `0x${(148 + 112 + index * 8).toString(16)}`,
bytes: "0x8",
},
})),
},
],
signals: [],
debugger: { status: "not-requested" },
note_interpretation_completeness: "unknown",
decoder_diagnostics: {
stdout: "decoder diagnostic",
stderr: "",
truncated: false,
},
diagnostics: { stdout: "decoder diagnostic", stderr: "", truncated: false },
limitations: ["Historical PID is recorded metadata."],
};
};
/** Source-owned SIGSEGV descriptor for scalar/source binding regressions. */
export const recordedCrashSignalFixture = (path?: string): RecordedCrash => {
const value = recordedCrashFixture(path);
const descriptor = Buffer.alloc(32);
descriptor.writeInt32LE(11, 0);
descriptor.writeInt32LE(-2, 4);
descriptor.writeInt32LE(1, 8);
descriptor.writeBigUInt64LE(0x1122334455667788n, 16);
value.artifact.bytes = 640;
value.segments = value.segments.map((segment) => ({
...segment,
file_size: "0x198",
}));
value.notes.push({
index: 1,
segment_index: 0,
type: "NT_SIGINFO",
location: { offset: "0x1e4", bytes: "0x34" },
owner_location: { offset: "0x1f0", bytes: "0x5" },
owner_bytes_base64: Buffer.from("CORE\0").toString("base64"),
owner_display: "CORE",
descriptor_location: { offset: "0x1f8", bytes: "0x20" },
descriptor_bytes_base64: descriptor.toString("base64"),
});
value.signals.push({
note_index: 1,
number: 11,
code: 1,
errno: -2,
fault_address: "0x1122334455667788",
fault_address_meaning: "recorded-sigsegv-address",
thread_association: "unknown",
});
return value;
};
/** Construct only the original byte ranges consumed by the provider protocol tests. */
export const recordedCrashFixtureBytes = (value: RecordedCrash): Buffer => {
const bytes = Buffer.alloc(value.artifact.bytes);
bytes.set([0x7f, 0x45, 0x4c, 0x46, 2, 1, 1]);
bytes.writeUInt16LE(4, 16);
bytes.writeUInt16LE(62, 18);
bytes.writeBigUInt64LE(64n, 32);
bytes.writeUInt16LE(56, 54);
bytes.writeUInt16LE(value.segments.length, 56);
for (const segment of value.segments) {
const start = Number(BigInt(segment.header_location.offset));
bytes.writeUInt32LE(segment.type === "PT_NOTE" ? 4 : 0, start);
bytes.writeUInt32LE(Number(BigInt(segment.flags)), start + 4);
for (const [field, offset] of [
[segment.offset, 8],
[segment.virtual_address, 16],
[segment.physical_address, 24],
[segment.file_size, 32],
[segment.memory_size, 40],
[segment.alignment, 48],
] as const)
bytes.writeBigUInt64LE(BigInt(field), start + offset);
}
for (const note of value.notes) {
const start = Number(BigInt(note.location.offset));
bytes.writeUInt32LE(Number(BigInt(note.owner_location.bytes)), start);
bytes.writeUInt32LE(
Number(BigInt(note.descriptor_location.bytes)),
start + 4,
);
bytes.writeUInt32LE(
note.type === "NT_PRSTATUS" ? 1 : 0x53494749,
start + 8,
);
Buffer.from(note.owner_bytes_base64, "base64").copy(
bytes,
Number(BigInt(note.owner_location.offset)),
);
Buffer.from(note.descriptor_bytes_base64, "base64").copy(
bytes,
Number(BigInt(note.descriptor_location.offset)),
);
}
return bytes;
};
export const RECORDED_CRASH_TEST_PROVIDER = {
id: "fixture-recorded-core",
name: "Source-owned recorded-core seam",
version: "1",
} as const;
/** Source-owned debugger representation with deliberately unreported permission flags. */
export const recordedCrashDebuggerFixture = (): Extract<
RecordedCrash["debugger"],
{ status: "available" }
> => ({
status: "available",
gdb_version: "source seam",
pwndbg_version: "source seam",
connection: "core",
executable: null,
historical_pid: 123,
reported_limits: {
address_space_bytes: 3221225472,
cpu_seconds: 30,
file_size_bytes: 67108864,
},
maps: [
{
start: "0x1000",
end: "0x2000",
offset: "0x0",
reported_flags: 0,
permissions: null,
pathname_display: "recorded/path",
current_file_identity: "unknown",
},
],
confidence: "derived",
completeness: "unknown",
diagnostics: { stdout: "", stderr: "", truncated: false },
});