rea-agents 6.3.0 → 6.4.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 +7 -4
- package/bridge/ghidra/ReaGhidraApplySeeds.java +151 -0
- package/bridge/ghidra/ReaGhidraBridge.java +597 -209
- package/bridge/ghidra/ReaGhidraNoReturnFix.java +123 -0
- package/dist/adb/AdbConfiguration.js +88 -0
- package/dist/adb/AdbDeviceOutput.js +186 -0
- package/dist/adb/AdbProvider.js +1190 -0
- package/dist/adb/AdbShellOutput.js +309 -0
- package/dist/android/AndroidTargetSnapshot.js +104 -22
- package/dist/android/JadxConfiguration.js +44 -24
- package/dist/android/JadxProvider.js +51 -19
- package/dist/apktool/ApktoolConfiguration.js +84 -0
- package/dist/apktool/ApktoolDecodeOutput.js +59 -0
- package/dist/apktool/ApktoolProvider.js +506 -0
- package/dist/application/AnalysisProvider.js +8 -2
- package/dist/application/AppBundleExecutable.js +27 -22
- package/dist/application/BinaryTargetResolver.js +22 -2
- package/dist/application/CapabilityInventory.js +11 -1
- package/dist/application/ClientConfigurationDocument.js +70 -0
- package/dist/application/ClientConfigurationFiles.js +91 -0
- package/dist/application/ClientRegistrationEnvironment.js +35 -0
- package/dist/application/ClientRegistrationStatus.js +66 -31
- package/dist/application/DirectAnalysis.js +2 -2
- package/dist/application/DirectAnalysisCleanup.js +1 -1
- package/dist/application/DirectAnalysisStatus.js +1 -1
- package/dist/application/Doctor.js +5 -3
- package/dist/application/DoctorDiagnostics.js +1 -1
- package/dist/application/EvidenceBundleCommands.js +6 -12
- package/dist/application/GeminiClientSettings.js +139 -0
- package/dist/application/HermesClientHome.js +115 -0
- package/dist/application/HopperDownload.js +39 -0
- package/dist/application/InvestigationProviders.js +6 -0
- package/dist/application/JsonFiles.js +6 -5
- package/dist/{cliJsonFile.js → application/JsonInputFile.js} +108 -35
- package/dist/application/LinuxHopper.js +4 -12
- package/dist/application/MacHopper.js +172 -149
- package/dist/application/MipsElfAbiFlags.js +140 -0
- package/dist/application/ProviderOperationExecution.js +31 -0
- package/dist/application/ReconstructionObligationCandidates.js +9 -3
- package/dist/application/ReferenceSourceImport.js +76 -29
- package/dist/application/ReferenceSourceImportEntries.js +18 -9
- package/dist/application/ReferenceSourceImportPolicy.js +99 -23
- package/dist/application/ReferenceSourceImportTypes.js +30 -22
- package/dist/application/ReferenceSourceVcsAdapter.js +145 -30
- package/dist/application/RegularFileRead.js +93 -7
- package/dist/application/Setup.js +54 -6
- package/dist/application/SetupClientConfiguration.js +116 -16
- package/dist/application/SetupHost.js +102 -24
- package/dist/application/SetupPlan.js +5 -8
- package/dist/application/SetupSkill.js +58 -39
- package/dist/application/SupportedClients.js +290 -65
- package/dist/application/Uninstall.js +158 -10
- package/dist/application/UpdateMaintenance.js +17 -21
- package/dist/application/Utf8JsonInput.js +7 -0
- package/dist/application/WebScriptExportService.js +131 -65
- package/dist/application/WebSourceLocationService.js +3 -0
- package/dist/application/adb/AdbDeviceAnalysisPort.js +1 -0
- package/dist/application/adb/AdbDeviceAnalysisService.js +13 -0
- package/dist/application/analysisView/AnalysisViewService.js +40 -2
- package/dist/application/apktool/ApktoolResourceAnalysisPort.js +1 -0
- package/dist/application/apktool/ApktoolResourceAnalysisService.js +13 -0
- package/dist/application/binary/AnalysisClientCleanup.js +0 -24
- package/dist/application/binary/BinarySession.js +2 -1
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +2 -1
- package/dist/application/binaryDiagnostics/PeResourcesPort.js +1 -0
- package/dist/application/binaryDiagnostics/PeResourcesService.js +111 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +2 -1
- package/dist/application/evm/EvmInterfaceService.js +3 -0
- package/dist/application/firmware/FirmwareAnalysisService.js +3 -0
- package/dist/application/investigation/InspectEvidenceBundle.js +18 -0
- package/dist/application/javascript/ElectronBoundaryGraphContext.js +3 -2
- package/dist/application/javascript/ElectronBoundaryGraphIpc.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +19 -6
- package/dist/application/javascript/ElectronBoundaryGraphWindows.js +3 -3
- package/dist/application/javascript/JavaScriptApplicationService.js +22 -11
- package/dist/application/javascript/JavaScriptApplicationWorkflowEvidence.js +5 -6
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +171 -30
- package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +14 -16
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +67 -19
- package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +4 -3
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +11 -5
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +19 -16
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +92 -10
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +258 -235
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +115 -26
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +4 -1
- package/dist/application/javascript/JavaScriptModuleRelationships.js +6 -4
- package/dist/application/javascript/JavaScriptRecoveryService.js +3 -0
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +9 -3
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +199 -61
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +12 -19
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +4 -1
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -3
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +5 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +19 -8
- package/dist/application/jeb/JebAnalysisPort.js +1 -0
- package/dist/application/jeb/JebAnalysisService.js +13 -0
- package/dist/application/managed/ManagedApplicationGraphService.js +1 -1
- package/dist/application/native/NativeUiActionTrace.js +16 -8
- package/dist/application/native/NativeValueTrace.js +23 -6
- package/dist/application/process/ProcessCli.js +25 -20
- package/dist/artifacts/ArtifactPaths.js +129 -8
- package/dist/artifacts/ArtifactProvider.js +20 -15
- package/dist/artifacts/ArtifactReader.js +23 -0
- package/dist/artifacts/ArtifactResourceScope.js +100 -0
- package/dist/artifacts/AsarArtifactReader.js +176 -102
- package/dist/artifacts/AsarHeader.js +24 -0
- package/dist/artifacts/DirectoryArtifactReader.js +168 -65
- package/dist/artifacts/MachOSliceArtifactReader.js +116 -39
- package/dist/artifacts/NativeDmgArtifactReader.js +29 -22
- package/dist/artifacts/SafeOutputTree.js +245 -70
- package/dist/artifacts/SafeOutputTreeCleanup.js +45 -0
- package/dist/artifacts/SafeOutputTreeCreationFailure.js +20 -0
- package/dist/artifacts/SafeOutputTreeIdentity.js +42 -0
- package/dist/artifacts/SafeOutputTreeReadback.js +33 -0
- package/dist/artifacts/ZipArtifactReader.js +77 -27
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +58 -18
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +62 -24
- package/dist/artifacts/apple/KeyedArchiveReader.js +32 -13
- package/dist/artifacts/extraction/ArtifactExtraction.js +110 -86
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +110 -43
- package/dist/artifacts/inventory/ArtifactInventory.js +5 -4
- package/dist/artifacts/inventory/classify.js +75 -32
- package/dist/artifacts/inventory/hashStableRootArtifact.js +48 -15
- package/dist/artifacts/inventory/reader.js +13 -5
- package/dist/artifacts/inventory/scanCanonical.js +62 -25
- package/dist/artifacts/inventory/scanReader.js +38 -11
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +15 -9
- package/dist/artifacts/javascript/JavaScriptSourceAnalysis.js +3 -0
- package/dist/browser/BrowserScenarioPartialObservation.js +8 -2
- package/dist/browser/BrowserScenarioSecrets.js +52 -37
- package/dist/browser/CdpBrowserProvider.js +5 -0
- package/dist/browser/CdpCaptureDocuments.js +40 -6
- package/dist/browser/CdpCaptureDomSvg.js +210 -0
- package/dist/browser/CdpCaptureEventBodyShapes.js +4 -8
- package/dist/browser/CdpCaptureEventHandlers.js +26 -9
- package/dist/browser/CdpCaptureEvents.js +4 -9
- package/dist/browser/CdpConnection.js +22 -5
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpTargetSession.js +30 -34
- package/dist/browser/CdpWebMcpDiscovery.js +32 -10
- package/dist/browser/ElectronFileScope.js +99 -9
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +60 -4
- package/dist/browser/PlaywrightElectronActiveProvider.js +11 -6
- package/dist/browser/PlaywrightScenarioArtifacts.js +5 -5
- package/dist/browser/PlaywrightScenarioBrowser.js +69 -7
- package/dist/browser/PlaywrightScenarioSession.js +127 -54
- package/dist/browser/PlaywrightScenarioStorage.js +507 -0
- package/dist/browser/PngVisualDiff.js +198 -29
- package/dist/browser/WebSourceMapFetcher.js +3 -3
- package/dist/browser/assets/LocalWebScriptArtifacts.js +3 -1
- package/dist/browser/assets/PublishWebScripts.js +75 -20
- package/dist/browser/assets/WebArtifactReads.js +23 -1
- package/dist/browser/assets/WebSourceLocationArtifacts.js +1 -0
- package/dist/browser/execution/CdpExecutionCapture.js +3 -3
- package/dist/browser/execution/CdpPreciseCoverage.js +5 -8
- package/dist/browser/history/HarCapture.js +14 -0
- package/dist/browser/history/HarCaptureProcess.js +2 -10
- package/dist/browser/history/MitmproxyCaptureAdapter.js +3 -1
- package/dist/browser/modules/WebModuleArtifacts.js +1 -0
- package/dist/cli/adbCommands.js +337 -0
- package/dist/cli/analysisViewCommands.js +39 -1
- package/dist/cli/apktoolCommands.js +53 -0
- package/dist/cli/artifactCommands.js +8 -11
- package/dist/cli/binaryDiagnosticsCommands.js +19 -1
- package/dist/cli/browserAdvancedCommands.js +65 -36
- package/dist/cli/coreBinaryCommands.js +0 -5
- package/dist/cli/coreNativeCommands.js +1 -14
- package/dist/cli/electronCommands.js +6 -1
- package/dist/cli/evmCommands.js +13 -4
- package/dist/cli/firmwareCommands.js +7 -2
- package/dist/cli/javascriptApplicationAnalysis.js +17 -1
- package/dist/cli/javascriptRecoveryCommands.js +22 -15
- package/dist/cli/jebCommands.js +99 -0
- package/dist/cli/jsonOutput.js +11 -4
- package/dist/cli/referenceSourceImportStatus.js +7 -0
- package/dist/cli/setupCommands.js +15 -3
- package/dist/cli/utilityCommands.js +66 -18
- package/dist/cli/webScriptCommands.js +20 -1
- package/dist/cli/webSourceLocationCommands.js +21 -9
- package/dist/cli.js +6 -0
- package/dist/cliBrowserScenarioCommands.js +2 -1
- package/dist/cliCommandNames.js +32 -0
- package/dist/cliJsonInput.js +2 -2
- package/dist/cliObservationOptions.js +3 -0
- package/dist/composition/adb.js +3 -0
- package/dist/composition/apktool.js +3 -0
- package/dist/composition/binaryDiagnostics.js +4 -0
- package/dist/composition/directAnalysis.js +12 -4
- package/dist/composition/javascriptAnalysisWorkerProcess.js +48 -0
- package/dist/composition/jeb.js +6 -0
- package/dist/config/environment.js +10 -0
- package/dist/config/ghidraLanguageOverride.js +9 -0
- package/dist/config/mcpInputSchemaProfile.js +27 -0
- package/dist/config/parseConfig.js +28 -1
- package/dist/contracts/adb/adbToolContracts.js +353 -0
- package/dist/contracts/advertisedInputExamples.js +48 -0
- package/dist/contracts/analysisDetail.js +10 -0
- package/dist/contracts/analysisViewToolContracts.js +17 -2
- package/dist/contracts/apktool/apktoolToolContracts.js +33 -0
- package/dist/contracts/artifactToolContracts.js +8 -5
- package/dist/contracts/browserToolContracts.js +1 -1
- package/dist/contracts/compactInputSchema.js +256 -0
- package/dist/contracts/functionWorkflowToolContracts.js +1 -1
- package/dist/contracts/inputSchemaPresentation.js +10 -10
- package/dist/contracts/javascript/electronToolContracts.js +15 -3
- package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +1 -1
- package/dist/contracts/jeb/jebToolContracts.js +64 -0
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +25 -3
- package/dist/contracts/officialToolContracts.js +5 -5
- package/dist/contracts/sessionToolContracts.js +2 -2
- package/dist/contracts/sessionToolSchemas.js +6 -2
- package/dist/contracts/toolContractExamples.js +6 -0
- package/dist/contracts/toolContractTypes.js +3 -0
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +167 -0
- package/dist/contracts/toolOutputSchemaGroups.js +5 -3
- package/dist/contracts/toolSchemaMetadata.js +82 -7
- package/dist/domain/adb/adbDeviceAnalysis.js +583 -0
- package/dist/domain/analysisErrorCleanup.js +29 -0
- package/dist/domain/analysisErrorPresentation.js +18 -6
- package/dist/domain/analysisErrorProjection.js +4 -1
- package/dist/domain/analysisSnapshot.js +2 -1
- package/dist/domain/analysisView/analysisView.js +52 -2
- package/dist/domain/analysisView/binaryLayoutView.js +2 -0
- package/dist/domain/analysisView/javascriptApplicationView.js +2 -0
- package/dist/domain/analysisView/nativeFunctionView.js +155 -0
- package/dist/domain/android/androidApplication.js +25 -20
- package/dist/domain/apktool/apktoolResourceAnalysis.js +77 -0
- package/dist/domain/apple/appleApplication.js +40 -23
- package/dist/domain/apple/appleBundleAnatomy.js +95 -28
- package/dist/domain/apple/dyldPaths.js +9 -1
- package/dist/domain/apple/dylibResolution.js +2 -2
- package/dist/domain/apple/interfaceBuilderGraph.js +22 -19
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +10 -1
- package/dist/domain/artifactComparison.js +35 -7
- package/dist/domain/artifactGraph.js +5 -3
- package/dist/domain/artifactIdentity.js +30 -2
- package/dist/domain/artifactInspection.js +3 -43
- package/dist/domain/artifactIntegrityPolicy.js +10 -0
- package/dist/domain/artifactInventoryEvidence.js +11 -12
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/binaryTarget.js +16 -0
- package/dist/domain/binaryTargetTypes.js +8 -1
- package/dist/domain/browserObservationSchemas.js +8 -4
- package/dist/domain/canonicalJsonDigestSteps.js +34 -12
- package/dist/domain/compactStringIdentity.js +9 -0
- package/dist/domain/evidence.js +2 -1
- package/dist/domain/evidenceRecordSummary.js +144 -0
- package/dist/domain/inputIssueProjection.js +16 -1
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +12 -13
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +11 -20
- package/dist/domain/javascript/electronStaticAnalysisNative.js +70 -40
- package/dist/domain/javascript/electronStaticAnalysisValues.js +16 -0
- package/dist/domain/javascript/javascriptAnalysisResourceControls.js +45 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +4 -1
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +6 -6
- package/dist/domain/javascript/javascriptApplicationGraph.js +79 -18
- package/dist/domain/javascript/javascriptApplicationProjectionResources.js +35 -0
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +28 -12
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +9 -1
- package/dist/domain/javascript/javascriptAstFingerprint.js +58 -31
- package/dist/domain/javascript/javascriptAstValues.js +32 -0
- package/dist/domain/javascript/javascriptElectronMemberWrites.js +50 -0
- package/dist/domain/javascript/javascriptModuleSemanticIr.js +15 -0
- package/dist/domain/javascript/javascriptNativeHandoff.js +6 -1
- package/dist/domain/javascript/javascriptRpcEndpoints.js +253 -0
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +1 -3
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +7 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +8 -11
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +190 -33
- package/dist/domain/javascript/javascriptSemanticCallableResults.js +42 -0
- package/dist/domain/javascript/javascriptSemanticCalls.js +8 -1
- package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +15 -4
- package/dist/domain/javascript/javascriptSemanticFileProjection.js +1 -0
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +42 -41
- package/dist/domain/javascript/javascriptSemanticGraph.js +69 -23
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +2 -10
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +40 -7
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +341 -87
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +78 -35
- package/dist/domain/javascript/javascriptSemanticObjectReferences.js +381 -0
- package/dist/domain/javascript/javascriptSemanticObjects.js +7 -1
- package/dist/domain/javascript/javascriptSemanticProjection.js +52 -14
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +77 -0
- package/dist/domain/javascript/javascriptSemanticQuery.js +27 -29
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +1 -3
- package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +219 -0
- package/dist/domain/javascript/javascriptSemanticReturns.js +13 -23
- package/dist/domain/javascript/javascriptSemanticState.js +22 -2
- package/dist/domain/javascript/javascriptSemanticTraversal.js +19 -1
- package/dist/domain/javascript/javascriptSemanticValues.js +47 -19
- package/dist/domain/javascript/javascriptSourceAnalysis.js +1 -0
- package/dist/domain/javascript/javascriptStaticAnalysis.js +29 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +8 -6
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +49 -5
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +8 -4
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +1 -0
- package/dist/domain/jeb/jebAnalysis.js +114 -0
- package/dist/domain/jsonShape.js +63 -52
- package/dist/domain/jsonValue.js +3 -0
- package/dist/domain/managed/managedApplicationGraph.js +37 -0
- package/dist/domain/managed/managedApplicationGraphCoverage.js +8 -2
- package/dist/domain/managed/managedApplicationGraphNodes.js +32 -22
- package/dist/domain/managed/managedArtifact.js +1 -0
- package/dist/domain/managed/managedInspectionEvidence.js +13 -0
- package/dist/domain/native/nativeAotPe.js +1408 -0
- package/dist/domain/native/nativeInstruction.js +21 -0
- package/dist/domain/native/nativeMetadataRecovery.js +79 -6
- package/dist/domain/native/peResources.js +94 -0
- package/dist/domain/nativeConvention.js +33 -0
- package/dist/domain/process/processCapture.js +91 -1
- package/dist/domain/process/processCaptureExample.js +24 -0
- package/dist/domain/process/processCaptureValidation.js +79 -0
- package/dist/domain/process/processScenario.js +59 -7
- package/dist/domain/propertyListKeys.js +3 -1
- package/dist/domain/referenceSourceGraph.js +25 -16
- package/dist/domain/referenceSourceImportParsing.js +6 -3
- package/dist/domain/referenceSourcePathIdentity.js +22 -0
- package/dist/domain/referenceSourceRequireBindings.js +137 -0
- package/dist/domain/webBundleAnalyzerInspection.js +14 -2
- package/dist/domain/webCaptureDiff.js +102 -4
- package/dist/domain/webScriptExportError.js +10 -4
- package/dist/domain/webScriptExportPlan.js +7 -13
- package/dist/domain/zipPackageFormat.js +4 -1
- package/dist/domain/zodCollectionSteps.js +24 -0
- package/dist/dotnet/ManagedArtifactInspector.js +55 -43
- package/dist/dotnet/ManagedDecodeBudget.js +80 -0
- package/dist/dotnet/ManagedMemberInspector.js +13 -6
- package/dist/dotnet/ManagedMemberInspectorCore.js +2 -2
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +4 -2
- package/dist/dotnet/ManagedMemberRows.js +9 -4
- package/dist/dotnet/ManagedMetadataHeaps.js +15 -5
- package/dist/dotnet/ManagedMetadataInventoryRows.js +20 -11
- package/dist/dotnet/ManagedMetadataLayout.js +10 -4
- package/dist/dotnet/ManagedMethodBodyReader.js +8 -3
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +3 -2
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +49 -34
- package/dist/dotnet/ManagedPeReader.js +41 -25
- package/dist/dotnet/ManagedReaderFailure.js +2 -1
- package/dist/dotnet/ManagedStaticProvider.js +55 -24
- package/dist/evaluation/AgentEvaluationReport.js +9 -5
- package/dist/evaluation/CodexAgentEval.js +43 -13
- package/dist/evm/EvmoleFailures.js +0 -2
- package/dist/evm/EvmoleInterfaceProvider.js +67 -2
- package/dist/filesystem/OwnedDirectoryHandle.js +29 -0
- package/dist/filesystem/OwnedFileHandle.js +36 -0
- package/dist/filesystem/RegularFile.js +33 -1
- package/dist/filesystem/StableFileHash.js +46 -0
- package/dist/filesystem/readFileHandleChunks.js +26 -0
- package/dist/firmware/FirmwareCommand.js +25 -3
- package/dist/firmware/FirmwareFiles.js +23 -8
- package/dist/firmware/FirmwareProvider.js +156 -32
- package/dist/firmware/FirmwarePublication.js +24 -3
- package/dist/firmware/FirmwareRelease.js +1 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +55 -4
- package/dist/ghidra/GhidraAnalysisSeeds.js +211 -0
- package/dist/ghidra/GhidraClient.js +76 -4
- package/dist/ghidra/GhidraDiagnostics.js +11 -8
- package/dist/ghidra/GhidraFunctionValues.js +26 -2
- package/dist/ghidra/GhidraInstallation.js +1 -1
- package/dist/ghidra/GhidraInventoryValues.js +23 -1
- package/dist/ghidra/GhidraLanguageCatalog.js +99 -0
- package/dist/ghidra/GhidraLauncher.js +80 -39
- package/dist/ghidra/GhidraLoadImageAttest.js +49 -2
- package/dist/ghidra/GhidraMipsProfile.js +79 -0
- package/dist/ghidra/GhidraProvider.js +57 -9
- package/dist/ghidra/GhidraProviderCapabilities.js +18 -8
- package/dist/ghidra/GhidraProviderClient.js +282 -21
- package/dist/ghidra/GhidraSessionValues.js +9 -2
- package/dist/hopper/HopperAnalysisProfile.js +2 -0
- package/dist/hopper/HopperClient.js +15 -6
- package/dist/hopper/HopperMachOImage.js +2 -0
- package/dist/hopper/HopperProvider.js +13 -2
- package/dist/ida/IdaOperationRunner.js +8 -2
- package/dist/ida/IdaProvider.js +7 -0
- package/dist/ida/IdaSessionClient.js +3 -1
- package/dist/ida/IdaWorkspace.js +4 -2
- package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +326 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +520 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +63 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +521 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +116 -0
- package/dist/javascript/recovery/RecoveryFiles.js +18 -7
- package/dist/javascript/recovery/WakaruCommand.js +22 -9
- package/dist/javascript/recovery/WakaruExecution.js +11 -7
- package/dist/javascript/recovery/WakaruProvider.js +139 -16
- package/dist/javascript/recovery/WakaruPublication.js +14 -4
- package/dist/javascript/recovery/WakaruRelease.js +10 -3
- package/dist/javascript/recovery/WakaruReport.js +12 -7
- package/dist/javascript/recovery/WakaruVersion.js +24 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +16 -3
- package/dist/javascript/sourceMaps/SourceMapDecoder.js +63 -7
- package/dist/javascript/sourceMaps/SourceMapFormat.js +15 -4
- package/dist/jeb/JebMcpConnection.js +179 -0
- package/dist/jeb/JebMcpEndpoint.js +40 -0
- package/dist/jeb/JebProvider.js +299 -0
- package/dist/mcpDoctor.js +15 -6
- package/dist/native/AppleDispatchCoverage.js +25 -12
- package/dist/native/AppleDispatchMetadata.js +14 -7
- package/dist/native/AppleMachoFixups.js +71 -15
- package/dist/native/AppleMachoSelection.js +23 -3
- package/dist/native/NativeMacOSProvider.js +91 -16
- package/dist/native/NativeMachoInspection.js +11 -7
- package/dist/native/NativeUiHelperRuntime.js +6 -1
- package/dist/native/NativeUiObservation.js +4 -3
- package/dist/native/pe/PeResourceLayout.js +120 -0
- package/dist/native/pe/PeResourceParser.js +286 -0
- package/dist/native/pe/PeResourcesProvider.js +63 -0
- package/dist/process/BoundedFileBytes.js +30 -7
- package/dist/process/DarwinProcessRunTokenReader.js +8 -3
- package/dist/process/OwnedCommand.js +4 -3
- package/dist/process/ProcessOwnership.js +104 -112
- package/dist/process/ProcessOwnershipObservation.js +96 -39
- package/dist/process/ProcessOwnershipProcessTree.js +4 -4
- package/dist/process/ProcessRunTokenObservations.js +48 -0
- package/dist/process/ProviderDiagnosticRedaction.js +17 -0
- package/dist/process/ProviderProcess.js +4 -3
- package/dist/process/capture/FilesystemSnapshot.js +28 -4
- package/dist/process/capture/ProcessCaptureLifecycle.js +350 -59
- package/dist/process/capture/ProcessCaptureProgress.js +62 -0
- package/dist/process/capture/ProcessHarness.js +194 -26
- package/dist/process/capture/ProcessNormalization.js +3 -1
- package/dist/process/capture/ProcessScenarioRuntimeValidation.js +5 -2
- package/dist/process/capture/TerminalRenderer.js +24 -7
- package/dist/reference/ReferenceSourceReader.js +22 -5
- package/dist/reference/ReferenceSourceReaderEntries.js +114 -51
- package/dist/reference/ReferenceSourceReaderErrors.js +12 -0
- package/dist/reference/ReferenceSourceReaderFile.js +50 -10
- package/dist/reference/ReferenceSourceReaderValidate.js +4 -4
- package/dist/server/EvidenceMcpServer.js +36 -1
- package/dist/server/admittedToolOperation.js +9 -0
- package/dist/server/contractToolHandler.js +21 -0
- package/dist/server/createServer.js +97 -25
- package/dist/server/registerAdbTools.js +36 -0
- package/dist/server/registerAnalysisViewTool.js +4 -9
- package/dist/server/registerAndroidTools.js +3 -12
- package/dist/server/registerApktoolTools.js +14 -0
- package/dist/server/registerApplicationTools/compareExportShapes.js +4 -6
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +4 -5
- package/dist/server/registerApplicationTools/compareVersions.js +3 -2
- package/dist/server/registerApplicationTools/coverage.js +3 -2
- package/dist/server/registerApplicationTools/obligationLedger.js +3 -2
- package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +3 -2
- package/dist/server/registerApplicationTools/traceFeature.js +3 -2
- package/dist/server/registerApplicationTools/traceSemantics.js +4 -5
- package/dist/server/registerArtifactComparisonTool.js +5 -2
- package/dist/server/registerBinaryDiagnosticsTools.js +16 -4
- package/dist/server/registerBrowserScenarioTool.js +10 -7
- package/dist/server/registerBrowserTools.js +12 -9
- package/dist/server/registerBundleComparisonTool.js +16 -2
- package/dist/server/registerCloseLifecycleTool.js +32 -3
- package/dist/server/registerElectronTools.js +28 -10
- package/dist/server/registerEvmTools.js +4 -9
- package/dist/server/registerFirmwareTools.js +3 -11
- package/dist/server/registerFunctionComparisonTool.js +5 -2
- package/dist/server/registerJavaScriptRecoveryTool.js +4 -9
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +9 -6
- package/dist/server/registerJebTools.js +16 -0
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +4 -6
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +3 -2
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +3 -2
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +3 -2
- package/dist/server/registerPeResourcesTool.js +9 -0
- package/dist/server/registerProcessComparisonTool.js +5 -2
- package/dist/server/registerRecordedCrashTools.js +4 -9
- package/dist/server/registerSessionRecordTools.js +2 -1
- package/dist/server/registerSessionTools.js +49 -18
- package/dist/server/registerWebModuleTool.js +4 -9
- package/dist/server/registerWebNetworkCaptureTool.js +4 -9
- package/dist/server/registerWebRuntimeTools.js +6 -5
- package/dist/server/registerWebScriptTool.js +6 -3
- package/dist/server/registerWebSourceLocationTool.js +4 -9
- package/dist/server/toolResult.js +21 -2
- package/dist/windows/WindowsPrivateRuntime.js +12 -5
- package/install.sh +7 -4
- package/licenses/nativeaot-parser-MIT.txt +28 -0
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +33 -5
- package/scripts/rea.mjs +16 -1
- package/skills/reverse-engineer-anything/SKILL.md +52 -51
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +8 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +92 -13
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +22 -1
|
@@ -134,6 +134,8 @@ const chainedFixups = (image, range) => {
|
|
|
134
134
|
formats,
|
|
135
135
|
failures: issues.map(({ message }) => message),
|
|
136
136
|
issues,
|
|
137
|
+
examined: Math.max(ranges.length, 1),
|
|
138
|
+
unreadRebaseBytes: 0,
|
|
137
139
|
decode(address, raw) {
|
|
138
140
|
const segment = ranges.find(({ from, to }) => address >= from && address < to);
|
|
139
141
|
// Pointers outside fixup segments, such as in __TEXT, are stored plainly.
|
|
@@ -211,6 +213,7 @@ const setBindRegister = (image, stream, state, byte) => {
|
|
|
211
213
|
const segment = image.segments[immediate];
|
|
212
214
|
if (segment === undefined)
|
|
213
215
|
throw new RangeError("Bind segment index is out of range");
|
|
216
|
+
state.segmentIndex = immediate;
|
|
214
217
|
state.address = segment.address + uleb(bytes, cursor, end);
|
|
215
218
|
return true;
|
|
216
219
|
}
|
|
@@ -232,21 +235,50 @@ const readBindStream = (image, range, binds) => {
|
|
|
232
235
|
const cursor = { at: range.offset };
|
|
233
236
|
const state = {
|
|
234
237
|
ordinal: 0,
|
|
238
|
+
segmentIndex: -1,
|
|
235
239
|
symbol: "",
|
|
236
240
|
weak: false,
|
|
237
241
|
addend: 0n,
|
|
238
242
|
address: 0n,
|
|
239
243
|
};
|
|
240
|
-
const
|
|
241
|
-
|
|
244
|
+
const preflightRun = (count, skip) => {
|
|
245
|
+
if (count === 0n)
|
|
246
|
+
return;
|
|
247
|
+
const segment = image.segments[state.segmentIndex];
|
|
248
|
+
if (segment === undefined)
|
|
249
|
+
throw new RangeError("Bind location has no selected segment");
|
|
250
|
+
const stride = 8n + skip;
|
|
251
|
+
const end = state.address + (count - 1n) * stride + 8n;
|
|
252
|
+
if (state.address < segment.address || end > segment.address + segment.size)
|
|
253
|
+
throw new RangeError("Bind expansion leaves its file-backed segment");
|
|
254
|
+
};
|
|
255
|
+
const bind = (count, skip) => {
|
|
256
|
+
if (count === 0n)
|
|
257
|
+
return;
|
|
258
|
+
preflightRun(count, skip);
|
|
259
|
+
const stride = 8n + skip;
|
|
260
|
+
const binding = {
|
|
242
261
|
symbol: state.symbol,
|
|
243
262
|
library: range.stream === "weak"
|
|
244
263
|
? null
|
|
245
264
|
: libraryName(state.ordinal, image.dylibs),
|
|
246
265
|
weak: state.weak,
|
|
247
266
|
addend: state.addend,
|
|
248
|
-
}
|
|
249
|
-
|
|
267
|
+
};
|
|
268
|
+
const previous = binds.at(-1);
|
|
269
|
+
if (previous !== undefined &&
|
|
270
|
+
previous.stride === stride &&
|
|
271
|
+
previous.start + previous.count * stride === state.address &&
|
|
272
|
+
previous.binding.symbol === binding.symbol &&
|
|
273
|
+
previous.binding.library === binding.library &&
|
|
274
|
+
previous.binding.weak === binding.weak &&
|
|
275
|
+
previous.binding.addend === binding.addend) {
|
|
276
|
+
previous.count += count;
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
binds.push({ start: state.address, count, stride, binding });
|
|
280
|
+
}
|
|
281
|
+
state.address += count * stride;
|
|
250
282
|
};
|
|
251
283
|
while (cursor.at < end) {
|
|
252
284
|
const byte = bytes[cursor.at++] ?? 0;
|
|
@@ -259,19 +291,20 @@ const readBindStream = (image, range, binds) => {
|
|
|
259
291
|
return;
|
|
260
292
|
break;
|
|
261
293
|
case 0x90:
|
|
262
|
-
bind(0n);
|
|
294
|
+
bind(1n, 0n);
|
|
263
295
|
break;
|
|
264
296
|
case 0xa0:
|
|
265
|
-
bind(uleb(bytes, cursor, end));
|
|
297
|
+
bind(1n, uleb(bytes, cursor, end));
|
|
266
298
|
break;
|
|
267
299
|
case 0xb0:
|
|
268
|
-
bind(BigInt(byte & 0x0f) * 8n);
|
|
300
|
+
bind(1n, BigInt(byte & 0x0f) * 8n);
|
|
269
301
|
break;
|
|
270
302
|
case 0xc0: {
|
|
303
|
+
if (range.stream === "lazy")
|
|
304
|
+
throw new RangeError("Lazy bind streams do not support repeated bind opcodes");
|
|
271
305
|
const count = uleb(bytes, cursor, end);
|
|
272
306
|
const skip = uleb(bytes, cursor, end);
|
|
273
|
-
|
|
274
|
-
bind(skip);
|
|
307
|
+
bind(count, skip);
|
|
275
308
|
break;
|
|
276
309
|
}
|
|
277
310
|
default:
|
|
@@ -282,17 +315,24 @@ const readBindStream = (image, range, binds) => {
|
|
|
282
315
|
/** Build pointer decoding for one slice from its fixup load commands. */
|
|
283
316
|
export const parsePointerFixups = (bytes, commands, segments, baseAddress) => {
|
|
284
317
|
const image = { bytes, segments, dylibs: commands.dylibs, baseAddress };
|
|
285
|
-
|
|
286
|
-
|
|
318
|
+
const unreadRebaseBytes = commands.rebases.reduce((total, rebase) => total + rebase.size, 0);
|
|
319
|
+
if (commands.chained !== null) {
|
|
320
|
+
const chained = chainedFixups(image, commands.chained);
|
|
321
|
+
return unreadRebaseBytes === 0
|
|
322
|
+
? chained
|
|
323
|
+
: { ...chained, unreadRebaseBytes };
|
|
324
|
+
}
|
|
287
325
|
if (commands.binds.length === 0)
|
|
288
326
|
return {
|
|
289
327
|
kind: "none",
|
|
290
328
|
formats: [],
|
|
291
329
|
failures: [],
|
|
292
330
|
issues: [],
|
|
331
|
+
examined: 0,
|
|
332
|
+
unreadRebaseBytes,
|
|
293
333
|
decode: (_address, raw) => ({ kind: "rebase", target: raw }),
|
|
294
334
|
};
|
|
295
|
-
const binds =
|
|
335
|
+
const binds = [];
|
|
296
336
|
const failures = [];
|
|
297
337
|
for (const stream of commands.binds)
|
|
298
338
|
try {
|
|
@@ -306,11 +346,27 @@ export const parsePointerFixups = (bytes, commands, segments, baseAddress) => {
|
|
|
306
346
|
formats: [],
|
|
307
347
|
failures,
|
|
308
348
|
issues: failures.map((message) => issue("pointer_fixups", "bind_stream_decode_failed", message)),
|
|
349
|
+
examined: commands.binds.length,
|
|
350
|
+
unreadRebaseBytes,
|
|
309
351
|
decode(address, raw) {
|
|
310
|
-
|
|
311
|
-
|
|
352
|
+
let match;
|
|
353
|
+
for (const run of binds) {
|
|
354
|
+
const { start, count, stride } = run;
|
|
355
|
+
const distance = address - start;
|
|
356
|
+
if (distance >= 0n &&
|
|
357
|
+
distance % stride === 0n &&
|
|
358
|
+
distance / stride < count) {
|
|
359
|
+
if (match !== undefined)
|
|
360
|
+
return {
|
|
361
|
+
kind: "unsupported",
|
|
362
|
+
reason: `Ambiguous bind records target pointer location 0x${address.toString(16)}`,
|
|
363
|
+
};
|
|
364
|
+
match = run;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return match === undefined
|
|
312
368
|
? { kind: "rebase", target: raw }
|
|
313
|
-
: { kind: "bind", ...
|
|
369
|
+
: { kind: "bind", ...match.binding };
|
|
314
370
|
},
|
|
315
371
|
};
|
|
316
372
|
};
|
|
@@ -35,7 +35,9 @@ export const selectMachoSlice = (bytes, architecture) => {
|
|
|
35
35
|
const headerEnd = 8 + count * stride;
|
|
36
36
|
if (count > 128 || headerEnd > bytes.length)
|
|
37
37
|
throw malformed("Malformed FAT architecture table");
|
|
38
|
-
const cpu = architecture
|
|
38
|
+
const cpu = MACHO_CPU_TYPE[architecture];
|
|
39
|
+
if (cpu === undefined)
|
|
40
|
+
throw invalid("Requested FAT architecture is absent");
|
|
39
41
|
const declarations = readFatSliceDeclarations(bytes.subarray(8, headerEnd), {
|
|
40
42
|
count,
|
|
41
43
|
wide: fat64,
|
|
@@ -63,8 +65,22 @@ export const selectMachoSlice = (bytes, architecture) => {
|
|
|
63
65
|
}
|
|
64
66
|
if (selected === undefined)
|
|
65
67
|
throw invalid("Requested FAT architecture is absent");
|
|
68
|
+
if (selected.slice + 4 > bytes.length)
|
|
69
|
+
throw malformed("Truncated Mach-O header");
|
|
70
|
+
const sliceMagic = bytes.readUInt32LE(selected.slice);
|
|
71
|
+
if (sliceMagic === MH_MAGIC || sliceMagic === MH_CIGAM)
|
|
72
|
+
throw invalid(`Unsupported 32-bit Mach-O metadata for requested CPU type ${architecture}`);
|
|
66
73
|
return selected;
|
|
67
74
|
};
|
|
75
|
+
/** CPU types admitted by `machArchitecture` in the domain binary target parser. */
|
|
76
|
+
const MACHO_CPU_TYPE = {
|
|
77
|
+
x86: 7,
|
|
78
|
+
x86_64: 0x01000007,
|
|
79
|
+
arm: 12,
|
|
80
|
+
arm64: 0x0100000c,
|
|
81
|
+
};
|
|
82
|
+
const MH_MAGIC = 0xfeedface;
|
|
83
|
+
const MH_CIGAM = 0xcefaedfe;
|
|
68
84
|
/** Parse segments/sections for a little-endian 64-bit Mach-O architecture slice. */
|
|
69
85
|
export const parseMachoLayout = (bytes, architecture) => {
|
|
70
86
|
if (bytes.length < 4)
|
|
@@ -95,6 +111,7 @@ export const parseMachoLayout = (bytes, architecture) => {
|
|
|
95
111
|
sections: [],
|
|
96
112
|
dylibs: [],
|
|
97
113
|
binds: [],
|
|
114
|
+
rebases: [],
|
|
98
115
|
chained: null,
|
|
99
116
|
baseAddress: undefined,
|
|
100
117
|
};
|
|
@@ -115,7 +132,7 @@ export const parseMachoLayout = (bytes, architecture) => {
|
|
|
115
132
|
collectFixupCommand(bytes, command, state);
|
|
116
133
|
cursor += command.size;
|
|
117
134
|
}
|
|
118
|
-
const { segments, sections, chained, binds, dylibs } = state;
|
|
135
|
+
const { segments, sections, chained, binds, rebases, dylibs } = state;
|
|
119
136
|
const offset = (address, size = 1) => {
|
|
120
137
|
const matches = segments.filter((segment) => address >= segment.address &&
|
|
121
138
|
address + BigInt(size) <= segment.address + segment.size);
|
|
@@ -130,7 +147,7 @@ export const parseMachoLayout = (bytes, architecture) => {
|
|
|
130
147
|
segments,
|
|
131
148
|
sections,
|
|
132
149
|
offset,
|
|
133
|
-
fixups: { chained, binds, dylibs },
|
|
150
|
+
fixups: { chained, binds, rebases, dylibs },
|
|
134
151
|
baseAddress: state.baseAddress ?? 0n,
|
|
135
152
|
};
|
|
136
153
|
};
|
|
@@ -190,6 +207,9 @@ const collectFixupCommand = (bytes, { cursor, kind, size }, state) => {
|
|
|
190
207
|
else if (kind === LC_DYLD_INFO || kind === LC_DYLD_INFO_ONLY) {
|
|
191
208
|
if (size < 48)
|
|
192
209
|
throw new RangeError("Truncated dyld-info command");
|
|
210
|
+
const rebase = range(cursor + 8);
|
|
211
|
+
if (rebase.size > 0)
|
|
212
|
+
state.rebases.push(rebase);
|
|
193
213
|
for (const [at, stream] of [
|
|
194
214
|
[cursor + 16, "bind"],
|
|
195
215
|
[cursor + 24, "weak"],
|
|
@@ -12,8 +12,10 @@ import { NATIVE_TOOL_CONTRACTS, } from "../contracts/native/nativeToolContracts.
|
|
|
12
12
|
import { toolContract } from "../contracts/toolContracts.js";
|
|
13
13
|
import { analysisInputErrorFromIssues } from "../domain/inputIssueProjection.js";
|
|
14
14
|
import { AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisInputError, AnalysisOutputError, AnalysisResourceConstraintError, AnalysisTimeoutError, } from "../domain/analysisErrorCore.js";
|
|
15
|
+
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
15
16
|
import { BinaryTargetError } from "../domain/configurationErrors.js";
|
|
16
17
|
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
|
18
|
+
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
|
|
17
19
|
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
|
18
20
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
19
21
|
import { omittedPrototypeKeysLimitation, parseXmlPropertyList, } from "../domain/propertyListKeys.js";
|
|
@@ -26,6 +28,8 @@ import { parseDemangledSymbols } from "./parsers/demangle.js";
|
|
|
26
28
|
import { parseLipoArchitectures } from "./parsers/lipo.js";
|
|
27
29
|
import { parsePlistJson, parsePlistXml, plistJsonNeedsNumberTypes, } from "./parsers/plist.js";
|
|
28
30
|
import { architectureLocations, inspectNativeMacho, } from "./NativeMachoInspection.js";
|
|
31
|
+
import { analysisErrorWithCleanupFailure } from "../domain/analysisErrorCleanup.js";
|
|
32
|
+
import { createNativeUiHelperRuntime, } from "./NativeUiHelperRuntime.js";
|
|
29
33
|
/** Read-only semantic provider composed from Xcode command-line utilities. */
|
|
30
34
|
export class NativeMacOSProvider {
|
|
31
35
|
runner;
|
|
@@ -54,6 +58,9 @@ class NativeMacOSClient {
|
|
|
54
58
|
runner;
|
|
55
59
|
tracer;
|
|
56
60
|
environment;
|
|
61
|
+
#pendingNativeUiRuntimes = new Set();
|
|
62
|
+
#nativeUiTail = Promise.resolve();
|
|
63
|
+
#closed = false;
|
|
57
64
|
constructor(target, runner, tracer, environment) {
|
|
58
65
|
this.target = target;
|
|
59
66
|
this.runner = runner;
|
|
@@ -61,6 +68,8 @@ class NativeMacOSClient {
|
|
|
61
68
|
this.environment = environment;
|
|
62
69
|
}
|
|
63
70
|
async execute(operation, parameters, options) {
|
|
71
|
+
if (this.#closed)
|
|
72
|
+
return err(new AnalysisCapabilityUnavailableError(IDENTITY.id, operation, "Native provider client is closed"));
|
|
64
73
|
if (options?.signal?.aborted === true)
|
|
65
74
|
return err(new AnalysisCancelledError(operation));
|
|
66
75
|
if (operation === "health")
|
|
@@ -107,21 +116,12 @@ class NativeMacOSClient {
|
|
|
107
116
|
}
|
|
108
117
|
if (operation === "observe_native_ui" ||
|
|
109
118
|
operation === "capture_native_ui_scenario") {
|
|
110
|
-
|
|
111
|
-
environment: this.environment,
|
|
112
|
-
signal: options?.signal,
|
|
113
|
-
});
|
|
114
|
-
return result.ok
|
|
115
|
-
? ok(createAnalysisExecution(result.value, IDENTITY, {
|
|
116
|
-
limitations: result.value.limitations,
|
|
117
|
-
}))
|
|
118
|
-
: result;
|
|
119
|
+
return this.#observeNativeUi(operation, parameters, options?.signal);
|
|
119
120
|
}
|
|
120
121
|
try {
|
|
121
122
|
const observation = await this.#dispatch(operation, parameters, options?.signal);
|
|
122
123
|
return observation.ok
|
|
123
124
|
? ok(createAnalysisExecution(observation.value.result, IDENTITY, {
|
|
124
|
-
rawResult: { provenance: observation.value.provenance },
|
|
125
125
|
limitations: observation.value.limitations,
|
|
126
126
|
locations: observation.value.locations,
|
|
127
127
|
}))
|
|
@@ -133,8 +133,87 @@ class NativeMacOSClient {
|
|
|
133
133
|
}));
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
close() {
|
|
137
|
-
|
|
136
|
+
async close() {
|
|
137
|
+
this.#closed = true;
|
|
138
|
+
const uiCleanupFailures = await this.#serializeNativeUi(() => this.#retryNativeUiCleanup());
|
|
139
|
+
const tracer = await this.tracer.close();
|
|
140
|
+
if (uiCleanupFailures.length === 0)
|
|
141
|
+
return tracer;
|
|
142
|
+
const uiCleanup = this.#nativeUiCleanupFailure(uiCleanupFailures, "close_binary");
|
|
143
|
+
return tracer.ok
|
|
144
|
+
? err(uiCleanup)
|
|
145
|
+
: err(analysisErrorWithCleanupFailure(tracer.error, uiCleanup));
|
|
146
|
+
}
|
|
147
|
+
#observeNativeUi(operation, parameters, signal) {
|
|
148
|
+
return this.#serializeNativeUi(async () => {
|
|
149
|
+
if (this.#closed)
|
|
150
|
+
return err(new AnalysisCapabilityUnavailableError(IDENTITY.id, operation, "Native provider client is closed"));
|
|
151
|
+
const earlierCleanupFailures = await this.#retryNativeUiCleanup();
|
|
152
|
+
if (earlierCleanupFailures.length > 0)
|
|
153
|
+
return err(this.#nativeUiCleanupFailure(earlierCleanupFailures, operation));
|
|
154
|
+
const runtime = createNativeUiHelperRuntime(this.environment);
|
|
155
|
+
this.#pendingNativeUiRuntimes.add(runtime);
|
|
156
|
+
let result;
|
|
157
|
+
try {
|
|
158
|
+
result = await observeNativeUi(this.target, operation, parameters, {
|
|
159
|
+
environment: this.environment,
|
|
160
|
+
signal,
|
|
161
|
+
runtime,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (cause) {
|
|
165
|
+
result = err(cause instanceof AnalysisError
|
|
166
|
+
? cause
|
|
167
|
+
: new ProviderAdapterError(IDENTITY.id, operation, { cause }));
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
await runtime.close();
|
|
171
|
+
this.#pendingNativeUiRuntimes.delete(runtime);
|
|
172
|
+
}
|
|
173
|
+
catch (cause) {
|
|
174
|
+
const cleanup = this.#nativeUiCleanupFailure([{ runtime, cause }], operation, result.ok ? result.value : undefined);
|
|
175
|
+
return err(result.ok
|
|
176
|
+
? cleanup
|
|
177
|
+
: analysisErrorWithCleanupFailure(result.error, cleanup, operation));
|
|
178
|
+
}
|
|
179
|
+
return result.ok
|
|
180
|
+
? ok(createAnalysisExecution(result.value, IDENTITY, {
|
|
181
|
+
limitations: result.value.limitations,
|
|
182
|
+
}))
|
|
183
|
+
: result;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
#serializeNativeUi(operation) {
|
|
187
|
+
const call = this.#nativeUiTail.then(operation, operation);
|
|
188
|
+
this.#nativeUiTail = call.then(() => undefined, () => undefined);
|
|
189
|
+
return call;
|
|
190
|
+
}
|
|
191
|
+
async #retryNativeUiCleanup() {
|
|
192
|
+
const failures = [];
|
|
193
|
+
for (const runtime of this.#pendingNativeUiRuntimes) {
|
|
194
|
+
try {
|
|
195
|
+
await runtime.close();
|
|
196
|
+
this.#pendingNativeUiRuntimes.delete(runtime);
|
|
197
|
+
}
|
|
198
|
+
catch (cause) {
|
|
199
|
+
failures.push({ runtime, cause });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return failures;
|
|
203
|
+
}
|
|
204
|
+
#nativeUiCleanupFailure(failures, operation, partialObservation) {
|
|
205
|
+
const resources = failures.flatMap(({ runtime }) => runtime.resources());
|
|
206
|
+
return new ProviderCleanupError(IDENTITY.id, resources.length === 0 ? ["native-ui-runtime"] : resources, {
|
|
207
|
+
reason: "Native UI runtime cleanup remains incomplete",
|
|
208
|
+
failures: failures.map(({ runtime, cause }) => ({
|
|
209
|
+
resources: [...runtime.resources()],
|
|
210
|
+
reason: cause instanceof Error ? cause.message : String(cause),
|
|
211
|
+
})),
|
|
212
|
+
}, {
|
|
213
|
+
operation,
|
|
214
|
+
cause: new AggregateError(failures.map(({ cause }) => cause), "Native UI runtime cleanup failed"),
|
|
215
|
+
...(partialObservation === undefined ? {} : { partialObservation }),
|
|
216
|
+
});
|
|
138
217
|
}
|
|
139
218
|
#dispatch(operation, parameters, signal) {
|
|
140
219
|
switch (operation) {
|
|
@@ -176,7 +255,6 @@ class NativeMacOSClient {
|
|
|
176
255
|
});
|
|
177
256
|
return ok({
|
|
178
257
|
result: jsonValueSchema.parse(result),
|
|
179
|
-
provenance,
|
|
180
258
|
limitations: [],
|
|
181
259
|
locations: architectureLocations(result.architectures.items),
|
|
182
260
|
});
|
|
@@ -198,7 +276,6 @@ class NativeMacOSClient {
|
|
|
198
276
|
});
|
|
199
277
|
return ok({
|
|
200
278
|
result: jsonValueSchema.parse(result),
|
|
201
|
-
provenance,
|
|
202
279
|
limitations: [],
|
|
203
280
|
locations: [],
|
|
204
281
|
});
|
|
@@ -271,7 +348,6 @@ class NativeMacOSClient {
|
|
|
271
348
|
});
|
|
272
349
|
return ok({
|
|
273
350
|
result: jsonValueSchema.parse(result),
|
|
274
|
-
provenance,
|
|
275
351
|
limitations: result.limitations,
|
|
276
352
|
locations: [],
|
|
277
353
|
});
|
|
@@ -385,7 +461,6 @@ class NativeMacOSClient {
|
|
|
385
461
|
});
|
|
386
462
|
return ok({
|
|
387
463
|
result: jsonValueSchema.parse(result),
|
|
388
|
-
provenance,
|
|
389
464
|
limitations: parsed.value.limitations,
|
|
390
465
|
locations: [{ kind: "artifact-path", path: plist.value }],
|
|
391
466
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AnalysisOutputError } from "../domain/analysisErrorCore.js";
|
|
1
2
|
import { inspectMachoSchema, } from "../domain/native/nativeInspection.js";
|
|
2
3
|
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
3
4
|
import { err, ok } from "../domain/result.js";
|
|
@@ -30,7 +31,11 @@ export const inspectNativeMacho = async (context) => {
|
|
|
30
31
|
const lipo = captures.find(({ tool }) => tool === "lipo");
|
|
31
32
|
if (lipo === undefined)
|
|
32
33
|
throw new TypeError("Missing lipo capture");
|
|
33
|
-
const
|
|
34
|
+
const availableArchitectures = parseLipoArchitectures(lipo.stdout).map(({ name }) => name);
|
|
35
|
+
const selection = selectArchitecture(context.target, availableArchitectures);
|
|
36
|
+
if (selection.status === "absent")
|
|
37
|
+
return err(new AnalysisOutputError("inspect_macho", `lipo did not list ${selection.architecture}; refusing to read another slice`));
|
|
38
|
+
const selectedArchitecture = selection.status === "selected" ? selection.architecture : null;
|
|
34
39
|
for (const [tool, prefix] of REQUIRED_SLICE_COMMANDS) {
|
|
35
40
|
const captured = await context.run(tool, [
|
|
36
41
|
...prefix,
|
|
@@ -67,7 +72,6 @@ export const inspectNativeMacho = async (context) => {
|
|
|
67
72
|
: normalized;
|
|
68
73
|
return ok({
|
|
69
74
|
result: jsonValueSchema.parse(result),
|
|
70
|
-
provenance: result.provenance,
|
|
71
75
|
limitations: result.limitations,
|
|
72
76
|
locations: fileOffsetLocations(result, segmentOffset),
|
|
73
77
|
});
|
|
@@ -226,19 +230,19 @@ const selectedArchitectureArguments = (tool, architecture) => {
|
|
|
226
230
|
};
|
|
227
231
|
const selectArchitecture = (target, available) => {
|
|
228
232
|
if (target.kind !== "executable" || target.availableArchitectures.length < 2)
|
|
229
|
-
return
|
|
233
|
+
return { status: "unfiltered" };
|
|
230
234
|
const normalized = target.architecture === "x86" ? "i386" : target.architecture;
|
|
231
235
|
if (available.includes(normalized))
|
|
232
|
-
return normalized;
|
|
236
|
+
return { status: "selected", architecture: normalized };
|
|
233
237
|
// BinaryTarget intentionally normalizes ARM64 CPU subtypes. Recover the
|
|
234
238
|
// concrete arm64e slice name from lipo before invoking slice-aware tools.
|
|
235
239
|
if (normalized === "arm64") {
|
|
236
240
|
const arm64e = available.find((architecture) => architecture === "arm64e");
|
|
237
241
|
if (arm64e !== undefined)
|
|
238
|
-
return arm64e;
|
|
242
|
+
return { status: "selected", architecture: arm64e };
|
|
239
243
|
const variant = available.find((architecture) => /^arm64e\.[A-Za-z0-9_]+$/u.test(architecture));
|
|
240
244
|
if (variant !== undefined)
|
|
241
|
-
return variant;
|
|
245
|
+
return { status: "selected", architecture: variant };
|
|
242
246
|
}
|
|
243
|
-
return normalized;
|
|
247
|
+
return { status: "absent", architecture: normalized };
|
|
244
248
|
};
|
|
@@ -41,6 +41,7 @@ export const createNativeUiHelperRuntime = (environment) => {
|
|
|
41
41
|
const output = await execFileOutput(executable, [JSON.stringify(parameters)], {
|
|
42
42
|
timeout: 30_000,
|
|
43
43
|
maxBuffer: NATIVE_UI_HELPER_MAX_BUFFER,
|
|
44
|
+
stopSignal: "SIGTERM",
|
|
44
45
|
env: selectedEnvironment,
|
|
45
46
|
...(signal === undefined ? {} : { signal }),
|
|
46
47
|
});
|
|
@@ -54,8 +55,12 @@ export const createNativeUiHelperRuntime = (environment) => {
|
|
|
54
55
|
return {
|
|
55
56
|
invoke,
|
|
56
57
|
close: async () => {
|
|
57
|
-
if (root !== undefined)
|
|
58
|
+
if (root !== undefined) {
|
|
58
59
|
await rm(root, { recursive: true, force: true });
|
|
60
|
+
root = undefined;
|
|
61
|
+
executable = undefined;
|
|
62
|
+
}
|
|
59
63
|
},
|
|
64
|
+
resources: () => (root === undefined ? [] : [root]),
|
|
60
65
|
};
|
|
61
66
|
};
|
|
@@ -5,7 +5,7 @@ import { AnalysisCancelledError, AnalysisCapabilityUnavailableError, AnalysisInp
|
|
|
5
5
|
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
|
6
6
|
import {} from "../domain/analysisErrorBase.js";
|
|
7
7
|
import { err, ok } from "../domain/result.js";
|
|
8
|
-
import { createNativeUiHelperRuntime } from "./NativeUiHelperRuntime.js";
|
|
8
|
+
import { createNativeUiHelperRuntime, } from "./NativeUiHelperRuntime.js";
|
|
9
9
|
import { NATIVE_UI_OUTPUT_BUDGET_BYTES, NATIVE_UI_OUTPUT_WEIGHT, } from "./NativeUiOutputBudget.js";
|
|
10
10
|
const helper = fileURLToPath(new URL("../../bridge/native/ReaNativeUI.swift", import.meta.url));
|
|
11
11
|
const responseSchema = z.discriminatedUnion("ok", [
|
|
@@ -18,7 +18,7 @@ const responseSchema = z.discriminatedUnion("ok", [
|
|
|
18
18
|
]);
|
|
19
19
|
/** Capture a selected existing app window and run explicitly selected scenarios. */
|
|
20
20
|
export const observeNativeUi = async (target, operation, parameters, options) => {
|
|
21
|
-
const runtime = createNativeUiHelperRuntime(options.environment);
|
|
21
|
+
const runtime = options.runtime ?? createNativeUiHelperRuntime(options.environment);
|
|
22
22
|
try {
|
|
23
23
|
return await observeWithHelper(target, operation, parameters, {
|
|
24
24
|
...options,
|
|
@@ -26,7 +26,8 @@ export const observeNativeUi = async (target, operation, parameters, options) =>
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
finally {
|
|
29
|
-
|
|
29
|
+
if (options.runtime === undefined)
|
|
30
|
+
await runtime.close();
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
const observeWithHelper = async (target, operation, parameters, options) => {
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
|
2
|
+
export const peFailure = (message) => {
|
|
3
|
+
throw new ArtifactReaderFailure("format", message);
|
|
4
|
+
};
|
|
5
|
+
export const requirePeRange = (bytes, offset, length) => {
|
|
6
|
+
if (!Number.isSafeInteger(offset) ||
|
|
7
|
+
!Number.isSafeInteger(length) ||
|
|
8
|
+
offset < 0 ||
|
|
9
|
+
length < 0 ||
|
|
10
|
+
offset > bytes.length - length)
|
|
11
|
+
peFailure(`PE range ${String(offset)} + ${String(length)} leaves the artifact.`);
|
|
12
|
+
};
|
|
13
|
+
// RVA ownership follows the declared virtual extent. Raw size describes
|
|
14
|
+
// initialized file bytes and can include file-alignment padding; loaders may
|
|
15
|
+
// map page-rounded tails, but those bytes are outside the declared section.
|
|
16
|
+
const virtualExtent = (section) => section.virtualSize === 0 ? section.size : section.virtualSize;
|
|
17
|
+
/** Header admission and unambiguous file-backed RVA mapping, independent of section names. */
|
|
18
|
+
export const readPeResourceLayout = (bytes) => {
|
|
19
|
+
requirePeRange(bytes, 0, 64);
|
|
20
|
+
if (bytes.readUInt16LE(0) !== 0x5a4d)
|
|
21
|
+
peFailure("Expected an MZ PE image.");
|
|
22
|
+
const pe = bytes.readUInt32LE(60);
|
|
23
|
+
requirePeRange(bytes, pe, 24);
|
|
24
|
+
if (bytes.readUInt32LE(pe) !== 0x4550)
|
|
25
|
+
peFailure("Expected a PE signature.");
|
|
26
|
+
const sectionCount = bytes.readUInt16LE(pe + 6);
|
|
27
|
+
const optionalSize = bytes.readUInt16LE(pe + 20);
|
|
28
|
+
const optional = pe + 24;
|
|
29
|
+
requirePeRange(bytes, optional, optionalSize);
|
|
30
|
+
if (optionalSize < 64)
|
|
31
|
+
peFailure("Truncated PE optional header.");
|
|
32
|
+
const magic = bytes.readUInt16LE(optional);
|
|
33
|
+
if (magic !== 0x10b && magic !== 0x20b)
|
|
34
|
+
peFailure("Unsupported PE optional header magic.");
|
|
35
|
+
const countAt = magic === 0x10b ? 92 : 108;
|
|
36
|
+
const directoriesAt = countAt + 4;
|
|
37
|
+
if (optionalSize < directoriesAt)
|
|
38
|
+
peFailure("Truncated PE data directory count.");
|
|
39
|
+
const directoryCount = bytes.readUInt32LE(optional + countAt);
|
|
40
|
+
if (directoryCount > Math.floor((optionalSize - directoriesAt) / 8))
|
|
41
|
+
peFailure("PE directory count exceeds its optional header.");
|
|
42
|
+
const headerSize = bytes.readUInt32LE(optional + 60);
|
|
43
|
+
const table = optional + optionalSize;
|
|
44
|
+
requirePeRange(bytes, table, sectionCount * 40);
|
|
45
|
+
if (headerSize < table + sectionCount * 40 || headerSize > bytes.length)
|
|
46
|
+
peFailure("Invalid PE SizeOfHeaders.");
|
|
47
|
+
const sections = [];
|
|
48
|
+
for (let index = 0; index < sectionCount; index++) {
|
|
49
|
+
const at = table + index * 40;
|
|
50
|
+
const section = {
|
|
51
|
+
rva: bytes.readUInt32LE(at + 12),
|
|
52
|
+
virtualSize: bytes.readUInt32LE(at + 8),
|
|
53
|
+
offset: bytes.readUInt32LE(at + 20),
|
|
54
|
+
size: bytes.readUInt32LE(at + 16),
|
|
55
|
+
};
|
|
56
|
+
if (section.rva + virtualExtent(section) > 0x100000000)
|
|
57
|
+
peFailure("PE section RVA range overflows.");
|
|
58
|
+
if (section.size > 0) {
|
|
59
|
+
requirePeRange(bytes, section.offset, section.size);
|
|
60
|
+
if (section.offset < headerSize)
|
|
61
|
+
peFailure("PE section raw bytes overlap headers.");
|
|
62
|
+
}
|
|
63
|
+
sections.push(section);
|
|
64
|
+
}
|
|
65
|
+
const backed = sections
|
|
66
|
+
.filter(({ size }) => size > 0)
|
|
67
|
+
.sort((left, right) => left.offset - right.offset);
|
|
68
|
+
for (let index = 1; index < backed.length; index++) {
|
|
69
|
+
const previous = backed[index - 1];
|
|
70
|
+
const current = backed[index];
|
|
71
|
+
if (previous !== undefined &&
|
|
72
|
+
current !== undefined &&
|
|
73
|
+
current.offset < previous.offset + previous.size)
|
|
74
|
+
peFailure("PE sections have overlapping raw file ranges.");
|
|
75
|
+
}
|
|
76
|
+
const map = (rva, size) => {
|
|
77
|
+
if (rva + size > 0x100000000)
|
|
78
|
+
peFailure("Resource RVA range overflows.");
|
|
79
|
+
const candidates = sections.filter((section) => rva >= section.rva && rva - section.rva < virtualExtent(section));
|
|
80
|
+
if (rva < headerSize) {
|
|
81
|
+
if (sections.some((section) => section.rva < rva + size &&
|
|
82
|
+
section.rva + virtualExtent(section) > rva) ||
|
|
83
|
+
size > headerSize - rva)
|
|
84
|
+
peFailure("Ambiguous resource header RVA mapping.");
|
|
85
|
+
requirePeRange(bytes, rva, size);
|
|
86
|
+
return rva;
|
|
87
|
+
}
|
|
88
|
+
if (candidates.length !== 1)
|
|
89
|
+
peFailure("Resource RVA has missing or overlapping section mappings.");
|
|
90
|
+
const section = candidates[0];
|
|
91
|
+
if (section === undefined)
|
|
92
|
+
return peFailure("Missing resource section.");
|
|
93
|
+
const within = rva - section.rva;
|
|
94
|
+
if (size > virtualExtent(section) - within)
|
|
95
|
+
peFailure("Resource range leaves its section's virtual size.");
|
|
96
|
+
if (within > section.size || size > section.size - within)
|
|
97
|
+
peFailure("Resource range is not entirely file-backed in one section.");
|
|
98
|
+
// A second section starting inside the requested interval is ambiguous too.
|
|
99
|
+
if (sections.some((other) => other !== section &&
|
|
100
|
+
other.rva < rva + size &&
|
|
101
|
+
other.rva + virtualExtent(other) > rva))
|
|
102
|
+
peFailure("Resource interval intersects overlapping virtual sections.");
|
|
103
|
+
const offset = section.offset + within;
|
|
104
|
+
requirePeRange(bytes, offset, size);
|
|
105
|
+
return offset;
|
|
106
|
+
};
|
|
107
|
+
const directoryAt = optional + directoriesAt + 16;
|
|
108
|
+
const rva = directoryCount > 2 ? bytes.readUInt32LE(directoryAt) : 0;
|
|
109
|
+
const size = directoryCount > 2 ? bytes.readUInt32LE(directoryAt + 4) : 0;
|
|
110
|
+
if ((rva === 0) !== (size === 0))
|
|
111
|
+
peFailure("Inconsistent PE resource directory RVA/size.");
|
|
112
|
+
return {
|
|
113
|
+
format: magic === 0x10b ? "pe32" : "pe32-plus",
|
|
114
|
+
machine: bytes.readUInt16LE(pe + 4),
|
|
115
|
+
directoryAt,
|
|
116
|
+
rva,
|
|
117
|
+
size,
|
|
118
|
+
map,
|
|
119
|
+
};
|
|
120
|
+
};
|