rea-agents 3.2.1 → 4.0.1
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,389 +0,0 @@
|
|
|
1
|
-
import { createServer, } from "node:http";
|
|
2
|
-
import { WebSocketServer } from "ws";
|
|
3
|
-
import {} from "../domain/replayMachineRuntime.js";
|
|
4
|
-
import { closeReplayServer, listenOnLoopback, recordMachineEvent, readReplayRequestBody, ReplayRecorder, ReplayDelayScheduler, requestHeaders, } from "./LoopbackReplayRecorder.js";
|
|
5
|
-
const recordHttpResponse = (recorder, request, data, outcome) => recorder.record({
|
|
6
|
-
at_ms: recorder.atMs(),
|
|
7
|
-
protocol: "http",
|
|
8
|
-
direction: "response",
|
|
9
|
-
method: request.method,
|
|
10
|
-
path: request.path,
|
|
11
|
-
data,
|
|
12
|
-
outcome,
|
|
13
|
-
});
|
|
14
|
-
const handleMachineHttp = async (recorder, request, delays) => {
|
|
15
|
-
const machine = recorder.machine;
|
|
16
|
-
if (machine === undefined)
|
|
17
|
-
return;
|
|
18
|
-
const decision = recorder.dispatchMachine({
|
|
19
|
-
protocol: "http",
|
|
20
|
-
connection: "not_applicable",
|
|
21
|
-
at_ms: request.rawAtMs,
|
|
22
|
-
recorded_at_ms: request.recordedAtMs,
|
|
23
|
-
method: request.method,
|
|
24
|
-
path: request.path,
|
|
25
|
-
headers: requestHeaders(request.request),
|
|
26
|
-
body: request.body,
|
|
27
|
-
});
|
|
28
|
-
recordMachineEvent(recorder, {
|
|
29
|
-
at_ms: request.recordedAtMs,
|
|
30
|
-
protocol: "http",
|
|
31
|
-
direction: "request",
|
|
32
|
-
method: request.method,
|
|
33
|
-
path: request.path,
|
|
34
|
-
data: request.body,
|
|
35
|
-
}, decision);
|
|
36
|
-
if (decision.outcome !== "matched") {
|
|
37
|
-
request.response.statusCode = decision.outcome === "unmatched" ? 404 : 409;
|
|
38
|
-
request.response.end();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
for (const action of decision.actions) {
|
|
42
|
-
if (action.type === "delay")
|
|
43
|
-
await delays.wait(action.duration_ms);
|
|
44
|
-
else if (action.type === "disconnect") {
|
|
45
|
-
request.response.destroy();
|
|
46
|
-
recordHttpResponse(recorder, request, "", "disconnected");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
else if (action.type === "http_response") {
|
|
50
|
-
request.response.statusCode = action.status;
|
|
51
|
-
for (const [name, value] of Object.entries(action.headers))
|
|
52
|
-
request.response.setHeader(name, value);
|
|
53
|
-
request.response.end(action.body);
|
|
54
|
-
recordHttpResponse(recorder, request, machine.redact(action.body), "matched");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const handleStaticHttp = async (recorder, request, calls, delays) => {
|
|
59
|
-
const index = recorder.scenario.replay.http.findIndex((route) => route.method !== request.method || route.path !== request.path
|
|
60
|
-
? false
|
|
61
|
-
: (route.request_body === undefined ||
|
|
62
|
-
route.request_body === request.body) &&
|
|
63
|
-
Object.entries(route.request_headers).every(([name, value]) => request.request.headers[name.toLowerCase()] === value));
|
|
64
|
-
const route = recorder.scenario.replay.http[index];
|
|
65
|
-
const used = index < 0 ? 0 : (calls.get(index) ?? 0);
|
|
66
|
-
const outcome = route === undefined
|
|
67
|
-
? "unmatched"
|
|
68
|
-
: used >= route.max_calls
|
|
69
|
-
? "script_exhausted"
|
|
70
|
-
: "matched";
|
|
71
|
-
recorder.record({
|
|
72
|
-
at_ms: recorder.atMs(),
|
|
73
|
-
protocol: "http",
|
|
74
|
-
direction: "request",
|
|
75
|
-
method: request.method,
|
|
76
|
-
path: request.path,
|
|
77
|
-
data: request.body.length === 0 ? "" : "<redacted-request-body>",
|
|
78
|
-
outcome,
|
|
79
|
-
});
|
|
80
|
-
if (route === undefined || outcome === "script_exhausted") {
|
|
81
|
-
request.response.statusCode = route === undefined ? 404 : 409;
|
|
82
|
-
request.response.end();
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
calls.set(index, used + 1);
|
|
86
|
-
if (route.delay_ms > 0)
|
|
87
|
-
await delays.wait(route.delay_ms);
|
|
88
|
-
if (route.disconnect) {
|
|
89
|
-
request.response.destroy();
|
|
90
|
-
recordHttpResponse(recorder, request, "", "disconnected");
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
request.response.statusCode = route.status;
|
|
94
|
-
for (const [name, value] of Object.entries(route.response_headers))
|
|
95
|
-
request.response.setHeader(name, value);
|
|
96
|
-
request.response.end(route.body);
|
|
97
|
-
recordHttpResponse(recorder, request, route.body, "matched");
|
|
98
|
-
};
|
|
99
|
-
const handleHttpRequest = async (recorder, request, response, calls, delays) => {
|
|
100
|
-
const body = await readReplayRequestBody(request, recorder.scenario.limits.protocol_body_bytes);
|
|
101
|
-
const method = request.method ?? "GET";
|
|
102
|
-
const path = new URL(request.url ?? "/", "http://127.0.0.1").pathname;
|
|
103
|
-
if (body === undefined) {
|
|
104
|
-
recorder.truncated = true;
|
|
105
|
-
response.statusCode = 413;
|
|
106
|
-
response.end();
|
|
107
|
-
recorder.record({
|
|
108
|
-
at_ms: recorder.atMs(),
|
|
109
|
-
protocol: "http",
|
|
110
|
-
direction: "request",
|
|
111
|
-
method,
|
|
112
|
-
path,
|
|
113
|
-
data: "<body-over-limit>",
|
|
114
|
-
outcome: "unmatched",
|
|
115
|
-
});
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
const replayRequest = {
|
|
119
|
-
request,
|
|
120
|
-
response,
|
|
121
|
-
method,
|
|
122
|
-
path,
|
|
123
|
-
body,
|
|
124
|
-
rawAtMs: recorder.rawAtMs(),
|
|
125
|
-
recordedAtMs: recorder.atMs(),
|
|
126
|
-
};
|
|
127
|
-
await (recorder.machine === undefined
|
|
128
|
-
? handleStaticHttp(recorder, replayRequest, calls, delays)
|
|
129
|
-
: recorder.enqueueMachine(() => handleMachineHttp(recorder, replayRequest, delays)));
|
|
130
|
-
};
|
|
131
|
-
const createHttpHandler = (recorder, delays) => {
|
|
132
|
-
const calls = new Map();
|
|
133
|
-
return (request, response) => {
|
|
134
|
-
void handleHttpRequest(recorder, request, response, calls, delays).catch(() => {
|
|
135
|
-
recorder.truncated = true;
|
|
136
|
-
if (response.headersSent)
|
|
137
|
-
response.destroy();
|
|
138
|
-
else {
|
|
139
|
-
response.statusCode = 500;
|
|
140
|
-
response.end();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
const sendWebSocketScript = async (client, connection, recorder, delays) => {
|
|
146
|
-
const scripts = recorder.scenario.replay.websocket_connections;
|
|
147
|
-
const script = scripts[connection - 1];
|
|
148
|
-
if (scripts.length > 0 && script === undefined) {
|
|
149
|
-
recorder.record({
|
|
150
|
-
at_ms: recorder.atMs(),
|
|
151
|
-
protocol: "websocket",
|
|
152
|
-
direction: "sent",
|
|
153
|
-
method: null,
|
|
154
|
-
path: "/ws",
|
|
155
|
-
data: "",
|
|
156
|
-
outcome: "script_exhausted",
|
|
157
|
-
});
|
|
158
|
-
client.terminate();
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
const messages = script?.messages ??
|
|
162
|
-
recorder.scenario.replay.websocket_messages.map((data) => ({
|
|
163
|
-
data,
|
|
164
|
-
delay_ms: 0,
|
|
165
|
-
}));
|
|
166
|
-
for (const message of messages) {
|
|
167
|
-
if (message.delay_ms > 0)
|
|
168
|
-
await delays.wait(message.delay_ms);
|
|
169
|
-
if (client.readyState !== 1)
|
|
170
|
-
return;
|
|
171
|
-
client.send(message.data);
|
|
172
|
-
recorder.record({
|
|
173
|
-
at_ms: recorder.atMs(),
|
|
174
|
-
protocol: "websocket",
|
|
175
|
-
direction: "sent",
|
|
176
|
-
method: null,
|
|
177
|
-
path: "/ws",
|
|
178
|
-
data: message.data,
|
|
179
|
-
outcome: "matched",
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
if (script?.disconnect_after === true) {
|
|
183
|
-
client.close();
|
|
184
|
-
recorder.record({
|
|
185
|
-
at_ms: recorder.atMs(),
|
|
186
|
-
protocol: "websocket",
|
|
187
|
-
direction: "sent",
|
|
188
|
-
method: null,
|
|
189
|
-
path: "/ws",
|
|
190
|
-
data: "",
|
|
191
|
-
outcome: "disconnected",
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
const runWebSocketActions = async (client, recorder, decision, path, delays) => {
|
|
196
|
-
for (const action of decision.actions) {
|
|
197
|
-
if (action.type === "delay") {
|
|
198
|
-
await delays.wait(action.duration_ms);
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
if (action.type === "disconnect") {
|
|
202
|
-
client.close();
|
|
203
|
-
recorder.record({
|
|
204
|
-
at_ms: recorder.atMs(),
|
|
205
|
-
protocol: "websocket",
|
|
206
|
-
direction: "sent",
|
|
207
|
-
method: null,
|
|
208
|
-
path,
|
|
209
|
-
data: "",
|
|
210
|
-
outcome: "disconnected",
|
|
211
|
-
});
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (action.type === "websocket_send" && client.readyState === 1) {
|
|
215
|
-
client.send(action.data);
|
|
216
|
-
recorder.record({
|
|
217
|
-
at_ms: recorder.atMs(),
|
|
218
|
-
protocol: "websocket",
|
|
219
|
-
direction: "sent",
|
|
220
|
-
method: null,
|
|
221
|
-
path,
|
|
222
|
-
data: recorder.machine?.redact(action.data) ?? action.data,
|
|
223
|
-
outcome: "matched",
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
const handleStaticWebSocket = (client, recorder, connection, path, delays) => {
|
|
229
|
-
client.on("message", (value) => recorder.record({
|
|
230
|
-
at_ms: recorder.atMs(),
|
|
231
|
-
protocol: "websocket",
|
|
232
|
-
direction: "received",
|
|
233
|
-
method: null,
|
|
234
|
-
path,
|
|
235
|
-
data: value.toString(),
|
|
236
|
-
outcome: "matched",
|
|
237
|
-
}));
|
|
238
|
-
void sendWebSocketScript(client, connection, recorder, delays);
|
|
239
|
-
};
|
|
240
|
-
const handleMachineWebSocket = (options) => {
|
|
241
|
-
const { client, request, recorder, connection, path, delays } = options;
|
|
242
|
-
const machine = recorder.machine;
|
|
243
|
-
if (machine === undefined)
|
|
244
|
-
return;
|
|
245
|
-
void recorder
|
|
246
|
-
.enqueueMachine(async () => {
|
|
247
|
-
const connectedAt = recorder.atMs();
|
|
248
|
-
const connectionDecision = recorder.dispatchMachine({
|
|
249
|
-
protocol: "websocket_connect",
|
|
250
|
-
connection: connection === 1 ? "initial" : "reconnect",
|
|
251
|
-
at_ms: recorder.rawAtMs(),
|
|
252
|
-
recorded_at_ms: connectedAt,
|
|
253
|
-
method: null,
|
|
254
|
-
path,
|
|
255
|
-
headers: requestHeaders(request),
|
|
256
|
-
body: "",
|
|
257
|
-
});
|
|
258
|
-
recordMachineEvent(recorder, {
|
|
259
|
-
at_ms: connectedAt,
|
|
260
|
-
protocol: "websocket",
|
|
261
|
-
direction: "received",
|
|
262
|
-
method: null,
|
|
263
|
-
path,
|
|
264
|
-
data: "",
|
|
265
|
-
}, connectionDecision);
|
|
266
|
-
if (connectionDecision.outcome === "matched")
|
|
267
|
-
await runWebSocketActions(client, recorder, connectionDecision, path, delays);
|
|
268
|
-
else
|
|
269
|
-
client.close();
|
|
270
|
-
})
|
|
271
|
-
.catch(() => {
|
|
272
|
-
recorder.truncated = true;
|
|
273
|
-
client.terminate();
|
|
274
|
-
});
|
|
275
|
-
client.on("message", (value) => {
|
|
276
|
-
const body = value.toString();
|
|
277
|
-
const rawAtMs = recorder.rawAtMs();
|
|
278
|
-
const recordedAtMs = recorder.atMs();
|
|
279
|
-
void recorder
|
|
280
|
-
.enqueueMachine(async () => {
|
|
281
|
-
const decision = recorder.dispatchMachine({
|
|
282
|
-
protocol: "websocket_message",
|
|
283
|
-
connection: connection === 1 ? "initial" : "reconnect",
|
|
284
|
-
at_ms: rawAtMs,
|
|
285
|
-
recorded_at_ms: recordedAtMs,
|
|
286
|
-
method: null,
|
|
287
|
-
path,
|
|
288
|
-
headers: {},
|
|
289
|
-
body,
|
|
290
|
-
});
|
|
291
|
-
recordMachineEvent(recorder, {
|
|
292
|
-
at_ms: recordedAtMs,
|
|
293
|
-
protocol: "websocket",
|
|
294
|
-
direction: "received",
|
|
295
|
-
method: null,
|
|
296
|
-
path,
|
|
297
|
-
data: body,
|
|
298
|
-
}, decision);
|
|
299
|
-
if (decision.outcome === "matched")
|
|
300
|
-
await runWebSocketActions(client, recorder, decision, path, delays);
|
|
301
|
-
})
|
|
302
|
-
.catch(() => {
|
|
303
|
-
recorder.truncated = true;
|
|
304
|
-
client.terminate();
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
};
|
|
308
|
-
const createWebSocketReplay = (server, recorder, delays) => {
|
|
309
|
-
let connections = 0;
|
|
310
|
-
const websocket = new WebSocketServer({
|
|
311
|
-
noServer: true,
|
|
312
|
-
maxPayload: recorder.scenario.limits.protocol_body_bytes,
|
|
313
|
-
clientTracking: true,
|
|
314
|
-
});
|
|
315
|
-
server.on("upgrade", (request, socket, head) => {
|
|
316
|
-
if (recorder.machine === undefined &&
|
|
317
|
-
new URL(request.url ?? "/", "http://127.0.0.1").pathname !== "/ws") {
|
|
318
|
-
socket.destroy();
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
websocket.handleUpgrade(request, socket, head, (client) => websocket.emit("connection", client, request));
|
|
322
|
-
});
|
|
323
|
-
websocket.on("connection", (client, request) => {
|
|
324
|
-
connections += 1;
|
|
325
|
-
if (connections > recorder.scenario.limits.connections) {
|
|
326
|
-
recorder.truncated = true;
|
|
327
|
-
client.terminate();
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
client.on("error", () => undefined);
|
|
331
|
-
const path = new URL(request.url ?? "/", "http://127.0.0.1").pathname;
|
|
332
|
-
if (recorder.machine === undefined)
|
|
333
|
-
handleStaticWebSocket(client, recorder, connections, path, delays);
|
|
334
|
-
else
|
|
335
|
-
handleMachineWebSocket({
|
|
336
|
-
client,
|
|
337
|
-
request,
|
|
338
|
-
recorder,
|
|
339
|
-
connection: connections,
|
|
340
|
-
path,
|
|
341
|
-
delays,
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
return websocket;
|
|
345
|
-
};
|
|
346
|
-
/** Start bounded HTTP and WebSocket replay endpoints on IPv4 loopback only. */
|
|
347
|
-
export const startLoopbackReplay = async (scenario, recordEvent = () => undefined) => {
|
|
348
|
-
const recorder = new ReplayRecorder(scenario, recordEvent);
|
|
349
|
-
const delays = new ReplayDelayScheduler();
|
|
350
|
-
const server = createServer(createHttpHandler(recorder, delays));
|
|
351
|
-
const websocket = createWebSocketReplay(server, recorder, delays);
|
|
352
|
-
let closePromise;
|
|
353
|
-
let port;
|
|
354
|
-
try {
|
|
355
|
-
port = await listenOnLoopback(server);
|
|
356
|
-
}
|
|
357
|
-
catch (cause) {
|
|
358
|
-
await closeReplayServer(server).catch(() => undefined);
|
|
359
|
-
throw cause;
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
httpUrl: `http://127.0.0.1:${String(port)}`,
|
|
363
|
-
websocketUrl: `ws://127.0.0.1:${String(port)}/ws`,
|
|
364
|
-
get events() {
|
|
365
|
-
return recorder.events.map((event) => ({ ...event }));
|
|
366
|
-
},
|
|
367
|
-
get transitions() {
|
|
368
|
-
return recorder.transitions.map((transition) => ({
|
|
369
|
-
...transition,
|
|
370
|
-
sensitive_aliases: [...transition.sensitive_aliases],
|
|
371
|
-
}));
|
|
372
|
-
},
|
|
373
|
-
get truncated() {
|
|
374
|
-
return recorder.truncated;
|
|
375
|
-
},
|
|
376
|
-
async close() {
|
|
377
|
-
closePromise ??= (async () => {
|
|
378
|
-
delays.close();
|
|
379
|
-
recorder.stopMachineAdmission();
|
|
380
|
-
await recorder.drainMachine();
|
|
381
|
-
for (const client of websocket.clients)
|
|
382
|
-
client.terminate();
|
|
383
|
-
await new Promise((resolveClose) => websocket.close(() => resolveClose()));
|
|
384
|
-
await closeReplayServer(server);
|
|
385
|
-
})();
|
|
386
|
-
await closePromise;
|
|
387
|
-
},
|
|
388
|
-
};
|
|
389
|
-
};
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { ReplayMachineRuntime, } from "../domain/replayMachineRuntime.js";
|
|
2
|
-
import { scheduleProcessDelay } from "./ProcessTimer.js";
|
|
3
|
-
/** Bounded protocol and replay-machine observations for one process run. */
|
|
4
|
-
export class ReplayRecorder {
|
|
5
|
-
scenario;
|
|
6
|
-
recordEvent;
|
|
7
|
-
events = [];
|
|
8
|
-
started = Date.now();
|
|
9
|
-
machine;
|
|
10
|
-
#machineQueue = Promise.resolve();
|
|
11
|
-
#machineAdmissionOpen = true;
|
|
12
|
-
truncated = false;
|
|
13
|
-
constructor(scenario, recordEvent = () => undefined) {
|
|
14
|
-
this.scenario = scenario;
|
|
15
|
-
this.recordEvent = recordEvent;
|
|
16
|
-
this.machine =
|
|
17
|
-
scenario.replay.machine === null
|
|
18
|
-
? undefined
|
|
19
|
-
: new ReplayMachineRuntime(scenario.replay.machine);
|
|
20
|
-
}
|
|
21
|
-
get transitions() {
|
|
22
|
-
return this.machine?.timeline ?? [];
|
|
23
|
-
}
|
|
24
|
-
atMs() {
|
|
25
|
-
return (Math.floor((Date.now() - this.started) /
|
|
26
|
-
this.scenario.normalization.time_bucket_ms) * this.scenario.normalization.time_bucket_ms);
|
|
27
|
-
}
|
|
28
|
-
rawAtMs() {
|
|
29
|
-
return Date.now() - this.started;
|
|
30
|
-
}
|
|
31
|
-
enqueueMachine(operation) {
|
|
32
|
-
if (!this.#machineAdmissionOpen)
|
|
33
|
-
return Promise.reject(new Error("replay machine is closing"));
|
|
34
|
-
const result = this.#machineQueue.then(operation);
|
|
35
|
-
this.#machineQueue = result.then(() => undefined, () => undefined);
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
stopMachineAdmission() {
|
|
39
|
-
this.#machineAdmissionOpen = false;
|
|
40
|
-
}
|
|
41
|
-
async drainMachine() {
|
|
42
|
-
await this.#machineQueue;
|
|
43
|
-
}
|
|
44
|
-
dispatchMachine(event) {
|
|
45
|
-
if (this.machine === undefined)
|
|
46
|
-
throw new Error("replay machine is not configured");
|
|
47
|
-
return this.machine.dispatch(event);
|
|
48
|
-
}
|
|
49
|
-
recordTransition(decision) {
|
|
50
|
-
if (decision.transition !== null)
|
|
51
|
-
this.recordEvent("replay_transitions", decision.transition.sequence);
|
|
52
|
-
}
|
|
53
|
-
record(event) {
|
|
54
|
-
if (this.events.length >= this.scenario.limits.protocol_events) {
|
|
55
|
-
this.truncated = true;
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const sequence = this.events.length;
|
|
59
|
-
this.events.push({ sequence, ...event });
|
|
60
|
-
this.recordEvent("protocol_events", sequence);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
export const requestHeaders = (request) => Object.fromEntries(Object.entries(request.headers).flatMap(([name, value]) => value === undefined
|
|
64
|
-
? []
|
|
65
|
-
: [[name, Array.isArray(value) ? value.join(", ") : value]]));
|
|
66
|
-
export const readReplayRequestBody = async (request, limit) => {
|
|
67
|
-
const chunks = [];
|
|
68
|
-
let bytes = 0;
|
|
69
|
-
for await (const chunk of request) {
|
|
70
|
-
const value = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
71
|
-
bytes += value.byteLength;
|
|
72
|
-
if (bytes > limit)
|
|
73
|
-
return undefined;
|
|
74
|
-
chunks.push(value);
|
|
75
|
-
}
|
|
76
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
77
|
-
};
|
|
78
|
-
export const recordMachineEvent = (recorder, event, decision) => {
|
|
79
|
-
recorder.record({
|
|
80
|
-
...event,
|
|
81
|
-
data: recorder.machine?.redact(event.data) ?? event.data,
|
|
82
|
-
outcome: decision.outcome,
|
|
83
|
-
});
|
|
84
|
-
recorder.recordTransition(decision);
|
|
85
|
-
};
|
|
86
|
-
/** Owns replay delays so endpoint shutdown can release every waiting handler. */
|
|
87
|
-
export class ReplayDelayScheduler {
|
|
88
|
-
#pending = new Map();
|
|
89
|
-
#closed = false;
|
|
90
|
-
wait(durationMs) {
|
|
91
|
-
if (this.#closed)
|
|
92
|
-
return Promise.resolve();
|
|
93
|
-
return new Promise((resolveDelay) => {
|
|
94
|
-
let timer;
|
|
95
|
-
const finish = () => {
|
|
96
|
-
this.#pending.delete(timer);
|
|
97
|
-
resolveDelay();
|
|
98
|
-
};
|
|
99
|
-
timer = scheduleProcessDelay(durationMs, finish);
|
|
100
|
-
this.#pending.set(timer, finish);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
close() {
|
|
104
|
-
if (this.#closed)
|
|
105
|
-
return;
|
|
106
|
-
this.#closed = true;
|
|
107
|
-
for (const [timer, finish] of this.#pending) {
|
|
108
|
-
timer.cancel();
|
|
109
|
-
finish();
|
|
110
|
-
}
|
|
111
|
-
this.#pending.clear();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export const listenOnLoopback = async (server) => {
|
|
115
|
-
await new Promise((resolveListen, rejectListen) => {
|
|
116
|
-
server.once("error", rejectListen);
|
|
117
|
-
server.listen(0, "127.0.0.1", () => {
|
|
118
|
-
server.off("error", rejectListen);
|
|
119
|
-
resolveListen();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
const address = server.address();
|
|
123
|
-
if (address === null || typeof address === "string")
|
|
124
|
-
throw new Error("loopback replay did not acquire a TCP port");
|
|
125
|
-
return address.port;
|
|
126
|
-
};
|
|
127
|
-
export const closeReplayServer = (server) => new Promise((resolveClose, rejectClose) => {
|
|
128
|
-
server.close((error) => error === undefined ? resolveClose() : rejectClose(error));
|
|
129
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { projectPermissionFailure } from "./PermissionFailure.js";
|
|
2
|
-
import { AnalysisCapabilityUnavailableError, AnalysisInputError, AnalysisProtocolError, } from "../domain/errors.js";
|
|
3
|
-
import { createEvidence, parseEvidence, } from "../domain/evidence.js";
|
|
4
|
-
import { jsonValueSchema } from "../domain/jsonValue.js";
|
|
5
|
-
import { managedRuntimeCorrelationInputSchema, planManagedRuntimeCorrelation, } from "../domain/managedRuntimeCorrelation.js";
|
|
6
|
-
import { err, ok } from "../domain/result.js";
|
|
7
|
-
import { MANAGED_WORKFLOW_PROVIDER } from "./InvestigationProviders.js";
|
|
8
|
-
import { digestJson } from "./JavaScriptReplayPlanning.js";
|
|
9
|
-
const OPERATION = "plan_managed_runtime_correlation";
|
|
10
|
-
/** A managed-runtime policy that grants no runtime-correlation authority. */
|
|
11
|
-
export const MANAGED_RUNTIME_DISABLED = {
|
|
12
|
-
status: "disabled",
|
|
13
|
-
};
|
|
14
|
-
/** Create a separately authorized, non-executing managed runtime plan Evidence. */
|
|
15
|
-
export const planManagedRuntimeCorrelationEvidence = async (dependencies, rawInput) => {
|
|
16
|
-
const parsed = managedRuntimeCorrelationInputSchema.safeParse(rawInput);
|
|
17
|
-
if (!parsed.success)
|
|
18
|
-
return err(new AnalysisInputError(OPERATION, { cause: parsed.error }));
|
|
19
|
-
return planManagedRuntimeCorrelationEvidenceValidated(dependencies, parsed.data);
|
|
20
|
-
};
|
|
21
|
-
/** Plan runtime correlation from input parsed by a trusted adapter. */
|
|
22
|
-
export const planManagedRuntimeCorrelationEvidenceValidated = async (dependencies, input) => {
|
|
23
|
-
const policy = dependencies.policy();
|
|
24
|
-
if (policy.status === "disabled")
|
|
25
|
-
return err(new AnalysisCapabilityUnavailableError(MANAGED_WORKFLOW_PROVIDER.id, OPERATION, "managed runtime correlation is disabled; configure exact roots and runtime executable before enabling it"));
|
|
26
|
-
if (dependencies.authority === undefined)
|
|
27
|
-
return err(new AnalysisCapabilityUnavailableError(MANAGED_WORKFLOW_PROVIDER.id, OPERATION, "managed runtime permission policy is not configured"));
|
|
28
|
-
let staticEvidence, artifactPath;
|
|
29
|
-
try {
|
|
30
|
-
staticEvidence = parseEvidence(input.static_members);
|
|
31
|
-
artifactPath = artifactPathFor(staticEvidence);
|
|
32
|
-
}
|
|
33
|
-
catch (cause) {
|
|
34
|
-
return err(new AnalysisInputError(OPERATION, { cause }));
|
|
35
|
-
}
|
|
36
|
-
const authorized = await dependencies.authority.explain({
|
|
37
|
-
capability: "managed_runtime",
|
|
38
|
-
roots: [artifactPath],
|
|
39
|
-
executables: [policy.executablePath],
|
|
40
|
-
environment_names: [],
|
|
41
|
-
network: "none",
|
|
42
|
-
mount: false,
|
|
43
|
-
operation_identity: operationIdentity(input, staticEvidence),
|
|
44
|
-
}, "read", { remediation: "restart" });
|
|
45
|
-
if (!authorized.ok)
|
|
46
|
-
return err(projectPermissionFailure(authorized.error));
|
|
47
|
-
try {
|
|
48
|
-
const result = planManagedRuntimeCorrelation(input, policy.executablePath, authorized.value.grant_id);
|
|
49
|
-
return ok(createEvidence({
|
|
50
|
-
path: result.static_observation.artifact_path,
|
|
51
|
-
sha256: result.static_observation.artifact_sha256,
|
|
52
|
-
format: "pe",
|
|
53
|
-
}, MANAGED_WORKFLOW_PROVIDER, {
|
|
54
|
-
predicateType: "rea.managed-runtime-correlation-plan",
|
|
55
|
-
operation: OPERATION,
|
|
56
|
-
parameters: {
|
|
57
|
-
static_members_evidence_id: staticEvidence.evidence_id,
|
|
58
|
-
method: jsonValueSchema.parse(input.method),
|
|
59
|
-
requested_effect: input.requested_effect,
|
|
60
|
-
host: jsonValueSchema.parse(input.host),
|
|
61
|
-
bounds: jsonValueSchema.parse(input.bounds),
|
|
62
|
-
},
|
|
63
|
-
result: jsonValueSchema.parse(result),
|
|
64
|
-
rawResult: null,
|
|
65
|
-
confidence: "derived",
|
|
66
|
-
authority: "analyst-inference",
|
|
67
|
-
environment: null,
|
|
68
|
-
limitations: result.limitations,
|
|
69
|
-
locations: [
|
|
70
|
-
{
|
|
71
|
-
kind: "artifact-path",
|
|
72
|
-
path: result.static_observation.artifact_path,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
evidenceLinks: result.evidence_links,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
catch (cause) {
|
|
79
|
-
return err(cause instanceof TypeError
|
|
80
|
-
? new AnalysisInputError(OPERATION, { cause })
|
|
81
|
-
: new AnalysisProtocolError("Managed runtime correlation planning produced an invalid result", { cause }));
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const artifactPathFor = (evidence) => {
|
|
85
|
-
const result = evidence.normalized_result;
|
|
86
|
-
if (typeof result === "object" &&
|
|
87
|
-
result !== null &&
|
|
88
|
-
"artifact" in result &&
|
|
89
|
-
typeof result.artifact === "object" &&
|
|
90
|
-
result.artifact !== null &&
|
|
91
|
-
"path" in result.artifact &&
|
|
92
|
-
typeof result.artifact.path === "string")
|
|
93
|
-
return result.artifact.path;
|
|
94
|
-
throw new AnalysisInputError(OPERATION, {
|
|
95
|
-
cause: new TypeError("Managed member Evidence does not expose an artifact path"),
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
const operationIdentity = (input, evidence) => `${OPERATION}:${digestJson({
|
|
99
|
-
evidence_id: evidence.evidence_id,
|
|
100
|
-
method: input.method,
|
|
101
|
-
requested_effect: input.requested_effect,
|
|
102
|
-
host: input.host,
|
|
103
|
-
bounds: input.bounds,
|
|
104
|
-
})}`;
|