Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
fix(native): reject signal-terminated command captures (#608)
Rudy Mizrahi Celeklib81d18eeee9d
diff --git a/src/native/CommandRunner.ts b/src/native/CommandRunner.tsindex c8e55fd79..be6329e03 100644--- a/src/native/CommandRunner.ts+++ b/src/native/CommandRunner.ts@@ -223,7 +223,7 @@ const captureProcess = (finish(err(new NativeCommandFailure(tool, reason, code)));return;}- if (code !== 0 && options.acceptNonZero !== true) {+ if (signal !== null || (code !== 0 && options.acceptNonZero !== true)) {finish(err(new NativeCommandFailure(tool, "nonzero-exit", code)));return;}diff --git a/tests/boundary/providers/native/nativeCommandTermination.test.ts b/tests/boundary/providers/native/nativeCommandTermination.test.tsnew file mode 100644index 000000000..d40596dbc--- /dev/null+++ b/tests/boundary/providers/native/nativeCommandTermination.test.ts@@ -0,0 +1,29 @@+import { createHash } from "node:crypto";+import { readFile } from "node:fs/promises";+import { expect, it } from "vitest";+import { XcrunCommandRunner } from "../../../../src/native/CommandRunner.js";+import { ok } from "../../../../src/domain/result.js";++it.skipIf(process.platform === "win32")(+ "does not accept signal termination as an allowed nonzero exit",+ async () => {+ const sha256 = createHash("sha256")+ .update(await readFile(process.execPath))+ .digest("hex");+ const runner = new XcrunCommandRunner(async () =>+ ok({ path: process.execPath, sha256 }),+ );+ const exited = await runner.run("file", ["-e", "process.exit(1)"], {+ acceptNonZero: true,+ });+ expect(exited.ok).toBe(true);+ if (exited.ok) expect(exited.value.exitCode).toBe(1);+ const killed = await runner.run(+ "file",+ ["-e", "process.kill(process.pid, 'SIGTERM')"],+ { acceptNonZero: true },+ );+ expect(killed.ok).toBe(false);+ if (!killed.ok) expect(killed.error.reason).toBe("nonzero-exit");+ },+);