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
|
@@ -19,43 +19,86 @@ export const invalidateSemanticEscapedPath = (value, path) => {
|
|
|
19
19
|
? { ...value, properties: value.properties.map(invalidateChild) }
|
|
20
20
|
: { ...value, items: value.items.map(invalidateChild) };
|
|
21
21
|
};
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Invalidate only slots that explicit mutations can affect, as if applying each
|
|
24
|
+
* path in order. Paths are grouped per slot so that many writes to one object
|
|
25
|
+
* cost one pass over its slots rather than one pass per write.
|
|
26
|
+
*/
|
|
27
|
+
export const invalidateSemanticMutationPaths = (value, paths) => {
|
|
28
|
+
if (paths.length === 0)
|
|
29
|
+
return value;
|
|
30
|
+
// An unknown key or a replaced value leaves nothing that a later path can
|
|
31
|
+
// restore, wherever it occurs in the sequence.
|
|
32
|
+
if ((value.status !== "object" && value.status !== "array") ||
|
|
33
|
+
paths.some(([key]) => key === undefined || key === null))
|
|
34
|
+
return {
|
|
35
|
+
status: "unknown",
|
|
36
|
+
reason: "This property may have been mutated.",
|
|
37
|
+
};
|
|
38
|
+
// Writing an array length discards every item known before it.
|
|
39
|
+
const reset = value.status === "array"
|
|
40
|
+
? paths.findLastIndex(([key]) => key === "length")
|
|
41
|
+
: -1;
|
|
42
|
+
const base = reset < 0
|
|
43
|
+
? value
|
|
44
|
+
: { status: "array", items: [], unknownItems: true, omittedItems: null };
|
|
45
|
+
const slots = base.status === "object" ? base.properties : base.items;
|
|
46
|
+
const slotsByName = new Map();
|
|
47
|
+
slots.forEach((property, index) => {
|
|
48
|
+
const indexes = slotsByName.get(property.name) ?? [];
|
|
49
|
+
indexes.push(index);
|
|
50
|
+
slotsByName.set(property.name, indexes);
|
|
51
|
+
});
|
|
52
|
+
const slotPaths = new Map();
|
|
53
|
+
const replacedSlots = new Set();
|
|
54
|
+
const select = (index, remaining) => {
|
|
55
|
+
const selected = slotPaths.get(index) ?? [];
|
|
56
|
+
selected.push(remaining);
|
|
57
|
+
slotPaths.set(index, selected);
|
|
58
|
+
if (remaining.length === 0)
|
|
59
|
+
replacedSlots.add(index);
|
|
28
60
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
61
|
+
// An added slot is already unknown, so later paths that select it are inert.
|
|
62
|
+
const added = new Set();
|
|
63
|
+
for (const [key, ...remaining] of paths.slice(reset + 1)) {
|
|
64
|
+
if (key === undefined || key === null)
|
|
65
|
+
continue;
|
|
66
|
+
if (typeof key === "object") {
|
|
67
|
+
slots.forEach((property, index) => {
|
|
68
|
+
if (semanticPropertyPathKeyMatches(key, property.name))
|
|
69
|
+
select(index, remaining);
|
|
70
|
+
});
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const indexes = slotsByName.get(String(key));
|
|
74
|
+
if (indexes === undefined)
|
|
75
|
+
added.add(String(key));
|
|
76
|
+
else
|
|
77
|
+
for (const index of indexes)
|
|
78
|
+
select(index, remaining);
|
|
79
|
+
}
|
|
80
|
+
const properties = slots.map((property, index) => {
|
|
81
|
+
const selected = slotPaths.get(index);
|
|
82
|
+
return selected === undefined
|
|
83
|
+
? property
|
|
84
|
+
: {
|
|
43
85
|
...property,
|
|
44
|
-
...(
|
|
86
|
+
...(replacedSlots.has(index)
|
|
45
87
|
? { presence: "unknown-coverage" }
|
|
46
88
|
: {}),
|
|
47
|
-
value:
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
89
|
+
value: invalidateSemanticMutationPaths(property.value, selected),
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
for (const name of added)
|
|
93
|
+
properties.push({
|
|
94
|
+
name,
|
|
95
|
+
value: {
|
|
96
|
+
status: "unknown",
|
|
97
|
+
reason: "This property may have been mutated.",
|
|
98
|
+
},
|
|
99
|
+
presence: "unknown-coverage",
|
|
100
|
+
});
|
|
101
|
+
return base.status === "object"
|
|
102
|
+
? { ...base, properties }
|
|
103
|
+
: { ...base, items: properties };
|
|
61
104
|
};
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import * as t from "@babel/types";
|
|
2
|
+
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
3
|
+
import { semanticCallableResultExpressions } from "./javascriptSemanticCallableResults.js";
|
|
4
|
+
import { semanticStaticPropertyKey, unwrapJavaScriptExpression, } from "./javascriptAstValues.js";
|
|
5
|
+
import { semanticPropertyPathKeyMatches, } from "./javascriptSemanticPropertyPaths.js";
|
|
6
|
+
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
7
|
+
export const semanticClassCandidates = (root, state) => {
|
|
8
|
+
const pending = [root];
|
|
9
|
+
const seenNodes = new Set();
|
|
10
|
+
const seenBindings = new Set();
|
|
11
|
+
const classes = [];
|
|
12
|
+
for (let cursor = 0; cursor < pending.length; cursor++) {
|
|
13
|
+
const node = pending[cursor];
|
|
14
|
+
if (node === undefined)
|
|
15
|
+
continue;
|
|
16
|
+
const expression = unwrapJavaScriptExpression(node).node;
|
|
17
|
+
if (seenNodes.has(expression))
|
|
18
|
+
continue;
|
|
19
|
+
seenNodes.add(expression);
|
|
20
|
+
if (t.isClass(expression)) {
|
|
21
|
+
classes.push(expression);
|
|
22
|
+
}
|
|
23
|
+
else if (t.isIdentifier(expression)) {
|
|
24
|
+
const binding = resolveSemanticBindingState(state, expression, expression.name);
|
|
25
|
+
if (binding === undefined || seenBindings.has(binding.bindingId))
|
|
26
|
+
continue;
|
|
27
|
+
seenBindings.add(binding.bindingId);
|
|
28
|
+
for (const initializer of binding.initializers)
|
|
29
|
+
pending.push(initializer.node);
|
|
30
|
+
}
|
|
31
|
+
else if (t.isConditionalExpression(expression) ||
|
|
32
|
+
t.isLogicalExpression(expression)) {
|
|
33
|
+
pending.push(t.isConditionalExpression(expression)
|
|
34
|
+
? expression.consequent
|
|
35
|
+
: expression.left, t.isConditionalExpression(expression)
|
|
36
|
+
? expression.alternate
|
|
37
|
+
: expression.right);
|
|
38
|
+
}
|
|
39
|
+
else if (t.isSequenceExpression(expression)) {
|
|
40
|
+
const last = expression.expressions.at(-1);
|
|
41
|
+
if (last !== undefined)
|
|
42
|
+
pending.push(last);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return classes;
|
|
46
|
+
};
|
|
47
|
+
const instanceFieldReferences = (root, propertyName, path, state) => {
|
|
48
|
+
const references = [];
|
|
49
|
+
const pending = [{ klass: root, excluded: new Set() }];
|
|
50
|
+
const selections = new Map();
|
|
51
|
+
let definiteNames;
|
|
52
|
+
for (let cursor = 0; cursor < pending.length; cursor++) {
|
|
53
|
+
const current = pending[cursor];
|
|
54
|
+
if (current === undefined)
|
|
55
|
+
continue;
|
|
56
|
+
const previous = selections.get(current.klass);
|
|
57
|
+
// A shared base can be reached through different derived classes. Only
|
|
58
|
+
// exclusions common to those paths can suppress a field in that base.
|
|
59
|
+
const excluded = previous === undefined
|
|
60
|
+
? current.excluded
|
|
61
|
+
: new Set([...previous].filter((name) => current.excluded.has(name)));
|
|
62
|
+
if (previous !== undefined && previous.size === excluded.size)
|
|
63
|
+
continue;
|
|
64
|
+
selections.set(current.klass, excluded);
|
|
65
|
+
const shadowed = new Set(excluded);
|
|
66
|
+
for (const member of [...current.klass.body.body].reverse()) {
|
|
67
|
+
if (!t.isClassProperty(member) || member.static)
|
|
68
|
+
continue;
|
|
69
|
+
const key = semanticStaticPropertyKey(member.key, member.computed);
|
|
70
|
+
if (key !== null && shadowed.has(key))
|
|
71
|
+
continue;
|
|
72
|
+
if (key !== null)
|
|
73
|
+
shadowed.add(key);
|
|
74
|
+
if ((propertyName === null || key === null || key === propertyName) &&
|
|
75
|
+
member.value != null)
|
|
76
|
+
references.push({ node: member.value, path });
|
|
77
|
+
}
|
|
78
|
+
const bases = current.klass.superClass == null
|
|
79
|
+
? []
|
|
80
|
+
: semanticClassCandidates(current.klass.superClass, state);
|
|
81
|
+
if (bases.length === 0)
|
|
82
|
+
definiteNames =
|
|
83
|
+
definiteNames === undefined
|
|
84
|
+
? shadowed
|
|
85
|
+
: new Set([...definiteNames].filter((name) => shadowed.has(name)));
|
|
86
|
+
for (const klass of bases)
|
|
87
|
+
pending.push({ klass, excluded: shadowed });
|
|
88
|
+
}
|
|
89
|
+
return { references, definiteNames: definiteNames ?? new Set() };
|
|
90
|
+
};
|
|
91
|
+
const classPropertyDescriptors = (klass, propertyName, kind) => {
|
|
92
|
+
const isStatic = kind === "static";
|
|
93
|
+
const selectedGetters = [];
|
|
94
|
+
const fields = [];
|
|
95
|
+
const indexedMembers = [];
|
|
96
|
+
klass.body.body.forEach((member, index) => {
|
|
97
|
+
if ((t.isClassMethod(member) ||
|
|
98
|
+
(kind === "static" && t.isClassProperty(member))) &&
|
|
99
|
+
member.static === isStatic)
|
|
100
|
+
indexedMembers.push({
|
|
101
|
+
member,
|
|
102
|
+
index,
|
|
103
|
+
key: semanticStaticPropertyKey(member.key, member.computed),
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
const matchingMembers = propertyName === null
|
|
107
|
+
? []
|
|
108
|
+
: indexedMembers.filter(({ key }) => key === propertyName);
|
|
109
|
+
const uncertainGetters = indexedMembers.filter((entry) => {
|
|
110
|
+
const { member, key } = entry;
|
|
111
|
+
return (t.isClassMethod(member) &&
|
|
112
|
+
member.kind === "get" &&
|
|
113
|
+
(propertyName === null || (member.computed && key === null)));
|
|
114
|
+
});
|
|
115
|
+
const getters = matchingMembers.filter((entry) => t.isClassMethod(entry.member) && entry.member.kind === "get");
|
|
116
|
+
const getter = getters.at(-1);
|
|
117
|
+
const getterIndex = getter?.index ?? -1;
|
|
118
|
+
const laterDataMember = matchingMembers.some(({ member, index }) => t.isClassProperty(member) ||
|
|
119
|
+
(t.isClassMethod(member) &&
|
|
120
|
+
member.kind === "method" &&
|
|
121
|
+
index > getterIndex));
|
|
122
|
+
const seenFields = new Set();
|
|
123
|
+
for (const { member, key } of [...indexedMembers].reverse()) {
|
|
124
|
+
if (!t.isClassProperty(member))
|
|
125
|
+
continue;
|
|
126
|
+
if (key !== null && seenFields.has(key))
|
|
127
|
+
continue;
|
|
128
|
+
if (key !== null)
|
|
129
|
+
seenFields.add(key);
|
|
130
|
+
if (propertyName === null || key === null || key === propertyName)
|
|
131
|
+
fields.push(member);
|
|
132
|
+
}
|
|
133
|
+
if (getters.length > 0 && !laterDataMember && getter !== undefined)
|
|
134
|
+
selectedGetters.push(getter.member);
|
|
135
|
+
for (const { member, index } of uncertainGetters)
|
|
136
|
+
if (!matchingMembers.some(({ member: matching, index: matchingIndex }) => (t.isClassProperty(matching) ||
|
|
137
|
+
(t.isClassMethod(matching) &&
|
|
138
|
+
(matching.kind === "method" || matching.kind === "get"))) &&
|
|
139
|
+
matchingIndex > index))
|
|
140
|
+
selectedGetters.push(member);
|
|
141
|
+
return {
|
|
142
|
+
getters: selectedGetters,
|
|
143
|
+
fields,
|
|
144
|
+
inherits: matchingMembers.length === 0,
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export const semanticClassPropertyReferences = (lookup, selection, state, activeGetters = new Map()) => {
|
|
148
|
+
const root = lookup.owner;
|
|
149
|
+
const receiver = lookup.receiver ?? root;
|
|
150
|
+
const [key, ...path] = selection;
|
|
151
|
+
const propertyName = key == null || typeof key === "object" ? null : String(key);
|
|
152
|
+
const pending = [root];
|
|
153
|
+
const seen = new Set();
|
|
154
|
+
const possibleResults = [];
|
|
155
|
+
// Instance fields are own properties, including fields initialized by base
|
|
156
|
+
// constructors. They take precedence over every prototype descriptor.
|
|
157
|
+
let instanceFields = new Set();
|
|
158
|
+
if (lookup.kind === "instance") {
|
|
159
|
+
const fields = instanceFieldReferences(root, propertyName, path, state);
|
|
160
|
+
possibleResults.push(...fields.references);
|
|
161
|
+
instanceFields = fields.definiteNames;
|
|
162
|
+
if (propertyName !== null && instanceFields.has(propertyName))
|
|
163
|
+
return possibleResults;
|
|
164
|
+
}
|
|
165
|
+
for (let cursor = 0; cursor < pending.length; cursor++) {
|
|
166
|
+
const klass = pending[cursor];
|
|
167
|
+
if (klass === undefined || seen.has(klass))
|
|
168
|
+
continue;
|
|
169
|
+
seen.add(klass);
|
|
170
|
+
const descriptors = classPropertyDescriptors(klass, propertyName, lookup.kind);
|
|
171
|
+
for (const field of descriptors.fields)
|
|
172
|
+
if (field.value != null)
|
|
173
|
+
possibleResults.push({ node: field.value, path });
|
|
174
|
+
for (const getter of descriptors.getters) {
|
|
175
|
+
const key = semanticStaticPropertyKey(getter.key, getter.computed);
|
|
176
|
+
if (key !== null && instanceFields.has(key))
|
|
177
|
+
continue;
|
|
178
|
+
possibleResults.push(...getterResultReferences({ getter, owner: klass, receiver }, path, state, activeGetters));
|
|
179
|
+
}
|
|
180
|
+
// An exact own descriptor suppresses inherited lookup. Dynamic computed
|
|
181
|
+
// descriptors may or may not match, so retain possible superclass results.
|
|
182
|
+
if (descriptors.inherits &&
|
|
183
|
+
klass.superClass !== null &&
|
|
184
|
+
klass.superClass !== undefined)
|
|
185
|
+
pending.push(...semanticClassCandidates(klass.superClass, state));
|
|
186
|
+
}
|
|
187
|
+
return possibleResults;
|
|
188
|
+
};
|
|
189
|
+
const objectReceiverReference = (object, path, state) => {
|
|
190
|
+
// A literal's enclosing binding owns its slots. Returning the literal
|
|
191
|
+
// itself would bypass invalidation of that binding's observed properties.
|
|
192
|
+
let current = object;
|
|
193
|
+
const projection = [];
|
|
194
|
+
while (true) {
|
|
195
|
+
const parent = state.parentsByNode.get(current);
|
|
196
|
+
if (t.isVariableDeclarator(parent) &&
|
|
197
|
+
parent.init === current &&
|
|
198
|
+
t.isIdentifier(parent.id))
|
|
199
|
+
return [{ node: parent.id, path: [...projection, ...path] }];
|
|
200
|
+
if (t.isObjectProperty(parent) && parent.value === current) {
|
|
201
|
+
projection.unshift(semanticStaticPropertyKey(parent.key, parent.computed));
|
|
202
|
+
const container = state.parentsByNode.get(parent);
|
|
203
|
+
if (t.isObjectExpression(container)) {
|
|
204
|
+
current = container;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
return [{ node: object, path }];
|
|
211
|
+
};
|
|
212
|
+
const getterResultReferences = (invocation, path, state, activeGetters = new Map()) => {
|
|
213
|
+
const { getter, owner, receiver = owner } = invocation;
|
|
214
|
+
const previousLength = activeGetters.get(getter);
|
|
215
|
+
if (previousLength !== undefined && previousLength <= path.length)
|
|
216
|
+
return [];
|
|
217
|
+
// Repeated receiver reads may revisit a getter while consuming a finite
|
|
218
|
+
// path; recursive getters that preserve or grow that path cannot progress.
|
|
219
|
+
const active = new Map(activeGetters).set(getter, path.length);
|
|
220
|
+
const isStatic = t.isClassMethod(getter) && getter.static;
|
|
221
|
+
const resolve = (node, remaining) => {
|
|
222
|
+
const expression = unwrapJavaScriptExpression(node).node;
|
|
223
|
+
if (t.isThisExpression(expression)) {
|
|
224
|
+
if (t.isClass(receiver)) {
|
|
225
|
+
return semanticClassPropertyReferences({ owner: receiver, kind: isStatic ? "static" : "instance" }, remaining, state, active);
|
|
226
|
+
}
|
|
227
|
+
return objectReceiverReference(receiver, remaining, state);
|
|
228
|
+
}
|
|
229
|
+
if (t.isMemberExpression(expression) ||
|
|
230
|
+
t.isOptionalMemberExpression(expression)) {
|
|
231
|
+
if (t.isPrivateName(expression.property) &&
|
|
232
|
+
t.isThisExpression(expression.object) &&
|
|
233
|
+
t.isClass(owner)) {
|
|
234
|
+
const privateName = expression.property.id.name;
|
|
235
|
+
return owner.body.body.flatMap((member) => t.isClassPrivateProperty(member) &&
|
|
236
|
+
member.static === isStatic &&
|
|
237
|
+
member.key.id.name === privateName &&
|
|
238
|
+
member.value != null
|
|
239
|
+
? [{ node: member.value, path: remaining }]
|
|
240
|
+
: []);
|
|
241
|
+
}
|
|
242
|
+
const key = semanticStaticPropertyKey(expression.property, expression.computed);
|
|
243
|
+
if (t.isSuper(expression.object) &&
|
|
244
|
+
t.isClass(owner) &&
|
|
245
|
+
owner.superClass != null) {
|
|
246
|
+
return semanticClassCandidates(owner.superClass, state).flatMap((base) => semanticClassPropertyReferences({
|
|
247
|
+
owner: base,
|
|
248
|
+
receiver: t.isClass(receiver) ? receiver : owner,
|
|
249
|
+
kind: isStatic ? "static" : "prototype",
|
|
250
|
+
}, [key, ...remaining], state, active));
|
|
251
|
+
}
|
|
252
|
+
return resolve(expression.object, [key, ...remaining]);
|
|
253
|
+
}
|
|
254
|
+
if (t.isConditionalExpression(expression))
|
|
255
|
+
return [
|
|
256
|
+
...resolve(expression.consequent, remaining),
|
|
257
|
+
...resolve(expression.alternate, remaining),
|
|
258
|
+
];
|
|
259
|
+
if (t.isLogicalExpression(expression))
|
|
260
|
+
return [
|
|
261
|
+
...resolve(expression.left, remaining),
|
|
262
|
+
...resolve(expression.right, remaining),
|
|
263
|
+
];
|
|
264
|
+
if (t.isSequenceExpression(expression)) {
|
|
265
|
+
const last = expression.expressions.at(-1);
|
|
266
|
+
return last === undefined ? [] : resolve(last, remaining);
|
|
267
|
+
}
|
|
268
|
+
return [{ node: expression, path: remaining }];
|
|
269
|
+
};
|
|
270
|
+
return semanticCallableResultExpressions(getter).flatMap(({ node }) => node === null ? [] : resolve(node, path));
|
|
271
|
+
};
|
|
272
|
+
export const semanticObjectPropertyReferences = (node, path, state) => {
|
|
273
|
+
const [key, ...remaining] = path;
|
|
274
|
+
const references = [];
|
|
275
|
+
const overwritten = new Set();
|
|
276
|
+
const dataOverwritten = new Set();
|
|
277
|
+
const accessorNames = new Set();
|
|
278
|
+
const getterNames = new Set();
|
|
279
|
+
const setterNames = new Set();
|
|
280
|
+
for (const property of [...node.properties].reverse()) {
|
|
281
|
+
if (t.isSpreadElement(property)) {
|
|
282
|
+
const selected = key ?? null;
|
|
283
|
+
if (typeof selected !== "object" && overwritten.has(String(selected)))
|
|
284
|
+
continue;
|
|
285
|
+
references.push({
|
|
286
|
+
node: property.argument,
|
|
287
|
+
path: [
|
|
288
|
+
typeof selected === "object"
|
|
289
|
+
? {
|
|
290
|
+
...selected,
|
|
291
|
+
excludedKeys: [
|
|
292
|
+
...new Set([
|
|
293
|
+
...(selected?.excludedKeys ?? []),
|
|
294
|
+
...overwritten,
|
|
295
|
+
]),
|
|
296
|
+
].sort(compareUnicodeCodePoints),
|
|
297
|
+
}
|
|
298
|
+
: selected,
|
|
299
|
+
...remaining,
|
|
300
|
+
],
|
|
301
|
+
});
|
|
302
|
+
if (selected !== null &&
|
|
303
|
+
typeof selected !== "object" &&
|
|
304
|
+
t.isObjectExpression(property.argument) &&
|
|
305
|
+
objectExpressionDefinesKey(property.argument, String(selected))) {
|
|
306
|
+
overwritten.add(String(selected));
|
|
307
|
+
dataOverwritten.add(String(selected));
|
|
308
|
+
}
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const name = semanticStaticPropertyKey(property.key, property.computed);
|
|
312
|
+
const isGetter = t.isObjectMethod(property) && property.kind === "get";
|
|
313
|
+
const isSetter = t.isObjectMethod(property) && property.kind === "set";
|
|
314
|
+
if (name !== null &&
|
|
315
|
+
(isGetter || isSetter
|
|
316
|
+
? dataOverwritten.has(name) ||
|
|
317
|
+
(isGetter ? getterNames.has(name) : setterNames.has(name))
|
|
318
|
+
: dataOverwritten.has(name) || accessorNames.has(name)))
|
|
319
|
+
continue;
|
|
320
|
+
if (name === null || semanticPropertyPathKeyMatches(key ?? null, name)) {
|
|
321
|
+
if (t.isObjectMethod(property) && property.kind === "get") {
|
|
322
|
+
references.push(...getterResultReferences({ getter: property, owner: node }, remaining, state));
|
|
323
|
+
}
|
|
324
|
+
else if (t.isObjectMethod(property) && property.kind === "set") {
|
|
325
|
+
// A setter contributes no readable reference. A paired getter is
|
|
326
|
+
// handled independently when it appears earlier in this object.
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
references.push({
|
|
330
|
+
node: t.isObjectProperty(property) ? property.value : property,
|
|
331
|
+
path: remaining,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (name !== null) {
|
|
336
|
+
if (isGetter) {
|
|
337
|
+
getterNames.add(name);
|
|
338
|
+
accessorNames.add(name);
|
|
339
|
+
overwritten.add(name);
|
|
340
|
+
}
|
|
341
|
+
else if (isSetter) {
|
|
342
|
+
setterNames.add(name);
|
|
343
|
+
accessorNames.add(name);
|
|
344
|
+
overwritten.add(name);
|
|
345
|
+
}
|
|
346
|
+
else if (!(t.isObjectProperty(property) &&
|
|
347
|
+
!property.computed &&
|
|
348
|
+
!property.shorthand &&
|
|
349
|
+
name === "__proto__")) {
|
|
350
|
+
overwritten.add(name);
|
|
351
|
+
dataOverwritten.add(name);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return references;
|
|
356
|
+
};
|
|
357
|
+
const objectExpressionDefinesKey = (root, key) => {
|
|
358
|
+
const pending = [root];
|
|
359
|
+
const seen = new Set();
|
|
360
|
+
for (let cursor = 0; cursor < pending.length; cursor++) {
|
|
361
|
+
const object = pending[cursor];
|
|
362
|
+
if (object === undefined || seen.has(object))
|
|
363
|
+
continue;
|
|
364
|
+
seen.add(object);
|
|
365
|
+
for (const property of object.properties) {
|
|
366
|
+
if (t.isSpreadElement(property)) {
|
|
367
|
+
if (t.isObjectExpression(property.argument))
|
|
368
|
+
pending.push(property.argument);
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
const name = semanticStaticPropertyKey(property.key, property.computed);
|
|
372
|
+
if (name === key &&
|
|
373
|
+
!(t.isObjectProperty(property) &&
|
|
374
|
+
!property.computed &&
|
|
375
|
+
!property.shorthand &&
|
|
376
|
+
name === "__proto__"))
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
};
|
|
@@ -109,7 +109,13 @@ const collectDestructuring = (node, ownerCallableId, state, output) => {
|
|
|
109
109
|
};
|
|
110
110
|
const addObjectOperation = (input, state, output) => {
|
|
111
111
|
output.push({
|
|
112
|
-
|
|
112
|
+
// These high-volume IDs must not retain intermediate concatenations.
|
|
113
|
+
objectOperationId: [
|
|
114
|
+
"object",
|
|
115
|
+
input.kind,
|
|
116
|
+
String(input.node.start ?? -1),
|
|
117
|
+
String(input.node.end ?? -1),
|
|
118
|
+
].join(":"),
|
|
113
119
|
kind: input.kind,
|
|
114
120
|
location: range(input.node),
|
|
115
121
|
ownerCallableId: input.ownerCallableId,
|
|
@@ -2,7 +2,7 @@ import * as t from "@babel/types";
|
|
|
2
2
|
import { resolveSemanticBindingState, semanticResolutionBlocked, isUnshadowedGlobal, } from "./javascriptSemanticState.js";
|
|
3
3
|
import { semanticRequireOrigin } from "./javascriptSemanticRequireOrigin.js";
|
|
4
4
|
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
5
|
-
import {
|
|
5
|
+
import { completeSemanticSteps, traverseJavaScriptAstSteps, } from "./javascriptSemanticTraversal.js";
|
|
6
6
|
import { evaluateSemanticBinding, evaluateSemanticProvenance, } from "./javascriptSemanticValues.js";
|
|
7
7
|
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
|
8
8
|
import { propertyName, semanticStaticPropertyKey, } from "./javascriptAstValues.js";
|
|
@@ -62,11 +62,13 @@ export const collectSemanticModuleLink = (node, state) => {
|
|
|
62
62
|
collectCommonJsExport(node, state);
|
|
63
63
|
};
|
|
64
64
|
/** Collect lexical references after definitions exist, optionally for one name. */
|
|
65
|
-
export const collectSemanticReferences = (program, state, name) =>
|
|
65
|
+
export const collectSemanticReferences = (program, state, name) => completeSemanticSteps(collectSemanticReferencesSteps(program, state, name));
|
|
66
|
+
/** Collect lexical references in steps while preserving resolution and visit order. */
|
|
67
|
+
export function* collectSemanticReferencesSteps(program, state, name) {
|
|
66
68
|
const output = [];
|
|
67
69
|
const seen = new Set();
|
|
68
70
|
const patterns = [];
|
|
69
|
-
|
|
71
|
+
yield* traverseJavaScriptAstSteps(program, {
|
|
70
72
|
enter: (node, parent, readAncestors) => {
|
|
71
73
|
if (isPatternNode(node))
|
|
72
74
|
patterns.push(node);
|
|
@@ -111,7 +113,7 @@ export const collectSemanticReferences = (program, state, name) => {
|
|
|
111
113
|
},
|
|
112
114
|
});
|
|
113
115
|
return output;
|
|
114
|
-
}
|
|
116
|
+
}
|
|
115
117
|
/** Freeze collected scopes into deterministic IR order. */
|
|
116
118
|
export const immutableSemanticScopes = (state) => state.scopes.map((scope) => ({
|
|
117
119
|
scopeId: scope.scopeId,
|
|
@@ -258,17 +260,54 @@ const collectCommonJsExport = (node, state) => {
|
|
|
258
260
|
const exportedName = commonJsExportName(node.left, state);
|
|
259
261
|
if (exportedName === undefined)
|
|
260
262
|
return;
|
|
261
|
-
const
|
|
263
|
+
const receiverEffect = isCommonJsModuleExports(node.left, state)
|
|
264
|
+
? null
|
|
265
|
+
: commonJsExportReceiverEffect(node.right, state);
|
|
266
|
+
if (receiverEffect === "detached")
|
|
267
|
+
return;
|
|
268
|
+
// Simple assignment chains yield their rightmost assigned value. Compound
|
|
269
|
+
// and logical writes also depend on the previous value, so remain unknown.
|
|
270
|
+
let value = node.operator === "=" && receiverEffect !== "uncertain" ? node.right : null;
|
|
271
|
+
while (t.isAssignmentExpression(value, { operator: "=" }))
|
|
272
|
+
value = value.right;
|
|
273
|
+
const origin = value === null ? undefined : semanticRequireOrigin(value, state);
|
|
262
274
|
addModuleLink(state, {
|
|
263
275
|
kind: "commonjs-export",
|
|
264
276
|
specifier: origin?.specifier ?? null,
|
|
265
277
|
importedName: origin?.importedPath.at(-1) ?? null,
|
|
266
|
-
localName: t.isIdentifier(
|
|
278
|
+
localName: value !== null && t.isIdentifier(value) ? value.name : null,
|
|
267
279
|
exportedName,
|
|
268
|
-
callableId: semanticCallableIdForNode(
|
|
280
|
+
callableId: value === null ? null : semanticCallableIdForNode(value),
|
|
269
281
|
location: range(node),
|
|
270
282
|
}, node);
|
|
271
283
|
};
|
|
284
|
+
/**
|
|
285
|
+
* An outer property assignment captures its receiver before evaluating the
|
|
286
|
+
* RHS. When that chain assigns a freshly created identity to `module.exports`,
|
|
287
|
+
* the outer write targets the old exports object and cannot define an export
|
|
288
|
+
* on the value ultimately returned by the CommonJS module. Reassignments from
|
|
289
|
+
* existing bindings may preserve identity, so this guard leaves them as
|
|
290
|
+
* export candidates.
|
|
291
|
+
*/
|
|
292
|
+
const commonJsExportReceiverEffect = (node, state) => {
|
|
293
|
+
let value = node;
|
|
294
|
+
while (t.isAssignmentExpression(value, { operator: "=" })) {
|
|
295
|
+
if (isCommonJsModuleExports(value.left, state))
|
|
296
|
+
return isFreshAssignmentResult(value.right) ? "detached" : "uncertain";
|
|
297
|
+
value = value.right;
|
|
298
|
+
}
|
|
299
|
+
return null;
|
|
300
|
+
};
|
|
301
|
+
const isFreshAssignmentResult = (node) => {
|
|
302
|
+
let value = node;
|
|
303
|
+
while (t.isAssignmentExpression(value, { operator: "=" }))
|
|
304
|
+
value = value.right;
|
|
305
|
+
return (t.isArrowFunctionExpression(value) ||
|
|
306
|
+
t.isFunctionExpression(value) ||
|
|
307
|
+
t.isClassExpression(value) ||
|
|
308
|
+
t.isObjectExpression(value) ||
|
|
309
|
+
t.isArrayExpression(value));
|
|
310
|
+
};
|
|
272
311
|
const addModuleLink = (state, link, referenceNode) => {
|
|
273
312
|
const collected = { ...link, callableId: link.callableId ?? null };
|
|
274
313
|
state.moduleLinks.push(collected);
|
|
@@ -457,8 +496,7 @@ const defaultDeclarationName = (declaration) => (t.isFunctionDeclaration(declara
|
|
|
457
496
|
? declaration.id.name
|
|
458
497
|
: null;
|
|
459
498
|
const commonJsExportName = (node, state) => {
|
|
460
|
-
|
|
461
|
-
return "default";
|
|
499
|
+
// Rebinding the CommonJS `exports` alias does not replace `module.exports`.
|
|
462
500
|
if (!t.isMemberExpression(node) && !t.isOptionalMemberExpression(node))
|
|
463
501
|
return undefined;
|
|
464
502
|
const key = semanticStaticPropertyKey(node.property, node.computed);
|
|
@@ -468,12 +506,12 @@ const commonJsExportName = (node, state) => {
|
|
|
468
506
|
if (isUnshadowedGlobal(node.object, state, "exports"))
|
|
469
507
|
return key === null ? "*" : key || "*";
|
|
470
508
|
if (t.isMemberExpression(node.object) &&
|
|
471
|
-
|
|
472
|
-
semanticStaticPropertyKey(node.object.property, node.object.computed) ===
|
|
473
|
-
"exports")
|
|
509
|
+
isCommonJsModuleExports(node.object, state))
|
|
474
510
|
return key === null ? "*" : key || "default";
|
|
475
|
-
if (
|
|
476
|
-
semanticStaticPropertyKey(node.property, node.computed) === "exports")
|
|
511
|
+
if (isCommonJsModuleExports(node, state))
|
|
477
512
|
return "default";
|
|
478
513
|
return undefined;
|
|
479
514
|
};
|
|
515
|
+
const isCommonJsModuleExports = (node, state) => (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) &&
|
|
516
|
+
isUnshadowedGlobal(node.object, state, "module") &&
|
|
517
|
+
semanticStaticPropertyKey(node.property, node.computed) === "exports";
|