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,20 +1,19 @@
|
|
|
1
1
|
import { parseProcessCapture } from "../domain/processCapture.js";
|
|
2
2
|
import { err, ok } from "../domain/result.js";
|
|
3
|
+
import { AnalysisCapabilityUnavailableError, } from "../domain/errors.js";
|
|
3
4
|
import { ProcessCaptureError, processCaptureCancelled, } from "./ProcessCaptureError.js";
|
|
4
5
|
export { ProcessCaptureError } from "./ProcessCaptureError.js";
|
|
5
|
-
import { startLoopbackReplay } from "./LoopbackReplay.js";
|
|
6
6
|
import { startProcessSampler } from "./ProcessSampling.js";
|
|
7
7
|
import { snapshotRoots } from "./FilesystemSnapshot.js";
|
|
8
|
-
import { ProcessCheckpoints } from "./ProcessCheckpoints.js";
|
|
9
8
|
import { TerminalRenderer } from "./TerminalRenderer.js";
|
|
10
|
-
import {
|
|
11
|
-
import { normalizeProcessShimEvent, normalizeProcessText, } from "./ProcessNormalization.js";
|
|
9
|
+
import { normalizeProcessText } from "./ProcessNormalization.js";
|
|
12
10
|
import { selectCapturedProcessGroupIds } from "../process/ProcessOwnership.js";
|
|
13
|
-
import { awaitTerminalExit, buildCaptureResult, captureTerminalFrames, createRunManifest, observeSettlement, prepareProcessCapture, releaseProcessResources, resolveProcessResult, } from "./ProcessCaptureLifecycle.js";
|
|
14
|
-
import { assertNotCancelled } from "./
|
|
11
|
+
import { awaitTerminalExit, buildCaptureResult, captureTerminalFrames, createRunManifest, observeSettlement, prepareProcessCapture, releaseProcessResources, resolveProcessResult, settleProcessCaptureJournal, } from "./ProcessCaptureLifecycle.js";
|
|
12
|
+
import { assertNotCancelled, resolveProcessScenarioRuntimePaths, } from "./ProcessScenarioRuntimeValidation.js";
|
|
15
13
|
import { createProcessCaptureJournal, scheduleScenarioInteractions, } from "./ProcessCaptureJournal.js";
|
|
16
|
-
import { assertSupportedReactiveScenario, projectProcessReactiveRun, startProcessReactiveHarness, } from "./ProcessReactiveHarness.js";
|
|
17
14
|
import { makeProcessCaptureEnvironment } from "./ProcessCaptureEnvironment.js";
|
|
15
|
+
import { classifyFilesystemEffects } from "./ProcessFilesystemEffects.js";
|
|
16
|
+
import { processCaptureOwnershipUnavailableReason } from "./ProcessCaptureCapability.js";
|
|
18
17
|
export { probeProcessCaptureCapability } from "./ProcessCaptureCapability.js";
|
|
19
18
|
const cleanupFailedStartup = async (options) => {
|
|
20
19
|
options.terminal?.kill("SIGKILL");
|
|
@@ -37,59 +36,19 @@ const createTerminalRenderer = (scenario, temporaryRoot, terminalPid, recordEven
|
|
|
37
36
|
normalize: (value) => normalizeProcessText(value, scenario, temporaryRoot, terminalPid()),
|
|
38
37
|
recordEvent,
|
|
39
38
|
});
|
|
40
|
-
/**
|
|
41
|
-
* Wait until the capture journal stops growing.
|
|
42
|
-
*
|
|
43
|
-
* node-pty reports buffered output through `onData` callbacks rather than an
|
|
44
|
-
* awaitable read, so chunks can still be in flight after the child exits. The
|
|
45
|
-
* quiet interval is measured in elapsed time rather than scheduler turns:
|
|
46
|
-
* consecutive `setImmediate` turns elapse in microseconds, so any fixed number
|
|
47
|
-
* of them finishes long before a delayed pty callback under host contention,
|
|
48
|
-
* which is exactly when the trailing chunk matters. `maxWaitMs` bounds the
|
|
49
|
-
* total wait so a pathological stream cannot stall exit.
|
|
50
|
-
*/
|
|
51
|
-
const settleTrailingJournal = async (journal, quietMs = 25, maxWaitMs = 500) => {
|
|
52
|
-
const deadline = Date.now() + maxWaitMs;
|
|
53
|
-
let observed = journal.length;
|
|
54
|
-
let lastChangeAt = Date.now();
|
|
55
|
-
while (Date.now() < deadline) {
|
|
56
|
-
await new Promise((resolve) => setTimeout(resolve, 4));
|
|
57
|
-
if (journal.length !== observed) {
|
|
58
|
-
observed = journal.length;
|
|
59
|
-
lastChangeAt = Date.now();
|
|
60
|
-
}
|
|
61
|
-
else if (Date.now() - lastChangeAt >= quietMs)
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const reactiveCapture = (options, protocolEvents) => ({
|
|
66
|
-
...options,
|
|
67
|
-
processSamples: options.samples,
|
|
68
|
-
protocolEvents,
|
|
69
|
-
});
|
|
70
39
|
const startCaptureRuntime = async (options) => {
|
|
71
40
|
const { scenario } = options;
|
|
72
|
-
let replay;
|
|
73
41
|
let renderer;
|
|
74
|
-
let checkpoints;
|
|
75
|
-
let shimReplay;
|
|
76
42
|
let terminal;
|
|
77
|
-
let reactive;
|
|
78
43
|
try {
|
|
79
44
|
const { spawn } = await import("@lydell/node-pty");
|
|
80
|
-
replay = await startLoopbackReplay(scenario, options.recordEvent);
|
|
81
45
|
const startedAt = new Date();
|
|
82
46
|
const started = Date.now();
|
|
83
47
|
let lastOutput = started;
|
|
84
48
|
renderer = createTerminalRenderer(scenario, options.temporaryRoot, () => terminal?.pid ?? -1, options.recordEvent);
|
|
85
|
-
checkpoints = new ProcessCheckpoints(scenario, started, options.before, {
|
|
86
|
-
signal: options.signal,
|
|
87
|
-
recordEvent: options.recordEvent,
|
|
88
|
-
});
|
|
89
|
-
shimReplay = await startCommandShimReplay(scenario, options.temporaryRoot, started, options.recordEvent);
|
|
90
49
|
terminal = spawn(scenario.executable, [...scenario.arguments], {
|
|
91
50
|
cwd: scenario.working_directory,
|
|
92
|
-
env: makeProcessCaptureEnvironment(
|
|
51
|
+
env: makeProcessCaptureEnvironment(options),
|
|
93
52
|
cols: scenario.terminal.columns,
|
|
94
53
|
rows: scenario.terminal.rows,
|
|
95
54
|
name: "xterm-256color",
|
|
@@ -100,16 +59,6 @@ const startCaptureRuntime = async (options) => {
|
|
|
100
59
|
started,
|
|
101
60
|
onOutput: () => (lastOutput = Date.now()),
|
|
102
61
|
renderer,
|
|
103
|
-
checkpoints,
|
|
104
|
-
});
|
|
105
|
-
reactive = startProcessReactiveHarness({
|
|
106
|
-
capture: reactiveCapture(options, () => replay?.events ?? []),
|
|
107
|
-
scenario,
|
|
108
|
-
terminal: () => terminal,
|
|
109
|
-
renderer,
|
|
110
|
-
checkpoints,
|
|
111
|
-
shimReplay,
|
|
112
|
-
started,
|
|
113
62
|
});
|
|
114
63
|
scheduleScenarioInteractions({
|
|
115
64
|
...options,
|
|
@@ -126,57 +75,38 @@ const startCaptureRuntime = async (options) => {
|
|
|
126
75
|
recordEvent: options.recordEvent,
|
|
127
76
|
});
|
|
128
77
|
return {
|
|
129
|
-
replay,
|
|
130
78
|
renderer,
|
|
131
|
-
checkpoints,
|
|
132
|
-
shimReplay,
|
|
133
79
|
terminal,
|
|
134
80
|
started,
|
|
135
81
|
startedAt,
|
|
136
82
|
lastOutput: () => lastOutput,
|
|
137
83
|
framesTruncated,
|
|
138
84
|
stopSampler,
|
|
139
|
-
reactive,
|
|
140
85
|
};
|
|
141
86
|
}
|
|
142
87
|
catch (cause) {
|
|
143
|
-
reactive?.unsubscribe();
|
|
144
|
-
await reactive?.coordinator.close();
|
|
145
88
|
return cleanupFailedStartup({
|
|
146
89
|
cause,
|
|
147
90
|
timers: options.timers,
|
|
148
|
-
replay,
|
|
149
91
|
terminal,
|
|
150
92
|
renderer,
|
|
151
|
-
shimReplay,
|
|
152
|
-
checkpoints,
|
|
153
93
|
runId: options.runId,
|
|
154
94
|
temporaryRoot: options.temporaryRoot,
|
|
155
95
|
});
|
|
156
96
|
}
|
|
157
97
|
};
|
|
158
|
-
const normalizedShimEvents = (runtime, scenario, temporaryRoot) => runtime.shimReplay.events.map((event) => normalizeProcessShimEvent(event, scenario, temporaryRoot, runtime.terminal.pid));
|
|
159
98
|
const finishProcessRun = async (options) => {
|
|
160
|
-
options.runtime?.reactive?.unsubscribe();
|
|
161
99
|
await options.stopSampler();
|
|
162
100
|
const cleanupFailure = await releaseProcessResources({
|
|
163
101
|
timers: options.timers,
|
|
164
|
-
replay: options.runtime?.replay,
|
|
165
102
|
terminal: options.runtime?.terminal,
|
|
166
103
|
renderer: options.runtime?.renderer,
|
|
167
|
-
shimReplay: options.runtime?.shimReplay,
|
|
168
|
-
checkpoints: options.runtime?.checkpoints,
|
|
169
104
|
runId: options.runId,
|
|
170
105
|
temporaryRoot: options.temporaryRoot,
|
|
171
106
|
capturedProcessGroupIds: options.runtime === undefined
|
|
172
107
|
? []
|
|
173
108
|
: selectCapturedProcessGroupIds(options.runtime.terminal.pid, options.samples),
|
|
174
109
|
});
|
|
175
|
-
if (cleanupFailure !== undefined)
|
|
176
|
-
await options.runtime?.reactive?.coordinator.submit({
|
|
177
|
-
kind: "cleanup_failed",
|
|
178
|
-
});
|
|
179
|
-
await options.runtime?.reactive?.coordinator.close();
|
|
180
110
|
let { capture, executionFailure } = options;
|
|
181
111
|
let verifiedCapture;
|
|
182
112
|
if (capture !== undefined && cleanupFailure === undefined) {
|
|
@@ -185,7 +115,6 @@ const finishProcessRun = async (options) => {
|
|
|
185
115
|
: { ...capture.settlement, cleanup_outcome: "cleaned" };
|
|
186
116
|
const completedCapture = {
|
|
187
117
|
...capture,
|
|
188
|
-
reactive_run: projectProcessReactiveRun(options.runtime?.reactive),
|
|
189
118
|
settlement,
|
|
190
119
|
cleanup: {
|
|
191
120
|
owned_process_group: "verified",
|
|
@@ -203,45 +132,35 @@ const finishProcessRun = async (options) => {
|
|
|
203
132
|
};
|
|
204
133
|
const completeCapture = async (options) => {
|
|
205
134
|
const { runtime, scenario } = options;
|
|
206
|
-
runtime.checkpoints.trigger("root_exit");
|
|
207
135
|
const { reason } = options.exit;
|
|
208
|
-
if (reason === "cancelled")
|
|
209
|
-
if (runtime.reactive !== undefined) {
|
|
210
|
-
await runtime.reactive.coordinator.submit({ kind: "cancelled" });
|
|
211
|
-
runtime.reactive.unsubscribe();
|
|
212
|
-
}
|
|
136
|
+
if (reason === "cancelled")
|
|
213
137
|
throw processCaptureCancelled();
|
|
214
|
-
|
|
215
|
-
const settlement = await observeSettlement(options.runId, selectCapturedProcessGroupIds(runtime.terminal.pid, options.samples), scenario.settle_ms, options.recordEvent);
|
|
216
|
-
runtime.checkpoints.trigger("settled");
|
|
138
|
+
const settlement = await observeSettlement(options.runId, selectCapturedProcessGroupIds(runtime.terminal.pid, options.samples), scenario.settle_ms, options.recordEvent, options.hostPlatform);
|
|
217
139
|
const samplingPartial = (await runtime.stopSampler()).partial;
|
|
218
|
-
|
|
219
|
-
// Process, filesystem, shim, and protocol observations can be recorded
|
|
220
|
-
// during settlement after the PTY exits. Make target loss terminal only
|
|
221
|
-
// after that journal has drained, otherwise the coordinator's control
|
|
222
|
-
// priority discards a valid multi-source completion predicate.
|
|
223
|
-
//
|
|
224
|
-
// Draining the coordinator is not sufficient on its own: node-pty delivers
|
|
225
|
-
// buffered output through onData callbacks, which run outside the
|
|
226
|
-
// coordinator's queue. A trailing chunk that has not been delivered yet has
|
|
227
|
-
// produced no journal entry, so the drain has nothing to wait for and the
|
|
228
|
-
// target is declared lost while a terminal trigger is still satisfiable.
|
|
229
|
-
// Let any trailing chunks land first.
|
|
230
|
-
await settleTrailingJournal(options.eventJournal);
|
|
231
|
-
await runtime.reactive.coordinator.drain();
|
|
232
|
-
await runtime.reactive.coordinator.submit({ kind: "target_lost" });
|
|
233
|
-
runtime.reactive.unsubscribe();
|
|
234
|
-
}
|
|
140
|
+
await settleProcessCaptureJournal(options.eventJournal);
|
|
235
141
|
assertNotCancelled(options.signal);
|
|
236
142
|
const after = await snapshotRoots(scenario, options.signal);
|
|
143
|
+
options.recordEvent("filesystem_checkpoints", 1);
|
|
237
144
|
const renderedFrames = await runtime.renderer.frames();
|
|
238
|
-
const checkpoints =
|
|
239
|
-
|
|
240
|
-
|
|
145
|
+
const checkpoints = [
|
|
146
|
+
{
|
|
147
|
+
name: "before",
|
|
148
|
+
at_ms: 0,
|
|
149
|
+
files: options.before.files,
|
|
150
|
+
effects: [],
|
|
151
|
+
truncated: options.before.truncated,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "after_settlement",
|
|
155
|
+
at_ms: Math.max(0, Date.now() - runtime.started),
|
|
156
|
+
files: after.files,
|
|
157
|
+
effects: classifyFilesystemEffects(options.before.files, after.files),
|
|
158
|
+
truncated: after.truncated,
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
const manifest = await createRunManifest(scenario, runtime.startedAt, new Date(), { platform: options.hostPlatform, architecture: process.arch });
|
|
241
162
|
const truncated = options.initiallyTruncated ||
|
|
242
163
|
after.truncated ||
|
|
243
|
-
runtime.replay.truncated ||
|
|
244
|
-
runtime.shimReplay.truncated ||
|
|
245
164
|
runtime.framesTruncated() ||
|
|
246
165
|
checkpoints.some(({ truncated: partial }) => partial) ||
|
|
247
166
|
samplingPartial ||
|
|
@@ -250,7 +169,6 @@ const completeCapture = async (options) => {
|
|
|
250
169
|
frames: options.frames,
|
|
251
170
|
exit: { ...options.exit, reason },
|
|
252
171
|
samples: options.samples,
|
|
253
|
-
replay: runtime.replay,
|
|
254
172
|
before: options.before,
|
|
255
173
|
after,
|
|
256
174
|
truncated,
|
|
@@ -260,20 +178,19 @@ const completeCapture = async (options) => {
|
|
|
260
178
|
renderedFrames,
|
|
261
179
|
interactions: options.interactions,
|
|
262
180
|
checkpoints,
|
|
263
|
-
shimEvents: normalizedShimEvents(runtime, scenario, options.temporaryRoot),
|
|
264
181
|
settlement,
|
|
265
182
|
manifest,
|
|
266
183
|
eventJournal: options.eventJournal,
|
|
267
184
|
});
|
|
268
185
|
};
|
|
269
|
-
/** Execute one
|
|
270
|
-
const runProcessScenario = async (scenario,
|
|
271
|
-
|
|
272
|
-
const { temporaryRoot, runId, home, before } = await prepareProcessCapture(scenario, policy, signal);
|
|
186
|
+
/** Execute one caller-selected scenario and return bounded observations. */
|
|
187
|
+
const runProcessScenario = async (scenario, signal, hostEnvironment = process.env, hostPlatform = process.platform) => {
|
|
188
|
+
const { temporaryRoot, runId, before } = await prepareProcessCapture(scenario, signal);
|
|
273
189
|
const frames = [];
|
|
274
190
|
const samples = [];
|
|
275
191
|
const journal = createProcessCaptureJournal();
|
|
276
192
|
const { entries: eventJournal, recordEvent } = journal;
|
|
193
|
+
recordEvent("filesystem_checkpoints", 0);
|
|
277
194
|
let runtime;
|
|
278
195
|
const timers = new Set();
|
|
279
196
|
let capture;
|
|
@@ -284,17 +201,15 @@ const runProcessScenario = async (scenario, policy, signal) => {
|
|
|
284
201
|
try {
|
|
285
202
|
runtime = await startCaptureRuntime({
|
|
286
203
|
scenario,
|
|
287
|
-
|
|
204
|
+
hostEnvironment,
|
|
288
205
|
temporaryRoot,
|
|
289
206
|
runId,
|
|
290
|
-
before,
|
|
291
207
|
frames,
|
|
292
208
|
samples,
|
|
293
209
|
interactions,
|
|
294
210
|
timers,
|
|
295
211
|
dispatchedEventIndexes,
|
|
296
212
|
recordEvent,
|
|
297
|
-
journal,
|
|
298
213
|
...(signal === undefined ? {} : { signal }),
|
|
299
214
|
});
|
|
300
215
|
stopSampler = runtime.stopSampler;
|
|
@@ -311,6 +226,7 @@ const runProcessScenario = async (scenario, policy, signal) => {
|
|
|
311
226
|
});
|
|
312
227
|
capture = await completeCapture({
|
|
313
228
|
scenario,
|
|
229
|
+
hostPlatform,
|
|
314
230
|
runtime,
|
|
315
231
|
runId,
|
|
316
232
|
temporaryRoot,
|
|
@@ -341,9 +257,14 @@ const runProcessScenario = async (scenario, policy, signal) => {
|
|
|
341
257
|
});
|
|
342
258
|
};
|
|
343
259
|
/** Execute one scenario through a typed expected-failure channel. */
|
|
344
|
-
export const captureProcessScenario = async (scenario,
|
|
260
|
+
export const captureProcessScenario = async (scenario, signal, platform = process.platform, environment = process.env) => {
|
|
261
|
+
const ownershipReason = processCaptureOwnershipUnavailableReason(platform);
|
|
262
|
+
if (ownershipReason !== undefined)
|
|
263
|
+
return err(new AnalysisCapabilityUnavailableError("rea-process", "capture_process_scenario", ownershipReason));
|
|
345
264
|
try {
|
|
346
|
-
|
|
265
|
+
assertNotCancelled(signal);
|
|
266
|
+
const resolvedScenario = await resolveProcessScenarioRuntimePaths(scenario, environment);
|
|
267
|
+
return ok(await runProcessScenario(resolvedScenario, signal, environment, platform));
|
|
347
268
|
}
|
|
348
269
|
catch (cause) {
|
|
349
270
|
return err(cause instanceof ProcessCaptureError
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
/** Bucket one elapsed process-capture timestamp under scenario normalization. */
|
|
2
2
|
export const normalizeProcessElapsedTime = (elapsedMs, timeBucketMs) => Math.floor(elapsedMs / timeBucketMs) * timeBucketMs;
|
|
3
|
-
/** Normalize
|
|
3
|
+
/** Normalize one terminal/protocol payload under explicitly selected scenario rules. */
|
|
4
4
|
export const normalizeProcessText = (value, scenario, temporaryRoot, pid) => {
|
|
5
5
|
let normalized = value;
|
|
6
|
-
for (const alias of scenario.secret_aliases) {
|
|
7
|
-
const secret = scenario.environment[alias];
|
|
8
|
-
if (secret !== undefined && secret.length > 0)
|
|
9
|
-
normalized = normalized.replaceAll(secret, "<redacted>");
|
|
10
|
-
}
|
|
11
6
|
if (scenario.normalization.paths) {
|
|
12
7
|
normalized = normalized.replaceAll(temporaryRoot, "<temporary-root>");
|
|
13
8
|
normalized = normalized.replaceAll(scenario.working_directory, "<working-directory>");
|
|
14
9
|
normalized = normalized.replaceAll(scenario.executable, "<executable>");
|
|
15
|
-
for (const [index, root] of scenario.
|
|
10
|
+
for (const [index, root] of scenario.filesystem_observation_paths.entries())
|
|
16
11
|
normalized = normalized.replaceAll(root, `<filesystem-root-${String(index)}>`);
|
|
17
12
|
}
|
|
18
13
|
if (scenario.normalization.pids)
|
|
@@ -55,12 +50,6 @@ export const normalizeProcessSamples = (samples, scenario, rootPid) => {
|
|
|
55
50
|
command: normalizeCommand(sample.command),
|
|
56
51
|
}));
|
|
57
52
|
};
|
|
58
|
-
/** Normalize one shim observation identically for live matching and capture. */
|
|
59
|
-
export const normalizeProcessShimEvent = (event, scenario, temporaryRoot, rootPid) => ({
|
|
60
|
-
...event,
|
|
61
|
-
arguments: event.arguments.map((argument) => normalizeProcessText(argument, scenario, temporaryRoot, rootPid)),
|
|
62
|
-
working_directory: normalizeProcessText(event.working_directory, scenario, temporaryRoot, rootPid),
|
|
63
|
-
});
|
|
64
53
|
const normalizePidTokens = (value, identifiers) => {
|
|
65
54
|
const tokens = [...new Set(identifiers)]
|
|
66
55
|
.filter((identifier) => Number.isSafeInteger(identifier) && identifier > 0)
|
|
@@ -70,7 +59,3 @@ const normalizePidTokens = (value, identifiers) => {
|
|
|
70
59
|
return value;
|
|
71
60
|
return value.replace(new RegExp(`(?<!\\d)(?:${tokens.join("|")})(?!\\d)`, "gu"), "<pid>");
|
|
72
61
|
};
|
|
73
|
-
export const redactProtocolEvents = (events, scenario) => events.map((event) => ({
|
|
74
|
-
...event,
|
|
75
|
-
data: normalizeProcessText(event.data, scenario, "<no-temporary-root>", -1),
|
|
76
|
-
}));
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { access, realpath, stat } from "node:fs/promises";
|
|
2
|
+
import { constants as fsConstants } from "node:fs";
|
|
3
|
+
import { delimiter, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { ProcessCaptureError, processCaptureCancelled, } from "./ProcessCaptureError.js";
|
|
5
|
+
/** Resolve caller-selected executable and observation paths for this execution. */
|
|
6
|
+
export const resolveProcessScenarioRuntimePaths = async (scenario, environment = process.env) => {
|
|
7
|
+
const selectedWorkingDirectory = resolve(scenario.working_directory);
|
|
8
|
+
let workingDirectory;
|
|
9
|
+
try {
|
|
10
|
+
workingDirectory = await realpath(selectedWorkingDirectory);
|
|
11
|
+
}
|
|
12
|
+
catch (cause) {
|
|
13
|
+
throw new ProcessCaptureError(`working directory could not be resolved: ${selectedWorkingDirectory}${osFailure(cause)}`, { cause });
|
|
14
|
+
}
|
|
15
|
+
let workingDirectoryStat;
|
|
16
|
+
try {
|
|
17
|
+
workingDirectoryStat = await stat(workingDirectory);
|
|
18
|
+
}
|
|
19
|
+
catch (cause) {
|
|
20
|
+
throw new ProcessCaptureError(`working directory could not be inspected: ${workingDirectory}${osFailure(cause)}`, { cause });
|
|
21
|
+
}
|
|
22
|
+
if (!workingDirectoryStat.isDirectory())
|
|
23
|
+
throw new ProcessCaptureError(`working directory is not a directory: ${workingDirectory}`);
|
|
24
|
+
const executable = await resolveExecutable(scenario.executable, workingDirectory, scenario.environment.PATH ?? environment.PATH ?? "");
|
|
25
|
+
const observationPaths = scenario.filesystem_observation_paths.map((path) => resolve(workingDirectory, path));
|
|
26
|
+
return {
|
|
27
|
+
...scenario,
|
|
28
|
+
executable,
|
|
29
|
+
working_directory: workingDirectory,
|
|
30
|
+
filesystem_observation_paths: observationPaths,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Resolve a selected executable through the caller's effective PATH. */
|
|
34
|
+
export const resolveExecutable = async (command, workingDirectory, searchPath) => {
|
|
35
|
+
const directories = searchPath
|
|
36
|
+
.split(delimiter)
|
|
37
|
+
.map((directory) => directory === ""
|
|
38
|
+
? workingDirectory
|
|
39
|
+
: resolve(workingDirectory, directory));
|
|
40
|
+
const candidates = isAbsolute(command) || command.includes("/") || command.includes("\\")
|
|
41
|
+
? [resolve(workingDirectory, command)]
|
|
42
|
+
: directories.map((directory) => join(directory, command));
|
|
43
|
+
const failures = [];
|
|
44
|
+
for (const candidate of candidates) {
|
|
45
|
+
try {
|
|
46
|
+
await access(candidate, fsConstants.X_OK);
|
|
47
|
+
if ((await stat(candidate)).isFile())
|
|
48
|
+
return candidate;
|
|
49
|
+
failures.push(`${candidate} (not a regular file)`);
|
|
50
|
+
}
|
|
51
|
+
catch (cause) {
|
|
52
|
+
const code = osErrorCode(cause);
|
|
53
|
+
if (code !== "ENOENT" && code !== "ENOTDIR")
|
|
54
|
+
failures.push(`${candidate}${osFailure(cause)}`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
throw new ProcessCaptureError(failures.length === 0
|
|
59
|
+
? `executable could not be resolved: ${command}`
|
|
60
|
+
: `executable could not be resolved: ${command}; checked ${failures.join("; ")}`);
|
|
61
|
+
};
|
|
62
|
+
const osErrorCode = (cause) => typeof cause === "object" &&
|
|
63
|
+
cause !== null &&
|
|
64
|
+
"code" in cause &&
|
|
65
|
+
typeof cause.code === "string"
|
|
66
|
+
? cause.code
|
|
67
|
+
: undefined;
|
|
68
|
+
const osFailure = (cause) => {
|
|
69
|
+
const code = osErrorCode(cause);
|
|
70
|
+
return code === undefined ? "" : ` (${code})`;
|
|
71
|
+
};
|
|
72
|
+
/** Reject cancellation before a process capture operation begins. */
|
|
73
|
+
export const assertNotCancelled = (signal) => {
|
|
74
|
+
if (signal?.aborted === true)
|
|
75
|
+
throw processCaptureCancelled();
|
|
76
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js";
|
|
2
|
-
import { isSecretLikePath } from "../domain/referenceSourceClassification.js";
|
|
3
2
|
import { createHistoricalSourceGraph, historicalSourceLanguages, historicalSourceManifests, historicalSourceParseFailureKey, } from "../domain/referenceSourceGraph.js";
|
|
4
3
|
import { err, ok } from "../domain/result.js";
|
|
5
4
|
import { readReferenceSource } from "../reference/ReferenceSourceReader.js";
|
|
@@ -72,8 +71,8 @@ const sortExclusions = (exclusions) => [...exclusions].sort((left, right) => {
|
|
|
72
71
|
* Import a reference source directory into a committed historical source graph.
|
|
73
72
|
*
|
|
74
73
|
* The import is deterministic, parallel-safe, and never executes source, hooks,
|
|
75
|
-
* git subprocesses, or network requests.
|
|
76
|
-
*
|
|
74
|
+
* git subprocesses, or network requests. Paths explicitly excluded by the
|
|
75
|
+
* caller's reference-source policy are omitted from the graph.
|
|
77
76
|
*/
|
|
78
77
|
export const importReferenceSource = async (options) => {
|
|
79
78
|
if (isAborted(options.signal))
|
|
@@ -86,7 +85,7 @@ export const importReferenceSource = async (options) => {
|
|
|
86
85
|
return err(cancelled());
|
|
87
86
|
const exclusions = [];
|
|
88
87
|
const shouldExclude = (path) => {
|
|
89
|
-
if (
|
|
88
|
+
if (secrets.ignores(path)) {
|
|
90
89
|
exclusions.push({ path, reason: "configured-secret" });
|
|
91
90
|
return true;
|
|
92
91
|
}
|