refactor(binary): move production composition outside application workflows (#965)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import type { AppConfig } from "../config.js";
|
||||
import type { BinarySession } from "../application/binary/BinarySession.js";
|
||||
import { HopperProvider } from "../hopper/HopperProvider.js";
|
||||
import { GhidraProvider } from "../ghidra/GhidraProvider.js";
|
||||
import { IdaProvider } from "../ida/IdaProvider.js";
|
||||
import { silentLogger, type Logger } from "../logger.js";
|
||||
import { auxiliaryAnalysisProviderDeclarations } from "./auxiliaryAnalysisProviders.js";
|
||||
import { AnalysisProviderRegistry } from "../application/binary/AnalysisProviderRegistry.js";
|
||||
import { composeBinarySession } from "../application/binary/BinarySessionComposition.js";
|
||||
import { LazyAnalysisProvider } from "../application/binary/LazyAnalysisProvider.js";
|
||||
import { ManagedStaticProvider } from "../dotnet/ManagedStaticProvider.js";
|
||||
import { SessionProviderRouter } from "../application/binary/SessionProviderRouter.js";
|
||||
|
||||
/**
|
||||
* Compose the target-switching runtime shared directly by CLI and MCP adapters.
|
||||
* This is the sole production wiring point, so both adapters share identical
|
||||
* provider selection, profile, lifecycle, and Evidence semantics.
|
||||
*/
|
||||
export const createBinarySession = (
|
||||
config: AppConfig,
|
||||
logger: Logger = silentLogger,
|
||||
): BinarySession => {
|
||||
const hopper = new HopperProvider(config, logger);
|
||||
const ghidra = new GhidraProvider(config, logger);
|
||||
const ida = new IdaProvider(config);
|
||||
return composeBinarySession(
|
||||
new AnalysisProviderRegistry(
|
||||
[hopper, ghidra, ida],
|
||||
config.analysisProvider,
|
||||
),
|
||||
auxiliaryAnalysisProviderDeclarations().map(
|
||||
(declaration) => new LazyAnalysisProvider(declaration),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
/** Compose an execution-free managed session without native provider selection. */
|
||||
export const createManagedBinarySession = (): BinarySession =>
|
||||
composeBinarySession(
|
||||
SessionProviderRouter.selectable(new AnalysisProviderRegistry([]), [
|
||||
new ManagedStaticProvider(),
|
||||
]),
|
||||
);
|
||||
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
runDirectAnalysis as executeDirectAnalysis,
|
||||
runProviderAnalysis as executeProviderAnalysis,
|
||||
runManagedProviderExecution as executeManagedProvider,
|
||||
} from "../application/DirectAnalysis.js";
|
||||
import {
|
||||
runCapabilityStatus as executeCapabilityStatus,
|
||||
runProviderStatus as executeProviderStatus,
|
||||
} from "../application/DirectAnalysisStatus.js";
|
||||
import type { DirectAnalysisDependencies } from "../application/DirectAnalysisDependencies.js";
|
||||
import { createBinarySession, createManagedBinarySession } from "./binary.js";
|
||||
|
||||
const dependencies: DirectAnalysisDependencies = {
|
||||
createBinarySession,
|
||||
createManagedBinarySession,
|
||||
};
|
||||
|
||||
/** Run one isolated binary operation through the production session factory. */
|
||||
export const runDirectAnalysis = executeDirectAnalysis.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
|
||||
/** Run one isolated native, artifact or managed operation. */
|
||||
export const runProviderAnalysis = executeProviderAnalysis.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
|
||||
/** Execute managed metadata without constructing native provider candidates. */
|
||||
export const runManagedProviderExecution = executeManagedProvider.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
|
||||
/** Report production provider candidates without opening a target. */
|
||||
export const runProviderStatus = executeProviderStatus.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
|
||||
/** Report production session operations without opening a target. */
|
||||
export const runCapabilityStatus = executeCapabilityStatus.bind(
|
||||
undefined,
|
||||
dependencies,
|
||||
);
|
||||
Reference in New Issue
Block a user