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
|
@@ -21,3 +21,80 @@ export const semanticPropertyPathKeyMatches = (key, name) => {
|
|
|
21
21
|
const index = semanticArrayIndex(name);
|
|
22
22
|
return index !== null && index >= key.startIndex;
|
|
23
23
|
};
|
|
24
|
+
const coverageNode = () => ({
|
|
25
|
+
terminal: false,
|
|
26
|
+
exact: new Map(),
|
|
27
|
+
selectors: new Map(),
|
|
28
|
+
});
|
|
29
|
+
/** Index exact effect prefixes without widening distinct member paths. */
|
|
30
|
+
export class SemanticPropertyPathCoverage {
|
|
31
|
+
#root = coverageNode();
|
|
32
|
+
/** Retain a path only when no previously retained prefix covers it. */
|
|
33
|
+
retain(path) {
|
|
34
|
+
if (this.covers(path))
|
|
35
|
+
return false;
|
|
36
|
+
let node = this.#root;
|
|
37
|
+
for (const key of path) {
|
|
38
|
+
if (key !== null && typeof key !== "object") {
|
|
39
|
+
const name = String(key);
|
|
40
|
+
let child = node.exact.get(name);
|
|
41
|
+
if (child === undefined) {
|
|
42
|
+
child = coverageNode();
|
|
43
|
+
node.exact.set(name, child);
|
|
44
|
+
}
|
|
45
|
+
node = child;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const identity = JSON.stringify(key);
|
|
49
|
+
let selected = node.selectors.get(identity);
|
|
50
|
+
if (selected === undefined) {
|
|
51
|
+
selected = { key, node: coverageNode() };
|
|
52
|
+
node.selectors.set(identity, selected);
|
|
53
|
+
}
|
|
54
|
+
node = selected.node;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
node.terminal = true;
|
|
58
|
+
node.exact.clear();
|
|
59
|
+
node.selectors.clear();
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
/** Query retained prefixes without changing the coverage index. */
|
|
63
|
+
covers(path) {
|
|
64
|
+
const pending = [{ node: this.#root, offset: 0 }];
|
|
65
|
+
while (pending.length > 0) {
|
|
66
|
+
const current = pending.pop();
|
|
67
|
+
if (current === undefined)
|
|
68
|
+
break;
|
|
69
|
+
if (current.node.terminal)
|
|
70
|
+
return true;
|
|
71
|
+
const key = path[current.offset];
|
|
72
|
+
if (key === undefined)
|
|
73
|
+
continue;
|
|
74
|
+
if (key !== null && typeof key !== "object") {
|
|
75
|
+
const exact = current.node.exact.get(String(key));
|
|
76
|
+
if (exact !== undefined)
|
|
77
|
+
pending.push({ node: exact, offset: current.offset + 1 });
|
|
78
|
+
}
|
|
79
|
+
for (const selected of current.node.selectors.values()) {
|
|
80
|
+
if (keyCovers(selected.key, key))
|
|
81
|
+
pending.push({ node: selected.node, offset: current.offset + 1 });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const keyCovers = (covering, key) => {
|
|
88
|
+
if (covering === null)
|
|
89
|
+
return true;
|
|
90
|
+
if (key === null)
|
|
91
|
+
return false;
|
|
92
|
+
if (typeof key !== "object")
|
|
93
|
+
return typeof covering === "object"
|
|
94
|
+
? semanticPropertyPathKeyMatches(covering, String(key))
|
|
95
|
+
: String(covering) === String(key);
|
|
96
|
+
return (typeof covering === "object" &&
|
|
97
|
+
covering.excludedKeys.every((name) => key.excludedKeys.includes(name)) &&
|
|
98
|
+
(covering.startIndex === undefined ||
|
|
99
|
+
(key.startIndex !== undefined && covering.startIndex <= key.startIndex)));
|
|
100
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
2
1
|
import { isJavaScriptSemanticOwnershipRelation as ownershipRelation } from "./javascriptSemanticQueryRelations.js";
|
|
3
2
|
import { javaScriptSemanticQueryInputSchema, javaScriptSemanticQueryResultSchema, } from "./javascriptSemanticQuerySchemas.js";
|
|
4
3
|
import { assessJavaScriptSemanticQuery } from "./javascriptSemanticQueryAssessment.js";
|
|
@@ -8,13 +7,11 @@ export const queryJavaScriptSemanticGraph = (graph, rawInput) => {
|
|
|
8
7
|
const input = javaScriptSemanticQueryInputSchema.parse(rawInput);
|
|
9
8
|
const queryId = queryIdentifier(graph, input);
|
|
10
9
|
const seeds = resolveSeeds(graph, input);
|
|
11
|
-
const
|
|
12
|
-
const retainedSeeds = admission.nodeIds;
|
|
10
|
+
const nodes = new Map(graph.nodes.map((node) => [node.node_id, node]));
|
|
13
11
|
const adjacency = buildAdjacency(graph.relations, input);
|
|
14
|
-
const traversal = traverse(
|
|
12
|
+
const traversal = traverse(nodes, seeds, adjacency);
|
|
15
13
|
const result = createQueryResult(graph, traversal);
|
|
16
|
-
const
|
|
17
|
-
const relevantUnknowns = allRelevantUnknowns;
|
|
14
|
+
const relevantUnknowns = relevantUnknownFrontiers(graph, traversal.nodeIds, input);
|
|
18
15
|
const candidateRelations = relevantCandidateRelationCount(graph, traversal.nodeIds, input);
|
|
19
16
|
const expectedMatches = expectedMatchesFor(result.retainedNodes, result.retainedRelations, input);
|
|
20
17
|
const retainedContextIds = new Set([
|
|
@@ -36,7 +33,7 @@ export const queryJavaScriptSemanticGraph = (graph, rawInput) => {
|
|
|
36
33
|
seed: input.seed,
|
|
37
34
|
direction: input.direction,
|
|
38
35
|
status: assessment.status,
|
|
39
|
-
seed_node_ids:
|
|
36
|
+
seed_node_ids: seeds,
|
|
40
37
|
evidence_contexts: graph.evidence_contexts.filter(({ context_id }) => retainedContextIds.has(context_id)),
|
|
41
38
|
nodes: result.retainedNodes,
|
|
42
39
|
relations: result.retainedRelations,
|
|
@@ -48,7 +45,7 @@ export const queryJavaScriptSemanticGraph = (graph, rawInput) => {
|
|
|
48
45
|
traversed_relations: traversal.relationIds.size,
|
|
49
46
|
traversed_functions: traversal.functionIds.size,
|
|
50
47
|
traversed_modules: traversal.modules.size,
|
|
51
|
-
relevant_unknowns:
|
|
48
|
+
relevant_unknowns: relevantUnknowns.length,
|
|
52
49
|
},
|
|
53
50
|
coverage: assessment.coverage,
|
|
54
51
|
limitations: assessment.limitations,
|
|
@@ -59,17 +56,6 @@ const createQueryResult = (graph, traversal) => {
|
|
|
59
56
|
const retainedRelations = graph.relations.filter(({ relation_id }) => traversal.relationIds.has(relation_id));
|
|
60
57
|
return { retainedNodes, retainedRelations };
|
|
61
58
|
};
|
|
62
|
-
const admitSeeds = (graph, seeds) => {
|
|
63
|
-
const nodes = new Map(graph.nodes.map((node) => [node.node_id, node]));
|
|
64
|
-
const retained = [];
|
|
65
|
-
for (const nodeId of seeds) {
|
|
66
|
-
const node = nodes.get(nodeId);
|
|
67
|
-
if (node === undefined)
|
|
68
|
-
continue;
|
|
69
|
-
retained.push(nodeId);
|
|
70
|
-
}
|
|
71
|
-
return { nodeIds: retained };
|
|
72
|
-
};
|
|
73
59
|
const buildAdjacency = (relations, input) => {
|
|
74
60
|
const adjacency = new Map();
|
|
75
61
|
const allowed = input.allowed_relations === undefined
|
|
@@ -83,8 +69,6 @@ const buildAdjacency = (relations, input) => {
|
|
|
83
69
|
continue;
|
|
84
70
|
addDirectedEntries(adjacency, relation, input.direction);
|
|
85
71
|
}
|
|
86
|
-
for (const entries of adjacency.values())
|
|
87
|
-
entries.sort((left, right) => compareUnicodeCodePoints(`${left.relation.relation_id}\0${left.nextNodeId}`, `${right.relation.relation_id}\0${right.nextNodeId}`));
|
|
88
72
|
return adjacency;
|
|
89
73
|
};
|
|
90
74
|
const addDirectedEntries = (adjacency, relation, direction) => {
|
|
@@ -110,8 +94,7 @@ const addEntry = (adjacency, from, nextNodeId, relation) => {
|
|
|
110
94
|
entries.push({ relation, nextNodeId });
|
|
111
95
|
adjacency.set(from, entries);
|
|
112
96
|
};
|
|
113
|
-
const traverse = (
|
|
114
|
-
const nodes = new Map(graph.nodes.map((node) => [node.node_id, node]));
|
|
97
|
+
const traverse = (nodes, seeds, adjacency) => {
|
|
115
98
|
const nodeIds = new Set(seeds);
|
|
116
99
|
const relationIds = new Set();
|
|
117
100
|
const functionIds = new Set();
|
|
@@ -159,12 +142,27 @@ const relevantUnknownFrontiers = (graph, nodeIds, input) => {
|
|
|
159
142
|
unknown.relation_kinds.some((relation) => allowed.has(relation))));
|
|
160
143
|
};
|
|
161
144
|
const relevantCandidateRelationCount = (graph, nodeIds, input) => {
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
145
|
+
const allowed = input.allowed_relations === undefined
|
|
146
|
+
? null
|
|
147
|
+
: new Set(input.allowed_relations);
|
|
148
|
+
let relevant = 0;
|
|
149
|
+
for (const relation of graph.relations) {
|
|
150
|
+
if (relation.resolution !== "candidate" ||
|
|
151
|
+
(allowed !== null && !allowed.has(relation.relation)))
|
|
152
|
+
continue;
|
|
153
|
+
const sourceIsRelevant = nodeIds.has(relation.source_node_id);
|
|
154
|
+
const targetIsRelevant = nodeIds.has(relation.target_node_id);
|
|
155
|
+
if ((input.direction === "callers" &&
|
|
156
|
+
relation.relation === "calls" &&
|
|
157
|
+
targetIsRelevant) ||
|
|
158
|
+
(input.direction === "ownership" &&
|
|
159
|
+
ownershipRelation(relation.relation) &&
|
|
160
|
+
(sourceIsRelevant || targetIsRelevant)) ||
|
|
161
|
+
(input.direction === "backward-provenance" && targetIsRelevant) ||
|
|
162
|
+
(input.direction === "forward-influence" && sourceIsRelevant))
|
|
163
|
+
relevant += 1;
|
|
164
|
+
}
|
|
165
|
+
return relevant;
|
|
168
166
|
};
|
|
169
167
|
const expectedMatchesFor = (nodes, relations, input) => {
|
|
170
168
|
if (input.expected === null)
|
|
@@ -51,9 +51,7 @@ const seedMatches = (node, input, fingerprintFunctions) => {
|
|
|
51
51
|
if (seed.kind === "function")
|
|
52
52
|
return fingerprintFunctions.has(node.node_id);
|
|
53
53
|
if (seed.kind === "literal")
|
|
54
|
-
return
|
|
55
|
-
canonicalJavaScriptSemanticQueryJson(node.properties.value) ===
|
|
56
|
-
canonicalJavaScriptSemanticQueryJson(seed.value));
|
|
54
|
+
return node.kind === "literal" && node.properties.value === seed.value;
|
|
57
55
|
if (seed.kind === "property")
|
|
58
56
|
return node.kind === "property-slot" && node.properties.name === seed.name;
|
|
59
57
|
if (seed.kind === "endpoint")
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { semanticStaticPropertyKey, unwrapJavaScriptExpression, } from "./javascriptAstValues.js";
|
|
3
|
+
import { resolveLocalCallables, } from "./javascriptSemanticCallResolution.js";
|
|
4
|
+
import { semanticCallableResultExpressions } from "./javascriptSemanticCallableResults.js";
|
|
5
|
+
import { semanticArrayIndex, } from "./javascriptSemanticPropertyPaths.js";
|
|
6
|
+
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
7
|
+
/** Resolve local result references conservatively, without claiming call execution. */
|
|
8
|
+
export const createSemanticReturnedReferences = (state) => {
|
|
9
|
+
const callableById = new Map(state.callables.map((callable) => [callable.callableId, callable]));
|
|
10
|
+
const bindingCache = new Map();
|
|
11
|
+
const results = new WeakMap();
|
|
12
|
+
const objectTargets = new WeakMap();
|
|
13
|
+
return (callee) => {
|
|
14
|
+
const existing = results.get(callee);
|
|
15
|
+
if (existing !== undefined)
|
|
16
|
+
return existing;
|
|
17
|
+
const functions = new Set();
|
|
18
|
+
const resolution = resolveLocalCallables({
|
|
19
|
+
node: callee,
|
|
20
|
+
state,
|
|
21
|
+
callableById,
|
|
22
|
+
bindingCache,
|
|
23
|
+
seenBindings: new Set(),
|
|
24
|
+
});
|
|
25
|
+
for (const id of resolution.callableIds) {
|
|
26
|
+
const node = state.callableNodesById.get(id);
|
|
27
|
+
if (node !== undefined)
|
|
28
|
+
functions.add(node);
|
|
29
|
+
}
|
|
30
|
+
const pending = [
|
|
31
|
+
{ node: callee, path: [], bindings: new Set() },
|
|
32
|
+
];
|
|
33
|
+
for (let cursor = 0; cursor < pending.length; cursor++) {
|
|
34
|
+
const item = pending[cursor];
|
|
35
|
+
if (item === undefined)
|
|
36
|
+
break;
|
|
37
|
+
const node = unwrapJavaScriptExpression(item.node).node;
|
|
38
|
+
if (t.isIdentifier(node)) {
|
|
39
|
+
const binding = resolveSemanticBindingState(state, node, node.name);
|
|
40
|
+
if (binding === undefined || item.bindings.has(binding.bindingId))
|
|
41
|
+
continue;
|
|
42
|
+
const bindings = new Set([...item.bindings, binding.bindingId]);
|
|
43
|
+
for (const initializer of [
|
|
44
|
+
...binding.initializers,
|
|
45
|
+
...binding.referenceInitializers,
|
|
46
|
+
])
|
|
47
|
+
pending.push({
|
|
48
|
+
node: initializer.node,
|
|
49
|
+
path: [...initializer.projection, ...item.path],
|
|
50
|
+
bindings,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else if (t.isMemberExpression(node) ||
|
|
54
|
+
t.isOptionalMemberExpression(node)) {
|
|
55
|
+
const path = [];
|
|
56
|
+
let receiver = node;
|
|
57
|
+
while (t.isMemberExpression(receiver) ||
|
|
58
|
+
t.isOptionalMemberExpression(receiver)) {
|
|
59
|
+
path.push(semanticStaticPropertyKey(receiver.property, receiver.computed));
|
|
60
|
+
receiver = unwrapJavaScriptExpression(receiver.object).node;
|
|
61
|
+
}
|
|
62
|
+
pending.push({
|
|
63
|
+
...item,
|
|
64
|
+
node: receiver,
|
|
65
|
+
path: [...path.reverse(), ...item.path],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else if (t.isConditionalExpression(node) ||
|
|
69
|
+
t.isLogicalExpression(node)) {
|
|
70
|
+
pending.push({
|
|
71
|
+
...item,
|
|
72
|
+
node: t.isConditionalExpression(node) ? node.consequent : node.left,
|
|
73
|
+
}, {
|
|
74
|
+
...item,
|
|
75
|
+
node: t.isConditionalExpression(node) ? node.alternate : node.right,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else if (t.isSequenceExpression(node)) {
|
|
79
|
+
const last = node.expressions.at(-1);
|
|
80
|
+
if (last !== undefined)
|
|
81
|
+
pending.push({ ...item, node: last });
|
|
82
|
+
}
|
|
83
|
+
else if (t.isFunction(node) && item.path.length === 0)
|
|
84
|
+
functions.add(node);
|
|
85
|
+
else if (t.isObjectExpression(node))
|
|
86
|
+
selectObjectTargets(node, item, pending, objectTargets);
|
|
87
|
+
else if (t.isArrayExpression(node)) {
|
|
88
|
+
const [key, ...path] = item.path;
|
|
89
|
+
const index = key === undefined || key === null ? null : semanticArrayIndex(key);
|
|
90
|
+
let uncertainOffset = false;
|
|
91
|
+
node.elements.forEach((element, offset) => {
|
|
92
|
+
if (element === null)
|
|
93
|
+
return;
|
|
94
|
+
if (t.isSpreadElement(element)) {
|
|
95
|
+
uncertainOffset = true;
|
|
96
|
+
pending.push({
|
|
97
|
+
...item,
|
|
98
|
+
node: element.argument,
|
|
99
|
+
path: [null, ...path],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else if (index === null || uncertainOffset || index === offset)
|
|
103
|
+
pending.push({ ...item, node: element, path });
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
else if (t.isNewExpression(node))
|
|
107
|
+
pending.push({ ...item, node: node.callee });
|
|
108
|
+
else if (t.isClass(node)) {
|
|
109
|
+
const [key, ...path] = item.path;
|
|
110
|
+
for (const member of node.body.body) {
|
|
111
|
+
if (t.isClassMethod(member)) {
|
|
112
|
+
if ((item.path.length === 0 && member.kind === "constructor") ||
|
|
113
|
+
(key !== undefined &&
|
|
114
|
+
(key === null ||
|
|
115
|
+
semanticStaticPropertyKey(member.key, member.computed) ===
|
|
116
|
+
String(key))))
|
|
117
|
+
pending.push({ ...item, node: member, path });
|
|
118
|
+
}
|
|
119
|
+
else if (t.isClassProperty(member) &&
|
|
120
|
+
member.value !== null &&
|
|
121
|
+
member.value !== undefined &&
|
|
122
|
+
key !== undefined &&
|
|
123
|
+
(key === null ||
|
|
124
|
+
semanticStaticPropertyKey(member.key, member.computed) ===
|
|
125
|
+
String(key)))
|
|
126
|
+
pending.push({ ...item, node: member.value, path });
|
|
127
|
+
}
|
|
128
|
+
if (node.superClass !== null && node.superClass !== undefined)
|
|
129
|
+
pending.push({ ...item, node: node.superClass });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const output = [...functions].flatMap((node) => {
|
|
133
|
+
const callables = t.isClass(node)
|
|
134
|
+
? node.body.body.filter((member) => t.isClassMethod(member) && member.kind === "constructor")
|
|
135
|
+
: [node];
|
|
136
|
+
return callables.flatMap((callable) => semanticCallableResultExpressions(callable).flatMap(({ node, delegated }) => node === null
|
|
137
|
+
? []
|
|
138
|
+
: [{ node, projection: delegated ? [null] : [] }]));
|
|
139
|
+
});
|
|
140
|
+
results.set(callee, output);
|
|
141
|
+
return output;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
const selectObjectTargets = (node, item, pending, indexes) => {
|
|
145
|
+
const [key, ...path] = item.path;
|
|
146
|
+
if (key !== null && key !== undefined) {
|
|
147
|
+
const index = objectTargetIndex(node, indexes);
|
|
148
|
+
const property = index.propertyByName.get(String(key));
|
|
149
|
+
if (property !== undefined) {
|
|
150
|
+
const unknowns = [];
|
|
151
|
+
for (let unknown = index.trailingUnknownsByProperty.get(property); unknown !== undefined; unknown = unknown.previous)
|
|
152
|
+
unknowns.push(unknown);
|
|
153
|
+
for (const { node: unknown } of unknowns.reverse())
|
|
154
|
+
pending.push({
|
|
155
|
+
...item,
|
|
156
|
+
node: t.isSpreadElement(unknown)
|
|
157
|
+
? unknown.argument
|
|
158
|
+
: t.isObjectProperty(unknown)
|
|
159
|
+
? unknown.value
|
|
160
|
+
: unknown,
|
|
161
|
+
...(t.isSpreadElement(unknown) ? {} : { path }),
|
|
162
|
+
});
|
|
163
|
+
pending.push({
|
|
164
|
+
...item,
|
|
165
|
+
node: t.isObjectProperty(property) ? property.value : property,
|
|
166
|
+
path,
|
|
167
|
+
});
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
let replaced = false;
|
|
172
|
+
for (const property of [...node.properties].reverse()) {
|
|
173
|
+
if (replaced)
|
|
174
|
+
break;
|
|
175
|
+
if (t.isSpreadElement(property)) {
|
|
176
|
+
pending.push({ ...item, node: property.argument });
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const name = semanticStaticPropertyKey(property.key, property.computed);
|
|
180
|
+
if (key !== null &&
|
|
181
|
+
key !== undefined &&
|
|
182
|
+
name !== null &&
|
|
183
|
+
name !== String(key))
|
|
184
|
+
continue;
|
|
185
|
+
if (t.isObjectProperty(property))
|
|
186
|
+
pending.push({ ...item, node: property.value, path });
|
|
187
|
+
else
|
|
188
|
+
pending.push({ ...item, node: property, path });
|
|
189
|
+
if (key !== null && key !== undefined && name === String(key))
|
|
190
|
+
replaced = true;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
const objectTargetIndex = (node, indexes) => {
|
|
194
|
+
const existing = indexes.get(node);
|
|
195
|
+
if (existing !== undefined)
|
|
196
|
+
return existing;
|
|
197
|
+
const propertyByName = new Map();
|
|
198
|
+
const trailingUnknownsByProperty = new Map();
|
|
199
|
+
let trailingUnknown;
|
|
200
|
+
for (const property of [...node.properties].reverse()) {
|
|
201
|
+
if (t.isSpreadElement(property)) {
|
|
202
|
+
trailingUnknown = { node: property, previous: trailingUnknown };
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const name = semanticStaticPropertyKey(property.key, property.computed);
|
|
206
|
+
if (name === null) {
|
|
207
|
+
trailingUnknown = { node: property, previous: trailingUnknown };
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (propertyByName.has(name))
|
|
211
|
+
continue;
|
|
212
|
+
propertyByName.set(name, property);
|
|
213
|
+
if (trailingUnknown !== undefined)
|
|
214
|
+
trailingUnknownsByProperty.set(property, trailingUnknown);
|
|
215
|
+
}
|
|
216
|
+
const created = { propertyByName, trailingUnknownsByProperty };
|
|
217
|
+
indexes.set(node, created);
|
|
218
|
+
return created;
|
|
219
|
+
};
|
|
@@ -7,7 +7,8 @@ import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
|
7
7
|
import { evaluateSemanticExpression } from "./javascriptSemanticValues.js";
|
|
8
8
|
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
|
9
9
|
import { semanticReturnCoverage } from "./javascriptSemanticCoverage.js";
|
|
10
|
-
import {
|
|
10
|
+
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
|
11
|
+
import { semanticCallableResultExpressions } from "./javascriptSemanticCallableResults.js";
|
|
11
12
|
/** Evaluate direct returns while excluding every nested callable. */
|
|
12
13
|
export const collectSemanticReturns = (program, state, parserPartial) => {
|
|
13
14
|
const nodes = callableNodes(program);
|
|
@@ -43,7 +44,14 @@ export const collectSemanticReturns = (program, state, parserPartial) => {
|
|
|
43
44
|
};
|
|
44
45
|
});
|
|
45
46
|
};
|
|
46
|
-
const semanticReturnSiteId = (callableId, location) =>
|
|
47
|
+
const semanticReturnSiteId = (callableId, location) => [
|
|
48
|
+
callableId,
|
|
49
|
+
"return",
|
|
50
|
+
String(location.start.line),
|
|
51
|
+
String(location.start.column),
|
|
52
|
+
String(location.end.line),
|
|
53
|
+
String(location.end.column),
|
|
54
|
+
].join(":");
|
|
47
55
|
/** Link exports to callables only when lexical resolution is unique and exact. */
|
|
48
56
|
export const resolveSemanticModuleCallables = (state, callables) => {
|
|
49
57
|
const callableIds = new Set(callables.map(({ callableId }) => callableId));
|
|
@@ -75,27 +83,9 @@ const callableNodes = (program) => {
|
|
|
75
83
|
});
|
|
76
84
|
return output;
|
|
77
85
|
};
|
|
78
|
-
const directReturnExpressions = (callable) =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return [{ node: callable.body, location: range(callable.body) }];
|
|
82
|
-
if (!t.isFunction(callable))
|
|
83
|
-
return [];
|
|
84
|
-
const output = [];
|
|
85
|
-
const visit = (node) => {
|
|
86
|
-
if (t.isFunction(node) || t.isClass(node))
|
|
87
|
-
return;
|
|
88
|
-
if (t.isReturnStatement(node)) {
|
|
89
|
-
output.push({ node: node.argument ?? null, location: range(node) });
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
for (const child of childNodes(node))
|
|
93
|
-
visit(child);
|
|
94
|
-
};
|
|
95
|
-
for (const child of childNodes(callable.body))
|
|
96
|
-
visit(child);
|
|
97
|
-
return output;
|
|
98
|
-
};
|
|
86
|
+
const directReturnExpressions = (callable) => semanticCallableResultExpressions(callable)
|
|
87
|
+
.filter(({ kind }) => kind === "return")
|
|
88
|
+
.map(({ node, site }) => ({ node, location: range(site) }));
|
|
99
89
|
const callableIdsForBinding = (binding, state, admitted, seen) => {
|
|
100
90
|
// A single initializer does not prove an assignment executes or replace
|
|
101
91
|
// the unknown incoming value of a parameter/catch binding.
|
|
@@ -8,9 +8,11 @@ export const currentSemanticScope = (stack) => {
|
|
|
8
8
|
};
|
|
9
9
|
/** Create a stable source-position identity for one lexical scope. */
|
|
10
10
|
export const semanticScopeId = (kind, node) => `scope:${kind}:${String(node.start ?? -1)}:${String(node.end ?? -1)}`;
|
|
11
|
+
/** Create the canonical identity used by one binding in a lexical scope. */
|
|
12
|
+
export const semanticBindingId = (scopeId, name) => `${scopeId}:binding:${encodeURIComponent(name)}`;
|
|
11
13
|
/** Resolve one lexical name from the scope containing a node. */
|
|
12
14
|
export const resolveSemanticBindingState = (state, node, name) => {
|
|
13
|
-
let scope = state
|
|
15
|
+
let scope = semanticScopeForNode(state, node);
|
|
14
16
|
while (scope !== undefined) {
|
|
15
17
|
const binding = scope.bindings.get(name);
|
|
16
18
|
if (binding !== undefined)
|
|
@@ -26,7 +28,7 @@ export const resolveSemanticBindingState = (state, node, name) => {
|
|
|
26
28
|
};
|
|
27
29
|
/** Report whether an omitted binding scope blocks a trustworthy miss. */
|
|
28
30
|
export const semanticResolutionBlocked = (state, node, name) => {
|
|
29
|
-
let scope = state
|
|
31
|
+
let scope = semanticScopeForNode(state, node);
|
|
30
32
|
while (scope !== undefined) {
|
|
31
33
|
if (scope.bindings.has(name))
|
|
32
34
|
return false;
|
|
@@ -39,6 +41,24 @@ export const semanticResolutionBlocked = (state, node, name) => {
|
|
|
39
41
|
}
|
|
40
42
|
return false;
|
|
41
43
|
};
|
|
44
|
+
const semanticScopeForNode = (state, node) => {
|
|
45
|
+
let candidate = node;
|
|
46
|
+
while (candidate !== undefined) {
|
|
47
|
+
const scope = state.scopeByNode.get(candidate);
|
|
48
|
+
if (scope !== undefined) {
|
|
49
|
+
// Repeated references in a deep expression share this ancestry. Cache
|
|
50
|
+
// the traversed path without eagerly indexing nodes never resolved.
|
|
51
|
+
let descendant = node;
|
|
52
|
+
while (descendant !== undefined && descendant !== candidate) {
|
|
53
|
+
state.scopeByNode.set(descendant, scope);
|
|
54
|
+
descendant = state.parentsByNode.get(descendant);
|
|
55
|
+
}
|
|
56
|
+
return scope;
|
|
57
|
+
}
|
|
58
|
+
candidate = state.parentsByNode.get(candidate);
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
};
|
|
42
62
|
/** Resolve one name starting from an explicitly selected lexical scope. */
|
|
43
63
|
export const resolveSemanticBindingFromScope = (scope, name, state) => {
|
|
44
64
|
let candidate = scope;
|
|
@@ -9,7 +9,13 @@ import * as t from "@babel/types";
|
|
|
9
9
|
* has an ObjectProperty parent, so the parent alone cannot say whether the
|
|
10
10
|
* identifier declares a binding or is assigned to.
|
|
11
11
|
*/
|
|
12
|
-
export const traverseJavaScriptAst = (root, visitor) =>
|
|
12
|
+
export const traverseJavaScriptAst = (root, visitor) => completeSemanticSteps(traverseJavaScriptAstSteps(root, visitor));
|
|
13
|
+
/**
|
|
14
|
+
* {@link traverseJavaScriptAst} with a yield every 1,024 visited nodes, so a
|
|
15
|
+
* caller can serve control messages during one large traversal. Visit order
|
|
16
|
+
* and callbacks are identical.
|
|
17
|
+
*/
|
|
18
|
+
export function* traverseJavaScriptAstSteps(root, visitor) {
|
|
13
19
|
const ancestors = [];
|
|
14
20
|
const enter = (node, parent) => {
|
|
15
21
|
visitor.enter(node, parent, () => [...ancestors]);
|
|
@@ -17,6 +23,7 @@ export const traverseJavaScriptAst = (root, visitor) => {
|
|
|
17
23
|
return { node, parent, children: childNodes(node), nextIndex: 0 };
|
|
18
24
|
};
|
|
19
25
|
const pending = [enter(root, null)];
|
|
26
|
+
let visited = 1;
|
|
20
27
|
while (pending.length > 0) {
|
|
21
28
|
const current = pending.at(-1);
|
|
22
29
|
if (current === undefined)
|
|
@@ -24,6 +31,9 @@ export const traverseJavaScriptAst = (root, visitor) => {
|
|
|
24
31
|
const child = current.children[current.nextIndex];
|
|
25
32
|
if (child !== undefined) {
|
|
26
33
|
current.nextIndex += 1;
|
|
34
|
+
if (visited % 1024 === 0)
|
|
35
|
+
yield;
|
|
36
|
+
visited += 1;
|
|
27
37
|
pending.push(enter(child, current.node));
|
|
28
38
|
}
|
|
29
39
|
else {
|
|
@@ -32,6 +42,14 @@ export const traverseJavaScriptAst = (root, visitor) => {
|
|
|
32
42
|
pending.pop();
|
|
33
43
|
}
|
|
34
44
|
}
|
|
45
|
+
}
|
|
46
|
+
/** Run cooperative analysis steps to completion without yielding control. */
|
|
47
|
+
export const completeSemanticSteps = (steps) => {
|
|
48
|
+
for (;;) {
|
|
49
|
+
const step = steps.next();
|
|
50
|
+
if (step.done === true)
|
|
51
|
+
return step.value;
|
|
52
|
+
}
|
|
35
53
|
};
|
|
36
54
|
/**
|
|
37
55
|
* Child Babel nodes in `VISITOR_KEYS` order. Single owner for AST child
|