* fix(native): retain failed pwntools process and runtime cleanup Keep failed worker/debugger cleanup owners and their private files until verified process shutdown and successful directory removal. Retry cleanup before another inspection and expose shutdown through the shared services, CLI and MCP server. Serialize acquisition without delaying cancellation of queued callers, and preserve primary diagnostics when CLI cleanup fails. The original decoder reproduction left a live owned Node child with its runtime deleted and no retained cleanup owner; the regression now verifies retention, admission blocking, retries and eventual process/file cleanup. Validation: 10 lifecycle/public CLI/MCP tests, 20 service tests, test discovery 814/814, build:cached and full check including architecture guards. Actual POSIX process/filesystem boundaries used injected Node workers on macOS; real Linux pwntools/GDB provider parsing was not exercised. * test(native): verify retained recorded-crash cleanup lifecycle * fix(native): finalize diagnostic cleanup before publishing results * fix(native): retire decoder stages before reading runtime evidence --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
import { access } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect, it, onTestFinished } from "vitest";
|
|
import { AnalysisCancelledError } from "../../../src/domain/analysisErrorCore.js";
|
|
import {
|
|
createTestWorkspace,
|
|
removeTestWorkspace,
|
|
} from "../../../tests/support/workspace/workspaceFixture.js";
|
|
import { inspectPwndbgCore } from "../../../src/native/pwndbg/PwndbgCoreContext.js";
|
|
|
|
const diagnostics = { stdout: "", stderr: "", truncated: false };
|
|
|
|
it.each(["pre-aborted", "aborted-during-probe"] as const)(
|
|
"cancellation wins over debugger path failures: %s",
|
|
async (scenario) => {
|
|
const workspace = await createTestWorkspace("rea-pwndbg-cancel-");
|
|
onTestFinished(() => removeTestWorkspace(workspace.root));
|
|
const controller = new AbortController();
|
|
const gdb = join(workspace.root, "missing-gdb");
|
|
let probes = 0;
|
|
const probePath = async () => {
|
|
probes++;
|
|
if (scenario === "aborted-during-probe") {
|
|
await new Promise<void>((resolve) => {
|
|
setImmediate(() => {
|
|
controller.abort();
|
|
resolve();
|
|
});
|
|
});
|
|
throw new Error("path became unavailable");
|
|
}
|
|
throw new Error("path is unavailable");
|
|
};
|
|
if (scenario === "pre-aborted") controller.abort();
|
|
await expect(
|
|
inspectPwndbgCore({
|
|
environment: {
|
|
REA_PWNDBG_GDB: gdb,
|
|
REA_PWNDBG_GDBINIT: join(workspace.root, "missing-init"),
|
|
REA_PWNDBG_VENV_PATH: join(workspace.root, "missing-venv"),
|
|
},
|
|
rootPath: workspace.root,
|
|
diagnostics,
|
|
options: { signal: controller.signal },
|
|
probePath,
|
|
runCommand: () => {
|
|
throw new Error("No process should exist before cancellation");
|
|
},
|
|
}),
|
|
).rejects.toBeInstanceOf(AnalysisCancelledError);
|
|
expect(probes).toBe(scenario === "pre-aborted" ? 0 : 1);
|
|
await expect(
|
|
access(join(workspace.root, "debugger")),
|
|
).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
},
|
|
);
|