rea-agents 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -32
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/ArtifactExtraction.js +1 -1
- package/dist/application/ArtifactInventory/classify.js +42 -0
- package/dist/application/ArtifactInventory/hash.js +43 -0
- package/dist/application/ArtifactInventory/reader.js +41 -0
- package/dist/application/ArtifactInventory/scanCanonical.js +155 -0
- package/dist/application/ArtifactInventory/scanReader.js +124 -0
- package/dist/application/ArtifactInventory/types.js +10 -0
- package/dist/application/ArtifactInventory.js +9 -351
- package/dist/application/AuthorizedArtifactInventory.js +2 -2
- package/dist/application/BinarySession.js +47 -270
- package/dist/application/BinarySessionExecution.js +28 -0
- package/dist/application/BinarySessionOpen.js +39 -0
- package/dist/application/BinarySessionRecords.js +149 -0
- package/dist/application/BinarySessionStatus.js +75 -0
- package/dist/application/CapabilityInventory.js +24 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +1 -23
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +156 -238
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +23 -7
- package/dist/application/ElectronBoundaryGraphWindows.js +32 -8
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +20 -37
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptArtifactAnalysis.js +45 -6
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +23 -1
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- package/dist/application/JavaScriptArtifactGraphFindings.js +54 -8
- package/dist/application/JavaScriptArtifactGraphStructure.js +29 -101
- package/dist/application/JavaScriptArtifactPathResolution.js +269 -0
- package/dist/application/JavaScriptArtifactReconstruction.js +1 -1
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayService.js +182 -156
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- package/dist/application/NodeRuntimeCharacterizationService.js +196 -0
- package/dist/application/PermissionAuthority.js +106 -63
- package/dist/application/ProcessCaptureCapability.js +1 -1
- package/dist/application/ProcessCapturePermission.js +13 -0
- package/dist/application/ProcessCli.js +2 -12
- package/dist/application/ProcessHarness.js +1 -1
- package/dist/application/ProjectPermissionStore.js +48 -9
- package/dist/application/RealHopperAssertions.js +76 -0
- package/dist/application/ReconstructionCoverageService.js +69 -0
- package/dist/application/ReconstructionCoverageWorkspaceStore.js +31 -0
- package/dist/application/RuntimeExecutableDiagnostics.js +172 -0
- package/dist/application/Setup.js +147 -259
- package/dist/application/SetupClientConfiguration.js +220 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +123 -12
- package/dist/application/SetupSkill.js +26 -12
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +6 -3
- package/dist/application/WindowsCapabilities.js +86 -0
- package/dist/artifacts/AsarArtifactReader.js +11 -0
- package/dist/browser/BrowserProcessStartup.js +88 -0
- package/dist/browser/CdpCaptureDocuments.js +12 -8
- package/dist/browser/CdpCaptureEventBodyShapes.js +75 -0
- package/dist/browser/CdpCaptureEventHandlers.js +336 -0
- package/dist/browser/CdpCaptureEventHelpers.js +71 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +1 -0
- package/dist/browser/CdpCaptureEvents.js +29 -496
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -133
- package/dist/browser/CdpPageCaptureScripts.js +97 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpWebMcpDiscovery.js +38 -14
- package/dist/browser/PngVisualDiff.js +9 -2
- package/dist/catalogIdentity.js +4 -0
- package/dist/cli/artifactCommands.js +82 -0
- package/dist/cli/coreAnalysisCommands.js +232 -0
- package/dist/cli/managedCommands.js +397 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/options.js +9 -0
- package/dist/cli/setupCommands.js +108 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +122 -0
- package/dist/cli.js +10 -768
- package/dist/cliApplicationCommands.js +118 -4
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +4 -0
- package/dist/cliElectronCommands.js +33 -62
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- package/dist/cliObservationOptions.js +137 -0
- package/dist/cliPolicyCommands.js +80 -46
- package/dist/cliSetup.js +289 -0
- package/dist/config/environment.js +107 -0
- package/dist/config/parseConfig.js +228 -0
- package/dist/config/parsers.js +68 -0
- package/dist/config/permissions.js +30 -0
- package/dist/config/types.js +1 -0
- package/dist/config.js +1 -375
- package/dist/contracts/applicationToolContracts.js +134 -0
- package/dist/contracts/managedToolContracts.js +1 -1
- package/dist/contracts/managedWorkflowToolContracts.js +3 -3
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContracts.js +2 -2
- package/dist/contracts/toolEffects.js +14 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -550
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +34 -15
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -285
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +14 -2
- package/dist/domain/errors.js +4 -486
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/javascriptApplicationVersionItems.js +18 -6
- package/dist/domain/javascriptApplicationVersionKeys.js +8 -8
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureTraversal.js +19 -7
- package/dist/domain/javascriptRuntimeStaticCandidates.js +3 -1
- package/dist/domain/javascriptSemanticAnalysis.js +386 -0
- package/dist/domain/javascriptSemanticIr.js +30 -0
- package/dist/domain/javascriptSemanticProjection.js +366 -0
- package/dist/domain/javascriptSemanticState.js +40 -0
- package/dist/domain/javascriptSemanticTraversal.js +22 -0
- package/dist/domain/javascriptSemanticValues.js +352 -0
- package/dist/domain/javascriptStaticAnalysis.js +5 -221
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +71 -2
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +14 -364
- package/dist/domain/managedApplicationGraphCoverage.js +170 -0
- package/dist/domain/managedApplicationGraphNodeCoverage.js +6 -0
- package/dist/domain/managedApplicationGraphNodes.js +336 -0
- package/dist/domain/managedArtifact.js +16 -8
- package/dist/domain/managedMemberComparison.js +37 -391
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +27 -389
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +82 -69
- package/dist/domain/managedRuntimeCorrelation.js +12 -3
- package/dist/domain/nodeRuntimeCharacterization.js +66 -0
- package/dist/domain/permissionPolicy.js +2 -0
- package/dist/domain/reconstructionCoverage.js +387 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +212 -0
- package/dist/domain/reconstructionVerificationSchemas.js +8 -0
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/webBundleAnalyzer.js +3 -409
- package/dist/domain/webBundleAnalyzerAst.js +77 -0
- package/dist/domain/webBundleAnalyzerInspection.js +307 -0
- package/dist/domain/webBundleAnalyzerResult.js +120 -0
- package/dist/dotnet/ManagedArtifactInspector.js +50 -29
- package/dist/dotnet/ManagedMemberInspector.js +51 -785
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataInventory.js +42 -306
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +48 -111
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +143 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +311 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +102 -350
- package/dist/dotnet/ManagedPeReader.js +59 -28
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraClient.js +76 -91
- package/dist/ghidra/GhidraClientStartup.js +29 -0
- package/dist/ghidra/GhidraClientWire.js +34 -0
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraDiagnostics.js +6 -1
- package/dist/ghidra/GhidraInstallation.js +20 -15
- package/dist/ghidra/GhidraLauncher.js +93 -29
- package/dist/ghidra/GhidraProvider.js +61 -161
- package/dist/ghidra/GhidraProviderCapabilities.js +173 -0
- package/dist/ghidra/GhidraSessionValues.js +2 -0
- package/dist/ghidra/GhidraSocketConnection.js +44 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +30 -0
- package/dist/ghidra/GhidraTransport.js +71 -0
- package/dist/identity.js +3 -2
- package/dist/main/messages.js +5 -0
- package/dist/main/reload.js +49 -0
- package/dist/main/shutdown.js +25 -0
- package/dist/main/startup.js +14 -0
- package/dist/main/state.js +26 -0
- package/dist/main/transport.js +61 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +35 -146
- package/dist/process/PrivateRuntimeRoot.js +3 -2
- package/dist/process/ProcessOwnership.js +35 -0
- package/dist/process/ProviderProcess.js +2 -0
- package/dist/replay/JavaScriptReplayWorker.js +64 -50
- package/dist/replay/LinuxJavaScriptReplayRunner.js +173 -390
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +119 -54
- package/dist/server/registerApplicationTools/characterization.js +57 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/controlledReplay.js +38 -0
- package/dist/server/registerApplicationTools/coverage.js +84 -0
- package/dist/server/registerApplicationTools/helpers.js +42 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +10 -112
- package/dist/server/registerBrowserTools.js +59 -83
- package/dist/server/registerElectronTools.js +31 -46
- package/dist/server/registerEnhancedTools.js +34 -42
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +83 -116
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +65 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +8 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +43 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +39 -0
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +39 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +52 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +75 -0
- package/dist/server/registerManagedWorkflowTools.js +10 -274
- package/dist/server/registerOfficialTools.js +73 -59
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +2 -1
- package/dist/server/registerSessionTools.js +60 -164
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/toolRegistrationOptions.js +101 -3
- package/dist/server/toolResult.js +5 -0
- package/package.json +10 -11
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +20 -7
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from "incur";
|
|
2
|
+
import { runDirectAnalysis } from "../application/DirectAnalysis.js";
|
|
3
|
+
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
4
|
+
import { logCliCommand } from "../cliLogging.js";
|
|
5
|
+
import { directAnalysisOptions, providerSelectionOption } from "./options.js";
|
|
6
|
+
export const registerCoreAnalysisCommands = (cli, logger) => {
|
|
7
|
+
registerCoreCommands(cli, logger);
|
|
8
|
+
registerFunctionCommand(cli, logger);
|
|
9
|
+
registerSearchCommand(cli, logger);
|
|
10
|
+
registerXrefsCommand(cli, logger);
|
|
11
|
+
registerTraceCommand(cli, logger);
|
|
12
|
+
};
|
|
13
|
+
const registerCoreCommands = (cli, logger) => {
|
|
14
|
+
const overviewOptions = z.object({
|
|
15
|
+
detail: z
|
|
16
|
+
.enum(["concise", "detailed"])
|
|
17
|
+
.default("concise")
|
|
18
|
+
.describe("Overview detail level"),
|
|
19
|
+
limit: z
|
|
20
|
+
.number()
|
|
21
|
+
.int()
|
|
22
|
+
.min(1)
|
|
23
|
+
.max(50)
|
|
24
|
+
.default(10)
|
|
25
|
+
.describe("Maximum overview items to return"),
|
|
26
|
+
snapshot: z
|
|
27
|
+
.string()
|
|
28
|
+
.min(1)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Load and update a local analysis snapshot"),
|
|
31
|
+
provider: providerSelectionOption,
|
|
32
|
+
});
|
|
33
|
+
cli.command(CLI_COMMANDS.analyze, {
|
|
34
|
+
description: "Get an overview of an app",
|
|
35
|
+
args: z.object({
|
|
36
|
+
path: z.string().describe("App, program, or analysis database path"),
|
|
37
|
+
}),
|
|
38
|
+
options: overviewOptions,
|
|
39
|
+
run: ({ args, options }) => logCliCommand(logger, "analyze", () => runDirectAnalysis(args.path, "binary_overview", { detail: options.detail, limit: options.limit }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
40
|
+
});
|
|
41
|
+
cli.command(CLI_COMMANDS.inspect, {
|
|
42
|
+
description: "Inspect an app overview with evidence",
|
|
43
|
+
args: z.object({
|
|
44
|
+
path: z.string().describe("App, program, or analysis database path"),
|
|
45
|
+
}),
|
|
46
|
+
options: overviewOptions,
|
|
47
|
+
run: ({ args, options }) => logCliCommand(logger, "inspect", () => runDirectAnalysis(args.path, "binary_overview", { detail: options.detail, limit: options.limit }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
48
|
+
});
|
|
49
|
+
cli.command(CLI_COMMANDS.decompile, {
|
|
50
|
+
description: "Read one part of an app as code",
|
|
51
|
+
args: z.object({
|
|
52
|
+
path: z.string().describe("App or program path"),
|
|
53
|
+
address: z.string().describe("Procedure address"),
|
|
54
|
+
}),
|
|
55
|
+
options: z.object({
|
|
56
|
+
snapshot: z
|
|
57
|
+
.string()
|
|
58
|
+
.min(1)
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Load and update a local analysis snapshot"),
|
|
61
|
+
provider: providerSelectionOption,
|
|
62
|
+
}),
|
|
63
|
+
run: ({ args, options }) => logCliCommand(logger, "decompile", () => runDirectAnalysis(args.path, "procedure_pseudo_code", { procedure: args.address }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const registerXrefsCommand = (cli, logger) => {
|
|
67
|
+
cli.command(CLI_COMMANDS.xrefs, {
|
|
68
|
+
description: "List bounded references to an analyzed address",
|
|
69
|
+
args: z.object({
|
|
70
|
+
path: z.string().describe("App or program path"),
|
|
71
|
+
address: z.string().describe("Hexadecimal address"),
|
|
72
|
+
}),
|
|
73
|
+
options: z.object({
|
|
74
|
+
snapshot: z
|
|
75
|
+
.string()
|
|
76
|
+
.min(1)
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Load and update a local analysis snapshot"),
|
|
79
|
+
provider: providerSelectionOption,
|
|
80
|
+
}),
|
|
81
|
+
run: ({ args, options }) => logCliCommand(logger, "xrefs", () => runDirectAnalysis(args.path, "xrefs", { address: args.address }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const registerTraceCommand = (cli, logger) => {
|
|
85
|
+
cli.command(CLI_COMMANDS.trace, {
|
|
86
|
+
description: "Trace a bounded literal feature through analyzed references",
|
|
87
|
+
args: z.object({
|
|
88
|
+
path: z.string().describe("App or program path"),
|
|
89
|
+
query: z.string().min(1).describe("Literal feature query"),
|
|
90
|
+
}),
|
|
91
|
+
options: z.object({
|
|
92
|
+
caseSensitive: z
|
|
93
|
+
.boolean()
|
|
94
|
+
.default(false)
|
|
95
|
+
.describe("Match the query with exact letter case"),
|
|
96
|
+
limit: z
|
|
97
|
+
.number()
|
|
98
|
+
.int()
|
|
99
|
+
.min(1)
|
|
100
|
+
.max(100)
|
|
101
|
+
.default(20)
|
|
102
|
+
.describe("Maximum matching roots to examine"),
|
|
103
|
+
maxOperations: z
|
|
104
|
+
.number()
|
|
105
|
+
.int()
|
|
106
|
+
.min(1)
|
|
107
|
+
.max(100)
|
|
108
|
+
.default(20)
|
|
109
|
+
.describe("Maximum analysis operations in the trace"),
|
|
110
|
+
snapshot: z
|
|
111
|
+
.string()
|
|
112
|
+
.min(1)
|
|
113
|
+
.optional()
|
|
114
|
+
.describe("Load and update a local analysis snapshot"),
|
|
115
|
+
provider: providerSelectionOption,
|
|
116
|
+
}),
|
|
117
|
+
alias: {
|
|
118
|
+
caseSensitive: "case-sensitive",
|
|
119
|
+
maxOperations: "max-operations",
|
|
120
|
+
},
|
|
121
|
+
run: ({ args, options }) => logCliCommand(logger, "trace", () => runDirectAnalysis(args.path, "trace_feature", {
|
|
122
|
+
query: args.query,
|
|
123
|
+
case_sensitive: options.caseSensitive,
|
|
124
|
+
limit: options.limit,
|
|
125
|
+
max_operations: options.maxOperations,
|
|
126
|
+
}, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const registerFunctionCommand = (cli, logger) => {
|
|
130
|
+
cli.command(CLI_COMMANDS.function, {
|
|
131
|
+
description: "Analyze one bounded function with evidence",
|
|
132
|
+
args: z.object({
|
|
133
|
+
path: z.string().describe("App or program path"),
|
|
134
|
+
address: z.string().describe("Procedure name or address"),
|
|
135
|
+
}),
|
|
136
|
+
options: z.object({
|
|
137
|
+
includeAssembly: z
|
|
138
|
+
.boolean()
|
|
139
|
+
.default(false)
|
|
140
|
+
.describe("Include bounded assembly instructions"),
|
|
141
|
+
limit: z
|
|
142
|
+
.number()
|
|
143
|
+
.int()
|
|
144
|
+
.min(1)
|
|
145
|
+
.max(500)
|
|
146
|
+
.default(100)
|
|
147
|
+
.describe("Maximum referenced items to return"),
|
|
148
|
+
maxPseudocodeChars: z
|
|
149
|
+
.number()
|
|
150
|
+
.int()
|
|
151
|
+
.min(1)
|
|
152
|
+
.max(100_000)
|
|
153
|
+
.default(20_000)
|
|
154
|
+
.describe("Maximum pseudocode characters to return"),
|
|
155
|
+
maxInstructions: z
|
|
156
|
+
.number()
|
|
157
|
+
.int()
|
|
158
|
+
.min(1)
|
|
159
|
+
.max(5_000)
|
|
160
|
+
.default(500)
|
|
161
|
+
.describe("Maximum assembly instructions to return"),
|
|
162
|
+
snapshot: z
|
|
163
|
+
.string()
|
|
164
|
+
.min(1)
|
|
165
|
+
.optional()
|
|
166
|
+
.describe("Load and update a local analysis snapshot"),
|
|
167
|
+
provider: providerSelectionOption,
|
|
168
|
+
}),
|
|
169
|
+
alias: {
|
|
170
|
+
includeAssembly: "include-assembly",
|
|
171
|
+
maxPseudocodeChars: "max-pseudocode-chars",
|
|
172
|
+
maxInstructions: "max-instructions",
|
|
173
|
+
},
|
|
174
|
+
run: ({ args, options }) => logCliCommand(logger, "function", () => runDirectAnalysis(args.path, "analyze_function", {
|
|
175
|
+
procedure: args.address,
|
|
176
|
+
include_assembly: options.includeAssembly,
|
|
177
|
+
limit: options.limit,
|
|
178
|
+
max_pseudocode_chars: options.maxPseudocodeChars,
|
|
179
|
+
max_instructions: options.maxInstructions,
|
|
180
|
+
}, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
const registerSearchCommand = (cli, logger) => {
|
|
184
|
+
cli.command(CLI_COMMANDS.search, {
|
|
185
|
+
description: "Search bounded analyzed strings or procedure names",
|
|
186
|
+
args: z.object({
|
|
187
|
+
path: z.string().describe("App or program path"),
|
|
188
|
+
pattern: z.string().min(1).describe("Literal text or regex pattern"),
|
|
189
|
+
}),
|
|
190
|
+
options: z.object({
|
|
191
|
+
kind: z
|
|
192
|
+
.enum(["strings", "procedures"])
|
|
193
|
+
.default("strings")
|
|
194
|
+
.describe("Analyzed item kind to search"),
|
|
195
|
+
mode: z
|
|
196
|
+
.enum(["literal", "regex"])
|
|
197
|
+
.default("literal")
|
|
198
|
+
.describe("Interpret the pattern as literal text or a regex"),
|
|
199
|
+
caseSensitive: z
|
|
200
|
+
.boolean()
|
|
201
|
+
.default(false)
|
|
202
|
+
.describe("Match the pattern with exact letter case"),
|
|
203
|
+
offset: z
|
|
204
|
+
.number()
|
|
205
|
+
.int()
|
|
206
|
+
.min(0)
|
|
207
|
+
.default(0)
|
|
208
|
+
.describe("Zero-based matching-item offset"),
|
|
209
|
+
limit: z
|
|
210
|
+
.number()
|
|
211
|
+
.int()
|
|
212
|
+
.min(1)
|
|
213
|
+
.max(100)
|
|
214
|
+
.default(100)
|
|
215
|
+
.describe("Maximum matching items to return"),
|
|
216
|
+
snapshot: z
|
|
217
|
+
.string()
|
|
218
|
+
.min(1)
|
|
219
|
+
.optional()
|
|
220
|
+
.describe("Load and update a local analysis snapshot"),
|
|
221
|
+
provider: providerSelectionOption,
|
|
222
|
+
}),
|
|
223
|
+
alias: { caseSensitive: "case-sensitive" },
|
|
224
|
+
run: ({ args, options }) => logCliCommand(logger, "search", () => runDirectAnalysis(args.path, options.kind === "strings" ? "search_strings" : "search_procedures", {
|
|
225
|
+
pattern: args.pattern,
|
|
226
|
+
mode: options.mode,
|
|
227
|
+
case_sensitive: options.caseSensitive,
|
|
228
|
+
offset: options.offset,
|
|
229
|
+
limit: options.limit,
|
|
230
|
+
}, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
231
|
+
});
|
|
232
|
+
};
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { z } from "incur";
|
|
2
|
+
import { compareManagedMemberPaths, } from "../application/ManagedMemberComparisonService.js";
|
|
3
|
+
import { verifyManagedNativeBoundariesEvidence } from "../application/ManagedNativeVerificationService.js";
|
|
4
|
+
import { importManagedReconstructionEvidence } from "../application/ManagedReconstructionService.js";
|
|
5
|
+
import { planManagedRuntimeCorrelationEvidence } from "../application/ManagedRuntimeCorrelationService.js";
|
|
6
|
+
import { runProviderAnalysis } from "../application/DirectAnalysis.js";
|
|
7
|
+
import { parseConfig } from "../config.js";
|
|
8
|
+
import { loadConfiguredPermissionAuthority } from "../application/PermissionConfiguration.js";
|
|
9
|
+
import { parseCliJsonInput } from "../cliJsonInput.js";
|
|
10
|
+
import { projectAnalysisError } from "../domain/errors.js";
|
|
11
|
+
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
12
|
+
import { logCliCommand } from "../cliLogging.js";
|
|
13
|
+
import { registerProjectManagedApplicationGraph } from "./managedProjectGraphCommand.js";
|
|
14
|
+
const managedOffset = (subject) => z.number().int().min(0).default(0).describe(`Zero-based ${subject} offset`);
|
|
15
|
+
const managedLimit = (subject, maximum, fallback) => z
|
|
16
|
+
.number()
|
|
17
|
+
.int()
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(maximum)
|
|
20
|
+
.default(fallback)
|
|
21
|
+
.describe(`Maximum ${subject} to return`);
|
|
22
|
+
const managedInspectionLimits = {
|
|
23
|
+
maxFileBytes: z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.min(4_096)
|
|
27
|
+
.max(1_073_741_824)
|
|
28
|
+
.default(268_435_456)
|
|
29
|
+
.describe("Maximum managed artifact file size accepted for inspection"),
|
|
30
|
+
maxMetadataBytes: z
|
|
31
|
+
.number()
|
|
32
|
+
.int()
|
|
33
|
+
.min(256)
|
|
34
|
+
.max(268_435_456)
|
|
35
|
+
.default(67_108_864)
|
|
36
|
+
.describe("Maximum CLI metadata region size accepted for inspection"),
|
|
37
|
+
maxTableRows: z
|
|
38
|
+
.number()
|
|
39
|
+
.int()
|
|
40
|
+
.min(1)
|
|
41
|
+
.max(1_000_000)
|
|
42
|
+
.default(100_000)
|
|
43
|
+
.describe("Maximum rows accepted in any CLI metadata table"),
|
|
44
|
+
maxHeapItemBytes: z
|
|
45
|
+
.number()
|
|
46
|
+
.int()
|
|
47
|
+
.min(1)
|
|
48
|
+
.max(16_777_216)
|
|
49
|
+
.default(1_048_576)
|
|
50
|
+
.describe("Maximum bytes accepted for one CLI metadata heap item"),
|
|
51
|
+
};
|
|
52
|
+
export const registerManagedCommands = (cli, logger) => {
|
|
53
|
+
registerInspectManagedArtifact(cli, logger);
|
|
54
|
+
registerInspectManagedMembers(cli, logger);
|
|
55
|
+
registerInspectManagedNativeBoundaries(cli, logger);
|
|
56
|
+
registerCompareManagedMembers(cli, logger);
|
|
57
|
+
registerImportManagedReconstruction(cli, logger);
|
|
58
|
+
registerVerifyManagedNativeBoundaries(cli, logger);
|
|
59
|
+
registerPlanManagedRuntimeCorrelation(cli, logger);
|
|
60
|
+
registerProjectManagedApplicationGraph(cli, logger);
|
|
61
|
+
};
|
|
62
|
+
const registerInspectManagedArtifact = (cli, logger) => {
|
|
63
|
+
cli.command(CLI_COMMANDS.inspectManagedArtifact, {
|
|
64
|
+
description: "Inspect PE/CLI identity without loading target code",
|
|
65
|
+
args: z.object({
|
|
66
|
+
path: z.string().describe("Managed PE executable or assembly path"),
|
|
67
|
+
}),
|
|
68
|
+
options: z.object({
|
|
69
|
+
referenceOffset: managedOffset("assembly-reference"),
|
|
70
|
+
referenceLimit: managedLimit("assembly references", 500, 100),
|
|
71
|
+
resourceOffset: managedOffset("manifest-resource"),
|
|
72
|
+
resourceLimit: managedLimit("manifest resources", 500, 100),
|
|
73
|
+
attributeOffset: managedOffset("assembly-attribute"),
|
|
74
|
+
attributeLimit: managedLimit("assembly attributes", 500, 100),
|
|
75
|
+
...managedInspectionLimits,
|
|
76
|
+
}),
|
|
77
|
+
alias: {
|
|
78
|
+
referenceOffset: "reference-offset",
|
|
79
|
+
referenceLimit: "reference-limit",
|
|
80
|
+
resourceOffset: "resource-offset",
|
|
81
|
+
resourceLimit: "resource-limit",
|
|
82
|
+
attributeOffset: "attribute-offset",
|
|
83
|
+
attributeLimit: "attribute-limit",
|
|
84
|
+
maxFileBytes: "max-file-bytes",
|
|
85
|
+
maxMetadataBytes: "max-metadata-bytes",
|
|
86
|
+
maxTableRows: "max-table-rows",
|
|
87
|
+
maxHeapItemBytes: "max-heap-item-bytes",
|
|
88
|
+
},
|
|
89
|
+
run: ({ args, options }) => logCliCommand(logger, "inspect-managed-artifact", () => runProviderAnalysis(args.path, "inspect_managed_artifact", {
|
|
90
|
+
reference_offset: options.referenceOffset,
|
|
91
|
+
reference_limit: options.referenceLimit,
|
|
92
|
+
resource_offset: options.resourceOffset,
|
|
93
|
+
resource_limit: options.resourceLimit,
|
|
94
|
+
attribute_offset: options.attributeOffset,
|
|
95
|
+
attribute_limit: options.attributeLimit,
|
|
96
|
+
max_file_bytes: options.maxFileBytes,
|
|
97
|
+
max_metadata_bytes: options.maxMetadataBytes,
|
|
98
|
+
max_table_rows: options.maxTableRows,
|
|
99
|
+
max_heap_item_bytes: options.maxHeapItemBytes,
|
|
100
|
+
}, logger)),
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const registerInspectManagedMembers = (cli, logger) => {
|
|
104
|
+
cli.command(CLI_COMMANDS.inspectManagedMembers, {
|
|
105
|
+
description: "Inspect PE/CLI metadata members, signatures, and CIL anchors without loading target code",
|
|
106
|
+
args: z.object({
|
|
107
|
+
path: z.string().describe("Managed PE executable or assembly path"),
|
|
108
|
+
}),
|
|
109
|
+
options: z.object({
|
|
110
|
+
typeOffset: managedOffset("type definition"),
|
|
111
|
+
typeLimit: managedLimit("type definitions", 500, 100),
|
|
112
|
+
methodOffset: managedOffset("method definition"),
|
|
113
|
+
methodLimit: managedLimit("method definitions", 500, 100),
|
|
114
|
+
fieldOffset: managedOffset("field definition"),
|
|
115
|
+
fieldLimit: managedLimit("field definitions", 500, 100),
|
|
116
|
+
memberRefOffset: managedOffset("member reference"),
|
|
117
|
+
memberRefLimit: managedLimit("member references", 500, 100),
|
|
118
|
+
edgeOffset: managedOffset("member edge"),
|
|
119
|
+
edgeLimit: managedLimit("member edges", 1_000, 250),
|
|
120
|
+
instructionAnchorLimit: z
|
|
121
|
+
.number()
|
|
122
|
+
.int()
|
|
123
|
+
.min(0)
|
|
124
|
+
.max(500)
|
|
125
|
+
.default(100)
|
|
126
|
+
.describe("Maximum CIL instruction anchors per method"),
|
|
127
|
+
...managedInspectionLimits,
|
|
128
|
+
maxMethodBodyBytes: z
|
|
129
|
+
.number()
|
|
130
|
+
.int()
|
|
131
|
+
.min(1)
|
|
132
|
+
.max(16_777_216)
|
|
133
|
+
.default(1_048_576)
|
|
134
|
+
.describe("Maximum CIL method body size accepted for inspection"),
|
|
135
|
+
maxMethodInstructions: z
|
|
136
|
+
.number()
|
|
137
|
+
.int()
|
|
138
|
+
.min(1)
|
|
139
|
+
.max(100_000)
|
|
140
|
+
.default(10_000)
|
|
141
|
+
.describe("Maximum decoded CIL instructions per method"),
|
|
142
|
+
}),
|
|
143
|
+
alias: {
|
|
144
|
+
typeOffset: "type-offset",
|
|
145
|
+
typeLimit: "type-limit",
|
|
146
|
+
methodOffset: "method-offset",
|
|
147
|
+
methodLimit: "method-limit",
|
|
148
|
+
fieldOffset: "field-offset",
|
|
149
|
+
fieldLimit: "field-limit",
|
|
150
|
+
memberRefOffset: "member-ref-offset",
|
|
151
|
+
memberRefLimit: "member-ref-limit",
|
|
152
|
+
edgeOffset: "edge-offset",
|
|
153
|
+
edgeLimit: "edge-limit",
|
|
154
|
+
instructionAnchorLimit: "instruction-anchor-limit",
|
|
155
|
+
maxFileBytes: "max-file-bytes",
|
|
156
|
+
maxMetadataBytes: "max-metadata-bytes",
|
|
157
|
+
maxTableRows: "max-table-rows",
|
|
158
|
+
maxHeapItemBytes: "max-heap-item-bytes",
|
|
159
|
+
maxMethodBodyBytes: "max-method-body-bytes",
|
|
160
|
+
maxMethodInstructions: "max-method-instructions",
|
|
161
|
+
},
|
|
162
|
+
run: ({ args, options }) => logCliCommand(logger, "inspect-managed-members", () => runProviderAnalysis(args.path, "inspect_managed_members", {
|
|
163
|
+
type_offset: options.typeOffset,
|
|
164
|
+
type_limit: options.typeLimit,
|
|
165
|
+
method_offset: options.methodOffset,
|
|
166
|
+
method_limit: options.methodLimit,
|
|
167
|
+
field_offset: options.fieldOffset,
|
|
168
|
+
field_limit: options.fieldLimit,
|
|
169
|
+
member_ref_offset: options.memberRefOffset,
|
|
170
|
+
member_ref_limit: options.memberRefLimit,
|
|
171
|
+
edge_offset: options.edgeOffset,
|
|
172
|
+
edge_limit: options.edgeLimit,
|
|
173
|
+
instruction_anchor_limit: options.instructionAnchorLimit,
|
|
174
|
+
max_file_bytes: options.maxFileBytes,
|
|
175
|
+
max_metadata_bytes: options.maxMetadataBytes,
|
|
176
|
+
max_table_rows: options.maxTableRows,
|
|
177
|
+
max_heap_item_bytes: options.maxHeapItemBytes,
|
|
178
|
+
max_method_body_bytes: options.maxMethodBodyBytes,
|
|
179
|
+
max_method_instructions: options.maxMethodInstructions,
|
|
180
|
+
}, logger)),
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
const registerInspectManagedNativeBoundaries = (cli, logger) => {
|
|
184
|
+
cli.command(CLI_COMMANDS.inspectManagedNativeBoundaries, {
|
|
185
|
+
description: "Inspect PE/CLI PInvoke and native implementation boundary declarations without loading target code",
|
|
186
|
+
args: z.object({
|
|
187
|
+
path: z.string().describe("Managed PE executable or assembly path"),
|
|
188
|
+
}),
|
|
189
|
+
options: z.object({
|
|
190
|
+
moduleRefOffset: managedOffset("module reference"),
|
|
191
|
+
moduleRefLimit: managedLimit("module references", 500, 100),
|
|
192
|
+
importOffset: managedOffset("platform import"),
|
|
193
|
+
importLimit: managedLimit("platform imports", 500, 100),
|
|
194
|
+
implementationOffset: managedOffset("native implementation"),
|
|
195
|
+
implementationLimit: managedLimit("native implementations", 500, 100),
|
|
196
|
+
...managedInspectionLimits,
|
|
197
|
+
}),
|
|
198
|
+
alias: {
|
|
199
|
+
moduleRefOffset: "module-ref-offset",
|
|
200
|
+
moduleRefLimit: "module-ref-limit",
|
|
201
|
+
importOffset: "import-offset",
|
|
202
|
+
importLimit: "import-limit",
|
|
203
|
+
implementationOffset: "implementation-offset",
|
|
204
|
+
implementationLimit: "implementation-limit",
|
|
205
|
+
maxFileBytes: "max-file-bytes",
|
|
206
|
+
maxMetadataBytes: "max-metadata-bytes",
|
|
207
|
+
maxTableRows: "max-table-rows",
|
|
208
|
+
maxHeapItemBytes: "max-heap-item-bytes",
|
|
209
|
+
},
|
|
210
|
+
run: ({ args, options }) => logCliCommand(logger, "inspect-managed-native-boundaries", () => runProviderAnalysis(args.path, "inspect_managed_native_boundaries", {
|
|
211
|
+
module_ref_offset: options.moduleRefOffset,
|
|
212
|
+
module_ref_limit: options.moduleRefLimit,
|
|
213
|
+
import_offset: options.importOffset,
|
|
214
|
+
import_limit: options.importLimit,
|
|
215
|
+
implementation_offset: options.implementationOffset,
|
|
216
|
+
implementation_limit: options.implementationLimit,
|
|
217
|
+
max_file_bytes: options.maxFileBytes,
|
|
218
|
+
max_metadata_bytes: options.maxMetadataBytes,
|
|
219
|
+
max_table_rows: options.maxTableRows,
|
|
220
|
+
max_heap_item_bytes: options.maxHeapItemBytes,
|
|
221
|
+
}, logger)),
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
const compareManagedMemberArgs = z.object({
|
|
225
|
+
leftPath: z.string().describe("Baseline managed PE executable or assembly"),
|
|
226
|
+
rightPath: z.string().describe("Candidate managed PE executable or assembly"),
|
|
227
|
+
});
|
|
228
|
+
const registerCompareManagedMembers = (cli, logger) => {
|
|
229
|
+
cli.command(CLI_COMMANDS.compareManagedMembers, {
|
|
230
|
+
description: "Compare two managed PE/CLI member inventories without name-based matching",
|
|
231
|
+
args: compareManagedMemberArgs,
|
|
232
|
+
options: z.object({
|
|
233
|
+
maxMethodMatches: z
|
|
234
|
+
.number()
|
|
235
|
+
.int()
|
|
236
|
+
.min(1)
|
|
237
|
+
.max(50_000)
|
|
238
|
+
.default(10_000)
|
|
239
|
+
.describe("Maximum exact method matches to return"),
|
|
240
|
+
maxFieldMatches: z
|
|
241
|
+
.number()
|
|
242
|
+
.int()
|
|
243
|
+
.min(0)
|
|
244
|
+
.max(50_000)
|
|
245
|
+
.default(5_000)
|
|
246
|
+
.describe("Maximum exact field matches to return"),
|
|
247
|
+
maxCandidates: z
|
|
248
|
+
.number()
|
|
249
|
+
.int()
|
|
250
|
+
.min(1)
|
|
251
|
+
.max(500)
|
|
252
|
+
.default(50)
|
|
253
|
+
.describe("Maximum ambiguous candidates per unmatched member"),
|
|
254
|
+
typeLimit: managedLimit("type definitions per artifact", 500, 500),
|
|
255
|
+
methodLimit: managedLimit("method definitions per artifact", 500, 500),
|
|
256
|
+
fieldLimit: managedLimit("field definitions per artifact", 500, 500),
|
|
257
|
+
memberRefLimit: managedLimit("member references per artifact", 500, 500),
|
|
258
|
+
edgeLimit: managedLimit("member edges per artifact", 1_000, 1_000),
|
|
259
|
+
instructionAnchorLimit: z
|
|
260
|
+
.number()
|
|
261
|
+
.int()
|
|
262
|
+
.min(0)
|
|
263
|
+
.max(500)
|
|
264
|
+
.default(500)
|
|
265
|
+
.describe("Maximum CIL instruction anchors per compared method"),
|
|
266
|
+
...managedInspectionLimits,
|
|
267
|
+
maxMethodBodyBytes: z
|
|
268
|
+
.number()
|
|
269
|
+
.int()
|
|
270
|
+
.min(1)
|
|
271
|
+
.max(16_777_216)
|
|
272
|
+
.default(1_048_576)
|
|
273
|
+
.describe("Maximum CIL method body size accepted for comparison"),
|
|
274
|
+
maxMethodInstructions: z
|
|
275
|
+
.number()
|
|
276
|
+
.int()
|
|
277
|
+
.min(1)
|
|
278
|
+
.max(100_000)
|
|
279
|
+
.default(100_000)
|
|
280
|
+
.describe("Maximum decoded CIL instructions per compared method"),
|
|
281
|
+
}),
|
|
282
|
+
alias: {
|
|
283
|
+
maxMethodMatches: "max-method-matches",
|
|
284
|
+
maxFieldMatches: "max-field-matches",
|
|
285
|
+
maxCandidates: "max-candidates",
|
|
286
|
+
typeLimit: "type-limit",
|
|
287
|
+
methodLimit: "method-limit",
|
|
288
|
+
fieldLimit: "field-limit",
|
|
289
|
+
memberRefLimit: "member-ref-limit",
|
|
290
|
+
edgeLimit: "edge-limit",
|
|
291
|
+
instructionAnchorLimit: "instruction-anchor-limit",
|
|
292
|
+
maxFileBytes: "max-file-bytes",
|
|
293
|
+
maxMetadataBytes: "max-metadata-bytes",
|
|
294
|
+
maxTableRows: "max-table-rows",
|
|
295
|
+
maxHeapItemBytes: "max-heap-item-bytes",
|
|
296
|
+
maxMethodBodyBytes: "max-method-body-bytes",
|
|
297
|
+
maxMethodInstructions: "max-method-instructions",
|
|
298
|
+
},
|
|
299
|
+
run: ({ args, options }) => logCliCommand(logger, "compare-managed-members", async () => {
|
|
300
|
+
const result = await compareManagedMemberPaths({
|
|
301
|
+
leftPath: args.leftPath,
|
|
302
|
+
rightPath: args.rightPath,
|
|
303
|
+
comparisonLimits: {
|
|
304
|
+
max_method_matches: options.maxMethodMatches,
|
|
305
|
+
max_field_matches: options.maxFieldMatches,
|
|
306
|
+
max_candidates: options.maxCandidates,
|
|
307
|
+
},
|
|
308
|
+
memberLimits: buildMemberLimits(options),
|
|
309
|
+
});
|
|
310
|
+
return result.ok
|
|
311
|
+
? result.value
|
|
312
|
+
: {
|
|
313
|
+
error: "Managed member comparison failed",
|
|
314
|
+
...projectAnalysisError(result.error),
|
|
315
|
+
};
|
|
316
|
+
}),
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
const buildMemberLimits = (options) => ({
|
|
320
|
+
maxFileBytes: options.maxFileBytes,
|
|
321
|
+
typeOffset: 0,
|
|
322
|
+
typeLimit: options.typeLimit,
|
|
323
|
+
methodOffset: 0,
|
|
324
|
+
methodLimit: options.methodLimit,
|
|
325
|
+
fieldOffset: 0,
|
|
326
|
+
fieldLimit: options.fieldLimit,
|
|
327
|
+
memberRefOffset: 0,
|
|
328
|
+
memberRefLimit: options.memberRefLimit,
|
|
329
|
+
edgeOffset: 0,
|
|
330
|
+
edgeLimit: options.edgeLimit,
|
|
331
|
+
instructionAnchorLimit: options.instructionAnchorLimit,
|
|
332
|
+
maxMetadataBytes: options.maxMetadataBytes,
|
|
333
|
+
maxTableRows: options.maxTableRows,
|
|
334
|
+
maxHeapItemBytes: options.maxHeapItemBytes,
|
|
335
|
+
maxMethodBodyBytes: options.maxMethodBodyBytes,
|
|
336
|
+
maxMethodInstructions: options.maxMethodInstructions,
|
|
337
|
+
});
|
|
338
|
+
const registerImportManagedReconstruction = (cli, logger) => {
|
|
339
|
+
cli.command(CLI_COMMANDS.importManagedReconstruction, {
|
|
340
|
+
description: "Import decompiler-produced managed reconstruction against exact static member evidence",
|
|
341
|
+
args: z.object({
|
|
342
|
+
inputJson: z
|
|
343
|
+
.string()
|
|
344
|
+
.describe("Inline managed reconstruction JSON or JSON file path"),
|
|
345
|
+
}),
|
|
346
|
+
run: ({ args }) => logCliCommand(logger, "import-managed-reconstruction", async () => {
|
|
347
|
+
const input = await parseCliJsonInput(args.inputJson, "import-managed-reconstruction");
|
|
348
|
+
if (!input.ok)
|
|
349
|
+
return input.error;
|
|
350
|
+
const result = importManagedReconstructionEvidence(input.value);
|
|
351
|
+
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
352
|
+
}),
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
const registerVerifyManagedNativeBoundaries = (cli, logger) => {
|
|
356
|
+
cli.command(CLI_COMMANDS.verifyManagedNativeBoundaries, {
|
|
357
|
+
description: "Verify managed P/Invoke declarations against authenticated native Evidence",
|
|
358
|
+
args: z.object({
|
|
359
|
+
inputJson: z
|
|
360
|
+
.string()
|
|
361
|
+
.describe("Inline managed/native verification JSON or JSON file path"),
|
|
362
|
+
}),
|
|
363
|
+
run: ({ args }) => logCliCommand(logger, "verify-managed-native-boundaries", async () => {
|
|
364
|
+
const input = await parseCliJsonInput(args.inputJson, "verify-managed-native-boundaries");
|
|
365
|
+
if (!input.ok)
|
|
366
|
+
return input.error;
|
|
367
|
+
const result = verifyManagedNativeBoundariesEvidence(input.value);
|
|
368
|
+
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
369
|
+
}),
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
const registerPlanManagedRuntimeCorrelation = (cli, logger) => {
|
|
373
|
+
cli.command(CLI_COMMANDS.planManagedRuntimeCorrelation, {
|
|
374
|
+
description: "Plan a separately authorized managed runtime-correlation experiment without executing target code",
|
|
375
|
+
args: z.object({
|
|
376
|
+
inputJson: z
|
|
377
|
+
.string()
|
|
378
|
+
.describe("Inline managed runtime-correlation JSON or JSON file path"),
|
|
379
|
+
}),
|
|
380
|
+
run: ({ args }) => logCliCommand(logger, "plan-managed-runtime-correlation", async () => {
|
|
381
|
+
const input = await parseCliJsonInput(args.inputJson, "plan-managed-runtime-correlation");
|
|
382
|
+
if (!input.ok)
|
|
383
|
+
return input.error;
|
|
384
|
+
const config = parseConfig(process.env);
|
|
385
|
+
if (!config.ok)
|
|
386
|
+
return projectAnalysisError(config.error);
|
|
387
|
+
const authority = await loadConfiguredPermissionAuthority(config.value);
|
|
388
|
+
if (!authority.ok)
|
|
389
|
+
return projectAnalysisError(authority.error);
|
|
390
|
+
const result = await planManagedRuntimeCorrelationEvidence({
|
|
391
|
+
policy: config.value.managedRuntimePolicy,
|
|
392
|
+
authority: authority.value,
|
|
393
|
+
}, input.value);
|
|
394
|
+
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
395
|
+
}),
|
|
396
|
+
});
|
|
397
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "incur";
|
|
2
|
+
import { projectManagedApplicationGraphEvidence } from "../application/ManagedApplicationGraphService.js";
|
|
3
|
+
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
4
|
+
import { parseCliJsonInput } from "../cliJsonInput.js";
|
|
5
|
+
import { logCliCommand } from "../cliLogging.js";
|
|
6
|
+
import { projectAnalysisError } from "../domain/errors.js";
|
|
7
|
+
/** Register managed static-Evidence application graph projection. */
|
|
8
|
+
export const registerProjectManagedApplicationGraph = (cli, logger) => {
|
|
9
|
+
cli.command(CLI_COMMANDS.projectManagedApplicationGraph, {
|
|
10
|
+
description: "Project authenticated managed static Evidence into an application graph",
|
|
11
|
+
args: z.object({
|
|
12
|
+
inputJson: z
|
|
13
|
+
.string()
|
|
14
|
+
.describe("Inline managed application graph JSON or JSON file path"),
|
|
15
|
+
}),
|
|
16
|
+
run: ({ args }) => logCliCommand(logger, "project-managed-application-graph", async () => {
|
|
17
|
+
const input = await parseCliJsonInput(args.inputJson, "project-managed-application-graph");
|
|
18
|
+
if (!input.ok)
|
|
19
|
+
return input.error;
|
|
20
|
+
const result = projectManagedApplicationGraphEvidence(input.value);
|
|
21
|
+
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { analysisProviderSelectorSchema } from "../contracts/providerSelection.js";
|
|
2
|
+
export const providerSelectionOption = analysisProviderSelectorSchema
|
|
3
|
+
.optional()
|
|
4
|
+
.describe("Bind deep analysis to a provider ID or use deterministic auto selection");
|
|
5
|
+
export const directAnalysisOptions = (logger, snapshotPath, providerId) => ({
|
|
6
|
+
logger,
|
|
7
|
+
snapshotPath,
|
|
8
|
+
...(providerId === undefined ? {} : { providerId }),
|
|
9
|
+
});
|