rea-agents 2.0.0 → 2.2.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 +103 -38
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/AndroidApplicationService.js +17 -0
- package/dist/application/AppleApplicationService.js +17 -0
- 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 +11 -4
- 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/InventoryProjectionEvidence.js +41 -0
- package/dist/application/InvestigationProviders.js +12 -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/ProcessPairedExperiment.js +72 -0
- 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 +148 -260
- package/dist/application/SetupClientConfiguration.js +224 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +124 -12
- package/dist/application/SetupSkill.js +54 -36
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +12 -3
- package/dist/application/Upgrade.js +16 -1
- 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 +113 -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 +306 -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/electronToolContracts.js +51 -3
- package/dist/contracts/managedToolContracts.js +8 -3
- package/dist/contracts/managedWorkflowToolContracts.js +3 -3
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/sessionStatusContract.js +26 -0
- package/dist/contracts/toolContractTypes.js +12 -1
- package/dist/contracts/toolContracts.js +5 -12
- package/dist/contracts/toolEffects.js +14 -0
- package/dist/contracts/toolOutputSchemaGroups.js +274 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +328 -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/androidApplication.js +206 -0
- package/dist/domain/appleApplication.js +221 -0
- package/dist/domain/artifactComparison.js +34 -15
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/boundedCartesianProjection.js +15 -0
- 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/processComparison.js +19 -0
- package/dist/domain/processPairedExperiment.js +128 -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/replayMachine.js +316 -0
- package/dist/domain/replayMachineRuntime.js +215 -0
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/runtimeIdentification.js +210 -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/evaluation/CodexAgentEval.js +132 -0
- 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 +4 -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 +124 -56
- package/dist/server/javascriptApplicationResult.js +85 -0
- 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 +48 -49
- package/dist/server/registerEnhancedTools.js +34 -42
- package/dist/server/registerEvidenceResources.js +56 -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/registerJavaScriptApplicationGraphResource.js +69 -0
- package/dist/server/registerManagedTools.js +18 -1
- 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 +97 -26
- 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 +15 -4
- package/package.json +11 -11
- package/skills/reverse-engineer-anything/SKILL.md +76 -0
- package/skills/reverse-engineer-anything/references/controlled-replay.md +12 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +33 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +25 -0
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +36 -0
- package/skills/reverse-engineer-anything/references/runtime-observation.md +24 -0
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
- package/skills/rea-analysis/SKILL.md +0 -222
package/dist/cli.js
CHANGED
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
import { Cli
|
|
1
|
+
import { Cli } from "incur";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { createInterface } from "node:readline/promises";
|
|
4
|
-
import { runDoctor } from "./application/Doctor.js";
|
|
5
|
-
import { runDirectAnalysis, runProviderAnalysis, runSessionStatus, } from "./application/DirectAnalysis.js";
|
|
6
|
-
import { compareManagedMemberPaths } from "./application/ManagedMemberComparisonService.js";
|
|
7
|
-
import { projectManagedApplicationGraphEvidence } from "./application/ManagedApplicationGraphService.js";
|
|
8
|
-
import { verifyManagedNativeBoundariesEvidence } from "./application/ManagedNativeVerificationService.js";
|
|
9
|
-
import { importManagedReconstructionEvidence } from "./application/ManagedReconstructionService.js";
|
|
10
|
-
import { planManagedRuntimeCorrelationEvidence } from "./application/ManagedRuntimeCorrelationService.js";
|
|
11
|
-
import { runSetup, systemSetupHost, } from "./application/Setup.js";
|
|
12
|
-
import { runUninstall } from "./application/Uninstall.js";
|
|
13
|
-
import { runUpgrade, systemUpgradeHost } from "./application/Upgrade.js";
|
|
14
|
-
import { PRODUCT_IDENTITY } from "./identity.js";
|
|
15
3
|
import { createLogger, parseLogLevel } from "./logger.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
4
|
+
import { PRODUCT_IDENTITY } from "./identity.js";
|
|
5
|
+
import { registerSetupCommands } from "./cli/setupCommands.js";
|
|
6
|
+
import { registerCoreAnalysisCommands } from "./cli/coreAnalysisCommands.js";
|
|
7
|
+
import { registerUtilityCommands } from "./cli/utilityCommands.js";
|
|
8
|
+
import { registerArtifactCommands } from "./cli/artifactCommands.js";
|
|
9
|
+
import { registerManagedCommands } from "./cli/managedCommands.js";
|
|
10
|
+
import { registerInvestigationCommands } from "./cliInvestigationCommands.js";
|
|
19
11
|
import { registerEvidenceCommands } from "./cliEvidenceCommands.js";
|
|
20
12
|
import { registerProcessCommands } from "./cliProcessCommands.js";
|
|
21
|
-
import { registerInvestigationCommands } from "./cliInvestigationCommands.js";
|
|
22
|
-
import { AnalysisProtocolError, PermissionRequiredError, projectAnalysisError, } from "./domain/errors.js";
|
|
23
|
-
import { projectReferenceSourceImportError } from "./application/ReferenceSourceImportTypes.js";
|
|
24
|
-
import { loadConfiguredPermissionAuthority } from "./application/PermissionConfiguration.js";
|
|
25
13
|
import { registerPolicyCommands } from "./cliPolicyCommands.js";
|
|
26
14
|
import { registerBrowserCommands } from "./cliBrowserCommands.js";
|
|
27
15
|
import { registerAdvancedBrowserCommands } from "./cliBrowserAdvancedCommands.js";
|
|
28
16
|
import { registerElectronCommands } from "./cliElectronCommands.js";
|
|
29
17
|
import { registerApplicationCommands } from "./cliApplicationCommands.js";
|
|
30
|
-
import { CLI_COMMANDS } from "./cliCommandNames.js";
|
|
31
|
-
import { parseCliJsonInput } from "./cliJsonInput.js";
|
|
32
|
-
import { analysisProviderSelectorSchema, } from "./contracts/providerSelection.js";
|
|
33
|
-
import { createSystemDoctorHost } from "./doctorRuntime.js";
|
|
34
18
|
/**
|
|
35
19
|
* Build the one-shot Incur CLI without starting Hopper at import time.
|
|
36
20
|
* Analysis commands acquire and close their own sessions; bare `mcp` and
|
|
@@ -58,18 +42,12 @@ export const createCli = () => {
|
|
|
58
42
|
},
|
|
59
43
|
});
|
|
60
44
|
registerSetupCommands(cli, logger);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
registerSearchCommand(cli, logger);
|
|
64
|
-
registerXrefsCommand(cli, logger);
|
|
65
|
-
registerTraceCommand(cli, logger);
|
|
66
|
-
registerCapabilityCommands(cli, logger);
|
|
67
|
-
registerNativeCommands(cli, logger);
|
|
45
|
+
registerCoreAnalysisCommands(cli, logger);
|
|
46
|
+
registerUtilityCommands(cli, logger);
|
|
68
47
|
registerArtifactCommands(cli, logger);
|
|
69
48
|
registerManagedCommands(cli, logger);
|
|
70
49
|
registerInvestigationCommands(cli, logger);
|
|
71
50
|
registerEvidenceCommands(cli, logger);
|
|
72
|
-
registerReferenceSourceCommand(cli, logger);
|
|
73
51
|
registerProcessCommands(cli, logger);
|
|
74
52
|
registerPolicyCommands(cli, logger);
|
|
75
53
|
registerBrowserCommands(cli, logger);
|
|
@@ -78,739 +56,3 @@ export const createCli = () => {
|
|
|
78
56
|
registerApplicationCommands(cli, logger);
|
|
79
57
|
return cli;
|
|
80
58
|
};
|
|
81
|
-
const registerCoreCommands = (cli, logger) => {
|
|
82
|
-
const overviewOptions = z.object({
|
|
83
|
-
detail: z.enum(["concise", "detailed"]).default("concise"),
|
|
84
|
-
limit: z.number().int().min(1).max(50).default(10),
|
|
85
|
-
snapshot: z
|
|
86
|
-
.string()
|
|
87
|
-
.min(1)
|
|
88
|
-
.optional()
|
|
89
|
-
.describe("Load and update a local analysis snapshot"),
|
|
90
|
-
provider: providerSelectionOption,
|
|
91
|
-
});
|
|
92
|
-
cli.command(CLI_COMMANDS.analyze, {
|
|
93
|
-
description: "Get an overview of an app",
|
|
94
|
-
args: z.object({
|
|
95
|
-
path: z.string().describe("App, program, or analysis database path"),
|
|
96
|
-
}),
|
|
97
|
-
options: overviewOptions,
|
|
98
|
-
run: ({ args, options }) => logCliCommand(logger, "analyze", () => runDirectAnalysis(args.path, "binary_overview", { detail: options.detail, limit: options.limit }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
99
|
-
});
|
|
100
|
-
cli.command(CLI_COMMANDS.inspect, {
|
|
101
|
-
description: "Inspect an app overview with evidence",
|
|
102
|
-
args: z.object({
|
|
103
|
-
path: z.string().describe("App, program, or analysis database path"),
|
|
104
|
-
}),
|
|
105
|
-
options: overviewOptions,
|
|
106
|
-
run: ({ args, options }) => logCliCommand(logger, "inspect", () => runDirectAnalysis(args.path, "binary_overview", { detail: options.detail, limit: options.limit }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
107
|
-
});
|
|
108
|
-
cli.command(CLI_COMMANDS.decompile, {
|
|
109
|
-
description: "Read one part of an app as code",
|
|
110
|
-
args: z.object({
|
|
111
|
-
path: z.string().describe("App or program path"),
|
|
112
|
-
address: z.string().describe("Procedure address"),
|
|
113
|
-
}),
|
|
114
|
-
options: z.object({
|
|
115
|
-
snapshot: z.string().min(1).optional(),
|
|
116
|
-
provider: providerSelectionOption,
|
|
117
|
-
}),
|
|
118
|
-
run: ({ args, options }) => logCliCommand(logger, "decompile", () => runDirectAnalysis(args.path, "procedure_pseudo_code", { procedure: args.address }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
const registerSetupCommands = (cli, logger) => {
|
|
122
|
-
cli.command(CLI_COMMANDS.setup, {
|
|
123
|
-
description: "Install requirements and configure agents",
|
|
124
|
-
options: z.object({
|
|
125
|
-
yes: z
|
|
126
|
-
.boolean()
|
|
127
|
-
.default(false)
|
|
128
|
-
.describe("Approve user-owned setup actions without prompting"),
|
|
129
|
-
installHopper: z
|
|
130
|
-
.boolean()
|
|
131
|
-
.default(false)
|
|
132
|
-
.describe("Also approve Hopper installation with --yes"),
|
|
133
|
-
}),
|
|
134
|
-
alias: { yes: "y", installHopper: "install-hopper" },
|
|
135
|
-
run: ({ options, formatExplicit }) => logCliCommand(logger, "setup", () => runSetup({
|
|
136
|
-
approved: options.yes,
|
|
137
|
-
installHopper: options.installHopper,
|
|
138
|
-
structured: formatExplicit,
|
|
139
|
-
}, systemSetupHost(createSystemDoctorHost()), options.yes || formatExplicit || process.stdin.isTTY !== true
|
|
140
|
-
? undefined
|
|
141
|
-
: confirmSetup)),
|
|
142
|
-
});
|
|
143
|
-
cli.command(CLI_COMMANDS.doctor, {
|
|
144
|
-
description: "Check whether REA is ready",
|
|
145
|
-
options: z.object({
|
|
146
|
-
target: z.string().optional().describe("Optional app path to check"),
|
|
147
|
-
}),
|
|
148
|
-
run: ({ options }) => logCliCommand(logger, "doctor", () => runDoctor(options.target, createSystemDoctorHost())),
|
|
149
|
-
});
|
|
150
|
-
cli.command(CLI_COMMANDS.uninstall, {
|
|
151
|
-
description: "Remove REA-owned agent configuration and skill files",
|
|
152
|
-
options: z.object({
|
|
153
|
-
purgeData: z
|
|
154
|
-
.boolean()
|
|
155
|
-
.default(false)
|
|
156
|
-
.describe("Also remove REA caches and state"),
|
|
157
|
-
}),
|
|
158
|
-
alias: { purgeData: "purge-data" },
|
|
159
|
-
run: ({ options }) => logCliCommand(logger, "uninstall", () => runUninstall(options.purgeData)),
|
|
160
|
-
});
|
|
161
|
-
cli.command(CLI_COMMANDS.upgrade, {
|
|
162
|
-
description: "Upgrade a global npm installation to the latest REA release",
|
|
163
|
-
run: ({ formatExplicit }) => logCliCommand(logger, "upgrade", () => runUpgrade(PRODUCT_IDENTITY.packageVersion, systemUpgradeHost(), formatExplicit ? "structured" : "human")),
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
const confirmSetup = async (actions) => {
|
|
167
|
-
process.stdout.write("\nREA setup plan\n");
|
|
168
|
-
for (const action of actions)
|
|
169
|
-
process.stdout.write(` - ${action.detail}\n ${action.target}${action.external ? " (external software)" : ""}\n`);
|
|
170
|
-
const prompt = createInterface({
|
|
171
|
-
input: process.stdin,
|
|
172
|
-
output: process.stdout,
|
|
173
|
-
});
|
|
174
|
-
try {
|
|
175
|
-
const answer = (await prompt.question("Continue? [Y/n] "))
|
|
176
|
-
.trim()
|
|
177
|
-
.toLowerCase();
|
|
178
|
-
return answer === "" || answer === "y" || answer === "yes";
|
|
179
|
-
}
|
|
180
|
-
finally {
|
|
181
|
-
prompt.close();
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
const registerXrefsCommand = (cli, logger) => {
|
|
185
|
-
cli.command(CLI_COMMANDS.xrefs, {
|
|
186
|
-
description: "List bounded references to an analyzed address",
|
|
187
|
-
args: z.object({
|
|
188
|
-
path: z.string().describe("App or program path"),
|
|
189
|
-
address: z.string().describe("Hexadecimal address"),
|
|
190
|
-
}),
|
|
191
|
-
options: z.object({
|
|
192
|
-
snapshot: z.string().min(1).optional(),
|
|
193
|
-
provider: providerSelectionOption,
|
|
194
|
-
}),
|
|
195
|
-
run: ({ args, options }) => logCliCommand(logger, "xrefs", () => runDirectAnalysis(args.path, "xrefs", { address: args.address }, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
|
-
const registerTraceCommand = (cli, logger) => {
|
|
199
|
-
cli.command(CLI_COMMANDS.trace, {
|
|
200
|
-
description: "Trace a bounded literal feature through analyzed references",
|
|
201
|
-
args: z.object({
|
|
202
|
-
path: z.string().describe("App or program path"),
|
|
203
|
-
query: z.string().min(1).describe("Literal feature query"),
|
|
204
|
-
}),
|
|
205
|
-
options: z.object({
|
|
206
|
-
caseSensitive: z.boolean().default(false),
|
|
207
|
-
limit: z.number().int().min(1).max(100).default(20),
|
|
208
|
-
maxOperations: z.number().int().min(1).max(100).default(20),
|
|
209
|
-
snapshot: z.string().min(1).optional(),
|
|
210
|
-
provider: providerSelectionOption,
|
|
211
|
-
}),
|
|
212
|
-
alias: {
|
|
213
|
-
caseSensitive: "case-sensitive",
|
|
214
|
-
maxOperations: "max-operations",
|
|
215
|
-
},
|
|
216
|
-
run: ({ args, options }) => logCliCommand(logger, "trace", () => runDirectAnalysis(args.path, "trace_feature", {
|
|
217
|
-
query: args.query,
|
|
218
|
-
case_sensitive: options.caseSensitive,
|
|
219
|
-
limit: options.limit,
|
|
220
|
-
max_operations: options.maxOperations,
|
|
221
|
-
}, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
222
|
-
});
|
|
223
|
-
};
|
|
224
|
-
const registerCapabilityCommands = (cli, logger) => {
|
|
225
|
-
for (const command of [
|
|
226
|
-
CLI_COMMANDS.capabilities,
|
|
227
|
-
CLI_COMMANDS.providers,
|
|
228
|
-
]) {
|
|
229
|
-
cli.command(command, {
|
|
230
|
-
description: command === "capabilities"
|
|
231
|
-
? "List provider capabilities and side effects"
|
|
232
|
-
: "List configured analysis providers",
|
|
233
|
-
run: () => logCliCommand(logger, command, () => runSessionStatus(logger)),
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
const registerFunctionCommand = (cli, logger) => {
|
|
238
|
-
cli.command(CLI_COMMANDS.function, {
|
|
239
|
-
description: "Analyze one bounded function with evidence",
|
|
240
|
-
args: z.object({
|
|
241
|
-
path: z.string().describe("App or program path"),
|
|
242
|
-
address: z.string().describe("Procedure name or address"),
|
|
243
|
-
}),
|
|
244
|
-
options: z.object({
|
|
245
|
-
includeAssembly: z.boolean().default(false),
|
|
246
|
-
limit: z.number().int().min(1).max(500).default(100),
|
|
247
|
-
maxPseudocodeChars: z.number().int().min(1).max(100_000).default(20_000),
|
|
248
|
-
maxInstructions: z.number().int().min(1).max(5_000).default(500),
|
|
249
|
-
snapshot: z.string().min(1).optional(),
|
|
250
|
-
provider: providerSelectionOption,
|
|
251
|
-
}),
|
|
252
|
-
alias: {
|
|
253
|
-
includeAssembly: "include-assembly",
|
|
254
|
-
maxPseudocodeChars: "max-pseudocode-chars",
|
|
255
|
-
maxInstructions: "max-instructions",
|
|
256
|
-
},
|
|
257
|
-
run: ({ args, options }) => logCliCommand(logger, "function", () => runDirectAnalysis(args.path, "analyze_function", {
|
|
258
|
-
procedure: args.address,
|
|
259
|
-
include_assembly: options.includeAssembly,
|
|
260
|
-
limit: options.limit,
|
|
261
|
-
max_pseudocode_chars: options.maxPseudocodeChars,
|
|
262
|
-
max_instructions: options.maxInstructions,
|
|
263
|
-
}, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
264
|
-
});
|
|
265
|
-
};
|
|
266
|
-
const registerSearchCommand = (cli, logger) => {
|
|
267
|
-
cli.command(CLI_COMMANDS.search, {
|
|
268
|
-
description: "Search bounded analyzed strings or procedure names",
|
|
269
|
-
args: z.object({
|
|
270
|
-
path: z.string().describe("App or program path"),
|
|
271
|
-
pattern: z.string().min(1).describe("Literal text or regex pattern"),
|
|
272
|
-
}),
|
|
273
|
-
options: z.object({
|
|
274
|
-
kind: z.enum(["strings", "procedures"]).default("strings"),
|
|
275
|
-
mode: z.enum(["literal", "regex"]).default("literal"),
|
|
276
|
-
caseSensitive: z.boolean().default(false),
|
|
277
|
-
offset: z.number().int().min(0).default(0),
|
|
278
|
-
limit: z.number().int().min(1).max(100).default(100),
|
|
279
|
-
snapshot: z.string().min(1).optional(),
|
|
280
|
-
provider: providerSelectionOption,
|
|
281
|
-
}),
|
|
282
|
-
alias: { caseSensitive: "case-sensitive" },
|
|
283
|
-
run: ({ args, options }) => logCliCommand(logger, "search", () => runDirectAnalysis(args.path, options.kind === "strings" ? "search_strings" : "search_procedures", {
|
|
284
|
-
pattern: args.pattern,
|
|
285
|
-
mode: options.mode,
|
|
286
|
-
case_sensitive: options.caseSensitive,
|
|
287
|
-
offset: options.offset,
|
|
288
|
-
limit: options.limit,
|
|
289
|
-
}, directAnalysisOptions(logger, options.snapshot, options.provider))),
|
|
290
|
-
});
|
|
291
|
-
};
|
|
292
|
-
const registerReferenceSourceCommand = (cli, logger) => {
|
|
293
|
-
cli.command(CLI_COMMANDS.importReferenceSource, {
|
|
294
|
-
description: "Import a bounded source tree as historical reference only",
|
|
295
|
-
args: z.object({
|
|
296
|
-
root: z
|
|
297
|
-
.string()
|
|
298
|
-
.describe("Source root allowed by REA_REFERENCE_ROOTS_JSON"),
|
|
299
|
-
}),
|
|
300
|
-
run: ({ args }) => logCliCommand(logger, "import-reference-source", async () => {
|
|
301
|
-
const config = parseConfig(process.env);
|
|
302
|
-
if (!config.ok)
|
|
303
|
-
return {
|
|
304
|
-
error: "Import failed",
|
|
305
|
-
...projectAnalysisError(config.error),
|
|
306
|
-
};
|
|
307
|
-
const authority = await loadConfiguredPermissionAuthority(config.value);
|
|
308
|
-
if (!authority.ok)
|
|
309
|
-
return {
|
|
310
|
-
error: "Import failed",
|
|
311
|
-
...projectAnalysisError(authority.error),
|
|
312
|
-
};
|
|
313
|
-
const authorized = await authority.value.authorize({
|
|
314
|
-
capability: "reference_read",
|
|
315
|
-
roots: [args.root],
|
|
316
|
-
executables: [],
|
|
317
|
-
environment_names: [],
|
|
318
|
-
network: "none",
|
|
319
|
-
mount: false,
|
|
320
|
-
operation_identity: `import_reference_source:${args.root}`,
|
|
321
|
-
}, "read");
|
|
322
|
-
if (!authorized.ok) {
|
|
323
|
-
const error = authorized.error instanceof PermissionRequiredError
|
|
324
|
-
? authorized.error
|
|
325
|
-
: new AnalysisProtocolError(authorized.error.message, {
|
|
326
|
-
cause: authorized.error,
|
|
327
|
-
});
|
|
328
|
-
return {
|
|
329
|
-
error: "Import failed",
|
|
330
|
-
...projectAnalysisError(error),
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
const imported = await importReferenceSource({
|
|
334
|
-
root: args.root,
|
|
335
|
-
caller: "rea-cli",
|
|
336
|
-
policy: config.value.referenceSourcePolicy,
|
|
337
|
-
importer: PRODUCT_IDENTITY.packageName,
|
|
338
|
-
importerVersion: null,
|
|
339
|
-
});
|
|
340
|
-
return imported.ok
|
|
341
|
-
? imported.value
|
|
342
|
-
: {
|
|
343
|
-
error: "Import failed",
|
|
344
|
-
...projectReferenceSourceImportError(imported.error),
|
|
345
|
-
};
|
|
346
|
-
}),
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
const registerArtifactCommands = (cli, logger) => {
|
|
350
|
-
cli.command(CLI_COMMANDS.inventoryArtifact, {
|
|
351
|
-
description: "Build a bounded deterministic artifact graph",
|
|
352
|
-
args: z.object({
|
|
353
|
-
path: z.string().describe("Application or package path"),
|
|
354
|
-
}),
|
|
355
|
-
options: z.object({
|
|
356
|
-
offset: z.number().int().min(0).default(0),
|
|
357
|
-
limit: z.number().int().min(1).max(500).default(100),
|
|
358
|
-
integrityPolicy: z.enum(["fail", "record-and-continue"]).default("fail"),
|
|
359
|
-
integrityContinueApproved: z.boolean().default(false),
|
|
360
|
-
maxIntegrityMismatches: z.number().int().min(1).max(100).default(10),
|
|
361
|
-
nativeMountApproved: z.boolean().default(false),
|
|
362
|
-
}),
|
|
363
|
-
alias: {
|
|
364
|
-
integrityPolicy: "integrity-policy",
|
|
365
|
-
integrityContinueApproved: "integrity-continue-approved",
|
|
366
|
-
maxIntegrityMismatches: "max-integrity-mismatches",
|
|
367
|
-
nativeMountApproved: "native-mount-approved",
|
|
368
|
-
},
|
|
369
|
-
run: ({ args, options }) => logCliCommand(logger, "inventory-artifact", () => runProviderAnalysis(args.path, "inventory_artifact", {
|
|
370
|
-
node_offset: options.offset,
|
|
371
|
-
node_limit: options.limit,
|
|
372
|
-
occurrence_offset: options.offset,
|
|
373
|
-
occurrence_limit: options.limit,
|
|
374
|
-
edge_offset: options.offset,
|
|
375
|
-
edge_limit: options.limit,
|
|
376
|
-
integrity_policy: options.integrityPolicy,
|
|
377
|
-
integrity_continue_approved: options.integrityContinueApproved,
|
|
378
|
-
max_integrity_mismatches: options.maxIntegrityMismatches,
|
|
379
|
-
native_mount_approved: options.nativeMountApproved,
|
|
380
|
-
}, logger)),
|
|
381
|
-
});
|
|
382
|
-
cli.command(CLI_COMMANDS.extractArtifact, {
|
|
383
|
-
description: "Extract explicitly selected artifact occurrences safely",
|
|
384
|
-
args: z.object({
|
|
385
|
-
path: z.string().describe("Application or package path"),
|
|
386
|
-
outputRoot: z.string().describe("Absent absolute output root"),
|
|
387
|
-
occurrenceIds: z
|
|
388
|
-
.array(z.string().regex(/^occ_[a-f0-9]{64}$/u))
|
|
389
|
-
.min(1)
|
|
390
|
-
.max(500),
|
|
391
|
-
}),
|
|
392
|
-
alias: { outputRoot: "output-root", occurrenceIds: "occurrence-ids" },
|
|
393
|
-
run: ({ args }) => logCliCommand(logger, "extract-artifact", () => runProviderAnalysis(args.path, "extract_artifact", {
|
|
394
|
-
approved: true,
|
|
395
|
-
output_root: args.outputRoot,
|
|
396
|
-
occurrence_ids: args.occurrenceIds,
|
|
397
|
-
}, logger)),
|
|
398
|
-
});
|
|
399
|
-
};
|
|
400
|
-
const registerManagedCommands = (cli, logger) => {
|
|
401
|
-
cli.command(CLI_COMMANDS.inspectManagedArtifact, {
|
|
402
|
-
description: "Inspect PE/CLI identity without loading target code",
|
|
403
|
-
args: z.object({
|
|
404
|
-
path: z.string().describe("Managed PE executable or assembly path"),
|
|
405
|
-
}),
|
|
406
|
-
options: z.object({
|
|
407
|
-
referenceOffset: z.number().int().min(0).default(0),
|
|
408
|
-
referenceLimit: z.number().int().min(1).max(500).default(100),
|
|
409
|
-
resourceOffset: z.number().int().min(0).default(0),
|
|
410
|
-
resourceLimit: z.number().int().min(1).max(500).default(100),
|
|
411
|
-
attributeOffset: z.number().int().min(0).default(0),
|
|
412
|
-
attributeLimit: z.number().int().min(1).max(500).default(100),
|
|
413
|
-
maxFileBytes: z
|
|
414
|
-
.number()
|
|
415
|
-
.int()
|
|
416
|
-
.min(4_096)
|
|
417
|
-
.max(1_073_741_824)
|
|
418
|
-
.default(268_435_456),
|
|
419
|
-
maxMetadataBytes: z
|
|
420
|
-
.number()
|
|
421
|
-
.int()
|
|
422
|
-
.min(256)
|
|
423
|
-
.max(268_435_456)
|
|
424
|
-
.default(67_108_864),
|
|
425
|
-
maxTableRows: z.number().int().min(1).max(1_000_000).default(100_000),
|
|
426
|
-
maxHeapItemBytes: z
|
|
427
|
-
.number()
|
|
428
|
-
.int()
|
|
429
|
-
.min(1)
|
|
430
|
-
.max(16_777_216)
|
|
431
|
-
.default(1_048_576),
|
|
432
|
-
}),
|
|
433
|
-
alias: {
|
|
434
|
-
referenceOffset: "reference-offset",
|
|
435
|
-
referenceLimit: "reference-limit",
|
|
436
|
-
resourceOffset: "resource-offset",
|
|
437
|
-
resourceLimit: "resource-limit",
|
|
438
|
-
attributeOffset: "attribute-offset",
|
|
439
|
-
attributeLimit: "attribute-limit",
|
|
440
|
-
maxFileBytes: "max-file-bytes",
|
|
441
|
-
maxMetadataBytes: "max-metadata-bytes",
|
|
442
|
-
maxTableRows: "max-table-rows",
|
|
443
|
-
maxHeapItemBytes: "max-heap-item-bytes",
|
|
444
|
-
},
|
|
445
|
-
run: ({ args, options }) => logCliCommand(logger, "inspect-managed-artifact", () => runProviderAnalysis(args.path, "inspect_managed_artifact", {
|
|
446
|
-
reference_offset: options.referenceOffset,
|
|
447
|
-
reference_limit: options.referenceLimit,
|
|
448
|
-
resource_offset: options.resourceOffset,
|
|
449
|
-
resource_limit: options.resourceLimit,
|
|
450
|
-
attribute_offset: options.attributeOffset,
|
|
451
|
-
attribute_limit: options.attributeLimit,
|
|
452
|
-
max_file_bytes: options.maxFileBytes,
|
|
453
|
-
max_metadata_bytes: options.maxMetadataBytes,
|
|
454
|
-
max_table_rows: options.maxTableRows,
|
|
455
|
-
max_heap_item_bytes: options.maxHeapItemBytes,
|
|
456
|
-
}, logger)),
|
|
457
|
-
});
|
|
458
|
-
cli.command(CLI_COMMANDS.inspectManagedMembers, {
|
|
459
|
-
description: "Inspect PE/CLI metadata members, signatures, and CIL anchors without loading target code",
|
|
460
|
-
args: z.object({
|
|
461
|
-
path: z.string().describe("Managed PE executable or assembly path"),
|
|
462
|
-
}),
|
|
463
|
-
options: z.object({
|
|
464
|
-
typeOffset: z.number().int().min(0).default(0),
|
|
465
|
-
typeLimit: z.number().int().min(1).max(500).default(100),
|
|
466
|
-
methodOffset: z.number().int().min(0).default(0),
|
|
467
|
-
methodLimit: z.number().int().min(1).max(500).default(100),
|
|
468
|
-
fieldOffset: z.number().int().min(0).default(0),
|
|
469
|
-
fieldLimit: z.number().int().min(1).max(500).default(100),
|
|
470
|
-
memberRefOffset: z.number().int().min(0).default(0),
|
|
471
|
-
memberRefLimit: z.number().int().min(1).max(500).default(100),
|
|
472
|
-
edgeOffset: z.number().int().min(0).default(0),
|
|
473
|
-
edgeLimit: z.number().int().min(1).max(1_000).default(250),
|
|
474
|
-
instructionAnchorLimit: z.number().int().min(0).max(500).default(100),
|
|
475
|
-
maxFileBytes: z
|
|
476
|
-
.number()
|
|
477
|
-
.int()
|
|
478
|
-
.min(4_096)
|
|
479
|
-
.max(1_073_741_824)
|
|
480
|
-
.default(268_435_456),
|
|
481
|
-
maxMetadataBytes: z
|
|
482
|
-
.number()
|
|
483
|
-
.int()
|
|
484
|
-
.min(256)
|
|
485
|
-
.max(268_435_456)
|
|
486
|
-
.default(67_108_864),
|
|
487
|
-
maxTableRows: z.number().int().min(1).max(1_000_000).default(100_000),
|
|
488
|
-
maxHeapItemBytes: z
|
|
489
|
-
.number()
|
|
490
|
-
.int()
|
|
491
|
-
.min(1)
|
|
492
|
-
.max(16_777_216)
|
|
493
|
-
.default(1_048_576),
|
|
494
|
-
maxMethodBodyBytes: z
|
|
495
|
-
.number()
|
|
496
|
-
.int()
|
|
497
|
-
.min(1)
|
|
498
|
-
.max(16_777_216)
|
|
499
|
-
.default(1_048_576),
|
|
500
|
-
maxMethodInstructions: z
|
|
501
|
-
.number()
|
|
502
|
-
.int()
|
|
503
|
-
.min(1)
|
|
504
|
-
.max(100_000)
|
|
505
|
-
.default(10_000),
|
|
506
|
-
}),
|
|
507
|
-
alias: {
|
|
508
|
-
typeOffset: "type-offset",
|
|
509
|
-
typeLimit: "type-limit",
|
|
510
|
-
methodOffset: "method-offset",
|
|
511
|
-
methodLimit: "method-limit",
|
|
512
|
-
fieldOffset: "field-offset",
|
|
513
|
-
fieldLimit: "field-limit",
|
|
514
|
-
memberRefOffset: "member-ref-offset",
|
|
515
|
-
memberRefLimit: "member-ref-limit",
|
|
516
|
-
edgeOffset: "edge-offset",
|
|
517
|
-
edgeLimit: "edge-limit",
|
|
518
|
-
instructionAnchorLimit: "instruction-anchor-limit",
|
|
519
|
-
maxFileBytes: "max-file-bytes",
|
|
520
|
-
maxMetadataBytes: "max-metadata-bytes",
|
|
521
|
-
maxTableRows: "max-table-rows",
|
|
522
|
-
maxHeapItemBytes: "max-heap-item-bytes",
|
|
523
|
-
maxMethodBodyBytes: "max-method-body-bytes",
|
|
524
|
-
maxMethodInstructions: "max-method-instructions",
|
|
525
|
-
},
|
|
526
|
-
run: ({ args, options }) => logCliCommand(logger, "inspect-managed-members", () => runProviderAnalysis(args.path, "inspect_managed_members", {
|
|
527
|
-
type_offset: options.typeOffset,
|
|
528
|
-
type_limit: options.typeLimit,
|
|
529
|
-
method_offset: options.methodOffset,
|
|
530
|
-
method_limit: options.methodLimit,
|
|
531
|
-
field_offset: options.fieldOffset,
|
|
532
|
-
field_limit: options.fieldLimit,
|
|
533
|
-
member_ref_offset: options.memberRefOffset,
|
|
534
|
-
member_ref_limit: options.memberRefLimit,
|
|
535
|
-
edge_offset: options.edgeOffset,
|
|
536
|
-
edge_limit: options.edgeLimit,
|
|
537
|
-
instruction_anchor_limit: options.instructionAnchorLimit,
|
|
538
|
-
max_file_bytes: options.maxFileBytes,
|
|
539
|
-
max_metadata_bytes: options.maxMetadataBytes,
|
|
540
|
-
max_table_rows: options.maxTableRows,
|
|
541
|
-
max_heap_item_bytes: options.maxHeapItemBytes,
|
|
542
|
-
max_method_body_bytes: options.maxMethodBodyBytes,
|
|
543
|
-
max_method_instructions: options.maxMethodInstructions,
|
|
544
|
-
}, logger)),
|
|
545
|
-
});
|
|
546
|
-
cli.command(CLI_COMMANDS.inspectManagedNativeBoundaries, {
|
|
547
|
-
description: "Inspect PE/CLI PInvoke and native implementation boundary declarations without loading target code",
|
|
548
|
-
args: z.object({
|
|
549
|
-
path: z.string().describe("Managed PE executable or assembly path"),
|
|
550
|
-
}),
|
|
551
|
-
options: z.object({
|
|
552
|
-
moduleRefOffset: z.number().int().min(0).default(0),
|
|
553
|
-
moduleRefLimit: z.number().int().min(1).max(500).default(100),
|
|
554
|
-
importOffset: z.number().int().min(0).default(0),
|
|
555
|
-
importLimit: z.number().int().min(1).max(500).default(100),
|
|
556
|
-
implementationOffset: z.number().int().min(0).default(0),
|
|
557
|
-
implementationLimit: z.number().int().min(1).max(500).default(100),
|
|
558
|
-
maxFileBytes: z
|
|
559
|
-
.number()
|
|
560
|
-
.int()
|
|
561
|
-
.min(4_096)
|
|
562
|
-
.max(1_073_741_824)
|
|
563
|
-
.default(268_435_456),
|
|
564
|
-
maxMetadataBytes: z
|
|
565
|
-
.number()
|
|
566
|
-
.int()
|
|
567
|
-
.min(256)
|
|
568
|
-
.max(268_435_456)
|
|
569
|
-
.default(67_108_864),
|
|
570
|
-
maxTableRows: z.number().int().min(1).max(1_000_000).default(100_000),
|
|
571
|
-
maxHeapItemBytes: z
|
|
572
|
-
.number()
|
|
573
|
-
.int()
|
|
574
|
-
.min(1)
|
|
575
|
-
.max(16_777_216)
|
|
576
|
-
.default(1_048_576),
|
|
577
|
-
}),
|
|
578
|
-
alias: {
|
|
579
|
-
moduleRefOffset: "module-ref-offset",
|
|
580
|
-
moduleRefLimit: "module-ref-limit",
|
|
581
|
-
importOffset: "import-offset",
|
|
582
|
-
importLimit: "import-limit",
|
|
583
|
-
implementationOffset: "implementation-offset",
|
|
584
|
-
implementationLimit: "implementation-limit",
|
|
585
|
-
maxFileBytes: "max-file-bytes",
|
|
586
|
-
maxMetadataBytes: "max-metadata-bytes",
|
|
587
|
-
maxTableRows: "max-table-rows",
|
|
588
|
-
maxHeapItemBytes: "max-heap-item-bytes",
|
|
589
|
-
},
|
|
590
|
-
run: ({ args, options }) => logCliCommand(logger, "inspect-managed-native-boundaries", () => runProviderAnalysis(args.path, "inspect_managed_native_boundaries", {
|
|
591
|
-
module_ref_offset: options.moduleRefOffset,
|
|
592
|
-
module_ref_limit: options.moduleRefLimit,
|
|
593
|
-
import_offset: options.importOffset,
|
|
594
|
-
import_limit: options.importLimit,
|
|
595
|
-
implementation_offset: options.implementationOffset,
|
|
596
|
-
implementation_limit: options.implementationLimit,
|
|
597
|
-
max_file_bytes: options.maxFileBytes,
|
|
598
|
-
max_metadata_bytes: options.maxMetadataBytes,
|
|
599
|
-
max_table_rows: options.maxTableRows,
|
|
600
|
-
max_heap_item_bytes: options.maxHeapItemBytes,
|
|
601
|
-
}, logger)),
|
|
602
|
-
});
|
|
603
|
-
cli.command(CLI_COMMANDS.compareManagedMembers, {
|
|
604
|
-
description: "Compare two managed PE/CLI member inventories without name-based matching",
|
|
605
|
-
args: z.object({
|
|
606
|
-
leftPath: z
|
|
607
|
-
.string()
|
|
608
|
-
.describe("Baseline managed PE executable or assembly"),
|
|
609
|
-
rightPath: z
|
|
610
|
-
.string()
|
|
611
|
-
.describe("Candidate managed PE executable or assembly"),
|
|
612
|
-
}),
|
|
613
|
-
options: z.object({
|
|
614
|
-
maxMethodMatches: z.number().int().min(1).max(50_000).default(10_000),
|
|
615
|
-
maxFieldMatches: z.number().int().min(0).max(50_000).default(5_000),
|
|
616
|
-
maxCandidates: z.number().int().min(1).max(500).default(50),
|
|
617
|
-
typeLimit: z.number().int().min(1).max(500).default(500),
|
|
618
|
-
methodLimit: z.number().int().min(1).max(500).default(500),
|
|
619
|
-
fieldLimit: z.number().int().min(1).max(500).default(500),
|
|
620
|
-
memberRefLimit: z.number().int().min(1).max(500).default(500),
|
|
621
|
-
edgeLimit: z.number().int().min(1).max(1_000).default(1_000),
|
|
622
|
-
instructionAnchorLimit: z.number().int().min(0).max(500).default(500),
|
|
623
|
-
maxFileBytes: z
|
|
624
|
-
.number()
|
|
625
|
-
.int()
|
|
626
|
-
.min(4_096)
|
|
627
|
-
.max(1_073_741_824)
|
|
628
|
-
.default(268_435_456),
|
|
629
|
-
maxMetadataBytes: z
|
|
630
|
-
.number()
|
|
631
|
-
.int()
|
|
632
|
-
.min(256)
|
|
633
|
-
.max(268_435_456)
|
|
634
|
-
.default(67_108_864),
|
|
635
|
-
maxTableRows: z.number().int().min(1).max(1_000_000).default(100_000),
|
|
636
|
-
maxHeapItemBytes: z
|
|
637
|
-
.number()
|
|
638
|
-
.int()
|
|
639
|
-
.min(1)
|
|
640
|
-
.max(16_777_216)
|
|
641
|
-
.default(1_048_576),
|
|
642
|
-
maxMethodBodyBytes: z
|
|
643
|
-
.number()
|
|
644
|
-
.int()
|
|
645
|
-
.min(1)
|
|
646
|
-
.max(16_777_216)
|
|
647
|
-
.default(1_048_576),
|
|
648
|
-
maxMethodInstructions: z
|
|
649
|
-
.number()
|
|
650
|
-
.int()
|
|
651
|
-
.min(1)
|
|
652
|
-
.max(100_000)
|
|
653
|
-
.default(100_000),
|
|
654
|
-
}),
|
|
655
|
-
alias: {
|
|
656
|
-
maxMethodMatches: "max-method-matches",
|
|
657
|
-
maxFieldMatches: "max-field-matches",
|
|
658
|
-
maxCandidates: "max-candidates",
|
|
659
|
-
typeLimit: "type-limit",
|
|
660
|
-
methodLimit: "method-limit",
|
|
661
|
-
fieldLimit: "field-limit",
|
|
662
|
-
memberRefLimit: "member-ref-limit",
|
|
663
|
-
edgeLimit: "edge-limit",
|
|
664
|
-
instructionAnchorLimit: "instruction-anchor-limit",
|
|
665
|
-
maxFileBytes: "max-file-bytes",
|
|
666
|
-
maxMetadataBytes: "max-metadata-bytes",
|
|
667
|
-
maxTableRows: "max-table-rows",
|
|
668
|
-
maxHeapItemBytes: "max-heap-item-bytes",
|
|
669
|
-
maxMethodBodyBytes: "max-method-body-bytes",
|
|
670
|
-
maxMethodInstructions: "max-method-instructions",
|
|
671
|
-
},
|
|
672
|
-
run: ({ args, options }) => logCliCommand(logger, "compare-managed-members", async () => {
|
|
673
|
-
const result = await compareManagedMemberPaths({
|
|
674
|
-
leftPath: args.leftPath,
|
|
675
|
-
rightPath: args.rightPath,
|
|
676
|
-
comparisonLimits: {
|
|
677
|
-
max_method_matches: options.maxMethodMatches,
|
|
678
|
-
max_field_matches: options.maxFieldMatches,
|
|
679
|
-
max_candidates: options.maxCandidates,
|
|
680
|
-
},
|
|
681
|
-
memberLimits: {
|
|
682
|
-
maxFileBytes: options.maxFileBytes,
|
|
683
|
-
typeOffset: 0,
|
|
684
|
-
typeLimit: options.typeLimit,
|
|
685
|
-
methodOffset: 0,
|
|
686
|
-
methodLimit: options.methodLimit,
|
|
687
|
-
fieldOffset: 0,
|
|
688
|
-
fieldLimit: options.fieldLimit,
|
|
689
|
-
memberRefOffset: 0,
|
|
690
|
-
memberRefLimit: options.memberRefLimit,
|
|
691
|
-
edgeOffset: 0,
|
|
692
|
-
edgeLimit: options.edgeLimit,
|
|
693
|
-
instructionAnchorLimit: options.instructionAnchorLimit,
|
|
694
|
-
maxMetadataBytes: options.maxMetadataBytes,
|
|
695
|
-
maxTableRows: options.maxTableRows,
|
|
696
|
-
maxHeapItemBytes: options.maxHeapItemBytes,
|
|
697
|
-
maxMethodBodyBytes: options.maxMethodBodyBytes,
|
|
698
|
-
maxMethodInstructions: options.maxMethodInstructions,
|
|
699
|
-
},
|
|
700
|
-
});
|
|
701
|
-
return result.ok
|
|
702
|
-
? result.value
|
|
703
|
-
: {
|
|
704
|
-
error: "Managed member comparison failed",
|
|
705
|
-
...projectAnalysisError(result.error),
|
|
706
|
-
};
|
|
707
|
-
}),
|
|
708
|
-
});
|
|
709
|
-
cli.command(CLI_COMMANDS.importManagedReconstruction, {
|
|
710
|
-
description: "Import decompiler-produced managed reconstruction against exact static member evidence",
|
|
711
|
-
args: z.object({
|
|
712
|
-
inputJson: z
|
|
713
|
-
.string()
|
|
714
|
-
.describe("Inline managed reconstruction JSON or JSON file path"),
|
|
715
|
-
}),
|
|
716
|
-
run: ({ args }) => logCliCommand(logger, "import-managed-reconstruction", async () => {
|
|
717
|
-
const input = await parseCliJsonInput(args.inputJson, "import-managed-reconstruction");
|
|
718
|
-
if (!input.ok)
|
|
719
|
-
return input.error;
|
|
720
|
-
const result = importManagedReconstructionEvidence(input.value);
|
|
721
|
-
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
722
|
-
}),
|
|
723
|
-
});
|
|
724
|
-
cli.command(CLI_COMMANDS.verifyManagedNativeBoundaries, {
|
|
725
|
-
description: "Verify managed P/Invoke declarations against authenticated native Evidence",
|
|
726
|
-
args: z.object({
|
|
727
|
-
inputJson: z
|
|
728
|
-
.string()
|
|
729
|
-
.describe("Inline managed/native verification JSON or JSON file path"),
|
|
730
|
-
}),
|
|
731
|
-
run: ({ args }) => logCliCommand(logger, "verify-managed-native-boundaries", async () => {
|
|
732
|
-
const input = await parseCliJsonInput(args.inputJson, "verify-managed-native-boundaries");
|
|
733
|
-
if (!input.ok)
|
|
734
|
-
return input.error;
|
|
735
|
-
const result = verifyManagedNativeBoundariesEvidence(input.value);
|
|
736
|
-
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
737
|
-
}),
|
|
738
|
-
});
|
|
739
|
-
cli.command(CLI_COMMANDS.planManagedRuntimeCorrelation, {
|
|
740
|
-
description: "Plan a separately authorized managed runtime-correlation experiment without executing target code",
|
|
741
|
-
args: z.object({
|
|
742
|
-
inputJson: z
|
|
743
|
-
.string()
|
|
744
|
-
.describe("Inline managed runtime-correlation JSON or JSON file path"),
|
|
745
|
-
}),
|
|
746
|
-
run: ({ args }) => logCliCommand(logger, "plan-managed-runtime-correlation", async () => {
|
|
747
|
-
const input = await parseCliJsonInput(args.inputJson, "plan-managed-runtime-correlation");
|
|
748
|
-
if (!input.ok)
|
|
749
|
-
return input.error;
|
|
750
|
-
const config = parseConfig(process.env);
|
|
751
|
-
if (!config.ok)
|
|
752
|
-
return projectAnalysisError(config.error);
|
|
753
|
-
const authority = await loadConfiguredPermissionAuthority(config.value);
|
|
754
|
-
if (!authority.ok)
|
|
755
|
-
return projectAnalysisError(authority.error);
|
|
756
|
-
const result = await planManagedRuntimeCorrelationEvidence({
|
|
757
|
-
policy: config.value.managedRuntimePolicy,
|
|
758
|
-
authority: authority.value,
|
|
759
|
-
}, input.value);
|
|
760
|
-
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
761
|
-
}),
|
|
762
|
-
});
|
|
763
|
-
cli.command(CLI_COMMANDS.projectManagedApplicationGraph, {
|
|
764
|
-
description: "Project authenticated managed static Evidence into an application graph",
|
|
765
|
-
args: z.object({
|
|
766
|
-
inputJson: z
|
|
767
|
-
.string()
|
|
768
|
-
.describe("Inline managed application graph JSON or JSON file path"),
|
|
769
|
-
}),
|
|
770
|
-
run: ({ args }) => logCliCommand(logger, "project-managed-application-graph", async () => {
|
|
771
|
-
const input = await parseCliJsonInput(args.inputJson, "project-managed-application-graph");
|
|
772
|
-
if (!input.ok)
|
|
773
|
-
return input.error;
|
|
774
|
-
const result = projectManagedApplicationGraphEvidence(input.value);
|
|
775
|
-
return result.ok ? result.value : projectAnalysisError(result.error);
|
|
776
|
-
}),
|
|
777
|
-
});
|
|
778
|
-
};
|
|
779
|
-
const registerNativeCommands = (cli, logger) => {
|
|
780
|
-
for (const [command, tool] of [
|
|
781
|
-
[CLI_COMMANDS.inspectMacho, "inspect_macho"],
|
|
782
|
-
[CLI_COMMANDS.inspectSignature, "inspect_signature"],
|
|
783
|
-
[CLI_COMMANDS.listArchitectures, "list_architectures"],
|
|
784
|
-
]) {
|
|
785
|
-
cli.command(command, {
|
|
786
|
-
description: `Run ${tool} without launching Hopper`,
|
|
787
|
-
args: z.object({ path: z.string().describe("Mach-O or app path") }),
|
|
788
|
-
run: ({ args }) => logCliCommand(logger, command, () => runProviderAnalysis(args.path, tool, {}, logger)),
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
cli.command(CLI_COMMANDS.inspectPlist, {
|
|
792
|
-
description: "Parse app plist metadata without launching Hopper",
|
|
793
|
-
args: z.object({ path: z.string().describe("App or Mach-O path") }),
|
|
794
|
-
options: z.object({
|
|
795
|
-
relativePath: z.string().default("Contents/Info.plist"),
|
|
796
|
-
}),
|
|
797
|
-
alias: { relativePath: "relative-path" },
|
|
798
|
-
run: ({ args, options }) => logCliCommand(logger, "inspect-plist", () => runProviderAnalysis(args.path, "inspect_plist", { relative_path: options.relativePath }, logger)),
|
|
799
|
-
});
|
|
800
|
-
cli.command(CLI_COMMANDS.demangleSwift, {
|
|
801
|
-
description: "Demangle a bounded Swift symbol batch without Hopper",
|
|
802
|
-
args: z.object({
|
|
803
|
-
path: z.string().describe("Artifact path used for evidence identity"),
|
|
804
|
-
symbols: z.array(z.string().min(1)).min(1).max(500),
|
|
805
|
-
}),
|
|
806
|
-
run: ({ args }) => logCliCommand(logger, "demangle-swift", () => runProviderAnalysis(args.path, "demangle_swift", { symbols: args.symbols }, logger)),
|
|
807
|
-
});
|
|
808
|
-
};
|
|
809
|
-
const providerSelectionOption = analysisProviderSelectorSchema
|
|
810
|
-
.optional()
|
|
811
|
-
.describe("Bind deep analysis to a provider ID or use deterministic auto selection");
|
|
812
|
-
const directAnalysisOptions = (logger, snapshotPath, providerId) => ({
|
|
813
|
-
logger,
|
|
814
|
-
snapshotPath,
|
|
815
|
-
...(providerId === undefined ? {} : { providerId }),
|
|
816
|
-
});
|