rea-agents 5.0.0 → 6.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 +168 -655
- package/bridge/android/ReaJadxBridge.java +14 -5
- package/bridge/ghidra/ReaGhidraBridge.java +173 -47
- package/bridge/hopper_bridge.py +310 -128
- package/bridge/mitmproxy/capture.py +208 -0
- package/bridge/native/rea_lldb_tracer.py +839 -0
- package/bridge/process/ProcessRunTokenReader.swift +297 -0
- package/bridge/process/ProcessRunTokenReaderMain.swift +35 -0
- package/bridge/pwndbg/core_context.py +101 -0
- package/bridge/pwndbg/launch.py +39 -0
- package/bridge/pwndbg/launch_impl.py +34 -0
- package/bridge/pwntools/decoder_runtime.py +59 -0
- package/bridge/pwntools/layout.py +39 -0
- package/bridge/pwntools/layout_impl.py +309 -0
- package/bridge/pwntools/recorded_crash.py +39 -0
- package/bridge/pwntools/recorded_crash_impl.py +147 -0
- package/dist/android/JadxConfiguration.js +196 -33
- package/dist/android/JadxMcpTransport.js +4 -0
- package/dist/android/JadxProtocol.js +6 -0
- package/dist/android/JadxProvider.js +20 -2
- package/dist/android/JadxSession.js +23 -4
- package/dist/application/AnalysisContextQueries.js +8 -35
- package/dist/application/AnalysisDocument.js +32 -0
- package/dist/application/AppBundleExecutable.js +67 -21
- package/dist/application/CallPathTracing.js +19 -3
- package/dist/application/CapabilityInventory.js +27 -3
- package/dist/application/ClientConfigurationDocument.js +871 -6
- package/dist/application/ClientRegistrationIdentity.js +26 -5
- package/dist/application/ClientRegistrationStatus.js +29 -14
- package/dist/application/DirectAnalysis.js +97 -33
- package/dist/application/Doctor.js +4 -2
- package/dist/application/DoctorScope.js +25 -13
- package/dist/application/EnhancedLiteralTracing.js +22 -25
- package/dist/application/EnhancedTools.js +13 -11
- package/dist/application/EvidenceBundleFiles.js +24 -12
- package/dist/application/FunctionAnalysisEvidence.js +2 -3
- package/dist/application/InventoryProjectionEvidence.js +4 -3
- package/dist/application/InvestigationProviders.js +3 -2
- package/dist/application/JsonFiles.js +50 -28
- package/dist/application/ProcedureAddressResolution.js +11 -0
- package/dist/application/ReconstructionCoverageService.js +7 -4
- package/dist/application/ReconstructionObligationCandidates.js +5 -1
- package/dist/application/ReconstructionObligationLedgerService.js +4 -3
- package/dist/application/Setup.js +13 -1
- package/dist/application/SetupClientConfiguration.js +10 -15
- package/dist/application/SetupHost.js +5 -2
- package/dist/application/SetupPlan.js +5 -3
- package/dist/application/SupportedClients.js +34 -1
- package/dist/application/Uninstall.js +4 -3
- package/dist/application/Update.js +18 -3
- package/dist/application/UpdateRuntime.js +46 -25
- package/dist/application/WebModuleTraceService.js +4 -2
- package/dist/application/WebNetworkCapturePort.js +1 -0
- package/dist/application/WebNetworkCaptureService.js +134 -0
- package/dist/application/WebRuntimeService.js +5 -3
- package/dist/application/WebScriptExportService.js +2 -2
- package/dist/application/WebSourceLocationService.js +4 -2
- package/dist/application/WindowsCapabilities.js +1 -1
- package/dist/application/WorkflowEvidence.js +82 -0
- package/dist/application/binary/AnalysisProviderEvaluation.js +21 -5
- package/dist/application/binary/AnalysisProviderRegistry.js +2 -0
- package/dist/application/binary/AnalysisSnapshotCache.js +52 -12
- package/dist/application/binary/BinarySession.js +131 -76
- package/dist/application/binary/BinarySessionOpen.js +19 -6
- package/dist/application/binary/BinarySessionRecords.js +45 -3
- package/dist/application/binary/BinarySessionStatus.js +17 -1
- package/dist/application/binary/CompositeProvider.js +13 -0
- package/dist/application/binary/LazyAnalysisProvider.js +3 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +59 -0
- package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +62 -0
- package/dist/application/evm/EvmInterfacePort.js +1 -0
- package/dist/application/evm/EvmInterfaceService.js +64 -0
- package/dist/application/investigation/EvidenceLedger.js +21 -7
- package/dist/application/investigation/InvestigationRecords.js +8 -0
- package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +25 -5
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +19 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +34 -14
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +5 -5
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +47 -27
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +39 -7
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +80 -27
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +33 -12
- package/dist/application/javascript/JavaScriptModuleRelationships.js +37 -8
- package/dist/application/javascript/JavaScriptRecoveryService.js +4 -2
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +3 -1
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +149 -72
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +14 -15
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +41 -1
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -9
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +118 -12
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +27 -5
- package/dist/application/managed/ManagedApplicationGraphService.js +4 -3
- package/dist/application/managed/ManagedMemberComparisonService.js +7 -4
- package/dist/application/managed/ManagedNativeVerificationService.js +4 -3
- package/dist/application/managed/ManagedReconstructionService.js +4 -3
- package/dist/application/{ProcessCli.js → process/ProcessCli.js} +23 -15
- package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +8 -7
- package/dist/application/workflowInputError.js +18 -0
- package/dist/artifacts/ArtifactProvider.js +42 -5
- package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
- package/dist/artifacts/MachOSliceArtifactReader.js +98 -14
- package/dist/artifacts/NativeDmgArtifactReader.js +13 -6
- package/dist/artifacts/ZipArtifactReader.js +3 -0
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +22 -3
- package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +176 -56
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +195 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +36 -22
- package/dist/artifacts/apple/MachoLoadCommandReader.js +355 -0
- package/dist/artifacts/apple/NibArchive.js +81 -14
- package/dist/artifacts/apple/NibViewHierarchy.js +10 -3
- package/dist/artifacts/apple/PlistNumberLiterals.js +164 -0
- package/dist/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
- package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +16 -11
- package/dist/{application → artifacts/inventory}/ArtifactInventory.js +4 -4
- package/dist/{application/ArtifactInventory → artifacts/inventory}/classify.js +2 -2
- package/dist/{application/ArtifactInventory → artifacts/inventory}/reader.js +5 -5
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanCanonical.js +14 -17
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +6 -2
- package/dist/artifacts/readStableArtifact.js +20 -4
- package/dist/browser/CdpCaptureCompleteness.js +2 -0
- package/dist/browser/CdpCaptureEventHandlers.js +165 -12
- package/dist/browser/CdpCaptureEventTypes.js +5 -1
- package/dist/browser/CdpCaptureEvents.js +34 -0
- package/dist/browser/CdpConnection.js +30 -11
- package/dist/browser/CdpOptionalCommand.js +2 -3
- package/dist/browser/CdpPageCapture.js +23 -1
- package/dist/browser/PlaywrightElectronActiveActions.js +32 -23
- package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +130 -122
- package/dist/browser/WebSourceMapFetcher.js +426 -72
- package/dist/browser/assets/LocalWebScriptArtifacts.js +2 -2
- package/dist/browser/history/CaptureFailures.js +137 -0
- package/dist/browser/history/CaptureFormatError.js +10 -0
- package/dist/browser/history/CaptureRedaction.js +65 -0
- package/dist/browser/history/CaptureRelease.js +17 -0
- package/dist/browser/history/HarCapture.js +165 -0
- package/dist/browser/history/HarCaptureAdapter.js +20 -0
- package/dist/browser/history/HarCaptureProcess.js +57 -0
- package/dist/browser/history/HarJson.js +92 -0
- package/dist/browser/history/HarSchema.js +72 -0
- package/dist/browser/history/HistoricalCaptureDecoder.js +188 -0
- package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
- package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
- package/dist/cli/analysisSelector.js +23 -0
- package/dist/cli/applicationCommands.js +2 -3
- package/dist/cli/artifactCommands.js +26 -1
- package/dist/cli/binaryDiagnosticsCommands.js +39 -0
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +78 -20
- package/dist/cli/electronCommands.js +21 -13
- package/dist/cli/evmCommands.js +24 -0
- package/dist/cli/firmwareCommands.js +6 -3
- package/dist/cli/javascriptApplicationAnalysis.js +20 -3
- package/dist/cli/jsonOutput.js +38 -0
- package/dist/cli/nativeCallCommands.js +34 -0
- package/dist/cli/processCommands.js +1 -1
- package/dist/cli/streamedJsonOutput.js +56 -0
- package/dist/cli/utilityCommands.js +2 -0
- package/dist/cli/webNetworkCaptureCommands.js +40 -0
- package/dist/cli/webRuntimeCommands.js +8 -8
- package/dist/cli.js +11 -4
- package/dist/cliBrowserScenarioCommands.js +2 -2
- package/dist/cliCommandNames.js +6 -1
- package/dist/cliJsonInput.js +35 -1
- package/dist/cliOutput.js +21 -6
- package/dist/composition/binaryDiagnostics.js +8 -0
- package/dist/composition/evm.js +4 -0
- package/dist/composition/webNetworkCaptures.js +6 -0
- package/dist/config/environment.js +4 -0
- package/dist/config/ghidraStartupTimeout.js +17 -0
- package/dist/config/mcpResponseBudget.js +22 -0
- package/dist/config/parseConfig.js +2 -1
- package/dist/contracts/artifactToolContracts.js +6 -0
- package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
- package/dist/contracts/browserToolContracts.js +4 -3
- package/dist/contracts/enhancedInputs.js +5 -3
- package/dist/contracts/enhancedToolContracts.js +3 -3
- package/dist/contracts/errorSchemas.js +8 -1
- package/dist/contracts/evm/evmToolContracts.js +20 -0
- package/dist/contracts/hopperMemoryContracts.js +2 -5
- package/dist/contracts/investigationExamples.js +2 -2
- package/dist/contracts/javascript/electronToolContracts.js +1 -1
- package/dist/contracts/managed/managedToolContracts.js +8 -6
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
- package/dist/contracts/native/nativeToolContracts.js +21 -3
- package/dist/contracts/officialToolContracts.js +26 -24
- package/dist/contracts/process/processCaptureExample.js +2 -0
- package/dist/contracts/promptContracts.js +3 -3
- package/dist/contracts/sessionLifecycleInputs.js +18 -5
- package/dist/contracts/sessionStatusContract.js +8 -2
- package/dist/contracts/sessionToolContracts.js +8 -3
- package/dist/contracts/sessionToolSchemas.js +8 -4
- package/dist/contracts/toolContractExamples.js +1 -2
- package/dist/contracts/toolContractHelpers.js +4 -1
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +30 -1
- package/dist/contracts/toolOutputSchemaGroups.js +33 -28
- package/dist/contracts/toolOutputSchemaPrimitives.js +19 -1
- package/dist/contracts/toolSchemaMetadata.js +69 -10
- package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
- package/dist/domain/analysisErrorBase.js +22 -2
- package/dist/domain/analysisErrorCore.js +61 -5
- package/dist/domain/analysisErrorPresentation.js +95 -12
- package/dist/domain/analysisErrorProjection.js +148 -19
- package/dist/domain/analysisSnapshot.js +166 -2
- package/dist/domain/android/androidAnalysis.js +2 -4
- package/dist/domain/android/androidApplication.js +17 -9
- package/dist/domain/apple/appleApplication.js +41 -14
- package/dist/domain/apple/dyldEnvironment.js +73 -0
- package/dist/domain/apple/dyldPaths.js +81 -0
- package/dist/domain/apple/dylibResolution.js +478 -0
- package/dist/domain/apple/dylibResolutionFindings.js +77 -0
- package/dist/domain/apple/interfaceBuilderGraph.js +25 -13
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +13 -3
- package/dist/domain/apple/keyedArchive.js +9 -1
- package/dist/domain/apple/machoContainer.js +54 -0
- package/dist/domain/apple/plistNumbers.js +76 -0
- package/dist/domain/artifactIdentity.js +29 -0
- package/dist/domain/artifactInventoryEvidence.js +19 -24
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/bridgeCandidateProjection.js +71 -0
- package/dist/domain/browserCompleteness.js +1 -0
- package/dist/domain/browserObservation.js +1 -1
- package/dist/domain/browserObservationError.js +24 -5
- package/dist/domain/browserObservationSchemas.js +13 -0
- package/dist/domain/browserScenarioValues.js +5 -2
- package/dist/domain/bundleComparison.js +3 -2
- package/dist/domain/callPathSchemas.js +1 -1
- package/dist/domain/canonicalDigest.js +13 -1
- package/dist/domain/canonicalJsonDigestSteps.js +133 -0
- package/dist/domain/canonicalOrdering.js +9 -5
- package/dist/domain/changedBehavior.js +9 -9
- package/dist/domain/comparisonSourceEvidence.js +40 -0
- package/dist/domain/comparisonStatus.js +2 -30
- package/dist/domain/configurationErrors.js +1 -1
- package/dist/domain/conformanceTrustGate.js +0 -16
- package/dist/domain/evidence.js +78 -11
- package/dist/domain/evidenceBundle.js +42 -1
- package/dist/domain/evidenceErrors.js +12 -1
- package/dist/domain/evm/evmInterface.js +63 -0
- package/dist/domain/explicitSensitiveFailure.js +108 -0
- package/dist/domain/explicitSensitiveValues.js +10 -0
- package/dist/domain/firmware/firmwareAnalysis.js +10 -4
- package/dist/domain/hopperErrors.js +23 -2
- package/dist/domain/hopperValues.js +51 -8
- package/dist/domain/immutableJson.js +114 -0
- package/dist/domain/inputIssueProjection.js +3 -0
- package/dist/domain/javascript/electronActiveObservation.js +37 -6
- package/dist/domain/javascript/electronStaticAnalysisValues.js +6 -12
- package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +71 -23
- package/dist/domain/javascript/javascriptApplicationGraph.js +13 -0
- package/dist/domain/javascript/javascriptAstValues.js +20 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
- package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
- package/dist/domain/javascript/javascriptRecovery.js +3 -8
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +97 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +6 -5
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +9 -17
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +22 -5
- package/dist/domain/javascript/javascriptSemanticGraph.js +34 -5
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +1 -0
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +25 -17
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -4
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
- package/dist/domain/javascript/javascriptSemanticValues.js +83 -11
- package/dist/domain/javascript/javascriptSourceParser.js +6 -2
- package/dist/domain/javascript/javascriptStaticAnalysis.js +22 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -3
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +14 -4
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +66 -7
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +28 -16
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -2
- package/dist/domain/jsonSerialization.js +109 -0
- package/dist/domain/jsonValue.js +91 -3
- package/dist/domain/localPath.js +8 -0
- package/dist/domain/managed/managedApplicationGraph.js +10 -10
- package/dist/domain/managed/managedInspectionEvidence.js +16 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +5 -9
- package/dist/domain/managed/managedNativeVerification.js +3 -9
- package/dist/domain/native/binaryLayout.js +357 -0
- package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
- package/dist/domain/native/nativeCallObservation.js +186 -0
- package/dist/domain/native/nativeCallPartialObservation.js +33 -0
- package/dist/domain/native/objcSwiftMetadata.js +0 -39
- package/dist/domain/native/recordedCrash.js +266 -0
- package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
- package/dist/domain/{processCapture.js → process/processCapture.js} +143 -2
- package/dist/domain/{processCaptureExample.js → process/processCaptureExample.js} +5 -0
- package/dist/domain/process/processCaptureParsing.js +54 -0
- package/dist/domain/{processCaptureValidation.js → process/processCaptureValidation.js} +18 -2
- package/dist/domain/{processComparison.js → process/processComparison.js} +39 -5
- package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
- package/dist/domain/{processScenario.js → process/processScenario.js} +11 -10
- package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
- package/dist/domain/propertyListKeys.js +1 -1
- package/dist/domain/propertyListXmlText.js +19 -0
- package/dist/domain/providerAdapterError.js +1 -1
- package/dist/domain/providerOperationHealth.js +54 -0
- package/dist/domain/providerSelectionError.js +4 -2
- package/dist/domain/reconstructionVerification.js +9 -46
- package/dist/domain/reconstructionVerificationSchemas.js +3 -3
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +9 -46
- package/dist/domain/webBundleAnalysis.js +20 -8
- package/dist/domain/webBundleAnalyzerInspection.js +13 -8
- package/dist/domain/webBundleAnalyzerResult.js +41 -2
- package/dist/domain/webCaptureDiff.js +1 -0
- package/dist/domain/webNetworkCapture.js +118 -0
- package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
- package/dist/domain/webRuntime.js +19 -5
- package/dist/domain/webSourceLocation.js +1 -0
- package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
- package/dist/dotnet/ManagedMemberInspector.js +4 -2
- package/dist/dotnet/ManagedMemberInspectorCore.js +38 -32
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +23 -7
- package/dist/dotnet/ManagedMemberRows.js +14 -3
- package/dist/dotnet/ManagedMetadataHeaps.js +20 -2
- package/dist/dotnet/ManagedMetadataInventory.js +38 -28
- package/dist/dotnet/ManagedMetadataInventoryRows.js +24 -10
- package/dist/dotnet/ManagedMethodBodyReader.js +7 -1
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +15 -3
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +3 -1
- package/dist/dotnet/ManagedPeReader.js +11 -0
- package/dist/evm/EvmBytecodeCarrier.js +21 -0
- package/dist/evm/EvmWorkerLimits.js +40 -0
- package/dist/evm/EvmoleFailures.js +126 -0
- package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
- package/dist/evm/EvmoleInterfaceProvider.js +273 -0
- package/dist/evm/EvmoleInterfaceWorker.js +87 -0
- package/dist/evm/EvmoleRelease.js +16 -0
- package/dist/firmware/FirmwareCommand.js +1 -0
- package/dist/firmware/FirmwareFiles.js +1 -1
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +5 -0
- package/dist/ghidra/GhidraClient.js +47 -14
- package/dist/ghidra/GhidraDiagnostics.js +7 -7
- package/dist/ghidra/GhidraFunctionValues.js +10 -7
- package/dist/ghidra/GhidraInstallation.js +18 -21
- package/dist/ghidra/GhidraInventoryValues.js +14 -4
- package/dist/ghidra/GhidraJavaLaunch.js +62 -0
- package/dist/ghidra/GhidraLauncher.js +34 -16
- package/dist/ghidra/GhidraProvider.js +2 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +15 -3
- package/dist/ghidra/GhidraProviderClient.js +23 -12
- package/dist/ghidra/GhidraSessionError.js +11 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +47 -12
- package/dist/ghidra/GhidraTransport.js +20 -0
- package/dist/hopper/BridgeLauncher.js +33 -11
- package/dist/hopper/HopperAnalysisProfile.js +62 -4
- package/dist/hopper/HopperCleanup.js +15 -3
- package/dist/hopper/HopperClient.js +222 -14
- package/dist/hopper/HopperFileOffset.js +237 -0
- package/dist/hopper/HopperMachOImage.js +196 -0
- package/dist/hopper/HopperOperationStage.js +6 -0
- package/dist/hopper/HopperProvider.js +63 -9
- package/dist/hopper/HopperProviderCapabilities.js +19 -1
- package/dist/hopper/HopperRegexSearch.js +137 -0
- package/dist/hopper/HopperRegexWorker.js +27 -0
- package/dist/hopper/HopperRequestQueue.js +68 -19
- package/dist/hopper/HopperTargetLease.js +3 -2
- package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -1
- package/dist/inspector/V8InspectorCaptureProjection.js +8 -3
- package/dist/inspector/V8InspectorProvider.js +47 -11
- package/dist/javascript/recovery/WakaruCommand.js +3 -0
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +17 -0
- package/dist/javascript/sourceMaps/SourceMapFormat.js +79 -31
- package/dist/javascript/sourceMaps/TraceSourceMap.js +14 -28
- package/dist/mcpDoctor.js +62 -2
- package/dist/native/AppleDispatchCoverage.js +47 -6
- package/dist/native/AppleDispatchDecodeFacts.js +6 -0
- package/dist/native/AppleDispatchMetadata.js +6 -3
- package/dist/native/AppleMachoFixups.js +48 -24
- package/dist/native/AppleMachoSelection.js +32 -16
- package/dist/native/AppleObjcCategories.js +6 -2
- package/dist/native/AppleObjcDispatchFacets.js +5 -2
- package/dist/native/AppleObjcProperties.js +2 -1
- package/dist/native/AppleSwiftDispatchFacets.js +27 -21
- package/dist/native/AppleSwiftVtables.js +21 -15
- package/dist/native/CommandRunner.js +82 -84
- package/dist/native/LldbCallTracer.js +541 -0
- package/dist/native/LldbRetainedObservations.js +178 -0
- package/dist/native/NativeCallObservation.js +194 -0
- package/dist/native/NativeMacOSProvider.js +117 -20
- package/dist/native/NativeMacOSProviderMetadata.js +8 -3
- package/dist/native/SignatureTargetBinding.js +155 -0
- package/dist/native/parsers/lipo.js +71 -1
- package/dist/native/pwndbg/PwndbgCoreContext.js +180 -0
- package/dist/native/pwntools/PwntoolsDecoder.js +203 -0
- package/dist/native/pwntools/PwntoolsFailures.js +180 -0
- package/dist/native/pwntools/PwntoolsLayoutProvider.js +36 -0
- package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +75 -0
- package/dist/native/pwntools/PwntoolsRelease.js +19 -0
- package/dist/native/pwntools/PwntoolsResourceLimits.js +76 -0
- package/dist/native/pwntools/RecordedCrashSourceBindings.js +46 -0
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +103 -0
- package/dist/process/DarwinProcessRunTokenReader.js +293 -0
- package/dist/process/ExecFileOutput.js +20 -0
- package/dist/process/OwnedCommand.js +118 -0
- package/dist/process/ProcessOwnership.js +431 -51
- package/dist/process/ProcessOwnershipObservation.js +209 -27
- package/dist/process/ProviderProcess.js +68 -10
- package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
- package/dist/{application → process/capture}/ProcessCaptureError.js +18 -2
- package/dist/process/capture/ProcessCaptureLifecycle.js +681 -0
- package/dist/{application → process/capture}/ProcessHarness.js +195 -29
- package/dist/{application → process/capture}/ProcessSampling.js +2 -2
- package/dist/server/EvidenceMcpServer.js +146 -0
- package/dist/server/createServer.js +37 -8
- package/dist/server/promptCompletion.js +10 -3
- package/dist/server/registerAndroidTools.js +2 -4
- package/dist/server/registerApplicationTools/helpers.js +2 -4
- package/dist/server/registerArtifactComparisonTool.js +11 -7
- package/dist/server/registerBinaryDiagnosticsTools.js +15 -0
- package/dist/server/registerBrowserScenarioTool.js +2 -4
- package/dist/server/registerBrowserTools.js +2 -4
- package/dist/server/registerBundleComparisonTool.js +2 -3
- package/dist/server/registerCloseLifecycleTool.js +8 -18
- package/dist/server/registerElectronTools.js +2 -4
- package/dist/server/registerEnhancedTools.js +18 -59
- package/dist/server/registerEvidenceTools.js +3 -5
- package/dist/server/registerEvmTools.js +15 -0
- package/dist/server/registerFirmwareTools.js +2 -4
- package/dist/server/registerFunctionComparisonTool.js +10 -6
- package/dist/server/registerInvestigationTools.js +7 -7
- package/dist/server/registerJavaScriptRecoveryTool.js +2 -4
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +2 -4
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +2 -4
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +2 -4
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +2 -4
- package/dist/server/registerOfficialTools.js +2 -4
- package/dist/server/registerProcessComparisonTool.js +72 -46
- package/dist/server/registerRecordedCrashTools.js +15 -0
- package/dist/server/registerSessionRecordTools.js +5 -6
- package/dist/server/registerSessionStatusTool.js +17 -3
- package/dist/server/registerSessionTools.js +13 -5
- package/dist/server/registerWebModuleTool.js +2 -4
- package/dist/server/registerWebNetworkCaptureTool.js +26 -0
- package/dist/server/registerWebRuntimeTools.js +3 -7
- package/dist/server/registerWebScriptTool.js +2 -4
- package/dist/server/registerWebSourceLocationTool.js +2 -4
- package/dist/server/runDerivedOperation.js +15 -3
- package/dist/server/sessionAvailabilityPolicy.js +3 -1
- package/dist/server/sessionToolPolicies.js +1 -1
- package/dist/server/toolRegistrationOptions.js +2 -2
- package/dist/server/toolResult.js +63 -11
- package/dist/server/toolResultEncoding.js +33 -0
- package/install.sh +1 -1
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +42 -9
- package/scripts/electron-active-hook-boundaries.cjs +18 -20
- package/scripts/electron-active-hook.cjs +241 -37
- package/scripts/rea.mjs +11 -3
- package/skills/reverse-engineer-anything/SKILL.md +32 -4
- package/skills/reverse-engineer-anything/references/javascript-applications.md +8 -1
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +29 -0
- package/third_party/README.md +60 -0
- package/third_party/evmole/LICENSE +21 -0
- package/third_party/evmole/README.md +22 -0
- package/third_party/pwndbg/LICENSE.md +21 -0
- package/third_party/pwndbg/README.md +23 -0
- package/third_party/pwntools/README.md +40 -0
- package/dist/application/AuthorizedArtifactInventory.js +0 -7
- package/dist/application/ProcessCaptureLifecycle.js +0 -299
- package/dist/application/StoreFileLock.js +0 -124
- package/dist/contracts/processCaptureExample.js +0 -2
- package/dist/domain/bytecodeProvider.js +0 -178
- package/dist/domain/customProtocolCapture.js +0 -137
- package/dist/domain/eventProcessTree.js +0 -225
- package/dist/domain/mobileApplicationInvestigation.js +0 -159
- package/dist/domain/packageAnalysis.js +0 -123
- package/dist/domain/peInspection.js +0 -197
- package/dist/domain/processCaptureParsing.js +0 -21
- package/dist/domain/protocolCapture.js +0 -217
- package/dist/domain/runtimeIdentification.js +0 -212
- package/dist/generatedMcpToolCatalog.js +0 -37
- package/dist/ghidra/GhidraDefaults.js +0 -2
- /package/dist/application/{ArtifactExtractionDestination.js → artifacts/ArtifactExtractionDestination.js} +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/policy.js +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/types.js +0 -0
- /package/dist/domain/{processEvidenceProvider.js → process/processEvidenceProvider.js} +0 -0
- /package/dist/domain/{processTraceComparison.js → process/processTraceComparison.js} +0 -0
- /package/dist/domain/{processTraceDimensionProjection.js → process/processTraceDimensionProjection.js} +0 -0
- /package/dist/domain/{processTraceEvaluation.js → process/processTraceEvaluation.js} +0 -0
- /package/dist/{application → process/capture}/FilesystemSnapshot.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureEnvironment.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureJournal.js +0 -0
- /package/dist/{application → process/capture}/ProcessFilesystemEffects.js +0 -0
- /package/dist/{application → process/capture}/ProcessNormalization.js +0 -0
- /package/dist/{application → process/capture}/ProcessScenarioRuntimeValidation.js +0 -0
- /package/dist/{application → process/capture}/ProcessTimer.js +0 -0
- /package/dist/{application → process/capture}/TerminalRenderer.js +0 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { access, readFile, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { constants } from "node:fs";
|
|
4
|
+
import { isAbsolute, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { createAnalysisExecution, } from "../application/AnalysisProvider.js";
|
|
8
|
+
import { readStableArtifact } from "../artifacts/readStableArtifact.js";
|
|
9
|
+
import { OwnedCommandFailure } from "../process/OwnedCommand.js";
|
|
10
|
+
import { AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisUnsupportedTargetError, AnalysisInputError, AnalysisOutputError, } from "../domain/analysisErrorCore.js";
|
|
11
|
+
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
12
|
+
import { evmInterfaceSchema } from "../domain/evm/evmInterface.js";
|
|
13
|
+
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
|
14
|
+
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
|
|
15
|
+
import { err, ok } from "../domain/result.js";
|
|
16
|
+
import { runOwnedCommand } from "../process/OwnedCommand.js";
|
|
17
|
+
import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js";
|
|
18
|
+
import { evmInterfaceFailure, capturedEvmOutput, } from "./EvmoleFailures.js";
|
|
19
|
+
import { evmoleInterfaceReplySchema, projectEvmoleInterface, } from "./EvmoleInterfaceAdapter.js";
|
|
20
|
+
import { EVMOLE_PROVIDER_IDENTITY, EVM_INTERFACE_LIMITS, EVM_FILE_SIZE_FAILURE_EXIT, } from "./EvmoleRelease.js";
|
|
21
|
+
import { decodeEvmBytecodeCarrier } from "./EvmBytecodeCarrier.js";
|
|
22
|
+
import { selectEvmWorkerLimits, } from "./EvmWorkerLimits.js";
|
|
23
|
+
const OPERATION = "inspect_evm_interface";
|
|
24
|
+
const replySchema = z.discriminatedUnion("ok", [
|
|
25
|
+
z.strictObject({
|
|
26
|
+
ok: z.literal(true),
|
|
27
|
+
version: z.literal("0.9.3"),
|
|
28
|
+
bytecode: z.strictObject({
|
|
29
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
30
|
+
bytes: z.number().int().nonnegative(),
|
|
31
|
+
hex: z.string().regex(/^(?:[a-f0-9]{2})*$/),
|
|
32
|
+
}),
|
|
33
|
+
raw: evmoleInterfaceReplySchema,
|
|
34
|
+
}),
|
|
35
|
+
z.strictObject({
|
|
36
|
+
ok: z.literal(false),
|
|
37
|
+
reason: z.enum(["format", "decoder", "output-limit", "unsupported"]),
|
|
38
|
+
message: z.string(),
|
|
39
|
+
}),
|
|
40
|
+
]);
|
|
41
|
+
/** Run unchanged EVMole/WASM in an owned worker; no target, chain or network execution. */
|
|
42
|
+
export class EvmoleInterfaceProvider {
|
|
43
|
+
environment;
|
|
44
|
+
launcher;
|
|
45
|
+
createRuntime;
|
|
46
|
+
constructor(environment = process.env, launcher, createRuntime = () => PrivateRuntimeRoot.create({ prefix: "rea-evm-interface-" })) {
|
|
47
|
+
this.environment = environment;
|
|
48
|
+
this.launcher = launcher;
|
|
49
|
+
this.createRuntime = createRuntime;
|
|
50
|
+
}
|
|
51
|
+
/** Bind recovered interface candidates to both original carrier and decoded byte identity. */
|
|
52
|
+
async inspect(input, options) {
|
|
53
|
+
let root;
|
|
54
|
+
let retainedOutput;
|
|
55
|
+
let phase = "configuration";
|
|
56
|
+
let workerLimits;
|
|
57
|
+
const limiter = this.environment.REA_EVM_PRLIMIT_COMMAND ?? "/usr/bin/prlimit";
|
|
58
|
+
let result;
|
|
59
|
+
try {
|
|
60
|
+
if (options?.signal?.aborted)
|
|
61
|
+
throw new AnalysisCancelledError(OPERATION);
|
|
62
|
+
if (process.platform !== "linux" || process.arch !== "x64")
|
|
63
|
+
throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, "Initial real-verified offline EVM interface profile supports Linux x64 only.");
|
|
64
|
+
try {
|
|
65
|
+
if (!isAbsolute(limiter))
|
|
66
|
+
throw new Error("REA_EVM_PRLIMIT_COMMAND must be an absolute executable path.");
|
|
67
|
+
await access(limiter, constants.X_OK);
|
|
68
|
+
if (!(await stat(limiter)).isFile())
|
|
69
|
+
throw new Error("Configured prlimit must be a regular executable file, not a directory.");
|
|
70
|
+
}
|
|
71
|
+
catch (cause) {
|
|
72
|
+
const reason = `Offline EVM interface inspection requires caller-supplied util-linux prlimit: ${limiter}; ${cause instanceof Error ? cause.message : String(cause)}`;
|
|
73
|
+
throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, reason, { cause, userMessage: reason });
|
|
74
|
+
}
|
|
75
|
+
let inheritedLimits;
|
|
76
|
+
try {
|
|
77
|
+
inheritedLimits = await readFile("/proc/self/limits", "utf8");
|
|
78
|
+
}
|
|
79
|
+
catch (cause) {
|
|
80
|
+
const reason = `Could not read inherited Linux resource limits at /proc/self/limits: ${cause instanceof Error ? cause.message : String(cause)}`;
|
|
81
|
+
throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, reason, { cause, userMessage: reason });
|
|
82
|
+
}
|
|
83
|
+
const limits = selectEvmWorkerLimits(inheritedLimits);
|
|
84
|
+
if (!limits.ok)
|
|
85
|
+
throw new AnalysisCapabilityUnavailableError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, limits.error, { userMessage: limits.error });
|
|
86
|
+
workerLimits = limits.value;
|
|
87
|
+
phase = "artifact-read";
|
|
88
|
+
const carrier = await readStableArtifact(input.path, EVM_INTERFACE_LIMITS.inputBytes, options?.signal);
|
|
89
|
+
phase = "worker";
|
|
90
|
+
root = await this.createRuntime();
|
|
91
|
+
const snapshotPath = join(root.path, "carrier.snapshot");
|
|
92
|
+
const requestPath = join(root.path, "request.json");
|
|
93
|
+
const replyPath = join(root.path, "reply.json");
|
|
94
|
+
await writeFile(snapshotPath, carrier.bytes, {
|
|
95
|
+
flag: "wx",
|
|
96
|
+
mode: 0o600,
|
|
97
|
+
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
98
|
+
});
|
|
99
|
+
await writeFile(requestPath, JSON.stringify({
|
|
100
|
+
snapshot_path: snapshotPath,
|
|
101
|
+
reply_path: replyPath,
|
|
102
|
+
failure_marker_path: join(root.path, "resource.failure"),
|
|
103
|
+
encoding: input.encoding,
|
|
104
|
+
}), { flag: "wx", mode: 0o600 });
|
|
105
|
+
const { NODE_OPTIONS: _ambientNodeOptions, ...environment } = this.environment;
|
|
106
|
+
const execution = await runOwnedCommand({
|
|
107
|
+
command: limiter,
|
|
108
|
+
arguments: [
|
|
109
|
+
`--as=${String(workerLimits.addressSpaceBytes)}:`,
|
|
110
|
+
`--fsize=${String(workerLimits.fileSizeBytes)}:`,
|
|
111
|
+
"--core=0:",
|
|
112
|
+
`--cpu=${String(workerLimits.cpuSeconds)}:`,
|
|
113
|
+
"--",
|
|
114
|
+
process.execPath,
|
|
115
|
+
"--max-old-space-size=256",
|
|
116
|
+
"--v8-pool-size=1",
|
|
117
|
+
"--disable-wasm-trap-handler",
|
|
118
|
+
fileURLToPath(new URL("./EvmoleInterfaceWorker.js", import.meta.url)),
|
|
119
|
+
requestPath,
|
|
120
|
+
],
|
|
121
|
+
cwd: root.path,
|
|
122
|
+
expectedCommand: null,
|
|
123
|
+
runId: `rea-evm-interface-${randomUUID()}`,
|
|
124
|
+
hostEnvironment: environment,
|
|
125
|
+
}, {
|
|
126
|
+
timeoutMs: EVM_INTERFACE_LIMITS.timeoutMs,
|
|
127
|
+
diagnosticBytes: EVM_INTERFACE_LIMITS.diagnosticBytes,
|
|
128
|
+
}, {
|
|
129
|
+
...(options?.signal === undefined ? {} : { signal: options.signal }),
|
|
130
|
+
...(this.launcher === undefined ? {} : { launcher: this.launcher }),
|
|
131
|
+
});
|
|
132
|
+
const capturedOutput = capturedEvmOutput(execution);
|
|
133
|
+
retainedOutput = capturedOutput;
|
|
134
|
+
let reply;
|
|
135
|
+
try {
|
|
136
|
+
const file = await readStableArtifact(replyPath, EVM_INTERFACE_LIMITS.outputBytes, options?.signal);
|
|
137
|
+
reply = replySchema.parse(JSON.parse(file.bytes.toString("utf8")));
|
|
138
|
+
}
|
|
139
|
+
catch (cause) {
|
|
140
|
+
if (options?.signal?.aborted)
|
|
141
|
+
throw new AnalysisCancelledError(OPERATION, { capturedOutput });
|
|
142
|
+
throw new AnalysisOutputError(OPERATION, `Owned interface worker reply failed for ${input.path}: ${cause instanceof Error ? cause.message : String(cause)}`, { cause, capturedOutput });
|
|
143
|
+
}
|
|
144
|
+
if (!reply.ok) {
|
|
145
|
+
if (reply.reason === "unsupported")
|
|
146
|
+
throw new AnalysisUnsupportedTargetError(OPERATION, input.path, reply.message, { capturedOutput });
|
|
147
|
+
if (reply.reason === "format")
|
|
148
|
+
throw new AnalysisInputError(OPERATION, { capturedOutput }, [
|
|
149
|
+
{
|
|
150
|
+
path: ["path"],
|
|
151
|
+
reason: "invalid_format",
|
|
152
|
+
message: reply.message,
|
|
153
|
+
},
|
|
154
|
+
]);
|
|
155
|
+
if (reply.reason === "output-limit")
|
|
156
|
+
throw new AnalysisOutputError(OPERATION, reply.message, {
|
|
157
|
+
capturedOutput,
|
|
158
|
+
});
|
|
159
|
+
throw new ProviderAdapterError(EVMOLE_PROVIDER_IDENTITY.id, OPERATION, {
|
|
160
|
+
diagnostics: {
|
|
161
|
+
phase,
|
|
162
|
+
failure_kind: reply.reason,
|
|
163
|
+
reason: reply.message,
|
|
164
|
+
stdout: execution.stdout.text,
|
|
165
|
+
stderr: execution.stderr.text,
|
|
166
|
+
captured_output: { ...capturedOutput },
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const selectedBytes = decodeEvmBytecodeCarrier(carrier.bytes, input.encoding);
|
|
171
|
+
const selectedHex = Buffer.from(selectedBytes).toString("hex");
|
|
172
|
+
const decodedHash = createHash("sha256")
|
|
173
|
+
.update(selectedBytes)
|
|
174
|
+
.digest("hex");
|
|
175
|
+
if (decodedHash !== reply.bytecode.sha256 ||
|
|
176
|
+
selectedHex !== reply.bytecode.hex ||
|
|
177
|
+
selectedBytes.length !== reply.bytecode.bytes)
|
|
178
|
+
throw new AnalysisOutputError(OPERATION, "Decoded bytecode representation does not match the selected carrier, encoding or reported SHA-256.", { capturedOutput });
|
|
179
|
+
const limitations = [
|
|
180
|
+
`Configured worker resource soft limits: address_space_bytes=${String(workerLimits.addressSpaceBytes)}, cpu_seconds=${String(workerLimits.cpuSeconds)}, file_size_bytes=${String(workerLimits.fileSizeBytes)}. Selected from inherited tighter limits; original hard limits are retained. Effective worker limits are not independently probed.`,
|
|
181
|
+
"Upstream may also report terminal metadata while recovering selectors. Its reported values are retained in raw_result, but integer precision and non-text-key coverage are unknown in the JS binding; complete original bytecode remains available.",
|
|
182
|
+
"Recovered selectors, argument strings and mutability are upstream inferences, not verified ABI signatures or names. Empty results do not prove the absence of callable dispatch.",
|
|
183
|
+
"Bytecode kind, hardfork and deployed-contract authenticity are unknown. This inspection performs no target runtime execution, chain/RPC lookup or network request.",
|
|
184
|
+
"Original carrier and decoded bytecode SHA-256 are distinct identities; SHA-256 is not the Ethereum Keccak code hash.",
|
|
185
|
+
"The owned worker has a 256 MiB JavaScript heap, 3 GiB virtual address-space limit and 30-second deadline. Virtual address space is distinct from resident memory; limits fail without partial success.",
|
|
186
|
+
];
|
|
187
|
+
const validated = evmInterfaceSchema.safeParse({
|
|
188
|
+
artifact: {
|
|
189
|
+
path: input.path,
|
|
190
|
+
sha256: carrier.sha256,
|
|
191
|
+
bytes: carrier.bytes.length,
|
|
192
|
+
encoding: input.encoding,
|
|
193
|
+
},
|
|
194
|
+
bytecode: {
|
|
195
|
+
...reply.bytecode,
|
|
196
|
+
digest_algorithm: "sha256",
|
|
197
|
+
kind: "unknown",
|
|
198
|
+
deployment_authenticity: "unknown",
|
|
199
|
+
hardfork: "unknown",
|
|
200
|
+
},
|
|
201
|
+
evidence_kind: "inferred",
|
|
202
|
+
functions: projectEvmoleInterface(reply.raw).functions,
|
|
203
|
+
discovery_completeness: "unknown",
|
|
204
|
+
runtime_execution: "not-performed",
|
|
205
|
+
diagnostics: {
|
|
206
|
+
stdout: execution.stdout.text,
|
|
207
|
+
stderr: execution.stderr.text,
|
|
208
|
+
truncated: capturedOutput.truncated,
|
|
209
|
+
},
|
|
210
|
+
limitations,
|
|
211
|
+
});
|
|
212
|
+
if (!validated.success)
|
|
213
|
+
throw new AnalysisOutputError(OPERATION, `Interface worker returned invalid bytecode-relative evidence: ${validated.error.issues[0]?.message ?? "schema mismatch"}`, { capturedOutput });
|
|
214
|
+
const report = validated.data;
|
|
215
|
+
result = ok(createAnalysisExecution(report, EVMOLE_PROVIDER_IDENTITY, {
|
|
216
|
+
rawResult: reply.raw,
|
|
217
|
+
subject: { path: input.path, format: "file", sha256: carrier.sha256 },
|
|
218
|
+
locations: [{ kind: "artifact-path", path: input.path }],
|
|
219
|
+
limitations,
|
|
220
|
+
}));
|
|
221
|
+
}
|
|
222
|
+
catch (cause) {
|
|
223
|
+
let fileFailure;
|
|
224
|
+
if (cause instanceof OwnedCommandFailure &&
|
|
225
|
+
cause.snapshot?.exitCode === EVM_FILE_SIZE_FAILURE_EXIT &&
|
|
226
|
+
cause.snapshot.signal === null &&
|
|
227
|
+
root !== undefined) {
|
|
228
|
+
try {
|
|
229
|
+
const marker = await readStableArtifact(join(root.path, "resource.failure"), 1);
|
|
230
|
+
if (!marker.bytes.equals(Buffer.from("F")))
|
|
231
|
+
throw new Error("Private worker failure marker does not match the observed exit status.");
|
|
232
|
+
fileFailure = { verified: true, failure: null };
|
|
233
|
+
}
|
|
234
|
+
catch (markerFailure) {
|
|
235
|
+
fileFailure = {
|
|
236
|
+
verified: false,
|
|
237
|
+
failure: markerFailure instanceof Error
|
|
238
|
+
? markerFailure.message
|
|
239
|
+
: String(markerFailure),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
result = err(options?.signal?.aborted &&
|
|
244
|
+
(cause === options.signal.reason ||
|
|
245
|
+
(cause instanceof Error && cause.name === "AbortError"))
|
|
246
|
+
? new AnalysisCancelledError(OPERATION, retainedOutput === undefined
|
|
247
|
+
? undefined
|
|
248
|
+
: { capturedOutput: retainedOutput })
|
|
249
|
+
: evmInterfaceFailure(cause, phase, input.path, workerLimits, limiter, fileFailure));
|
|
250
|
+
}
|
|
251
|
+
if (root !== undefined) {
|
|
252
|
+
try {
|
|
253
|
+
await root.close();
|
|
254
|
+
}
|
|
255
|
+
catch (cause) {
|
|
256
|
+
return err(new ProviderCleanupError(EVMOLE_PROVIDER_IDENTITY.id, [root.path], {
|
|
257
|
+
reason: cause instanceof Error ? cause.message : String(cause),
|
|
258
|
+
previous_error: result.ok
|
|
259
|
+
? null
|
|
260
|
+
: projectAnalysisError(result.error),
|
|
261
|
+
...(retainedOutput === undefined
|
|
262
|
+
? {}
|
|
263
|
+
: { captured_output: { ...retainedOutput } }),
|
|
264
|
+
}, { operation: OPERATION }));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return result.ok && options?.signal?.aborted
|
|
268
|
+
? err(new AnalysisCancelledError(OPERATION, retainedOutput === undefined
|
|
269
|
+
? undefined
|
|
270
|
+
: { capturedOutput: retainedOutput }))
|
|
271
|
+
: result;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { decodeEvmBytecodeCarrier, EvmCarrierFailure, } from "./EvmBytecodeCarrier.js";
|
|
5
|
+
import { projectEvmoleInterface } from "./EvmoleInterfaceAdapter.js";
|
|
6
|
+
import { EVM_INTERFACE_LIMITS, EVM_FILE_SIZE_FAILURE_EXIT, } from "./EvmoleRelease.js";
|
|
7
|
+
const requestSchema = z.strictObject({
|
|
8
|
+
snapshot_path: z.string(),
|
|
9
|
+
reply_path: z.string(),
|
|
10
|
+
failure_marker_path: z.string(),
|
|
11
|
+
encoding: z.enum(["raw", "hex"]),
|
|
12
|
+
});
|
|
13
|
+
class UnsupportedContainer extends Error {
|
|
14
|
+
}
|
|
15
|
+
const main = async () => {
|
|
16
|
+
const requestPath = process.argv[2];
|
|
17
|
+
if (requestPath === undefined)
|
|
18
|
+
throw new Error("Owned worker request path missing.");
|
|
19
|
+
const request = requestSchema.parse(JSON.parse(await readFile(requestPath, "utf8")));
|
|
20
|
+
let reply;
|
|
21
|
+
try {
|
|
22
|
+
const bytes = decodeEvmBytecodeCarrier(await readFile(request.snapshot_path), request.encoding);
|
|
23
|
+
if (bytes[0] === 0xef && bytes[1] === 0x00)
|
|
24
|
+
throw new UnsupportedContainer("Container marker EF00 is outside the verified flat-bytecode interface profile.");
|
|
25
|
+
const modulePath = import.meta.resolve("evmole/no_tla");
|
|
26
|
+
const metadata = z
|
|
27
|
+
.object({ version: z.literal("0.9.3") })
|
|
28
|
+
.parse(JSON.parse(await readFile(new URL("../package.json", modulePath), "utf8")));
|
|
29
|
+
const engine = await import("evmole/no_tla");
|
|
30
|
+
engine.initSync({
|
|
31
|
+
module: await readFile(new URL(import.meta.resolve("evmole/evmole_bg.wasm"))),
|
|
32
|
+
});
|
|
33
|
+
const inferred = projectEvmoleInterface(engine.contractInfo(Buffer.from(bytes).toString("hex"), {
|
|
34
|
+
selectors: true,
|
|
35
|
+
arguments: true,
|
|
36
|
+
stateMutability: true,
|
|
37
|
+
}));
|
|
38
|
+
reply = {
|
|
39
|
+
ok: true,
|
|
40
|
+
version: metadata.version,
|
|
41
|
+
bytecode: {
|
|
42
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
43
|
+
bytes: bytes.length,
|
|
44
|
+
hex: Buffer.from(bytes).toString("hex"),
|
|
45
|
+
},
|
|
46
|
+
raw: inferred.raw,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (cause) {
|
|
50
|
+
reply = {
|
|
51
|
+
ok: false,
|
|
52
|
+
reason: cause instanceof EvmCarrierFailure
|
|
53
|
+
? "format"
|
|
54
|
+
: cause instanceof UnsupportedContainer
|
|
55
|
+
? "unsupported"
|
|
56
|
+
: "decoder",
|
|
57
|
+
message: cause instanceof Error ? cause.message : String(cause),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
let encoded = JSON.stringify(reply);
|
|
61
|
+
if (Buffer.byteLength(encoded) > EVM_INTERFACE_LIMITS.outputBytes)
|
|
62
|
+
encoded = JSON.stringify({
|
|
63
|
+
ok: false,
|
|
64
|
+
reason: "output-limit",
|
|
65
|
+
message: "Complete interface evidence exceeds the 16 MiB reply budget.",
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
await writeFile(request.reply_path, encoded, { flag: "wx", mode: 0o600 });
|
|
69
|
+
}
|
|
70
|
+
catch (cause) {
|
|
71
|
+
if (cause instanceof Error && "code" in cause && cause.code === "EFBIG") {
|
|
72
|
+
try {
|
|
73
|
+
await writeFile(request.failure_marker_path, "F", {
|
|
74
|
+
flag: "wx",
|
|
75
|
+
mode: 0o600,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (markerFailure) {
|
|
79
|
+
process.stderr.write(`File-size failure marker unavailable: ${markerFailure instanceof Error ? markerFailure.message : String(markerFailure)}\n`);
|
|
80
|
+
}
|
|
81
|
+
process.exitCode = EVM_FILE_SIZE_FAILURE_EXIT;
|
|
82
|
+
}
|
|
83
|
+
else
|
|
84
|
+
throw cause;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
await main();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Unchanged locked npm/WASM profile; provenance is independent of chain deployment authenticity. */
|
|
2
|
+
export const EVMOLE_PROVIDER_IDENTITY = {
|
|
3
|
+
id: "evmole-interface",
|
|
4
|
+
name: "REA EVM interface adapter",
|
|
5
|
+
version: "evmole@0.9.3",
|
|
6
|
+
};
|
|
7
|
+
/** Worker-reserved status for an observed EFBIG write without a complete reply. */
|
|
8
|
+
export const EVM_FILE_SIZE_FAILURE_EXIT = 76;
|
|
9
|
+
/** Complete offline inspection budgets; worker JavaScript heap is bounded separately. */
|
|
10
|
+
export const EVM_INTERFACE_LIMITS = {
|
|
11
|
+
inputBytes: 4 * 1024 * 1024,
|
|
12
|
+
outputBytes: 16 * 1024 * 1024,
|
|
13
|
+
timeoutMs: 30_000,
|
|
14
|
+
diagnosticBytes: 1024 * 1024,
|
|
15
|
+
addressSpaceBytes: 3 * 1024 * 1024 * 1024,
|
|
16
|
+
};
|
|
@@ -102,7 +102,7 @@ export const readFirmwareReport = async (path, operation) => {
|
|
|
102
102
|
if (bytes === undefined)
|
|
103
103
|
throw new AnalysisOutputError(operation, `Report exceeded ${FIRMWARE_LIMITS.reportBytes} bytes`);
|
|
104
104
|
try {
|
|
105
|
-
const value = JSON.parse(
|
|
105
|
+
const value = JSON.parse(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes));
|
|
106
106
|
return value;
|
|
107
107
|
}
|
|
108
108
|
catch (cause) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Generated from package.json and package-lock.json; do not edit. */
|
|
2
2
|
export const PACKAGE_METADATA = {
|
|
3
3
|
name: "rea-agents",
|
|
4
|
-
version: "
|
|
4
|
+
version: "6.1.0", // x-release-please-version
|
|
5
5
|
serverSdkVersion: "2.3.1",
|
|
6
6
|
clientSdkVersion: "2.3.1",
|
|
7
7
|
coreSdkVersion: "2.3.1",
|
|
8
|
-
skillVersion: "
|
|
8
|
+
skillVersion: "33",
|
|
9
9
|
};
|
|
@@ -27,6 +27,11 @@ export const resolveGhidraAnalysisProfile = (target, identity, installation, sig
|
|
|
27
27
|
annotation_policy: "atomic-function-entry-metadata-v1",
|
|
28
28
|
load_image_observations: "source-mappings-entry-context-v2",
|
|
29
29
|
function_body_evidence: "complete-inclusive-ranges-v1",
|
|
30
|
+
function_references: "complete-body-and-entry-reference-manager-v2",
|
|
31
|
+
location_resolution: "explicit-address-exact-name-first-v2",
|
|
32
|
+
process_launch: installation.platform === "win32"
|
|
33
|
+
? "official-headless-script-v1"
|
|
34
|
+
: "inspected-jvm-launch-support-v1",
|
|
30
35
|
...(dos
|
|
31
36
|
? {
|
|
32
37
|
load_image_evidence: dosCom
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
3
|
import { err, ok } from "../domain/result.js";
|
|
5
4
|
import { silentLogger } from "../logger.js";
|
|
6
5
|
import { PendingOperations } from "../process/PendingOperations.js";
|
|
@@ -8,7 +7,7 @@ import { PrivateRuntimeRoot } from "../process/PrivateRuntimeRoot.js";
|
|
|
8
7
|
import { ProviderStartupDeadline } from "../process/ProviderDeadline.js";
|
|
9
8
|
import { ProviderRunLineage } from "../process/ProviderRunLineage.js";
|
|
10
9
|
import { ProviderProcessSupervisor, } from "../process/ProviderProcess.js";
|
|
11
|
-
import {
|
|
10
|
+
import { DEFAULT_GHIDRA_STARTUP_TIMEOUT_MS } from "../config/ghidraStartupTimeout.js";
|
|
12
11
|
import { createGhidraDiagnostics } from "./GhidraDiagnostics.js";
|
|
13
12
|
import { GhidraResponseBuffer } from "./GhidraResponseBuffer.js";
|
|
14
13
|
import { GhidraResponseRouter } from "./GhidraResponseRouter.js";
|
|
@@ -18,6 +17,7 @@ import { isGhidraShutdownAcknowledgement, parseGhidraSessionInfo, } from "./Ghid
|
|
|
18
17
|
import { createGhidraTargetSnapshot } from "./GhidraTargetSnapshot.js";
|
|
19
18
|
import { readFile } from "node:fs/promises";
|
|
20
19
|
import { connectGhidraSocket } from "./GhidraSocketConnection.js";
|
|
20
|
+
import { createGhidraEndpoint, } from "./GhidraTransport.js";
|
|
21
21
|
import { GhidraWire } from "./GhidraClientWire.js";
|
|
22
22
|
import { completeGhidraStartupHandshake } from "./GhidraClientStartup.js";
|
|
23
23
|
const SHUTDOWN_TIMEOUT_MS = 10_000;
|
|
@@ -32,6 +32,8 @@ export class GhidraClient {
|
|
|
32
32
|
#launch;
|
|
33
33
|
#process;
|
|
34
34
|
#runtimeRoot;
|
|
35
|
+
#socketRoot;
|
|
36
|
+
#endpointPath;
|
|
35
37
|
#snapshotPath;
|
|
36
38
|
#targetAdmission;
|
|
37
39
|
#token;
|
|
@@ -71,7 +73,7 @@ export class GhidraClient {
|
|
|
71
73
|
constructor(options) {
|
|
72
74
|
this.#options = {
|
|
73
75
|
...options,
|
|
74
|
-
startupTimeoutMs: options.startupTimeoutMs ??
|
|
76
|
+
startupTimeoutMs: options.startupTimeoutMs ?? DEFAULT_GHIDRA_STARTUP_TIMEOUT_MS,
|
|
75
77
|
platform: options.platform ?? process.platform,
|
|
76
78
|
transport: options.transport ?? "unix-socket",
|
|
77
79
|
};
|
|
@@ -90,8 +92,11 @@ export class GhidraClient {
|
|
|
90
92
|
start(signal) {
|
|
91
93
|
if (this.#closePromise !== undefined)
|
|
92
94
|
return this.#closePromise.then(() => this.start(signal));
|
|
93
|
-
if (this.#startPromise !== undefined)
|
|
95
|
+
if (this.#startPromise !== undefined) {
|
|
96
|
+
if (this.#startupController?.signal.aborted && !signal?.aborted)
|
|
97
|
+
return this.#startPromise.then((result) => result.ok ? result : this.start(signal));
|
|
94
98
|
return this.#startPromise;
|
|
99
|
+
}
|
|
95
100
|
const controller = new AbortController();
|
|
96
101
|
const onAbort = () => controller.abort(signal?.reason);
|
|
97
102
|
if (signal?.aborted === true)
|
|
@@ -177,10 +182,16 @@ export class GhidraClient {
|
|
|
177
182
|
return err(this.#failure("cancelled", "Ghidra startup was cancelled"));
|
|
178
183
|
if (this.#socket !== undefined || this.#runtimeRoot !== undefined)
|
|
179
184
|
return err(this.#failure("protocol", "Ghidra client is already started"));
|
|
185
|
+
this.#processSnapshot = undefined;
|
|
180
186
|
const deadline = new ProviderStartupDeadline(this.#options.startupTimeoutMs, signal);
|
|
181
187
|
try {
|
|
182
188
|
return await this.#startWithin(deadline);
|
|
183
189
|
}
|
|
190
|
+
catch (cause) {
|
|
191
|
+
if (cause instanceof GhidraSessionError)
|
|
192
|
+
return err(cause);
|
|
193
|
+
throw cause;
|
|
194
|
+
}
|
|
184
195
|
finally {
|
|
185
196
|
deadline.dispose();
|
|
186
197
|
}
|
|
@@ -198,12 +209,18 @@ export class GhidraClient {
|
|
|
198
209
|
}
|
|
199
210
|
if (deadline.signal.aborted)
|
|
200
211
|
return this.#startupInterrupted(deadline);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
let endpoint;
|
|
213
|
+
try {
|
|
214
|
+
const allocated = await createGhidraEndpoint(this.#runtimeRoot.path, this.#options.transport, this.#options.platform);
|
|
215
|
+
endpoint = allocated.endpoint;
|
|
216
|
+
this.#socketRoot = allocated.socketRoot;
|
|
217
|
+
this.#endpointPath = endpoint.path;
|
|
218
|
+
}
|
|
219
|
+
catch (cause) {
|
|
220
|
+
const failure = this.#failure("start", "Ghidra private endpoint allocation failed", cause);
|
|
221
|
+
await this.#cleanup();
|
|
222
|
+
return err(failure);
|
|
223
|
+
}
|
|
207
224
|
try {
|
|
208
225
|
const snapshot = await createGhidraTargetSnapshot(this.#options.targetPath, this.#runtimeRoot.path, this.#options.targetSha256, { signal: deadline.signal, platform: this.#options.platform });
|
|
209
226
|
this.#snapshotPath = snapshot.path;
|
|
@@ -274,7 +291,7 @@ export class GhidraClient {
|
|
|
274
291
|
deadline,
|
|
275
292
|
failure: this.#failure,
|
|
276
293
|
isClosed: () => this.#closing,
|
|
277
|
-
processExited: () => this.#
|
|
294
|
+
processExited: () => this.#process?.snapshot().exitCode !== undefined,
|
|
278
295
|
startupTimeoutMs: this.#options.startupTimeoutMs,
|
|
279
296
|
handlers: {
|
|
280
297
|
data: this.#onSocketData,
|
|
@@ -364,17 +381,26 @@ export class GhidraClient {
|
|
|
364
381
|
reason: stopped.reason,
|
|
365
382
|
});
|
|
366
383
|
this.#logger.warn({ reason: stopped.reason }, "Ghidra process cleanup failed closed");
|
|
367
|
-
|
|
368
|
-
|
|
384
|
+
// Keep the supervisor and private files available for a later close.
|
|
385
|
+
// A still-live JVM can recreate files if its runtime is removed here.
|
|
386
|
+
throw this.#failure("process", `Ghidra process cleanup was incomplete: ${stopped.reason}`);
|
|
369
387
|
}
|
|
370
388
|
}
|
|
371
389
|
this.#lastDiagnostics = this.#diagnostics();
|
|
372
390
|
this.#process = undefined;
|
|
373
391
|
this.#launch = undefined;
|
|
374
392
|
const runtimeRoot = this.#runtimeRoot;
|
|
393
|
+
const socketRoot = this.#socketRoot;
|
|
375
394
|
this.#runtimeRoot = undefined;
|
|
395
|
+
this.#socketRoot = undefined;
|
|
376
396
|
try {
|
|
377
|
-
await
|
|
397
|
+
const removed = await Promise.allSettled([
|
|
398
|
+
runtimeRoot?.close(),
|
|
399
|
+
socketRoot?.close(),
|
|
400
|
+
]);
|
|
401
|
+
const failed = removed.find((result) => result.status === "rejected");
|
|
402
|
+
if (failed?.status === "rejected")
|
|
403
|
+
throw failed.reason;
|
|
378
404
|
}
|
|
379
405
|
catch (cause) {
|
|
380
406
|
if (forceStop)
|
|
@@ -383,6 +409,7 @@ export class GhidraClient {
|
|
|
383
409
|
throw cause;
|
|
384
410
|
}
|
|
385
411
|
this.#snapshotPath = undefined;
|
|
412
|
+
this.#endpointPath = undefined;
|
|
386
413
|
this.#token = undefined;
|
|
387
414
|
this.#runId = undefined;
|
|
388
415
|
this.#responseBuffer.reset();
|
|
@@ -455,6 +482,12 @@ export class GhidraClient {
|
|
|
455
482
|
...(this.#runtimeRoot === undefined
|
|
456
483
|
? {}
|
|
457
484
|
: { runtimeRoot: this.#runtimeRoot.path }),
|
|
485
|
+
...(this.#socketRoot === undefined
|
|
486
|
+
? {}
|
|
487
|
+
: { socketRoot: this.#socketRoot.path }),
|
|
488
|
+
...(this.#endpointPath === undefined
|
|
489
|
+
? {}
|
|
490
|
+
: { endpointPath: this.#endpointPath }),
|
|
458
491
|
...(this.#launch === undefined ? {} : { launch: this.#launch }),
|
|
459
492
|
...(snapshot === undefined ? {} : { snapshot }),
|
|
460
493
|
...(this.#token === undefined ? {} : { token: this.#token }),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
/** Preserve actionable runtime coordinates after cleanup and redact bearer data. */
|
|
3
2
|
export const createGhidraDiagnostics = (options) => {
|
|
4
3
|
if (options.runtimeRoot === undefined &&
|
|
@@ -20,12 +19,13 @@ export const createGhidraDiagnostics = (options) => {
|
|
|
20
19
|
...(options.runId === undefined ? {} : { run_id: options.runId }),
|
|
21
20
|
...(options.runtimeRoot === undefined
|
|
22
21
|
? {}
|
|
23
|
-
: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
22
|
+
: { runtime_root: options.runtimeRoot }),
|
|
23
|
+
...(options.socketRoot === undefined
|
|
24
|
+
? {}
|
|
25
|
+
: { socket_root: options.socketRoot }),
|
|
26
|
+
...(options.endpointPath === undefined
|
|
27
|
+
? {}
|
|
28
|
+
: { endpoint_path: options.endpointPath }),
|
|
29
29
|
...(options.launch === undefined
|
|
30
30
|
? {}
|
|
31
31
|
: {
|
|
@@ -2,13 +2,14 @@ import { z } from "zod";
|
|
|
2
2
|
import { nativeFunctionAnnotationsInputSchema, nativeFunctionAnnotationsSchema, } from "../domain/native/nativeFunctionAnnotations.js";
|
|
3
3
|
import { nativeDataTypeSchema } from "../domain/native/nativeDataType.js";
|
|
4
4
|
import { nativeInstructionSchema, nativeCallTargetsSchema, } from "../domain/native/nativeInstruction.js";
|
|
5
|
-
import {
|
|
5
|
+
import { AnalysisOutputError, } from "../domain/analysisErrorCore.js";
|
|
6
6
|
import { functionBodyEntryAgrees, functionInstructionWindowSchema, functionDossierSchema, } from "../domain/hopperValues.js";
|
|
7
7
|
import { jsonObjectSchema, jsonValueSchema, } from "../domain/jsonValue.js";
|
|
8
8
|
import { nativeApiBoundarySchema } from "../domain/native/nativeApiBoundary.js";
|
|
9
9
|
import { nativeValueFlowSchema } from "../domain/native/nativeValueFlow.js";
|
|
10
10
|
import { err, ok } from "../domain/result.js";
|
|
11
|
-
import {
|
|
11
|
+
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
|
12
|
+
import { ghidraIdentifierSchema, ghidraInputAddressSchema, ghidraCanonicalAddressSchema, ghidraFunctionClassificationSchema as classification, ghidraFunctionBodySchema as ghidraFunctionBody, ghidraProcedureIdentitySchema as procedureIdentity, } from "./GhidraInventoryValues.js";
|
|
12
13
|
/** Function analysis and annotation operations admitted by the Ghidra adapter. */
|
|
13
14
|
export const GHIDRA_FUNCTION_OPERATIONS = [
|
|
14
15
|
"annotate_native_function",
|
|
@@ -37,15 +38,15 @@ const inputSchemas = {
|
|
|
37
38
|
.object({
|
|
38
39
|
document,
|
|
39
40
|
type: z.string().min(1).nullable().default(null),
|
|
40
|
-
address:
|
|
41
|
+
address: ghidraInputAddressSchema.nullable().default(null),
|
|
41
42
|
})
|
|
42
43
|
.strict()
|
|
43
44
|
.refine((value) => (value.type === null) !== (value.address === null), "Supply exactly one of type or address"),
|
|
44
45
|
inspect_native_instruction: z
|
|
45
|
-
.object({ document, address:
|
|
46
|
+
.object({ document, address: ghidraInputAddressSchema })
|
|
46
47
|
.strict(),
|
|
47
48
|
resolve_native_call_targets: z
|
|
48
|
-
.object({ document, address:
|
|
49
|
+
.object({ document, address: ghidraInputAddressSchema })
|
|
49
50
|
.strict(),
|
|
50
51
|
analyze_function: z.object({ procedure }).strict(),
|
|
51
52
|
procedure_assembly: z.object(directProcedure).strict(),
|
|
@@ -60,14 +61,16 @@ const inputSchemas = {
|
|
|
60
61
|
direction: z.enum(["incoming", "outgoing"]).default("outgoing"),
|
|
61
62
|
})
|
|
62
63
|
.strict(),
|
|
63
|
-
xrefs: z.object({ document, address:
|
|
64
|
+
xrefs: z.object({ document, address: ghidraInputAddressSchema }).strict(),
|
|
64
65
|
};
|
|
65
66
|
/** Validate and default one function request before it crosses the socket. */
|
|
66
67
|
export const parseGhidraFunctionInput = (operation, value) => {
|
|
67
68
|
const parsed = inputSchemas[operation].safeParse(value);
|
|
68
69
|
return parsed.success
|
|
69
70
|
? ok(jsonObjectSchema.parse(Object.fromEntries(Object.entries(parsed.data).filter(([, value]) => value !== undefined))))
|
|
70
|
-
: err(
|
|
71
|
+
: err(analysisInputErrorFromIssues(operation, parsed.error.issues, value, {
|
|
72
|
+
cause: parsed.error,
|
|
73
|
+
}));
|
|
71
74
|
};
|
|
72
75
|
const localVariable = z
|
|
73
76
|
.object({
|