Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(ida): retain analysis profile in partial operation evidence (#4645)

Vinícius Andrade126b6e20d459
diff --git a/src/ida/IdaOperationFailures.test.ts b/src/ida/IdaOperationFailures.test.ts
index f32b295e1..45e89f8ea 100644
--- a/src/ida/IdaOperationFailures.test.ts
+++ b/src/ida/IdaOperationFailures.test.ts
@@ -7,10 +7,12 @@ import {
RecordingIdaMcp,
} from "../../tests/fixtures/idaMcp.js";
import type { JsonValue } from "../domain/jsonValue.js";
+import { createAnalysisProfile } from "../domain/analysisProfile.js";
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import { AnalysisInputError } from "../domain/analysisErrorCore.js";
import { createIdaDiagnosticRedactor } from "./IdaDiagnosticRedactor.js";
import { decodeIdaToolResult } from "./IdaMcpConnection.js";
+import { IDA_PROVIDER_IDENTITY } from "./IdaProviderCapabilities.js";
import type { AnalysisOperation } from "../application/AnalysisProvider.js";
import { IdaSessionClient } from "./IdaSessionClient.js";
@@ -301,6 +303,7 @@ describe("headless IDA partial operation evidence", () => {
if (!result.ok) {
expect(result.error._tag).toBe("AnalysisCancelledError");
expect(result.error.partialObservation).toMatchObject({
+ analysis_profile: null,
normalized_result: {
status: "partial",
observations: [expect.objectContaining({ tool: "list_funcs" })],
@@ -313,6 +316,62 @@ describe("headless IDA partial operation evidence", () => {
});
});
+it("retains the session analysis profile when an operation fails after a completed reply", async () => {
+ const { root, target } = await createIdaTarget();
+ roots.push(root);
+ const producer = new RecordingIdaMcp(target, "headless");
+ producer.beforeCall = async (name) => {
+ if (name === "decompile")
+ decodeIdaToolResult({
+ isError: true,
+ content: [{ type: "text", text: "Decompiler failed" }],
+ });
+ };
+ const profile = createAnalysisProfile(IDA_PROVIDER_IDENTITY, {
+ mode: "headless",
+ protocol: "modern",
+ compatibility_profile: "database-supervisor",
+ database_revision: null,
+ cache_policy: "live",
+ registration_digest: "a".repeat(64),
+ });
+ const client = new IdaSessionClient(
+ {
+ command: "fixture",
+ args: [],
+ env: {},
+ mode: "headless",
+ timeoutMs: 1000,
+ workspaceRoot: root,
+ },
+ target,
+ producer,
+ profile,
+ );
+ try {
+ const result = await client.execute("procedure_pseudo_code", {
+ procedure: "main",
+ });
+ expect(result.ok).toBe(false);
+ if (!result.ok) {
+ expect(result.error.partialObservation).toMatchObject({
+ analysis_profile: profile,
+ normalized_result: {
+ status: "partial",
+ observations: [expect.objectContaining({ tool: "lookup_funcs" })],
+ },
+ });
+ expect(
+ projectAnalysisError(result.error).details?.partial_observation,
+ ).toMatchObject({
+ analysis_profile: profile,
+ });
+ }
+ } finally {
+ expect((await client.close()).ok).toBe(true);
+ }
+});
+
describe("headless IDA operation failures", () => {
it.each<{
tool: string;
diff --git a/src/ida/IdaSessionClient.ts b/src/ida/IdaSessionClient.ts
index 52e688266..5c0017990 100644
--- a/src/ida/IdaSessionClient.ts
+++ b/src/ida/IdaSessionClient.ts
@@ -500,6 +500,9 @@ export class IdaSessionClient implements AnalysisClient {
{ kind: "artifact-path", path: this.target.path },
...runner.locations,
],
+ ...(this.profile === undefined
+ ? {}
+ : { analysisProfile: this.profile }),
}),
);
}