Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(ghidra): attribute returned profile cancellation at its owner

morlutoc72786f289eb
diff --git a/src/ghidra/GhidraProvider.ts b/src/ghidra/GhidraProvider.ts
index 9f174ca66..b7489ecc7 100644
--- a/src/ghidra/GhidraProvider.ts
+++ b/src/ghidra/GhidraProvider.ts
@@ -341,6 +341,14 @@ export class GhidraProvider implements AnalysisProviderCandidate {
...options,
signal,
});
+ if (!result.ok && result.error instanceof AnalysisCancelledError)
+ return err(
+ analysisClientFailureForOperation(
+ result.error,
+ "ghidra",
+ "open_binary",
+ ),
+ );
if (result.ok && signal.aborted)
return err(
new AnalysisCancelledError("open_binary", {
diff --git a/tests/boundary/filesystem/ghidraProfileArtifactOwnership.test.ts b/tests/boundary/filesystem/ghidraProfileArtifactOwnership.test.ts
index 4da6e5773..652d33b84 100644
--- a/tests/boundary/filesystem/ghidraProfileArtifactOwnership.test.ts
+++ b/tests/boundary/filesystem/ghidraProfileArtifactOwnership.test.ts
@@ -7,6 +7,7 @@ import { GhidraProvider } from "../../../src/ghidra/GhidraProvider.js";
import { ghidraProfileInstallationHost } from "../../../src/ghidra/GhidraInstallation.fixture.js";
import { silentLogger } from "../../../src/logger.js";
import { createDeferred } from "../../fixtures/binarySession.js";
+import { STARTUP_OWNER_CLOSED } from "../../../src/process/SharedStartupAttempt.js";
import { readFile, rename, writeFile, type FileHandle } from "node:fs/promises";
import { join } from "node:path";
import { afterEach, expect, it, vi } from "vitest";
@@ -365,7 +366,17 @@ it("joins whole provider resolution before shutdown and gates the next admission
expect(opens).toBe(count);
expect(provider.hasPendingOwnedResources()).toBe(true);
release.resolve();
- expect((await resolving).ok).toBe(true);
+ const stopped = await resolving;
+ if (stopped.ok) throw new Error("Expected owned resolution cancellation");
+ expect(stopped.error.cause).toBe(STARTUP_OWNER_CLOSED);
+ expect(stopped).toMatchObject({
+ ok: false,
+ error: {
+ _tag: "AnalysisCancelledError",
+ operation: "open_binary",
+ cause: STARTUP_OWNER_CLOSED,
+ },
+ });
expect(await closing).toEqual({ ok: true, value: null });
expect((await next).ok).toBe(true);
expect(provider.hasPendingOwnedResources()).toBe(false);