refactor: return complete analysis results inline
This commit is contained in:
@@ -95,7 +95,6 @@ export class GhidraHeadlessLauncher implements GhidraLauncher {
|
||||
await writeFileAtomic(
|
||||
paths.descriptorPath,
|
||||
`${JSON.stringify({
|
||||
schema_version: 2,
|
||||
transport: session.transport,
|
||||
endpoint_path: session.endpointPath,
|
||||
token: session.token,
|
||||
@@ -137,7 +136,6 @@ export class GhidraHeadlessLauncher implements GhidraLauncher {
|
||||
await writeFileAtomic(
|
||||
paths.ownershipPath,
|
||||
`${JSON.stringify({
|
||||
schema_version: 1,
|
||||
run_id: session.runId,
|
||||
pid: started.ownership.leaderPid,
|
||||
process_group_id: started.ownership.processGroupId,
|
||||
|
||||
@@ -65,26 +65,14 @@ describe("Ghidra provider", () => {
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
operation: "list_procedures",
|
||||
pagination: "none",
|
||||
effects: expect.objectContaining({
|
||||
mutatesArtifact: false,
|
||||
mayShowUi: false,
|
||||
mayWriteFilesystem: true,
|
||||
}),
|
||||
limits: {
|
||||
maxResults: null,
|
||||
maxPayloadBytes: 1024 * 1024,
|
||||
timeoutMs: 10_000,
|
||||
},
|
||||
}),
|
||||
expect.objectContaining({
|
||||
operation: "analyze_function",
|
||||
pagination: "none",
|
||||
limits: {
|
||||
maxResults: null,
|
||||
maxPayloadBytes: 1024 * 1024,
|
||||
timeoutMs: 35_000,
|
||||
},
|
||||
limitations: expect.arrayContaining([
|
||||
expect.stringContaining(
|
||||
"unresolved targetless flows remain unknown",
|
||||
|
||||
@@ -39,7 +39,6 @@ describe("Ghidra provider capabilities", () => {
|
||||
Reflect.set(capabilities, 0, { ...first, available: false });
|
||||
Reflect.set(first, "available", false);
|
||||
Reflect.set(first.effects, "mutatesArtifact", true);
|
||||
Reflect.set(first.limits, "maxResults", 0);
|
||||
Reflect.set(first.limitations, 0, "forged limitation");
|
||||
|
||||
expect(provider.capabilities()).toEqual(published);
|
||||
|
||||
@@ -4,11 +4,6 @@ import type {
|
||||
} from "../application/AnalysisProvider.js";
|
||||
import { WINDOWS_NATIVE_AUTHORITY_UNAVAILABLE_REASON } from "../process/WindowsAuthority.js";
|
||||
import { GENERATED_MCP_TOOL_CATALOG } from "../generatedMcpToolCatalog.js";
|
||||
import {
|
||||
GHIDRA_DECOMPILE_REQUEST_TIMEOUT_MS,
|
||||
GHIDRA_MAX_LINE_BYTES,
|
||||
GHIDRA_REQUEST_TIMEOUT_MS,
|
||||
} from "./GhidraDefaults.js";
|
||||
import { GHIDRA_FUNCTION_OPERATIONS } from "./GhidraFunctionValues.js";
|
||||
import { GHIDRA_INVENTORY_OPERATIONS } from "./GhidraInventoryValues.js";
|
||||
|
||||
@@ -39,12 +34,6 @@ export const GHIDRA_PROVIDER_TOOL_CONTRACTS = Object.freeze(
|
||||
),
|
||||
);
|
||||
|
||||
const PAGINATED_OPERATIONS: ReadonlySet<string> = new Set([]);
|
||||
const DECOMPILE_OPERATIONS: ReadonlySet<string> = new Set([
|
||||
"procedure_pseudo_code",
|
||||
"analyze_function",
|
||||
]);
|
||||
|
||||
/** Health limitations shared by every Ghidra-backed capability. */
|
||||
export const healthLimitations = Object.freeze([
|
||||
"The session serves operations only after default Ghidra auto-analysis completes; an analysis timeout fails the open instead of exposing partial results.",
|
||||
@@ -157,10 +146,6 @@ export const CAPABILITIES: readonly CapabilityDescriptor[] = Object.freeze(
|
||||
operation,
|
||||
available: true,
|
||||
reason: null,
|
||||
pagination: PAGINATED_OPERATIONS.has(contract.name)
|
||||
? ("offset" as const)
|
||||
: ("none" as const),
|
||||
exhaustive: !PAGINATED_OPERATIONS.has(contract.name),
|
||||
effects: Object.freeze({
|
||||
mutatesArtifact: false,
|
||||
launchesProcess: true,
|
||||
@@ -170,13 +155,6 @@ export const CAPABILITIES: readonly CapabilityDescriptor[] = Object.freeze(
|
||||
changesPermissions: false,
|
||||
requiresRoot: false,
|
||||
}),
|
||||
limits: Object.freeze({
|
||||
maxResults: PAGINATED_OPERATIONS.has(contract.name) ? 500 : null,
|
||||
maxPayloadBytes: GHIDRA_MAX_LINE_BYTES,
|
||||
timeoutMs: DECOMPILE_OPERATIONS.has(contract.name)
|
||||
? GHIDRA_DECOMPILE_REQUEST_TIMEOUT_MS
|
||||
: GHIDRA_REQUEST_TIMEOUT_MS,
|
||||
}),
|
||||
limitations: Object.freeze(limitationsFor(contract.name)),
|
||||
});
|
||||
}),
|
||||
|
||||
@@ -79,8 +79,7 @@ const parseTcpEndpoint = (
|
||||
typeof value !== "object" ||
|
||||
value === null ||
|
||||
Array.isArray(value) ||
|
||||
!hasExactKeys(value, ["host", "port", "schema_version"]) ||
|
||||
value.schema_version !== 1 ||
|
||||
!hasExactKeys(value, ["host", "port"]) ||
|
||||
value.host !== "127.0.0.1" ||
|
||||
!Number.isSafeInteger(value.port) ||
|
||||
typeof value.port !== "number" ||
|
||||
|
||||
Reference in New Issue
Block a user