rea-agents 3.2.1 → 4.0.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 +183 -332
- package/bridge/ghidra/ReaGhidraBridge.java +561 -74
- package/bridge/hopper_bridge.py +70 -27
- package/bridge/native/ReaNativeUI.swift +157 -0
- package/dist/application/AnalysisContextQueries.js +19 -5
- package/dist/application/AnalysisSnapshotCache.js +30 -11
- package/dist/application/AppleAssetCatalogAnalysis.js +171 -0
- package/dist/application/ArtifactExtractionDestination.js +0 -12
- package/dist/application/ArtifactGraphConstruction.js +44 -11
- package/dist/application/ArtifactInventory/classify.js +7 -15
- package/dist/application/ArtifactInventory/hash.js +4 -2
- package/dist/application/ArtifactInventory/policy.js +2 -17
- package/dist/application/ArtifactInventory/reader.js +3 -3
- package/dist/application/ArtifactInventory/scanCanonical.js +2 -2
- package/dist/application/ArtifactInventory/scanReader.js +12 -4
- package/dist/application/ArtifactInventory/types.js +0 -3
- package/dist/application/BinarySession.js +28 -43
- package/dist/application/BinarySessionExecution.js +37 -1
- package/dist/application/BinaryTargetResolver.js +50 -4
- package/dist/application/BrowserEvidence.js +36 -7
- package/dist/application/BrowserObservationService.js +17 -44
- package/dist/application/BrowserScenarioCaptureService.js +2 -35
- package/dist/application/BrowserScenarioEvidence.js +13 -9
- package/dist/application/CapabilityClientRequirements.js +2 -11
- package/dist/application/CapabilityInventory.js +21 -35
- package/dist/application/ClientConfigurationDocument.js +84 -7
- package/dist/application/ClientRegistrationIdentity.js +32 -0
- package/dist/application/ClientRegistrationStatus.js +59 -6
- package/dist/application/DirectAnalysis.js +37 -58
- package/dist/application/DirectAnalysisStatus.js +4 -4
- package/dist/application/Doctor.js +89 -80
- package/dist/application/DoctorDiagnostics.js +2 -26
- package/dist/application/DoctorScope.js +8 -14
- package/dist/application/ElectronActiveEvidence.js +10 -27
- package/dist/application/ElectronActiveObservationService.js +9 -36
- package/dist/application/ElectronBoundaryAnalysis.js +2 -0
- package/dist/application/ElectronBoundaryGraphNative.js +1 -1
- package/dist/application/ElectronEvidence.js +8 -3
- package/dist/application/ElectronObservationService.js +9 -25
- package/dist/application/EnhancedLiteralTracing.js +4 -8
- package/dist/application/EnhancedTools.js +15 -35
- package/dist/application/FilesystemSnapshot.js +7 -8
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +2 -1
- package/dist/application/JavaScriptApplicationWorkflowService.js +31 -7
- package/dist/application/JavaScriptArtifactAnalysis.js +6 -4
- package/dist/application/JavaScriptArtifactFiles.js +5 -0
- package/dist/application/JavaScriptArtifactPathResolution.js +179 -47
- package/dist/application/JavaScriptRuntimeObservationEvidence.js +6 -3
- package/dist/application/JavaScriptRuntimeObservationService.js +9 -25
- package/dist/application/JavaScriptRuntimeReconciliationService.js +45 -4
- package/dist/application/JavaScriptSemanticGraphAsyncProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphChildProcessProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphDataProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphFlowProjection.js +14 -5
- package/dist/application/JsonFiles.js +1 -1
- package/dist/application/LazyAnalysisProvider.js +27 -6
- package/dist/application/ManagedMemberComparisonService.js +19 -6
- package/dist/application/NativeApiInspection.js +2 -0
- package/dist/application/NativeCallRoutes.js +72 -0
- package/dist/application/NativeDispatchMetadataInspection.js +33 -0
- package/dist/application/NativeUiActionTrace.js +73 -49
- package/dist/application/NativeValueTrace.js +320 -0
- package/dist/application/ProcessCaptureCapability.js +32 -5
- package/dist/application/ProcessCaptureEnvironment.js +9 -26
- package/dist/application/ProcessCaptureError.js +1 -5
- package/dist/application/ProcessCaptureJournal.js +3 -40
- package/dist/application/ProcessCaptureLifecycle.js +102 -111
- package/dist/application/ProcessCli.js +18 -25
- package/dist/application/ProcessEvidence.js +5 -7
- package/dist/application/ProcessFilesystemEffects.js +36 -0
- package/dist/application/ProcessHarness.js +41 -120
- package/dist/application/ProcessNormalization.js +2 -17
- package/dist/application/ProcessScenarioRuntimeValidation.js +76 -0
- package/dist/application/ReferenceSourceImport.js +3 -4
- package/dist/application/Setup.js +236 -84
- package/dist/application/SetupClientConfiguration.js +14 -9
- package/dist/application/SetupPlan.js +138 -86
- package/dist/application/SetupSkill.js +0 -1
- package/dist/application/SupportedClients.js +102 -21
- package/dist/application/Uninstall.js +31 -20
- package/dist/application/Update.js +93 -0
- package/dist/application/UpdateMaintenance.js +108 -0
- package/dist/application/UpdateRuntime.js +126 -0
- package/dist/application/runtime.js +13 -2
- package/dist/artifacts/ArtifactPaths.js +6 -8
- package/dist/artifacts/ArtifactProvider.js +94 -41
- package/dist/artifacts/AsarArtifactReader.js +19 -4
- package/dist/artifacts/KeyedArchiveReader.js +110 -0
- package/dist/artifacts/MachOSliceArtifactReader.js +53 -5
- package/dist/artifacts/ZipArtifactReader.js +18 -1
- package/dist/browser/BrowserScenarioSecrets.js +28 -1
- package/dist/browser/CdpBrowserProvider.js +36 -15
- package/dist/browser/CdpCaptureDocuments.js +22 -8
- package/dist/browser/CdpCaptureEventHandlers.js +14 -5
- package/dist/browser/CdpCaptureEventHelpers.js +13 -0
- package/dist/browser/CdpCaptureEvents.js +10 -1
- package/dist/browser/CdpElectronInspection.js +5 -10
- package/dist/browser/CdpElectronProvider.js +1 -5
- package/dist/browser/CdpElectronScripts.js +1 -1
- package/dist/browser/CdpEndpoint.js +3 -2
- package/dist/browser/CdpObservationSession.js +14 -10
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpPageCaptureScripts.js +1 -1
- package/dist/browser/CdpSafeMetadata.js +5 -4
- package/dist/browser/CdpScreenshot.js +16 -5
- package/dist/browser/CdpTargetSession.js +25 -4
- package/dist/browser/CdpWebMcpDiscovery.js +93 -20
- package/dist/browser/JavaScriptRuntimeScope.js +28 -2
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +9 -8
- package/dist/browser/PlaywrightElectronActiveActions.js +3 -10
- package/dist/browser/PlaywrightElectronActiveProvider.js +5 -5
- package/dist/browser/PlaywrightScenarioActions.js +1 -1
- package/dist/browser/PlaywrightScenarioArtifacts.js +13 -25
- package/dist/browser/PlaywrightScenarioBrowser.js +28 -25
- package/dist/browser/PlaywrightScenarioEvents.js +82 -93
- package/dist/browser/PlaywrightScenarioSession.js +27 -123
- package/dist/browser/PngVisualDiff.js +22 -3
- package/dist/browser/V8InspectorCaptureProjection.js +7 -1
- package/dist/browser/V8InspectorProvider.js +60 -7
- package/dist/browser/WebSourceMapFetcher.js +99 -53
- package/dist/cli/artifactCommands.js +56 -12
- package/dist/cli/coreAnalysisCommands.js +110 -0
- package/dist/cli/managedCommands.js +1 -31
- package/dist/cli/setupCommands.js +16 -14
- package/dist/cli/utilityCommands.js +61 -4
- package/dist/cli.js +5 -7
- package/dist/cliApplicationCommands.js +0 -83
- package/dist/cliBrowserAdvancedCommands.js +7 -11
- package/dist/cliBrowserCommands.js +15 -23
- package/dist/cliBrowserContext.js +3 -24
- package/dist/cliBrowserScenarioCommands.js +2 -10
- package/dist/cliCommandNames.js +82 -7
- package/dist/cliElectronCommands.js +10 -36
- package/dist/cliJavaScriptRuntimeCommands.js +6 -30
- package/dist/cliJsonInput.js +4 -2
- package/dist/cliLogging.js +16 -7
- package/dist/cliObservationOptions.js +1 -1
- package/dist/cliOutput.js +2 -4
- package/dist/cliProcessCommands.js +6 -33
- package/dist/cliSetup.js +90 -160
- package/dist/config/environment.js +2 -78
- package/dist/config/parseConfig.js +18 -109
- package/dist/config/parsers.js +0 -23
- package/dist/contracts/applicationToolContracts.js +1 -118
- package/dist/contracts/artifactToolContracts.js +11 -19
- package/dist/contracts/browserScenarioToolContracts.js +1 -5
- package/dist/contracts/browserToolContracts.js +9 -16
- package/dist/contracts/electronToolContracts.js +5 -6
- package/dist/contracts/enhancedInputs.js +3 -2
- package/dist/contracts/errorSchemas.js +16 -40
- package/dist/contracts/functionWorkflowToolContracts.js +2 -2
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +2 -2
- package/dist/contracts/javascriptRuntimeObservationToolContracts.js +4 -4
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +1 -1
- package/dist/contracts/managedToolContracts.js +7 -4
- package/dist/contracts/managedWorkflowExamples.js +0 -22
- package/dist/contracts/managedWorkflowToolContracts.js +16 -31
- package/dist/contracts/nativeToolContracts.js +9 -0
- package/dist/contracts/promptContracts.js +6 -6
- package/dist/contracts/sessionToolSchemas.js +3 -3
- package/dist/contracts/toolContractExamples.js +4 -3
- package/dist/contracts/toolContracts.js +18 -7
- package/dist/contracts/toolEffects.js +34 -21
- package/dist/contracts/toolOutputSchemaGroups.js +18 -5
- package/dist/contracts/toolOutputSchemaPrimitives.js +9 -6
- package/dist/contracts/toolSchemaMetadata.js +5 -8
- package/dist/doctorRuntime.js +0 -41
- package/dist/domain/analysisErrorPresentation.js +4 -28
- package/dist/domain/analysisErrorProjection.js +33 -50
- package/dist/domain/analysisProfile.js +1 -1
- package/dist/domain/analysisSnapshot.js +77 -3
- package/dist/domain/androidApplication.js +5 -4
- package/dist/domain/appleApplication.js +5 -4
- package/dist/domain/appleAssetCatalog.js +127 -0
- package/dist/domain/artifactComparison.js +7 -11
- package/dist/domain/artifactGraph.js +8 -6
- package/dist/domain/artifactInspection.js +13 -12
- package/dist/domain/binaryTarget.js +23 -9
- package/dist/domain/browserObservation.js +43 -24
- package/dist/domain/browserObservationSchemas.js +2 -1
- package/dist/domain/browserScenario.js +7 -107
- package/dist/domain/browserScenarioCapture.js +0 -1
- package/dist/domain/browserScenarioCaptureValues.js +5 -4
- package/dist/domain/browserScenarioDiff.js +1 -3
- package/dist/domain/browserScenarioValues.js +16 -107
- package/dist/domain/bundleComparison.js +18 -17
- package/dist/domain/callPathSchemas.js +17 -7
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/comparisonSemantics.js +19 -0
- package/dist/domain/completionLedgerGeneration.js +3 -2
- package/dist/domain/conformancePackage.js +2 -1
- package/dist/domain/conformanceTrustGate.js +3 -5
- package/dist/domain/customProtocolCapture.js +2 -2
- package/dist/domain/digests.js +30 -0
- package/dist/domain/dosMz.js +83 -0
- package/dist/domain/electronActiveObservation.js +7 -5
- package/dist/domain/electronObservation.js +3 -2
- package/dist/domain/electronStaticAnalysisNative.js +15 -6
- package/dist/domain/emptyArraySchema.js +3 -0
- package/dist/domain/errors.js +10 -28
- package/dist/domain/evidence.js +5 -3
- package/dist/domain/evidenceCompletionLedger.js +3 -2
- package/dist/domain/functionComparisonNormalization.js +24 -18
- package/dist/domain/functionComparisonResults.js +3 -7
- package/dist/domain/functionComparisonSchemas.js +3 -2
- package/dist/domain/hopperValues.js +108 -8
- package/dist/domain/javascriptApplicationAnalysis.js +4 -7
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +4 -3
- package/dist/domain/javascriptApplicationGraphSchemas.js +8 -7
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +9 -7
- package/dist/domain/javascriptApplicationVersionItems.js +12 -18
- package/dist/domain/javascriptAstValues.js +4 -0
- package/dist/domain/javascriptExportShapeComparison.js +1 -6
- package/dist/domain/javascriptExportShapeComparisonSchemas.js +6 -10
- package/dist/domain/javascriptExportShapeVariants.js +15 -2
- package/dist/domain/javascriptFeatureTraceSchemas.js +8 -7
- package/dist/domain/javascriptRuntimeObservation.js +14 -2
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +8 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +4 -2
- package/dist/domain/javascriptRuntimeReconciliationResult.js +6 -4
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +19 -18
- package/dist/domain/javascriptRuntimeStaticCandidates.js +18 -6
- package/dist/domain/javascriptSemanticAnalysis.js +57 -19
- package/dist/domain/javascriptSemanticAsyncEffects.js +39 -40
- package/dist/domain/javascriptSemanticCalls.js +46 -27
- package/dist/domain/javascriptSemanticChildProcesses.js +43 -50
- package/dist/domain/javascriptSemanticDataEffectHelpers.js +91 -18
- package/dist/domain/javascriptSemanticDataEffects.js +22 -10
- package/dist/domain/javascriptSemanticGraphSchemas.js +8 -6
- package/dist/domain/javascriptSemanticObjects.js +13 -3
- package/dist/domain/javascriptSemanticProjection.js +144 -38
- package/dist/domain/javascriptSemanticPromises.js +14 -27
- package/dist/domain/javascriptSemanticQuerySchemas.js +6 -9
- package/dist/domain/javascriptSemanticResources.js +2 -5
- package/dist/domain/javascriptSemanticState.js +4 -0
- package/dist/domain/javascriptSemanticTraceSchemas.js +2 -1
- package/dist/domain/javascriptSemanticTraversal.js +13 -5
- package/dist/domain/javascriptSemanticValues.js +10 -9
- package/dist/domain/javascriptSourceParser.js +5 -1
- package/dist/domain/javascriptStaticAnalysisCalls.js +8 -5
- package/dist/domain/javascriptStaticAnalysisHelpers.js +16 -7
- package/dist/domain/keyedArchive.js +181 -0
- package/dist/domain/managedApplicationGraph.js +4 -3
- package/dist/domain/managedArtifact.js +2 -1
- package/dist/domain/managedMemberComparison.js +18 -13
- package/dist/domain/managedMemberComparisonCoverage.js +2 -1
- package/dist/domain/managedMemberComparisonItems.js +27 -7
- package/dist/domain/managedMemberComparisonMatch.js +22 -6
- package/dist/domain/managedNativeVerificationMatch.js +2 -2
- package/dist/domain/managedNativeVerificationSchemas.js +7 -5
- package/dist/domain/managedReconstruction.js +6 -5
- package/dist/domain/nativeApiBoundary.js +7 -0
- package/dist/domain/nativeDataType.js +51 -0
- package/dist/domain/nativeInspection.js +0 -1
- package/dist/domain/nativeInstruction.js +82 -0
- package/dist/domain/nativeInvestigationGraph.js +9 -5
- package/dist/domain/nativeUiObservation.js +123 -0
- package/dist/domain/nativeValueFlow.js +17 -0
- package/dist/domain/nativeValueTrace.js +64 -0
- package/dist/domain/objcSwiftMetadata.js +39 -0
- package/dist/domain/peInspection.js +1 -0
- package/dist/domain/processCapture.js +5 -55
- package/dist/domain/processCaptureExample.js +0 -9
- package/dist/domain/processCaptureValidation.js +13 -144
- package/dist/domain/processComparison.js +3 -25
- package/dist/domain/processObservation.js +0 -29
- package/dist/domain/processScenario.js +28 -228
- package/dist/domain/processTraceDimensionProjection.js +0 -15
- package/dist/domain/processTraceEvaluation.js +0 -6
- package/dist/domain/protocolCapture.js +8 -36
- package/dist/domain/reconstructionCoverage.js +3 -2
- package/dist/domain/reconstructionObligationLedgerSchemas.js +4 -12
- package/dist/domain/reconstructionReadinessSchemas.js +4 -3
- package/dist/domain/reconstructionVerification.js +2 -1
- package/dist/domain/reconstructionVerificationSchemas.js +6 -13
- package/dist/domain/referenceSourceClassification.js +0 -110
- package/dist/domain/referenceSourceGraph.js +15 -5
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/runtimeIdentification.js +6 -5
- package/dist/domain/sourceMapContents.js +5 -0
- package/dist/domain/sourceToBundleComparison.js +3 -10
- package/dist/domain/sourceToBundleComparisonSchemas.js +7 -6
- package/dist/domain/sourceToBundleSignals.js +9 -3
- package/dist/domain/staticRuntimeCorrelation.js +5 -11
- package/dist/domain/webBundleAnalysis.js +17 -9
- package/dist/domain/webBundleAnalyzer.js +1 -1
- package/dist/domain/webCaptureDiff.js +5 -11
- package/dist/domain/webCaptureDiffSchemas.js +2 -1
- package/dist/domain/webMcpDiscovery.js +2 -1
- package/dist/dotnet/ManagedMemberInspectorCore.js +15 -7
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +57 -40
- package/dist/dotnet/ManagedMemberRows.js +2 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +15 -8
- package/dist/dotnet/ManagedPeReader.js +2 -0
- package/dist/generatedMcpToolCatalog.js +1 -1
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +15 -5
- package/dist/ghidra/GhidraClient.js +38 -8
- package/dist/ghidra/GhidraFunctionValues.js +56 -20
- package/dist/ghidra/GhidraInstallation.js +7 -4
- package/dist/ghidra/GhidraInventoryValues.js +44 -9
- package/dist/ghidra/GhidraLauncher.js +18 -3
- package/dist/ghidra/GhidraProvider.js +23 -2
- package/dist/ghidra/GhidraRequestQueue.js +45 -4
- package/dist/ghidra/GhidraSessionValues.js +5 -0
- package/dist/hopper/HopperAnalysisProfile.js +2 -0
- package/dist/hopper/HopperProvider.js +29 -6
- package/dist/hopper/HopperTargetLease.js +18 -4
- package/dist/logger.js +0 -13
- package/dist/main/messages.js +0 -1
- package/dist/main/reload.js +3 -32
- package/dist/main/shutdown.js +1 -2
- package/dist/main/transport.js +0 -17
- package/dist/main.js +0 -10
- package/dist/native/AppleDispatchMetadata.js +582 -0
- package/dist/native/AppleObjcProtocols.js +88 -0
- package/dist/native/AppleSwiftVtables.js +86 -0
- package/dist/native/CommandRunner.js +1 -1
- package/dist/native/NativeHostCapabilities.js +23 -0
- package/dist/native/NativeMacOSProvider.js +61 -9
- package/dist/native/NativeMachoInspection.js +39 -6
- package/dist/native/NativeUiHelperRuntime.js +42 -0
- package/dist/native/NativeUiObservation.js +174 -0
- package/dist/native/parsers/codesign.js +4 -1
- package/dist/native/parsers/dyldInfo.js +51 -25
- package/dist/native/parsers/lipo.js +13 -4
- package/dist/native/parsers/otool.js +84 -39
- package/dist/native/parsers/plist.js +2 -1
- package/dist/process/ExecFileOutput.js +5 -1
- package/dist/process/ProcessOwnership.js +69 -33
- package/dist/process/ProcessOwnershipObservation.js +31 -12
- package/dist/process/ProviderProcess.js +4 -2
- package/dist/reference/ReferenceSourceReaderEntries.js +48 -31
- package/dist/reference/ReferenceSourceReaderErrors.js +24 -0
- package/dist/reference/ReferenceSourceReaderFile.js +11 -5
- package/dist/reference/ReferenceSourceReaderValidate.js +22 -8
- package/dist/server/createServer.js +7 -62
- package/dist/server/registerApplicationTools/helpers.js +2 -9
- package/dist/server/registerApplicationTools.js +0 -4
- package/dist/server/registerArtifactComparisonTool.js +1 -1
- package/dist/server/registerBrowserScenarioTool.js +4 -2
- package/dist/server/registerBrowserTools.js +7 -7
- package/dist/server/registerBundleComparisonTool.js +1 -1
- package/dist/server/registerCloseLifecycleTool.js +1 -1
- package/dist/server/registerElectronTools.js +10 -4
- package/dist/server/registerEnhancedTools.js +20 -12
- package/dist/server/registerEvidenceTools.js +4 -28
- package/dist/server/registerFunctionComparisonTool.js +1 -1
- package/dist/server/registerInvestigationTools.js +6 -6
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -2
- package/dist/server/registerManagedTools.js +28 -14
- package/dist/server/registerManagedWorkflowTools.js +0 -2
- package/dist/server/registerProcessComparisonTool.js +1 -3
- package/dist/server/registerSessionRecordTools.js +9 -9
- package/dist/server/registerSessionStatusTool.js +1 -1
- package/dist/server/registerSessionTools.js +28 -57
- package/dist/server/sessionAvailabilityPolicy.js +2 -3
- package/dist/server/sessionToolPolicies.js +0 -4
- package/dist/server/toolResult.js +8 -10
- package/package.json +32 -22
- package/skills/reverse-engineer-anything/SKILL.md +15 -11
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +3 -2
- package/skills/reverse-engineer-anything/references/javascript-applications.md +3 -2
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +8 -6
- package/skills/reverse-engineer-anything/references/runtime-observation.md +15 -11
- package/dist/application/CommandShimReplay.js +0 -152
- package/dist/application/ConfiguredRoots.js +0 -19
- package/dist/application/InstrumentedJavaScriptReplayHost.js +0 -36
- package/dist/application/JavaScriptReplayPermission.js +0 -16
- package/dist/application/JavaScriptReplayPlanning.js +0 -207
- package/dist/application/JavaScriptReplayService.js +0 -274
- package/dist/application/LoopbackReplay.js +0 -389
- package/dist/application/LoopbackReplayRecorder.js +0 -129
- package/dist/application/ManagedRuntimeCorrelationService.js +0 -104
- package/dist/application/NodeRuntimeCharacterizationService.js +0 -191
- package/dist/application/PermissionAuthority.js +0 -268
- package/dist/application/PermissionConfiguration.js +0 -26
- package/dist/application/PermissionFailure.js +0 -5
- package/dist/application/ProcessCaptureAuthority.js +0 -24
- package/dist/application/ProcessCapturePermission.js +0 -13
- package/dist/application/ProcessCheckpoints.js +0 -178
- package/dist/application/ProcessReactiveCoordinator.js +0 -223
- package/dist/application/ProcessReactiveEffects.js +0 -153
- package/dist/application/ProcessReactiveHarness.js +0 -106
- package/dist/application/ProcessReactiveObservations.js +0 -105
- package/dist/application/ProjectPermissionStore.js +0 -199
- package/dist/application/RuntimeExecutableDiagnostics.js +0 -198
- package/dist/application/Upgrade.js +0 -134
- package/dist/browser/SensitiveTextCapture.js +0 -8
- package/dist/cliPolicyCommands.js +0 -185
- package/dist/config/browserScenario.js +0 -77
- package/dist/config/electronAutomation.js +0 -35
- package/dist/config/javascriptReplay.js +0 -41
- package/dist/config/managedRuntime.js +0 -25
- package/dist/config/passiveObservation.js +0 -87
- package/dist/config/permissions.js +0 -23
- package/dist/config/processCapture.js +0 -47
- package/dist/contracts/replayMachineExample.js +0 -37
- package/dist/domain/javascriptExportInstrumentation.js +0 -95
- package/dist/domain/javascriptReplay.js +0 -360
- package/dist/domain/managedRuntimeCorrelation.js +0 -181
- package/dist/domain/nodeRuntimeCharacterization.js +0 -63
- package/dist/domain/permissionPolicy.js +0 -176
- package/dist/domain/processCaptureReactiveSchema.js +0 -68
- package/dist/domain/processCaptureReactiveValidation.js +0 -180
- package/dist/domain/processReactiveCheckpointDataflow.js +0 -32
- package/dist/domain/processReactiveMatching.js +0 -196
- package/dist/domain/processReactiveRuntime.js +0 -116
- package/dist/domain/processReactiveScenario.js +0 -296
- package/dist/domain/processReactiveScenarioPreflight.js +0 -95
- package/dist/domain/processReactiveTransition.js +0 -187
- package/dist/domain/replayMachine.js +0 -320
- package/dist/domain/replayMachineRun.js +0 -168
- package/dist/domain/replayMachineRuntime.js +0 -296
- package/dist/domain/replayMachineValues.js +0 -84
- package/dist/domain/runtimeCharacterization.js +0 -84
- package/dist/replay/JavaScriptReplayWorker.js +0 -382
- package/dist/replay/JavaScriptReplayWorkerTypes.js +0 -1
- package/dist/replay/LinuxJavaScriptReplayRunner.js +0 -216
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +0 -121
- package/dist/replay/LinuxRuntimeClosure.js +0 -44
- package/dist/replay/LinuxSeccompPolicy.js +0 -40
- package/dist/replay/ReplayOutcome.js +0 -104
- package/dist/replay/ReplayProcessLifecycle.js +0 -96
- package/dist/replay/ReplaySeccompFile.js +0 -29
- package/dist/replay/ReplayWorkerProtocol.js +0 -58
- package/dist/replay/SystemJavaScriptReplayHost.js +0 -153
- package/dist/server/ProcessCaptureElicitation.js +0 -153
- package/dist/server/registerApplicationTools/characterization.js +0 -46
- package/dist/server/registerApplicationTools/controlledReplay.js +0 -31
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +0 -29
- package/dist/server/registerReplayMachineTool.js +0 -14
- package/skills/reverse-engineer-anything/references/controlled-replay.md +0 -12
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { applicationGraphEvidenceSchema } from "./javascriptApplicationEvidenceSchemas.js";
|
|
3
3
|
import { jsonValueSchema } from "./jsonValue.js";
|
|
4
|
-
|
|
4
|
+
import { digestSchema } from "./../domain/digests.js";
|
|
5
|
+
import { prefixedDigestSchema } from "./../domain/digests.js";
|
|
5
6
|
const boundedTextSchema = z.string().min(1);
|
|
6
|
-
const semanticNodeIdSchema =
|
|
7
|
+
const semanticNodeIdSchema = prefixedDigestSchema("jsrg_node");
|
|
7
8
|
const semanticRelationIdSchema = z
|
|
8
9
|
.string()
|
|
9
10
|
.regex(/^jsrg_relation_[a-f0-9]{64}$/u);
|
|
@@ -180,7 +181,7 @@ export const javaScriptSemanticNodeInputSchema = z.strictObject({
|
|
|
180
181
|
kind: z.enum(JAVASCRIPT_SEMANTIC_NODE_KINDS),
|
|
181
182
|
identity: semanticNodeIdentitySchema,
|
|
182
183
|
function_node_id: semanticNodeIdSchema.nullable(),
|
|
183
|
-
application_node_ids: z.array(
|
|
184
|
+
application_node_ids: z.array(prefixedDigestSchema("jag_node")),
|
|
184
185
|
label: z.string().min(1).nullable(),
|
|
185
186
|
properties: semanticPropertiesSchema,
|
|
186
187
|
evidence: applicationGraphEvidenceSchema,
|
|
@@ -216,6 +217,7 @@ export const JAVASCRIPT_SEMANTIC_UNKNOWN_REASONS = [
|
|
|
216
217
|
"bound-reached",
|
|
217
218
|
"dynamic-call",
|
|
218
219
|
"dynamic-property",
|
|
220
|
+
"dynamic-scope",
|
|
219
221
|
"eval-or-generated-code",
|
|
220
222
|
"incomplete-module",
|
|
221
223
|
"missing-source",
|
|
@@ -262,7 +264,7 @@ export const javaScriptSemanticFingerprintInputSchema = z.strictObject({
|
|
|
262
264
|
});
|
|
263
265
|
/** One canonical function fingerprint record. */
|
|
264
266
|
export const javaScriptSemanticFingerprintSchema = javaScriptSemanticFingerprintInputSchema.extend({
|
|
265
|
-
fingerprint_id:
|
|
267
|
+
fingerprint_id: prefixedDigestSchema("jsrg_fingerprint"),
|
|
266
268
|
fingerprint_sha256: digestSchema,
|
|
267
269
|
});
|
|
268
270
|
const familyCoverageSchema = z.strictObject({
|
|
@@ -288,7 +290,7 @@ const graphCoverageSchema = z.strictObject({
|
|
|
288
290
|
export const javaScriptSemanticGraphInputSchema = z.strictObject({
|
|
289
291
|
schema: z.literal("JavaScriptSemanticRelationGraph"),
|
|
290
292
|
root_artifact_sha256: digestSchema,
|
|
291
|
-
application_graph_id:
|
|
293
|
+
application_graph_id: prefixedDigestSchema("jag"),
|
|
292
294
|
root_node_ids: z.array(semanticNodeIdSchema).min(1),
|
|
293
295
|
nodes: z.array(javaScriptSemanticNodeSchema).min(1),
|
|
294
296
|
relations: z.array(javaScriptSemanticRelationSchema),
|
|
@@ -299,5 +301,5 @@ export const javaScriptSemanticGraphInputSchema = z.strictObject({
|
|
|
299
301
|
});
|
|
300
302
|
/** Stored JavaScript Semantic Relation Graph. */
|
|
301
303
|
export const javaScriptSemanticGraphRecordSchema = javaScriptSemanticGraphInputSchema.extend({
|
|
302
|
-
graph_id:
|
|
304
|
+
graph_id: prefixedDigestSchema("jsrg"),
|
|
303
305
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
import { semanticCallableIdForNode, semanticStaticPropertyName, } from "./javascriptSemanticProjection.js";
|
|
2
|
+
import { semanticCallableIdForNode, semanticReadsBeforeWrite, semanticStaticPropertyName, } from "./javascriptSemanticProjection.js";
|
|
3
3
|
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
4
4
|
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
|
5
|
-
import {
|
|
5
|
+
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
|
6
6
|
/** Recover bounded static property reads, writes, spreads, and destructuring. */
|
|
7
7
|
export const collectJavaScriptSemanticObjects = (program, state, callables) => {
|
|
8
8
|
const output = [];
|
|
@@ -46,6 +46,16 @@ const collectMember = (node, parent, ownerCallableId, context) => {
|
|
|
46
46
|
return;
|
|
47
47
|
const write = (t.isAssignmentExpression(parent) && parent.left === node) ||
|
|
48
48
|
(t.isUpdateExpression(parent) && parent.argument === node);
|
|
49
|
+
const readsBeforeWrite = write && semanticReadsBeforeWrite(node, parent);
|
|
50
|
+
if (readsBeforeWrite)
|
|
51
|
+
addObjectOperation({
|
|
52
|
+
node,
|
|
53
|
+
kind: "read",
|
|
54
|
+
ownerCallableId,
|
|
55
|
+
objectBindingId: expressionBindingId(node.object, state),
|
|
56
|
+
targetBindingId: null,
|
|
57
|
+
propertyName: name,
|
|
58
|
+
}, state, output);
|
|
49
59
|
addObjectOperation({
|
|
50
60
|
node,
|
|
51
61
|
kind: write ? "write" : "read",
|
|
@@ -62,7 +72,7 @@ const collectDestructuring = (node, ownerCallableId, state, output) => {
|
|
|
62
72
|
for (const property of node.id.properties) {
|
|
63
73
|
if (!t.isObjectProperty(property))
|
|
64
74
|
continue;
|
|
65
|
-
const name =
|
|
75
|
+
const name = semanticStaticPropertyName(property.key, property.computed);
|
|
66
76
|
if (name.length === 0)
|
|
67
77
|
continue;
|
|
68
78
|
const target = bindingIdentifier(property.value);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
import { resolveSemanticBindingState, semanticResolutionBlocked, } from "./javascriptSemanticState.js";
|
|
2
|
+
import { resolveSemanticBindingState, semanticResolutionBlocked, isUnshadowedGlobal, } from "./javascriptSemanticState.js";
|
|
3
3
|
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
|
4
4
|
import { evaluateSemanticBinding, evaluateSemanticProvenance, } from "./javascriptSemanticValues.js";
|
|
5
5
|
import { compareCodePoints, propertyName, range, stringValue, } from "./javascriptStaticAnalysisHelpers.js";
|
|
6
|
+
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
|
|
6
7
|
/** Retain callable identity without polluting lexical bindings. */
|
|
7
8
|
export const collectSemanticCallable = (input) => {
|
|
8
9
|
const { node, parent, containerScope, bodyScope, state } = input;
|
|
@@ -63,26 +64,37 @@ export const collectSemanticReferences = (program, state) => {
|
|
|
63
64
|
const output = [];
|
|
64
65
|
const seen = new Set();
|
|
65
66
|
traverseJavaScriptAst(program, {
|
|
66
|
-
enter: (node, parent) => {
|
|
67
|
+
enter: (node, parent, ancestors) => {
|
|
67
68
|
if (!t.isIdentifier(node) || parent === null)
|
|
68
69
|
return;
|
|
69
|
-
const role =
|
|
70
|
+
const role = semanticIdentifierRole(node, parent, ancestors);
|
|
70
71
|
if (role === null)
|
|
71
72
|
return;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
73
|
+
// A compound assignment or update reads before it writes; emit both so
|
|
74
|
+
// reference consumers see the read they actually execute.
|
|
75
|
+
const roles = role === "write" && semanticReadsBeforeWrite(node, parent)
|
|
76
|
+
? ["read", "write"]
|
|
77
|
+
: [role];
|
|
78
|
+
for (const resolvedRole of roles) {
|
|
79
|
+
const key = `${String(node.start)}:${resolvedRole}:${node.name}`;
|
|
80
|
+
if (seen.has(key))
|
|
81
|
+
continue;
|
|
82
|
+
seen.add(key);
|
|
83
|
+
const binding = resolveSemanticBindingState(state, node, node.name);
|
|
84
|
+
const blocked = binding === undefined &&
|
|
85
|
+
semanticResolutionBlocked(state, node, node.name);
|
|
86
|
+
output.push({
|
|
87
|
+
name: node.name,
|
|
88
|
+
role: resolvedRole,
|
|
89
|
+
location: range(node),
|
|
90
|
+
bindingId: binding?.bindingId ?? null,
|
|
91
|
+
resolution: binding !== undefined
|
|
92
|
+
? "resolved"
|
|
93
|
+
: blocked
|
|
94
|
+
? "unknown"
|
|
95
|
+
: "unbound",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
86
98
|
},
|
|
87
99
|
});
|
|
88
100
|
return output;
|
|
@@ -112,10 +124,10 @@ export const immutableSemanticBindings = (state) => [...state.bindingsById.value
|
|
|
112
124
|
}))
|
|
113
125
|
.sort((left, right) => compareCodePoints(left.bindingId, right.bindingId));
|
|
114
126
|
/** Recover a literal require origin plus an optional member chain. */
|
|
115
|
-
|
|
127
|
+
const semanticModuleOrigin = (node, projection, state) => {
|
|
116
128
|
if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) {
|
|
117
129
|
const nested = t.isNode(node.object)
|
|
118
|
-
? semanticModuleOrigin(node.object, projection)
|
|
130
|
+
? semanticModuleOrigin(node.object, projection, state)
|
|
119
131
|
: undefined;
|
|
120
132
|
const member = semanticStaticPropertyName(node.property, node.computed);
|
|
121
133
|
return nested === undefined || member === ""
|
|
@@ -125,6 +137,9 @@ export const semanticModuleOrigin = (node, projection) => {
|
|
|
125
137
|
if (!t.isCallExpression(node) ||
|
|
126
138
|
!t.isIdentifier(node.callee, { name: "require" }))
|
|
127
139
|
return undefined;
|
|
140
|
+
if (resolveSemanticBindingState(state, node.callee, "require") !== undefined ||
|
|
141
|
+
semanticResolutionBlocked(state, node.callee, "require"))
|
|
142
|
+
return undefined;
|
|
128
143
|
const specifier = stringValue(node.arguments[0]);
|
|
129
144
|
return specifier === undefined || projection.includes(null)
|
|
130
145
|
? undefined
|
|
@@ -133,10 +148,7 @@ export const semanticModuleOrigin = (node, projection) => {
|
|
|
133
148
|
importedPath: projection.map((segment) => String(segment)),
|
|
134
149
|
};
|
|
135
150
|
};
|
|
136
|
-
|
|
137
|
-
export const semanticStaticPropertyName = (property, computed) => computed && !t.isStringLiteral(property) && !t.isNumericLiteral(property)
|
|
138
|
-
? ""
|
|
139
|
-
: propertyName(property);
|
|
151
|
+
export { semanticStaticPropertyName } from "./javascriptAstValues.js";
|
|
140
152
|
const callableKind = (node) => {
|
|
141
153
|
if (t.isClassMethod(node) ||
|
|
142
154
|
t.isClassPrivateMethod(node) ||
|
|
@@ -160,7 +172,10 @@ const callableName = (node, parent) => {
|
|
|
160
172
|
t.isObjectMethod(node)) {
|
|
161
173
|
if (t.isPrivateName(node.key))
|
|
162
174
|
return `#${node.key.id.name}`;
|
|
163
|
-
|
|
175
|
+
// `{[key]() {}}` names nothing statically; reading `key` off the key node
|
|
176
|
+
// would report the variable name as the method name.
|
|
177
|
+
return (semanticStaticPropertyName(node.key, node.computed) ||
|
|
178
|
+
`[computed@${String(node.start ?? -1)}]`);
|
|
164
179
|
}
|
|
165
180
|
if (parent !== null &&
|
|
166
181
|
t.isVariableDeclarator(parent) &&
|
|
@@ -216,7 +231,7 @@ const collectNamedExports = (node, state) => {
|
|
|
216
231
|
});
|
|
217
232
|
};
|
|
218
233
|
const collectRequireLink = (node, state) => {
|
|
219
|
-
const origin = semanticModuleOrigin(node.init, []);
|
|
234
|
+
const origin = semanticModuleOrigin(node.init, [], state);
|
|
220
235
|
if (origin === undefined)
|
|
221
236
|
return;
|
|
222
237
|
for (const binding of requirePatternBindings(node.id, origin.importedPath))
|
|
@@ -252,10 +267,10 @@ const requirePatternBindings = (pattern, path) => {
|
|
|
252
267
|
return [];
|
|
253
268
|
};
|
|
254
269
|
const collectCommonJsExport = (node, state) => {
|
|
255
|
-
const exportedName = commonJsExportName(node.left);
|
|
270
|
+
const exportedName = commonJsExportName(node.left, state);
|
|
256
271
|
if (exportedName === undefined)
|
|
257
272
|
return;
|
|
258
|
-
const origin = semanticModuleOrigin(node.right, []);
|
|
273
|
+
const origin = semanticModuleOrigin(node.right, [], state);
|
|
259
274
|
addModuleLink(state, {
|
|
260
275
|
kind: "commonjs-export",
|
|
261
276
|
specifier: origin?.specifier ?? null,
|
|
@@ -288,12 +303,98 @@ const declarationCallableId = (declaration, localName) => {
|
|
|
288
303
|
? null
|
|
289
304
|
: semanticCallableIdForNode(declarator.init);
|
|
290
305
|
};
|
|
306
|
+
/**
|
|
307
|
+
* True when writing `node` also reads it first: a compound assignment
|
|
308
|
+
* (`+=`, `||=`, …) or an update (`++`/`--`). A plain `=` writes only.
|
|
309
|
+
*
|
|
310
|
+
* One predicate serves both member operations and identifier references so the
|
|
311
|
+
* two can never disagree about what counts as a read-modify-write.
|
|
312
|
+
*/
|
|
313
|
+
export const semanticReadsBeforeWrite = (node, parent) => (t.isAssignmentExpression(parent) &&
|
|
314
|
+
parent.left === node &&
|
|
315
|
+
parent.operator !== "=") ||
|
|
316
|
+
(t.isUpdateExpression(parent) && parent.argument === node);
|
|
317
|
+
/**
|
|
318
|
+
* Role of one identifier occurrence, given the node's ancestry.
|
|
319
|
+
*
|
|
320
|
+
* A binding inside a destructuring pattern has an ObjectProperty/ArrayPattern
|
|
321
|
+
* as its direct parent, so the immediate parent cannot tell a declaration
|
|
322
|
+
* (`const {a} = o`, `catch ({message})`) from an assignment target
|
|
323
|
+
* (`({a} = o)`, `for (a of list)`). Walking the ancestry to the nearest
|
|
324
|
+
* pattern-owning construct is what makes the distinction possible.
|
|
325
|
+
*/
|
|
326
|
+
export const semanticIdentifierRole = (node, parent, ancestors) => {
|
|
327
|
+
const patternAncestor = enclosingPatternAncestor(node, parent, ancestors);
|
|
328
|
+
if (patternAncestor !== null) {
|
|
329
|
+
if (isPatternOwnerDeclaration(patternAncestor))
|
|
330
|
+
return null;
|
|
331
|
+
return "write";
|
|
332
|
+
}
|
|
333
|
+
return semanticReferenceRole(node, parent);
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* The nearest ancestor that owns this identifier as a *bound* pattern slot, or
|
|
337
|
+
* null when the identifier is not being bound. A binding inside a pattern has
|
|
338
|
+
* an ObjectProperty/ArrayPattern parent, so the immediate parent cannot say
|
|
339
|
+
* whether the identifier declares a binding or is assigned to.
|
|
340
|
+
*
|
|
341
|
+
* Only the bound side counts: `{a = compute()}` binds `a` but merely *reads*
|
|
342
|
+
* `compute`, so the default-value side must not be mistaken for a binding.
|
|
343
|
+
*/
|
|
344
|
+
const enclosingPatternAncestor = (node, parent, ancestors) => {
|
|
345
|
+
const chain = [...ancestors, parent];
|
|
346
|
+
for (let index = chain.length - 1; index >= 0; index -= 1) {
|
|
347
|
+
const ancestor = chain[index];
|
|
348
|
+
if (ancestor === undefined || !isPatternNode(ancestor))
|
|
349
|
+
continue;
|
|
350
|
+
if (!bindsIdentifier(ancestor, parent, node))
|
|
351
|
+
continue;
|
|
352
|
+
// Found the binding slot; now find what owns the pattern.
|
|
353
|
+
for (let owner = index - 1; owner >= 0; owner -= 1) {
|
|
354
|
+
const candidate = chain[owner];
|
|
355
|
+
if (candidate === undefined)
|
|
356
|
+
continue;
|
|
357
|
+
if (t.isAssignmentExpression(candidate) ||
|
|
358
|
+
t.isForInStatement(candidate) ||
|
|
359
|
+
t.isForOfStatement(candidate))
|
|
360
|
+
return candidate;
|
|
361
|
+
if (isPatternOwnerDeclaration(candidate))
|
|
362
|
+
return candidate;
|
|
363
|
+
}
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
};
|
|
368
|
+
/** True when `parent` places `node` in the bound slot of `pattern`. */
|
|
369
|
+
const bindsIdentifier = (pattern, parent, node) => {
|
|
370
|
+
// The identifier sits directly in the pattern: `[b]`, `({b})`, `{b = 1}`.
|
|
371
|
+
if (parent === pattern)
|
|
372
|
+
return patternContains(pattern, node);
|
|
373
|
+
if (t.isObjectPattern(pattern))
|
|
374
|
+
return (t.isObjectProperty(parent) &&
|
|
375
|
+
(parent.value === node || (parent.shorthand && parent.key === node)));
|
|
376
|
+
if (t.isArrayPattern(pattern))
|
|
377
|
+
return pattern.elements.some((element) => element === parent);
|
|
378
|
+
if (t.isAssignmentPattern(pattern))
|
|
379
|
+
return pattern.left === parent;
|
|
380
|
+
return t.isRestElement(pattern) && pattern.argument === parent;
|
|
381
|
+
};
|
|
382
|
+
const isPatternNode = (node) => t.isObjectPattern(node) ||
|
|
383
|
+
t.isArrayPattern(node) ||
|
|
384
|
+
t.isAssignmentPattern(node) ||
|
|
385
|
+
t.isRestElement(node);
|
|
386
|
+
const isPatternOwnerDeclaration = (node) => (t.isVariableDeclarator(node) && t.isPattern(node.id)) ||
|
|
387
|
+
(t.isFunction(node) &&
|
|
388
|
+
node.params.some((value) => t.isPattern(value))) ||
|
|
389
|
+
(t.isCatchClause(node) && node.param !== null && t.isPattern(node.param));
|
|
291
390
|
/** Classify one identifier occurrence consistently with semantic references. */
|
|
292
391
|
export const semanticReferenceRole = (node, parent) => {
|
|
293
392
|
if (isDeclarationIdentifier(node, parent) || isNonReferenceKey(node, parent))
|
|
294
393
|
return null;
|
|
295
394
|
if ((t.isAssignmentExpression(parent) && parent.left === node) ||
|
|
296
|
-
t.isUpdateExpression(parent)
|
|
395
|
+
t.isUpdateExpression(parent) ||
|
|
396
|
+
((t.isForInStatement(parent) || t.isForOfStatement(parent)) &&
|
|
397
|
+
parent.left === node))
|
|
297
398
|
return "write";
|
|
298
399
|
if (t.isExportSpecifier(parent) && parent.local === node)
|
|
299
400
|
return "export";
|
|
@@ -361,20 +462,25 @@ const defaultDeclarationName = (declaration) => (t.isFunctionDeclaration(declara
|
|
|
361
462
|
t.isIdentifier(declaration.id)
|
|
362
463
|
? declaration.id.name
|
|
363
464
|
: null;
|
|
364
|
-
const commonJsExportName = (node) => {
|
|
365
|
-
if (
|
|
465
|
+
const commonJsExportName = (node, state) => {
|
|
466
|
+
if (isUnshadowedGlobal(node, state, "exports"))
|
|
366
467
|
return "default";
|
|
367
468
|
if (!t.isMemberExpression(node) && !t.isOptionalMemberExpression(node))
|
|
368
469
|
return undefined;
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
470
|
+
const key = memberKey(node);
|
|
471
|
+
// `exports[key]`/`module.exports[key]` assign an export whose name is not
|
|
472
|
+
// knowable. Report the wildcard rather than the variable name, and never
|
|
473
|
+
// collapse it into `default`, which would claim a real default export.
|
|
474
|
+
if (isUnshadowedGlobal(node.object, state, "exports"))
|
|
475
|
+
return key === null ? "*" : key || "*";
|
|
372
476
|
if (t.isMemberExpression(node.object) &&
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return
|
|
376
|
-
if (
|
|
377
|
-
|
|
477
|
+
isUnshadowedGlobal(node.object.object, state, "module") &&
|
|
478
|
+
memberKey(node.object) === "exports")
|
|
479
|
+
return key === null ? "*" : key || "default";
|
|
480
|
+
if (isUnshadowedGlobal(node.object, state, "module") &&
|
|
481
|
+
memberKey(node) === "exports")
|
|
378
482
|
return "default";
|
|
379
483
|
return undefined;
|
|
380
484
|
};
|
|
485
|
+
/** Exact member key, or null when a computed key commits no name. */
|
|
486
|
+
const memberKey = (node) => semanticStaticPropertyName(node.property, node.computed) || null;
|
|
@@ -3,6 +3,7 @@ import { semanticCallableIdForNode, semanticStaticPropertyName, } from "./javasc
|
|
|
3
3
|
import { resolveSemanticBindingState, semanticResolutionBlocked, } from "./javascriptSemanticState.js";
|
|
4
4
|
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
|
5
5
|
import { compareCodePoints, range, sourceRangesEqual, } from "./javascriptStaticAnalysisHelpers.js";
|
|
6
|
+
import { assignedSemanticResultBindings, containsSemanticNode, dataEffectMemberCallee, scalarAssignedResultBinding, } from "./javascriptSemanticDataEffectHelpers.js";
|
|
6
7
|
/** Recover explicit Promise construction, chaining, aggregation, and ownership. */
|
|
7
8
|
export const collectJavaScriptSemanticPromises = (program, state, callables) => {
|
|
8
9
|
const candidates = collectCandidates(program, state, callables);
|
|
@@ -61,7 +62,7 @@ const promiseCandidateDetails = (node, state) => {
|
|
|
61
62
|
isUnshadowedGlobalPromise(node.callee, state))
|
|
62
63
|
return { kind: "constructor", method: "new" };
|
|
63
64
|
if (t.isCallExpression(node) || t.isOptionalCallExpression(node)) {
|
|
64
|
-
const member =
|
|
65
|
+
const member = dataEffectMemberCallee(node);
|
|
65
66
|
if (member === null)
|
|
66
67
|
return null;
|
|
67
68
|
const method = semanticStaticPropertyName(member.property, member.computed);
|
|
@@ -83,9 +84,6 @@ const isUnshadowedGlobalPromise = (node, state) => resolveSemanticBindingState(s
|
|
|
83
84
|
!semanticResolutionBlocked(state, node, "Promise");
|
|
84
85
|
const isPromiseProducer = (node, state) => promiseCandidateDetails(unwrapExpression(node), state) !== null;
|
|
85
86
|
const semanticPromiseId = (kind, node) => `promise:${kind}:${String(node.start ?? -1)}:${String(node.end ?? -1)}`;
|
|
86
|
-
const memberCallee = (node) => t.isMemberExpression(node.callee) || t.isOptionalMemberExpression(node.callee)
|
|
87
|
-
? node.callee
|
|
88
|
-
: null;
|
|
89
87
|
const promiseOwnership = (candidate, candidateByNode, state, callables) => {
|
|
90
88
|
if (candidate.kind === "awaited-expression")
|
|
91
89
|
return emptyOwnership("awaited");
|
|
@@ -138,15 +136,14 @@ const ownershipAtAncestor = (ancestor, context) => {
|
|
|
138
136
|
: "boundary";
|
|
139
137
|
};
|
|
140
138
|
const assignedPromiseBinding = (ancestor, state) => {
|
|
141
|
-
if (t.isVariableDeclarator(ancestor) &&
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
return undefined;
|
|
139
|
+
if (!t.isVariableDeclarator(ancestor) && !t.isAssignmentExpression(ancestor))
|
|
140
|
+
return undefined;
|
|
141
|
+
const source = t.isVariableDeclarator(ancestor)
|
|
142
|
+
? ancestor.init
|
|
143
|
+
: ancestor.right;
|
|
144
|
+
if (source == null)
|
|
145
|
+
return undefined;
|
|
146
|
+
return scalarAssignedResultBinding(assignedSemanticResultBindings(source, [ancestor], state));
|
|
150
147
|
};
|
|
151
148
|
const returnedPromiseOwnership = (callableId, location, callables) => ({
|
|
152
149
|
ownership: "returned",
|
|
@@ -156,26 +153,16 @@ const returnedPromiseOwnership = (callableId, location, callables) => ({
|
|
|
156
153
|
const outerConsumesCandidate = (outer, candidate) => {
|
|
157
154
|
if (outer.kind === "chain" &&
|
|
158
155
|
(t.isCallExpression(outer.node) || t.isOptionalCallExpression(outer.node))) {
|
|
159
|
-
const member =
|
|
160
|
-
return member !== null &&
|
|
156
|
+
const member = dataEffectMemberCallee(outer.node);
|
|
157
|
+
return (member !== null && containsSemanticNode(member.object, candidate.node));
|
|
161
158
|
}
|
|
162
159
|
if (outer.kind === "aggregate" &&
|
|
163
160
|
(t.isCallExpression(outer.node) || t.isOptionalCallExpression(outer.node))) {
|
|
164
161
|
const input = outer.node.arguments[0];
|
|
165
|
-
return t.isNode(input) &&
|
|
162
|
+
return t.isNode(input) && containsSemanticNode(input, candidate.node);
|
|
166
163
|
}
|
|
167
164
|
return false;
|
|
168
165
|
};
|
|
169
|
-
const containsNode = (outer, inner) => outer.start !== null &&
|
|
170
|
-
outer.start !== undefined &&
|
|
171
|
-
outer.end !== null &&
|
|
172
|
-
outer.end !== undefined &&
|
|
173
|
-
inner.start !== null &&
|
|
174
|
-
inner.start !== undefined &&
|
|
175
|
-
inner.end !== null &&
|
|
176
|
-
inner.end !== undefined &&
|
|
177
|
-
outer.start <= inner.start &&
|
|
178
|
-
outer.end >= inner.end;
|
|
179
166
|
const emptyOwnership = (ownership) => ({
|
|
180
167
|
ownership,
|
|
181
168
|
ownerBindingId: null,
|
|
@@ -188,7 +175,7 @@ const promiseSources = (candidate, candidateByNode, state) => {
|
|
|
188
175
|
if (candidate.kind === "chain") {
|
|
189
176
|
const member = t.isCallExpression(candidate.node) ||
|
|
190
177
|
t.isOptionalCallExpression(candidate.node)
|
|
191
|
-
?
|
|
178
|
+
? dataEffectMemberCallee(candidate.node)
|
|
192
179
|
: null;
|
|
193
180
|
return member === null
|
|
194
181
|
? unresolvedPromise()
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { JAVASCRIPT_SEMANTIC_NODE_KINDS, JAVASCRIPT_SEMANTIC_RELATIONS, javaScriptSemanticNodeSchema, javaScriptSemanticRelationSchema, javaScriptSemanticUnknownSchema, } from "./javascriptSemanticGraphSchemas.js";
|
|
3
3
|
import { jsonValueSchema } from "./jsonValue.js";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { digestSchema } from "./../domain/digests.js";
|
|
5
|
+
import { prefixedDigestSchema } from "./../domain/digests.js";
|
|
6
|
+
const semanticNodeIdSchema = prefixedDigestSchema("jsrg_node");
|
|
6
7
|
const literalSeedSchema = z.strictObject({
|
|
7
8
|
kind: z.literal("literal"),
|
|
8
9
|
value: jsonValueSchema.refine((value) => value === null ||
|
|
@@ -18,7 +19,7 @@ export const javaScriptSemanticQuerySeedSchema = z.discriminatedUnion("kind", [
|
|
|
18
19
|
}),
|
|
19
20
|
z.strictObject({
|
|
20
21
|
kind: z.literal("application-node"),
|
|
21
|
-
node_id:
|
|
22
|
+
node_id: prefixedDigestSchema("jag_node"),
|
|
22
23
|
}),
|
|
23
24
|
literalSeedSchema,
|
|
24
25
|
z.strictObject({
|
|
@@ -42,9 +43,6 @@ export const javaScriptSemanticQuerySeedSchema = z.discriminatedUnion("kind", [
|
|
|
42
43
|
field: z.string().min(1),
|
|
43
44
|
}),
|
|
44
45
|
]);
|
|
45
|
-
const sourceMapAuthoritySchema = z.strictObject({
|
|
46
|
-
authority: z.literal("none"),
|
|
47
|
-
});
|
|
48
46
|
/** Parsed pure-domain query over one authenticated companion graph. */
|
|
49
47
|
export const javaScriptSemanticQueryInputSchema = z.strictObject({
|
|
50
48
|
seed: javaScriptSemanticQuerySeedSchema,
|
|
@@ -66,12 +64,11 @@ export const javaScriptSemanticQueryInputSchema = z.strictObject({
|
|
|
66
64
|
})
|
|
67
65
|
.nullable()
|
|
68
66
|
.default(null),
|
|
69
|
-
source_map_authority: sourceMapAuthoritySchema.default({ authority: "none" }),
|
|
70
67
|
});
|
|
71
68
|
/** Deterministic semantic trace result. */
|
|
72
69
|
export const javaScriptSemanticQueryResultSchema = z.strictObject({
|
|
73
|
-
query_id:
|
|
74
|
-
source_graph_id:
|
|
70
|
+
query_id: prefixedDigestSchema("jsrq"),
|
|
71
|
+
source_graph_id: prefixedDigestSchema("jsrg"),
|
|
75
72
|
seed: javaScriptSemanticQuerySeedSchema,
|
|
76
73
|
direction: javaScriptSemanticQueryInputSchema.shape.direction,
|
|
77
74
|
status: z.enum(["found", "no-match", "ambiguous", "partial", "unsupported"]),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import { semanticStaticPropertyName } from "./javascriptSemanticProjection.js";
|
|
3
3
|
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
4
|
-
import { outerDataEffectBinding, traverseDataEffects, } from "./javascriptSemanticDataEffectHelpers.js";
|
|
4
|
+
import { dataEffectMemberCallee, outerDataEffectBinding, traverseDataEffects, } from "./javascriptSemanticDataEffectHelpers.js";
|
|
5
5
|
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
|
6
6
|
const ACQUIRE_METHODS = [
|
|
7
7
|
"open",
|
|
@@ -56,7 +56,7 @@ const collectReleases = (program, context, acquisitions) => {
|
|
|
56
56
|
traverseDataEffects(program, context, (node) => {
|
|
57
57
|
if (!t.isCallExpression(node) && !t.isOptionalCallExpression(node))
|
|
58
58
|
return;
|
|
59
|
-
const member =
|
|
59
|
+
const member = dataEffectMemberCallee(node);
|
|
60
60
|
if (member === null || !t.isIdentifier(member.object))
|
|
61
61
|
return;
|
|
62
62
|
const method = RELEASE_METHODS.find((candidate) => candidate ===
|
|
@@ -126,6 +126,3 @@ const resourceModule = (specifier) => [
|
|
|
126
126
|
"tls",
|
|
127
127
|
].includes(specifier);
|
|
128
128
|
const resourceCandidateId = (candidate) => `resource:acquire:${String(candidate.node.start ?? -1)}:${String(candidate.node.end ?? -1)}`;
|
|
129
|
-
const memberCallee = (node) => t.isMemberExpression(node.callee) || t.isOptionalMemberExpression(node.callee)
|
|
130
|
-
? node.callee
|
|
131
|
-
: null;
|
|
@@ -70,3 +70,7 @@ export const semanticVariableScope = (scope, parent, state) => {
|
|
|
70
70
|
}
|
|
71
71
|
return candidate;
|
|
72
72
|
};
|
|
73
|
+
/** Identify a global name only when no lexical or dynamic environment shadows it. */
|
|
74
|
+
export const isUnshadowedGlobal = (node, state, name) => t.isIdentifier(node, { name }) &&
|
|
75
|
+
resolveSemanticBindingState(state, node, name) === undefined &&
|
|
76
|
+
!semanticResolutionBlocked(state, node, name);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { evidenceSchema } from "./evidence.js";
|
|
3
3
|
import { javaScriptSemanticQueryInputSchema, javaScriptSemanticQueryResultSchema, } from "./javascriptSemanticQuerySchemas.js";
|
|
4
|
-
|
|
4
|
+
import { prefixedDigestSchema } from "./../domain/digests.js";
|
|
5
|
+
const evidenceIdSchema = prefixedDigestSchema("ev");
|
|
5
6
|
/** Authenticated application Evidence plus one bounded semantic query. */
|
|
6
7
|
export const traceJavaScriptSemanticsInputSchema = z.strictObject({
|
|
7
8
|
application: evidenceSchema,
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Visit every Babel AST node in deterministic source-tree order.
|
|
4
|
+
*
|
|
5
|
+
* `ancestors` runs outermost-first and ends with the direct parent. Callers
|
|
6
|
+
* need it whenever meaning depends on where a node sits, not just what its
|
|
7
|
+
* immediate parent is — a binding inside `catch ({message})` or `({a} = o)`
|
|
8
|
+
* has an ObjectProperty parent, so the parent alone cannot say whether the
|
|
9
|
+
* identifier declares a binding or is assigned to.
|
|
10
|
+
*/
|
|
3
11
|
export const traverseJavaScriptAst = (root, visitor) => {
|
|
4
|
-
const visit = (node, parent) => {
|
|
5
|
-
visitor.enter(node, parent);
|
|
12
|
+
const visit = (node, parent, ancestors) => {
|
|
13
|
+
visitor.enter(node, parent, ancestors);
|
|
6
14
|
for (const child of childNodes(node))
|
|
7
|
-
visit(child, node);
|
|
15
|
+
visit(child, node, [...ancestors, node]);
|
|
8
16
|
visitor.exit?.(node, parent);
|
|
9
17
|
};
|
|
10
|
-
visit(root, null);
|
|
18
|
+
visit(root, null, []);
|
|
11
19
|
};
|
|
12
20
|
const childNodes = (node) => {
|
|
13
21
|
const keys = t.VISITOR_KEYS[node.type] ?? [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
2
|
+
import { resolveSemanticBindingState, semanticResolutionBlocked, } from "./javascriptSemanticState.js";
|
|
3
3
|
import { compareCodePoints, propertyName, stringValue, } from "./javascriptStaticAnalysisHelpers.js";
|
|
4
|
+
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
|
|
4
5
|
import { semanticAmbiguousProvenance, semanticLocalProvenance, semanticOriginsProvenance, semanticUnresolvedProvenance, uniqueSemanticOrigins, } from "./javascriptSemanticProvenance.js";
|
|
5
6
|
import { semanticPrimitiveCandidates as primitiveCandidates, semanticPrimitiveSet as primitiveSet, semanticPrimitiveValue as primitiveValue, } from "./javascriptSemanticPrimitives.js";
|
|
6
7
|
/** Evaluate one binding in the bounded constant-value lattice. */
|
|
@@ -243,7 +244,7 @@ const provenanceForBinding = (binding, context) => {
|
|
|
243
244
|
})));
|
|
244
245
|
};
|
|
245
246
|
const provenanceForExpression = (node, context) => {
|
|
246
|
-
const required = requireOrigin(node);
|
|
247
|
+
const required = requireOrigin(node, context.state);
|
|
247
248
|
if (required !== undefined)
|
|
248
249
|
return semanticOriginsProvenance([required]);
|
|
249
250
|
if (t.isIdentifier(node)) {
|
|
@@ -280,11 +281,11 @@ const provenanceForExpression = (node, context) => {
|
|
|
280
281
|
}
|
|
281
282
|
return semanticLocalProvenance();
|
|
282
283
|
};
|
|
283
|
-
const requireOrigin = (node) => {
|
|
284
|
+
const requireOrigin = (node, state) => {
|
|
284
285
|
if (t.isMemberExpression(node) || t.isOptionalMemberExpression(node)) {
|
|
285
286
|
if (!t.isNode(node.object))
|
|
286
287
|
return undefined;
|
|
287
|
-
const nested = requireOrigin(node.object);
|
|
288
|
+
const nested = requireOrigin(node.object, state);
|
|
288
289
|
const member = memberKey(node);
|
|
289
290
|
return nested === undefined || typeof member !== "string"
|
|
290
291
|
? undefined
|
|
@@ -293,6 +294,9 @@ const requireOrigin = (node) => {
|
|
|
293
294
|
if (!t.isCallExpression(node) ||
|
|
294
295
|
!t.isIdentifier(node.callee, { name: "require" }))
|
|
295
296
|
return undefined;
|
|
297
|
+
if (resolveSemanticBindingState(state, node.callee, "require") !== undefined ||
|
|
298
|
+
semanticResolutionBlocked(state, node.callee, "require"))
|
|
299
|
+
return undefined;
|
|
296
300
|
const specifier = stringValue(node.arguments[0]);
|
|
297
301
|
return specifier === undefined ? undefined : { specifier, importedPath: [] };
|
|
298
302
|
};
|
|
@@ -304,11 +308,8 @@ const mergeValues = (values) => {
|
|
|
304
308
|
: { status: "ambiguous", reason: "Branches have incompatible values." };
|
|
305
309
|
};
|
|
306
310
|
const memberKey = (node) => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (t.isStringLiteral(node.property) || t.isNumericLiteral(node.property))
|
|
310
|
-
return node.property.value;
|
|
311
|
-
return undefined;
|
|
311
|
+
const name = semanticStaticPropertyName(node.property, node.computed);
|
|
312
|
+
return name === "" ? undefined : name;
|
|
312
313
|
};
|
|
313
314
|
const nestedContext = (context, bindingId) => ({
|
|
314
315
|
state: context.state,
|
|
@@ -6,7 +6,11 @@ export const parseJavaScriptSource = (source) => {
|
|
|
6
6
|
sourceType: "unambiguous",
|
|
7
7
|
errorRecovery: true,
|
|
8
8
|
attachComment: false,
|
|
9
|
-
|
|
9
|
+
// "decorators-legacy" admits both the standard and the legacy decorator
|
|
10
|
+
// forms, including parameter decorators. Without it a decorated
|
|
11
|
+
// TypeScript source fails to parse at all rather than reporting
|
|
12
|
+
// recovered syntax, which loses every fact derived from that source.
|
|
13
|
+
plugins: ["decorators-legacy", "jsx", "typescript"],
|
|
10
14
|
});
|
|
11
15
|
}
|
|
12
16
|
catch {
|