rea-agents 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -332
- package/bridge/ghidra/ReaGhidraBridge.java +561 -74
- package/bridge/hopper_bridge.py +70 -27
- package/bridge/native/ReaNativeUI.swift +157 -0
- package/dist/application/AnalysisContextQueries.js +19 -5
- package/dist/application/AnalysisSnapshotCache.js +30 -11
- package/dist/application/AppleAssetCatalogAnalysis.js +171 -0
- package/dist/application/ArtifactExtractionDestination.js +0 -12
- package/dist/application/ArtifactGraphConstruction.js +44 -11
- package/dist/application/ArtifactInventory/classify.js +7 -15
- package/dist/application/ArtifactInventory/hash.js +4 -2
- package/dist/application/ArtifactInventory/policy.js +2 -17
- package/dist/application/ArtifactInventory/reader.js +3 -3
- package/dist/application/ArtifactInventory/scanCanonical.js +2 -2
- package/dist/application/ArtifactInventory/scanReader.js +12 -4
- package/dist/application/ArtifactInventory/types.js +0 -3
- package/dist/application/BinarySession.js +28 -43
- package/dist/application/BinarySessionExecution.js +37 -1
- package/dist/application/BinaryTargetResolver.js +50 -4
- package/dist/application/BrowserEvidence.js +36 -7
- package/dist/application/BrowserObservationService.js +17 -44
- package/dist/application/BrowserScenarioCaptureService.js +2 -35
- package/dist/application/BrowserScenarioEvidence.js +13 -9
- package/dist/application/CapabilityClientRequirements.js +2 -11
- package/dist/application/CapabilityInventory.js +21 -35
- package/dist/application/ClientConfigurationDocument.js +84 -7
- package/dist/application/ClientRegistrationIdentity.js +32 -0
- package/dist/application/ClientRegistrationStatus.js +59 -6
- package/dist/application/DirectAnalysis.js +37 -58
- package/dist/application/DirectAnalysisStatus.js +4 -4
- package/dist/application/Doctor.js +89 -80
- package/dist/application/DoctorDiagnostics.js +2 -26
- package/dist/application/DoctorScope.js +8 -14
- package/dist/application/ElectronActiveEvidence.js +10 -27
- package/dist/application/ElectronActiveObservationService.js +9 -36
- package/dist/application/ElectronBoundaryAnalysis.js +2 -0
- package/dist/application/ElectronBoundaryGraphNative.js +1 -1
- package/dist/application/ElectronEvidence.js +8 -3
- package/dist/application/ElectronObservationService.js +9 -25
- package/dist/application/EnhancedLiteralTracing.js +4 -8
- package/dist/application/EnhancedTools.js +15 -35
- package/dist/application/FilesystemSnapshot.js +7 -8
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +2 -1
- package/dist/application/JavaScriptApplicationWorkflowService.js +31 -7
- package/dist/application/JavaScriptArtifactAnalysis.js +6 -4
- package/dist/application/JavaScriptArtifactFiles.js +5 -0
- package/dist/application/JavaScriptArtifactPathResolution.js +179 -47
- package/dist/application/JavaScriptRuntimeObservationEvidence.js +6 -3
- package/dist/application/JavaScriptRuntimeObservationService.js +9 -25
- package/dist/application/JavaScriptRuntimeReconciliationService.js +45 -4
- package/dist/application/JavaScriptSemanticGraphAsyncProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphChildProcessProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphDataProjection.js +11 -0
- package/dist/application/JavaScriptSemanticGraphFlowProjection.js +14 -5
- package/dist/application/JsonFiles.js +1 -1
- package/dist/application/LazyAnalysisProvider.js +27 -6
- package/dist/application/ManagedMemberComparisonService.js +19 -6
- package/dist/application/NativeApiInspection.js +2 -0
- package/dist/application/NativeCallRoutes.js +72 -0
- package/dist/application/NativeDispatchMetadataInspection.js +33 -0
- package/dist/application/NativeUiActionTrace.js +73 -49
- package/dist/application/NativeValueTrace.js +320 -0
- package/dist/application/ProcessCaptureCapability.js +32 -5
- package/dist/application/ProcessCaptureEnvironment.js +9 -26
- package/dist/application/ProcessCaptureError.js +1 -5
- package/dist/application/ProcessCaptureJournal.js +3 -40
- package/dist/application/ProcessCaptureLifecycle.js +102 -111
- package/dist/application/ProcessCli.js +18 -25
- package/dist/application/ProcessEvidence.js +5 -7
- package/dist/application/ProcessFilesystemEffects.js +36 -0
- package/dist/application/ProcessHarness.js +41 -120
- package/dist/application/ProcessNormalization.js +2 -17
- package/dist/application/ProcessScenarioRuntimeValidation.js +76 -0
- package/dist/application/ReferenceSourceImport.js +3 -4
- package/dist/application/Setup.js +236 -84
- package/dist/application/SetupClientConfiguration.js +14 -9
- package/dist/application/SetupPlan.js +138 -86
- package/dist/application/SetupSkill.js +0 -1
- package/dist/application/SupportedClients.js +102 -21
- package/dist/application/Uninstall.js +31 -20
- package/dist/application/Update.js +93 -0
- package/dist/application/UpdateMaintenance.js +108 -0
- package/dist/application/UpdateRuntime.js +126 -0
- package/dist/application/runtime.js +13 -2
- package/dist/artifacts/ArtifactPaths.js +6 -8
- package/dist/artifacts/ArtifactProvider.js +94 -41
- package/dist/artifacts/AsarArtifactReader.js +19 -4
- package/dist/artifacts/KeyedArchiveReader.js +110 -0
- package/dist/artifacts/MachOSliceArtifactReader.js +53 -5
- package/dist/artifacts/ZipArtifactReader.js +18 -1
- package/dist/browser/BrowserScenarioSecrets.js +28 -1
- package/dist/browser/CdpBrowserProvider.js +36 -15
- package/dist/browser/CdpCaptureDocuments.js +22 -8
- package/dist/browser/CdpCaptureEventHandlers.js +14 -5
- package/dist/browser/CdpCaptureEventHelpers.js +13 -0
- package/dist/browser/CdpCaptureEvents.js +10 -1
- package/dist/browser/CdpElectronInspection.js +5 -10
- package/dist/browser/CdpElectronProvider.js +1 -5
- package/dist/browser/CdpElectronScripts.js +1 -1
- package/dist/browser/CdpEndpoint.js +3 -2
- package/dist/browser/CdpObservationSession.js +14 -10
- package/dist/browser/CdpPageCapture.js +1 -1
- package/dist/browser/CdpPageCaptureScripts.js +1 -1
- package/dist/browser/CdpSafeMetadata.js +5 -4
- package/dist/browser/CdpScreenshot.js +16 -5
- package/dist/browser/CdpTargetSession.js +25 -4
- package/dist/browser/CdpWebMcpDiscovery.js +93 -20
- package/dist/browser/JavaScriptRuntimeScope.js +28 -2
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +9 -8
- package/dist/browser/PlaywrightElectronActiveActions.js +3 -10
- package/dist/browser/PlaywrightElectronActiveProvider.js +5 -5
- package/dist/browser/PlaywrightScenarioActions.js +1 -1
- package/dist/browser/PlaywrightScenarioArtifacts.js +13 -25
- package/dist/browser/PlaywrightScenarioBrowser.js +28 -25
- package/dist/browser/PlaywrightScenarioEvents.js +82 -93
- package/dist/browser/PlaywrightScenarioSession.js +27 -123
- package/dist/browser/PngVisualDiff.js +22 -3
- package/dist/browser/V8InspectorCaptureProjection.js +7 -1
- package/dist/browser/V8InspectorProvider.js +60 -7
- package/dist/browser/WebSourceMapFetcher.js +99 -53
- package/dist/cli/artifactCommands.js +56 -12
- package/dist/cli/coreAnalysisCommands.js +110 -0
- package/dist/cli/managedCommands.js +1 -31
- package/dist/cli/setupCommands.js +16 -14
- package/dist/cli/utilityCommands.js +61 -4
- package/dist/cli.js +5 -7
- package/dist/cliApplicationCommands.js +0 -83
- package/dist/cliBrowserAdvancedCommands.js +7 -11
- package/dist/cliBrowserCommands.js +15 -23
- package/dist/cliBrowserContext.js +3 -24
- package/dist/cliBrowserScenarioCommands.js +2 -10
- package/dist/cliCommandNames.js +82 -7
- package/dist/cliElectronCommands.js +10 -36
- package/dist/cliJavaScriptRuntimeCommands.js +6 -30
- package/dist/cliJsonInput.js +4 -2
- package/dist/cliLogging.js +16 -7
- package/dist/cliObservationOptions.js +1 -1
- package/dist/cliOutput.js +2 -4
- package/dist/cliProcessCommands.js +6 -33
- package/dist/cliSetup.js +90 -160
- package/dist/config/environment.js +2 -78
- package/dist/config/parseConfig.js +18 -109
- package/dist/config/parsers.js +0 -23
- package/dist/contracts/applicationToolContracts.js +1 -118
- package/dist/contracts/artifactToolContracts.js +11 -19
- package/dist/contracts/browserScenarioToolContracts.js +1 -5
- package/dist/contracts/browserToolContracts.js +9 -16
- package/dist/contracts/electronToolContracts.js +5 -6
- package/dist/contracts/enhancedInputs.js +3 -2
- package/dist/contracts/errorSchemas.js +16 -40
- package/dist/contracts/functionWorkflowToolContracts.js +2 -2
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +2 -2
- package/dist/contracts/javascriptRuntimeObservationToolContracts.js +4 -4
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +1 -1
- package/dist/contracts/managedToolContracts.js +7 -4
- package/dist/contracts/managedWorkflowExamples.js +0 -22
- package/dist/contracts/managedWorkflowToolContracts.js +16 -31
- package/dist/contracts/nativeToolContracts.js +9 -0
- package/dist/contracts/promptContracts.js +6 -6
- package/dist/contracts/sessionToolSchemas.js +3 -3
- package/dist/contracts/toolContractExamples.js +4 -3
- package/dist/contracts/toolContracts.js +18 -7
- package/dist/contracts/toolEffects.js +34 -21
- package/dist/contracts/toolOutputSchemaGroups.js +18 -5
- package/dist/contracts/toolOutputSchemaPrimitives.js +9 -6
- package/dist/contracts/toolSchemaMetadata.js +5 -8
- package/dist/doctorRuntime.js +0 -41
- package/dist/domain/analysisErrorPresentation.js +4 -28
- package/dist/domain/analysisErrorProjection.js +33 -50
- package/dist/domain/analysisProfile.js +1 -1
- package/dist/domain/analysisSnapshot.js +77 -3
- package/dist/domain/androidApplication.js +5 -4
- package/dist/domain/appleApplication.js +5 -4
- package/dist/domain/appleAssetCatalog.js +127 -0
- package/dist/domain/artifactComparison.js +7 -11
- package/dist/domain/artifactGraph.js +8 -6
- package/dist/domain/artifactInspection.js +13 -12
- package/dist/domain/binaryTarget.js +23 -9
- package/dist/domain/browserObservation.js +43 -24
- package/dist/domain/browserObservationSchemas.js +2 -1
- package/dist/domain/browserScenario.js +7 -107
- package/dist/domain/browserScenarioCapture.js +0 -1
- package/dist/domain/browserScenarioCaptureValues.js +5 -4
- package/dist/domain/browserScenarioDiff.js +1 -3
- package/dist/domain/browserScenarioValues.js +16 -107
- package/dist/domain/bundleComparison.js +18 -17
- package/dist/domain/callPathSchemas.js +17 -7
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/comparisonSemantics.js +19 -0
- package/dist/domain/completionLedgerGeneration.js +3 -2
- package/dist/domain/conformancePackage.js +2 -1
- package/dist/domain/conformanceTrustGate.js +3 -5
- package/dist/domain/customProtocolCapture.js +2 -2
- package/dist/domain/digests.js +30 -0
- package/dist/domain/dosMz.js +83 -0
- package/dist/domain/electronActiveObservation.js +7 -5
- package/dist/domain/electronObservation.js +3 -2
- package/dist/domain/electronStaticAnalysisNative.js +15 -6
- package/dist/domain/emptyArraySchema.js +3 -0
- package/dist/domain/errors.js +10 -28
- package/dist/domain/evidence.js +5 -3
- package/dist/domain/evidenceCompletionLedger.js +3 -2
- package/dist/domain/functionComparisonNormalization.js +24 -18
- package/dist/domain/functionComparisonResults.js +3 -7
- package/dist/domain/functionComparisonSchemas.js +3 -2
- package/dist/domain/hopperValues.js +108 -8
- package/dist/domain/javascriptApplicationAnalysis.js +4 -7
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +4 -3
- package/dist/domain/javascriptApplicationGraphSchemas.js +8 -7
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +9 -7
- package/dist/domain/javascriptApplicationVersionItems.js +12 -18
- package/dist/domain/javascriptAstValues.js +4 -0
- package/dist/domain/javascriptExportShapeComparison.js +1 -6
- package/dist/domain/javascriptExportShapeComparisonSchemas.js +6 -10
- package/dist/domain/javascriptExportShapeVariants.js +15 -2
- package/dist/domain/javascriptFeatureTraceSchemas.js +8 -7
- package/dist/domain/javascriptRuntimeObservation.js +14 -2
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +8 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +4 -2
- package/dist/domain/javascriptRuntimeReconciliationResult.js +6 -4
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +19 -18
- package/dist/domain/javascriptRuntimeStaticCandidates.js +18 -6
- package/dist/domain/javascriptSemanticAnalysis.js +57 -19
- package/dist/domain/javascriptSemanticAsyncEffects.js +39 -40
- package/dist/domain/javascriptSemanticCalls.js +46 -27
- package/dist/domain/javascriptSemanticChildProcesses.js +43 -50
- package/dist/domain/javascriptSemanticDataEffectHelpers.js +91 -18
- package/dist/domain/javascriptSemanticDataEffects.js +22 -10
- package/dist/domain/javascriptSemanticGraphSchemas.js +8 -6
- package/dist/domain/javascriptSemanticObjects.js +13 -3
- package/dist/domain/javascriptSemanticProjection.js +144 -38
- package/dist/domain/javascriptSemanticPromises.js +14 -27
- package/dist/domain/javascriptSemanticQuerySchemas.js +6 -9
- package/dist/domain/javascriptSemanticResources.js +2 -5
- package/dist/domain/javascriptSemanticState.js +4 -0
- package/dist/domain/javascriptSemanticTraceSchemas.js +2 -1
- package/dist/domain/javascriptSemanticTraversal.js +13 -5
- package/dist/domain/javascriptSemanticValues.js +10 -9
- package/dist/domain/javascriptSourceParser.js +5 -1
- package/dist/domain/javascriptStaticAnalysisCalls.js +8 -5
- package/dist/domain/javascriptStaticAnalysisHelpers.js +16 -7
- package/dist/domain/keyedArchive.js +181 -0
- package/dist/domain/managedApplicationGraph.js +4 -3
- package/dist/domain/managedArtifact.js +2 -1
- package/dist/domain/managedMemberComparison.js +18 -13
- package/dist/domain/managedMemberComparisonCoverage.js +2 -1
- package/dist/domain/managedMemberComparisonItems.js +27 -7
- package/dist/domain/managedMemberComparisonMatch.js +22 -6
- package/dist/domain/managedNativeVerificationMatch.js +2 -2
- package/dist/domain/managedNativeVerificationSchemas.js +7 -5
- package/dist/domain/managedReconstruction.js +6 -5
- package/dist/domain/nativeApiBoundary.js +7 -0
- package/dist/domain/nativeDataType.js +51 -0
- package/dist/domain/nativeInspection.js +0 -1
- package/dist/domain/nativeInstruction.js +82 -0
- package/dist/domain/nativeInvestigationGraph.js +9 -5
- package/dist/domain/nativeUiObservation.js +123 -0
- package/dist/domain/nativeValueFlow.js +17 -0
- package/dist/domain/nativeValueTrace.js +64 -0
- package/dist/domain/objcSwiftMetadata.js +39 -0
- package/dist/domain/peInspection.js +1 -0
- package/dist/domain/processCapture.js +5 -55
- package/dist/domain/processCaptureExample.js +0 -9
- package/dist/domain/processCaptureValidation.js +13 -144
- package/dist/domain/processComparison.js +3 -25
- package/dist/domain/processObservation.js +0 -29
- package/dist/domain/processScenario.js +28 -228
- package/dist/domain/processTraceDimensionProjection.js +0 -15
- package/dist/domain/processTraceEvaluation.js +0 -6
- package/dist/domain/protocolCapture.js +8 -36
- package/dist/domain/reconstructionCoverage.js +3 -2
- package/dist/domain/reconstructionObligationLedgerSchemas.js +4 -12
- package/dist/domain/reconstructionReadinessSchemas.js +4 -3
- package/dist/domain/reconstructionVerification.js +2 -1
- package/dist/domain/reconstructionVerificationSchemas.js +6 -13
- package/dist/domain/referenceSourceClassification.js +0 -110
- package/dist/domain/referenceSourceGraph.js +15 -5
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/runtimeIdentification.js +6 -5
- package/dist/domain/sourceMapContents.js +5 -0
- package/dist/domain/sourceToBundleComparison.js +3 -10
- package/dist/domain/sourceToBundleComparisonSchemas.js +7 -6
- package/dist/domain/sourceToBundleSignals.js +9 -3
- package/dist/domain/staticRuntimeCorrelation.js +5 -11
- package/dist/domain/webBundleAnalysis.js +17 -9
- package/dist/domain/webBundleAnalyzer.js +1 -1
- package/dist/domain/webCaptureDiff.js +5 -11
- package/dist/domain/webCaptureDiffSchemas.js +2 -1
- package/dist/domain/webMcpDiscovery.js +2 -1
- package/dist/dotnet/ManagedMemberInspectorCore.js +15 -7
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +57 -40
- package/dist/dotnet/ManagedMemberRows.js +2 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +15 -8
- package/dist/dotnet/ManagedPeReader.js +2 -0
- package/dist/generatedMcpToolCatalog.js +1 -1
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +15 -5
- package/dist/ghidra/GhidraClient.js +38 -8
- package/dist/ghidra/GhidraFunctionValues.js +56 -20
- package/dist/ghidra/GhidraInstallation.js +7 -4
- package/dist/ghidra/GhidraInventoryValues.js +44 -9
- package/dist/ghidra/GhidraLauncher.js +18 -3
- package/dist/ghidra/GhidraProvider.js +23 -2
- package/dist/ghidra/GhidraRequestQueue.js +45 -4
- package/dist/ghidra/GhidraSessionValues.js +5 -0
- package/dist/hopper/HopperAnalysisProfile.js +2 -0
- package/dist/hopper/HopperProvider.js +29 -6
- package/dist/hopper/HopperTargetLease.js +18 -4
- package/dist/logger.js +0 -13
- package/dist/main/messages.js +0 -1
- package/dist/main/reload.js +3 -32
- package/dist/main/shutdown.js +1 -2
- package/dist/main/transport.js +0 -17
- package/dist/main.js +0 -10
- package/dist/native/AppleDispatchMetadata.js +582 -0
- package/dist/native/AppleObjcProtocols.js +88 -0
- package/dist/native/AppleSwiftVtables.js +86 -0
- package/dist/native/CommandRunner.js +1 -1
- package/dist/native/NativeHostCapabilities.js +23 -0
- package/dist/native/NativeMacOSProvider.js +61 -9
- package/dist/native/NativeMachoInspection.js +39 -6
- package/dist/native/NativeUiHelperRuntime.js +42 -0
- package/dist/native/NativeUiObservation.js +174 -0
- package/dist/native/parsers/codesign.js +4 -1
- package/dist/native/parsers/dyldInfo.js +51 -25
- package/dist/native/parsers/lipo.js +13 -4
- package/dist/native/parsers/otool.js +84 -39
- package/dist/native/parsers/plist.js +2 -1
- package/dist/process/ExecFileOutput.js +5 -1
- package/dist/process/ProcessOwnership.js +69 -33
- package/dist/process/ProcessOwnershipObservation.js +31 -12
- package/dist/process/ProviderProcess.js +4 -2
- package/dist/reference/ReferenceSourceReaderEntries.js +48 -31
- package/dist/reference/ReferenceSourceReaderErrors.js +24 -0
- package/dist/reference/ReferenceSourceReaderFile.js +11 -5
- package/dist/reference/ReferenceSourceReaderValidate.js +22 -8
- package/dist/server/createServer.js +7 -62
- package/dist/server/registerApplicationTools/helpers.js +2 -9
- package/dist/server/registerApplicationTools.js +0 -4
- package/dist/server/registerArtifactComparisonTool.js +1 -1
- package/dist/server/registerBrowserScenarioTool.js +4 -2
- package/dist/server/registerBrowserTools.js +7 -7
- package/dist/server/registerBundleComparisonTool.js +1 -1
- package/dist/server/registerCloseLifecycleTool.js +1 -1
- package/dist/server/registerElectronTools.js +10 -4
- package/dist/server/registerEnhancedTools.js +20 -12
- package/dist/server/registerEvidenceTools.js +4 -28
- package/dist/server/registerFunctionComparisonTool.js +1 -1
- package/dist/server/registerInvestigationTools.js +6 -6
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -2
- package/dist/server/registerManagedTools.js +28 -14
- package/dist/server/registerManagedWorkflowTools.js +0 -2
- package/dist/server/registerProcessComparisonTool.js +1 -3
- package/dist/server/registerSessionRecordTools.js +9 -9
- package/dist/server/registerSessionStatusTool.js +1 -1
- package/dist/server/registerSessionTools.js +28 -57
- package/dist/server/sessionAvailabilityPolicy.js +2 -3
- package/dist/server/sessionToolPolicies.js +0 -4
- package/dist/server/toolResult.js +8 -10
- package/package.json +32 -22
- package/skills/reverse-engineer-anything/SKILL.md +15 -11
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +3 -2
- package/skills/reverse-engineer-anything/references/javascript-applications.md +3 -2
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +8 -6
- package/skills/reverse-engineer-anything/references/runtime-observation.md +15 -11
- package/dist/application/CommandShimReplay.js +0 -152
- package/dist/application/ConfiguredRoots.js +0 -19
- package/dist/application/InstrumentedJavaScriptReplayHost.js +0 -36
- package/dist/application/JavaScriptReplayPermission.js +0 -16
- package/dist/application/JavaScriptReplayPlanning.js +0 -207
- package/dist/application/JavaScriptReplayService.js +0 -274
- package/dist/application/LoopbackReplay.js +0 -389
- package/dist/application/LoopbackReplayRecorder.js +0 -129
- package/dist/application/ManagedRuntimeCorrelationService.js +0 -104
- package/dist/application/NodeRuntimeCharacterizationService.js +0 -191
- package/dist/application/PermissionAuthority.js +0 -268
- package/dist/application/PermissionConfiguration.js +0 -26
- package/dist/application/PermissionFailure.js +0 -5
- package/dist/application/ProcessCaptureAuthority.js +0 -24
- package/dist/application/ProcessCapturePermission.js +0 -13
- package/dist/application/ProcessCheckpoints.js +0 -178
- package/dist/application/ProcessReactiveCoordinator.js +0 -223
- package/dist/application/ProcessReactiveEffects.js +0 -153
- package/dist/application/ProcessReactiveHarness.js +0 -106
- package/dist/application/ProcessReactiveObservations.js +0 -105
- package/dist/application/ProjectPermissionStore.js +0 -199
- package/dist/application/RuntimeExecutableDiagnostics.js +0 -198
- package/dist/application/Upgrade.js +0 -134
- package/dist/browser/SensitiveTextCapture.js +0 -8
- package/dist/cliPolicyCommands.js +0 -185
- package/dist/config/browserScenario.js +0 -77
- package/dist/config/electronAutomation.js +0 -35
- package/dist/config/javascriptReplay.js +0 -41
- package/dist/config/managedRuntime.js +0 -25
- package/dist/config/passiveObservation.js +0 -87
- package/dist/config/permissions.js +0 -23
- package/dist/config/processCapture.js +0 -47
- package/dist/contracts/replayMachineExample.js +0 -37
- package/dist/domain/javascriptExportInstrumentation.js +0 -95
- package/dist/domain/javascriptReplay.js +0 -360
- package/dist/domain/managedRuntimeCorrelation.js +0 -181
- package/dist/domain/nodeRuntimeCharacterization.js +0 -63
- package/dist/domain/permissionPolicy.js +0 -176
- package/dist/domain/processCaptureReactiveSchema.js +0 -68
- package/dist/domain/processCaptureReactiveValidation.js +0 -180
- package/dist/domain/processReactiveCheckpointDataflow.js +0 -32
- package/dist/domain/processReactiveMatching.js +0 -196
- package/dist/domain/processReactiveRuntime.js +0 -116
- package/dist/domain/processReactiveScenario.js +0 -296
- package/dist/domain/processReactiveScenarioPreflight.js +0 -95
- package/dist/domain/processReactiveTransition.js +0 -187
- package/dist/domain/replayMachine.js +0 -320
- package/dist/domain/replayMachineRun.js +0 -168
- package/dist/domain/replayMachineRuntime.js +0 -296
- package/dist/domain/replayMachineValues.js +0 -84
- package/dist/domain/runtimeCharacterization.js +0 -84
- package/dist/replay/JavaScriptReplayWorker.js +0 -382
- package/dist/replay/JavaScriptReplayWorkerTypes.js +0 -1
- package/dist/replay/LinuxJavaScriptReplayRunner.js +0 -216
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +0 -121
- package/dist/replay/LinuxRuntimeClosure.js +0 -44
- package/dist/replay/LinuxSeccompPolicy.js +0 -40
- package/dist/replay/ReplayOutcome.js +0 -104
- package/dist/replay/ReplayProcessLifecycle.js +0 -96
- package/dist/replay/ReplaySeccompFile.js +0 -29
- package/dist/replay/ReplayWorkerProtocol.js +0 -58
- package/dist/replay/SystemJavaScriptReplayHost.js +0 -153
- package/dist/server/ProcessCaptureElicitation.js +0 -153
- package/dist/server/registerApplicationTools/characterization.js +0 -46
- package/dist/server/registerApplicationTools/controlledReplay.js +0 -31
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +0 -29
- package/dist/server/registerReplayMachineTool.js +0 -14
- package/skills/reverse-engineer-anything/references/controlled-replay.md +0 -12
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
import { Script, SourceTextModule, SyntheticModule, createContext, } from "node:vm";
|
|
2
|
-
import { types } from "node:util";
|
|
3
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
-
const record = (value, label) => {
|
|
5
|
-
if (!isRecord(value))
|
|
6
|
-
throw new TypeError(`Invalid replay worker ${label}`);
|
|
7
|
-
return value;
|
|
8
|
-
};
|
|
9
|
-
const string = (value, label) => {
|
|
10
|
-
if (typeof value !== "string")
|
|
11
|
-
throw new TypeError(`Invalid replay worker ${label}`);
|
|
12
|
-
return value;
|
|
13
|
-
};
|
|
14
|
-
const integer = (value, label) => {
|
|
15
|
-
if (!Number.isSafeInteger(value) || Number(value) < 0)
|
|
16
|
-
throw new TypeError(`Invalid replay worker ${label}`);
|
|
17
|
-
return Number(value);
|
|
18
|
-
};
|
|
19
|
-
const parseWorkerModule = (value) => {
|
|
20
|
-
const module = record(value, "module");
|
|
21
|
-
const format = module.format;
|
|
22
|
-
if (format !== "esm" && format !== "commonjs-factory")
|
|
23
|
-
throw new TypeError("Invalid replay worker module format");
|
|
24
|
-
const dependencies = record(module.dependencies, "module dependencies");
|
|
25
|
-
if (Object.values(dependencies).some((dependency) => typeof dependency !== "string"))
|
|
26
|
-
throw new TypeError("Invalid replay worker module dependency");
|
|
27
|
-
return {
|
|
28
|
-
alias: string(module.alias, "module alias"),
|
|
29
|
-
format,
|
|
30
|
-
dependencies: Object.fromEntries(Object.entries(dependencies).map(([key, dependency]) => [
|
|
31
|
-
key,
|
|
32
|
-
string(dependency, "module dependency"),
|
|
33
|
-
])),
|
|
34
|
-
source: string(module.source, "module source"),
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
const parseWorkerSide = (value) => {
|
|
38
|
-
const side = record(value, "side");
|
|
39
|
-
if (!Array.isArray(side.modules))
|
|
40
|
-
throw new TypeError("Invalid replay worker modules");
|
|
41
|
-
return {
|
|
42
|
-
modules: side.modules.map(parseWorkerModule),
|
|
43
|
-
entryAlias: string(side.entryAlias, "entry alias"),
|
|
44
|
-
entryExport: string(side.entryExport, "entry export"),
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const parseWorkerRequest = (value) => {
|
|
48
|
-
const request = record(value, "request");
|
|
49
|
-
if (!Array.isArray(request.cases))
|
|
50
|
-
throw new TypeError("Invalid replay worker cases");
|
|
51
|
-
const determinism = record(request.determinism, "determinism");
|
|
52
|
-
const limits = record(request.limits, "limits");
|
|
53
|
-
return {
|
|
54
|
-
left: parseWorkerSide(request.left),
|
|
55
|
-
...(request.right === undefined
|
|
56
|
-
? {}
|
|
57
|
-
: { right: parseWorkerSide(request.right) }),
|
|
58
|
-
cases: request.cases.map((value) => {
|
|
59
|
-
const replayCase = record(value, "case");
|
|
60
|
-
if (!Array.isArray(replayCase.arguments))
|
|
61
|
-
throw new TypeError("Invalid replay worker case arguments");
|
|
62
|
-
return {
|
|
63
|
-
caseId: string(replayCase.caseId, "case ID"),
|
|
64
|
-
arguments: replayCase.arguments,
|
|
65
|
-
inputSha256: string(replayCase.inputSha256, "case digest"),
|
|
66
|
-
};
|
|
67
|
-
}),
|
|
68
|
-
determinism: {
|
|
69
|
-
clockIso: string(determinism.clockIso, "clock"),
|
|
70
|
-
randomSeed: integer(determinism.randomSeed, "random seed"),
|
|
71
|
-
},
|
|
72
|
-
limits: {
|
|
73
|
-
resultDepth: integer(limits.resultDepth, "result depth"),
|
|
74
|
-
resultNodes: integer(limits.resultNodes, "result nodes"),
|
|
75
|
-
exceptionBytes: integer(limits.exceptionBytes, "exception bytes"),
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
class ReplayDeniedError extends Error {
|
|
80
|
-
name = "ReplayDeniedError";
|
|
81
|
-
}
|
|
82
|
-
const main = async () => {
|
|
83
|
-
const chunks = [];
|
|
84
|
-
for await (const chunk of process.stdin)
|
|
85
|
-
chunks.push(Buffer.from(chunk));
|
|
86
|
-
const rawRequest = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
87
|
-
const request = parseWorkerRequest(rawRequest);
|
|
88
|
-
const left = [];
|
|
89
|
-
const right = [];
|
|
90
|
-
for (let index = 0; index < request.cases.length; index += 1) {
|
|
91
|
-
const replayCase = request.cases[index];
|
|
92
|
-
if (replayCase === undefined)
|
|
93
|
-
continue;
|
|
94
|
-
left.push(await runCase(request.left, replayCase, request, index));
|
|
95
|
-
if (request.right !== undefined)
|
|
96
|
-
right.push(await runCase(request.right, replayCase, request, index));
|
|
97
|
-
}
|
|
98
|
-
process.stdout.write(JSON.stringify({
|
|
99
|
-
left,
|
|
100
|
-
...(request.right === undefined ? {} : { right }),
|
|
101
|
-
}));
|
|
102
|
-
};
|
|
103
|
-
const runCase = async (side, replayCase, request, index) => {
|
|
104
|
-
try {
|
|
105
|
-
const loaded = await loadEntry(side, request, index);
|
|
106
|
-
if (typeof loaded !== "function")
|
|
107
|
-
throw new TypeError(`Replay export is not callable: ${side.entryExport}`);
|
|
108
|
-
const returned = await Reflect.apply(loaded, undefined, [
|
|
109
|
-
...replayCase.arguments,
|
|
110
|
-
]);
|
|
111
|
-
try {
|
|
112
|
-
return {
|
|
113
|
-
case_id: replayCase.caseId,
|
|
114
|
-
outcome: "return",
|
|
115
|
-
value: projectValue(returned, request.limits.resultDepth, request.limits.resultNodes),
|
|
116
|
-
input_sha256: replayCase.inputSha256,
|
|
117
|
-
output_sha256: null,
|
|
118
|
-
truncated: false,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
return exceptionOutcome(replayCase, "serialization_error", error, request.limits.exceptionBytes);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
return exceptionOutcome(replayCase, error instanceof ReplayDeniedError ? "denied" : "exception", error, request.limits.exceptionBytes);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const loadEntry = async (side, request, caseIndex) => {
|
|
130
|
-
const modules = new Map(side.modules.map((module) => [module.alias, module]));
|
|
131
|
-
const context = deterministicContext(request, caseIndex);
|
|
132
|
-
const esmCache = new Map();
|
|
133
|
-
const commonJsCache = new Map();
|
|
134
|
-
const loadCommonJs = (alias) => {
|
|
135
|
-
const cached = commonJsCache.get(alias);
|
|
136
|
-
if (cached !== undefined)
|
|
137
|
-
return cached;
|
|
138
|
-
const descriptor = requiredModule(modules, alias);
|
|
139
|
-
if (descriptor.format !== "commonjs-factory")
|
|
140
|
-
throw new TypeError(`Synchronous require cannot load ESM module: ${alias}`);
|
|
141
|
-
const module = { exports: {} };
|
|
142
|
-
commonJsCache.set(alias, module.exports);
|
|
143
|
-
const requireModule = (specifier) => {
|
|
144
|
-
const dependency = descriptor.dependencies[specifier];
|
|
145
|
-
if (dependency === undefined)
|
|
146
|
-
throw new ReplayDeniedError(`Undeclared require: ${specifier}`);
|
|
147
|
-
return loadCommonJs(dependency);
|
|
148
|
-
};
|
|
149
|
-
installRspackHelpers(requireModule);
|
|
150
|
-
const source = normalizeFactorySource(descriptor.source);
|
|
151
|
-
const factory = new Script(`(${source})`, {
|
|
152
|
-
filename: `/modules/${alias}.js`,
|
|
153
|
-
}).runInContext(context);
|
|
154
|
-
if (typeof factory !== "function")
|
|
155
|
-
throw new TypeError(`CommonJS factory is not callable: ${alias}`);
|
|
156
|
-
Reflect.apply(factory, undefined, [module, module.exports, requireModule]);
|
|
157
|
-
commonJsCache.set(alias, module.exports);
|
|
158
|
-
return module.exports;
|
|
159
|
-
};
|
|
160
|
-
const loadEsm = async (alias) => {
|
|
161
|
-
const cached = esmCache.get(alias);
|
|
162
|
-
if (cached !== undefined)
|
|
163
|
-
return cached;
|
|
164
|
-
const descriptor = requiredModule(modules, alias);
|
|
165
|
-
let module;
|
|
166
|
-
if (descriptor.format === "commonjs-factory") {
|
|
167
|
-
const exports = loadCommonJs(alias);
|
|
168
|
-
const names = [...new Set(["default", ...Object.keys(exports)])];
|
|
169
|
-
module = new SyntheticModule(names, function () {
|
|
170
|
-
this.setExport("default", exports);
|
|
171
|
-
for (const name of Object.keys(exports))
|
|
172
|
-
this.setExport(name, exports[name]);
|
|
173
|
-
}, { context, identifier: `rea:${alias}` });
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
module = new SourceTextModule(descriptor.source, {
|
|
177
|
-
context,
|
|
178
|
-
identifier: `rea:${alias}`,
|
|
179
|
-
initializeImportMeta: (meta) => {
|
|
180
|
-
meta.url = `rea:${alias}`;
|
|
181
|
-
},
|
|
182
|
-
importModuleDynamically: () => {
|
|
183
|
-
throw new ReplayDeniedError("Dynamic import is unavailable in controlled replay");
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
esmCache.set(alias, module);
|
|
188
|
-
await module.link(async (specifier) => {
|
|
189
|
-
const dependency = descriptor.dependencies[specifier];
|
|
190
|
-
if (dependency === undefined)
|
|
191
|
-
throw new ReplayDeniedError(`Undeclared import: ${specifier}`);
|
|
192
|
-
return loadEsm(dependency);
|
|
193
|
-
});
|
|
194
|
-
await module.evaluate();
|
|
195
|
-
return module;
|
|
196
|
-
};
|
|
197
|
-
const entry = requiredModule(modules, side.entryAlias);
|
|
198
|
-
if (entry.format === "commonjs-factory") {
|
|
199
|
-
const exported = loadCommonJs(side.entryAlias);
|
|
200
|
-
return side.entryExport === "default"
|
|
201
|
-
? (exported.default ?? exported)
|
|
202
|
-
: exported[side.entryExport];
|
|
203
|
-
}
|
|
204
|
-
const namespace = (await loadEsm(side.entryAlias)).namespace;
|
|
205
|
-
return Reflect.get(namespace, side.entryExport);
|
|
206
|
-
};
|
|
207
|
-
const deterministicContext = (request, caseIndex) => {
|
|
208
|
-
let state = (request.determinism.randomSeed + caseIndex) >>> 0;
|
|
209
|
-
const random = () => {
|
|
210
|
-
state ^= state << 13;
|
|
211
|
-
state ^= state >>> 17;
|
|
212
|
-
state ^= state << 5;
|
|
213
|
-
return (state >>> 0) / 0x1_0000_0000;
|
|
214
|
-
};
|
|
215
|
-
const epoch = Date.parse(request.determinism.clockIso);
|
|
216
|
-
class ReplayDate extends Date {
|
|
217
|
-
constructor(...arguments_) {
|
|
218
|
-
super(arguments_.length === 0 ? epoch : arguments_[0]);
|
|
219
|
-
}
|
|
220
|
-
static now() {
|
|
221
|
-
return epoch;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
const replayMath = Object.create(Math);
|
|
225
|
-
Object.defineProperty(replayMath, "random", { value: random });
|
|
226
|
-
return createContext({ Date: ReplayDate, Math: replayMath }, {
|
|
227
|
-
name: "rea-controlled-replay",
|
|
228
|
-
codeGeneration: { strings: false, wasm: false },
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
const installRspackHelpers = (require_) => {
|
|
232
|
-
const defineExports = (exports, definitions) => {
|
|
233
|
-
for (const [name, getter] of Object.entries(definitions))
|
|
234
|
-
if (!Object.prototype.hasOwnProperty.call(exports, name))
|
|
235
|
-
Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
236
|
-
};
|
|
237
|
-
const markModule = (exports) => {
|
|
238
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
239
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
240
|
-
};
|
|
241
|
-
const normalizeModule = (module) => {
|
|
242
|
-
const getter = () => (module.__esModule === true ? module.default : module);
|
|
243
|
-
Object.defineProperty(getter, "a", { get: getter });
|
|
244
|
-
return getter;
|
|
245
|
-
};
|
|
246
|
-
const passModule = (module) => module;
|
|
247
|
-
Object.defineProperties(require_, {
|
|
248
|
-
d: { value: defineExports },
|
|
249
|
-
r: { value: markModule },
|
|
250
|
-
n: { value: normalizeModule },
|
|
251
|
-
nmd: { value: passModule },
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
const requiredModule = (modules, alias) => {
|
|
255
|
-
const module = modules.get(alias);
|
|
256
|
-
if (module === undefined)
|
|
257
|
-
throw new TypeError(`Undeclared module alias: ${alias}`);
|
|
258
|
-
return module;
|
|
259
|
-
};
|
|
260
|
-
const normalizeFactorySource = (source) => /^\s*\d+\s*\(/u.test(source)
|
|
261
|
-
? source.replace(/^\s*\d+\s*\(/u, "function(")
|
|
262
|
-
: source;
|
|
263
|
-
const projectValue = (value, maximumDepth, maximumNodes) => projectValueRecursive(value, 0, new Set(), {
|
|
264
|
-
maximumDepth,
|
|
265
|
-
maximumNodes,
|
|
266
|
-
nodes: 0,
|
|
267
|
-
});
|
|
268
|
-
const projectValueRecursive = (candidate, depth, ancestors, context) => {
|
|
269
|
-
context.nodes += 1;
|
|
270
|
-
if (context.nodes > context.maximumNodes || depth > context.maximumDepth)
|
|
271
|
-
throw new RangeError("Replay result projection limit exceeded");
|
|
272
|
-
const leaf = projectLeaf(candidate);
|
|
273
|
-
if (leaf !== undefined)
|
|
274
|
-
return leaf;
|
|
275
|
-
if (typeof candidate !== "object" || candidate === null)
|
|
276
|
-
throw new TypeError(`Unsupported replay result type: ${typeof candidate}`);
|
|
277
|
-
if (types.isProxy(candidate))
|
|
278
|
-
throw new TypeError("Proxy replay results are unavailable");
|
|
279
|
-
if (ancestors.has(candidate))
|
|
280
|
-
throw new TypeError("Cyclic replay result");
|
|
281
|
-
ancestors.add(candidate);
|
|
282
|
-
try {
|
|
283
|
-
assertSupportedPrototype(candidate);
|
|
284
|
-
return projectComplexValue(candidate, depth, ancestors, context);
|
|
285
|
-
}
|
|
286
|
-
finally {
|
|
287
|
-
ancestors.delete(candidate);
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
const projectLeaf = (candidate) => {
|
|
291
|
-
if (candidate === null ||
|
|
292
|
-
typeof candidate === "string" ||
|
|
293
|
-
typeof candidate === "boolean")
|
|
294
|
-
return candidate;
|
|
295
|
-
if (typeof candidate === "number") {
|
|
296
|
-
if (!Number.isFinite(candidate))
|
|
297
|
-
throw new TypeError("Non-finite replay result number");
|
|
298
|
-
return candidate;
|
|
299
|
-
}
|
|
300
|
-
return undefined;
|
|
301
|
-
};
|
|
302
|
-
const assertSupportedPrototype = (candidate) => {
|
|
303
|
-
if (Array.isArray(candidate))
|
|
304
|
-
return;
|
|
305
|
-
const prototype = Object.getPrototypeOf(candidate);
|
|
306
|
-
if (prototype !== null && Object.getPrototypeOf(prototype) !== null)
|
|
307
|
-
throw new TypeError("Unsupported replay result prototype");
|
|
308
|
-
};
|
|
309
|
-
const projectComplexValue = (candidate, depth, ancestors, context) => {
|
|
310
|
-
const descriptors = Object.getOwnPropertyDescriptors(candidate);
|
|
311
|
-
const output = Array.isArray(candidate)
|
|
312
|
-
? []
|
|
313
|
-
: {};
|
|
314
|
-
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
315
|
-
if (key === "length" && Array.isArray(candidate))
|
|
316
|
-
continue;
|
|
317
|
-
if (!("value" in descriptor))
|
|
318
|
-
throw new TypeError("Replay result accessors are unavailable");
|
|
319
|
-
if (Array.isArray(output)) {
|
|
320
|
-
if (!/^\d+$/u.test(key))
|
|
321
|
-
throw new TypeError("Replay arrays may only contain indexed values");
|
|
322
|
-
output[Number(key)] = projectValueRecursive(descriptor.value, depth + 1, ancestors, context);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
output[key] = projectValueRecursive(descriptor.value, depth + 1, ancestors, context);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return output;
|
|
329
|
-
};
|
|
330
|
-
const exceptionOutcome = (replayCase, outcome, error, maximumBytes) => {
|
|
331
|
-
const details = exceptionDetails(error);
|
|
332
|
-
const name = bounded(details.name, maximumBytes);
|
|
333
|
-
const message = bounded(details.message, maximumBytes);
|
|
334
|
-
const stack = details.stack === null ? null : bounded(details.stack, maximumBytes);
|
|
335
|
-
return {
|
|
336
|
-
case_id: replayCase.caseId,
|
|
337
|
-
outcome,
|
|
338
|
-
exception: { name, message, stack },
|
|
339
|
-
input_sha256: replayCase.inputSha256,
|
|
340
|
-
output_sha256: null,
|
|
341
|
-
truncated: false,
|
|
342
|
-
};
|
|
343
|
-
};
|
|
344
|
-
const exceptionDetails = (error) => {
|
|
345
|
-
if (typeof error !== "object" || error === null)
|
|
346
|
-
return { name: "Error", message: "Unknown replay exception", stack: null };
|
|
347
|
-
if (types.isProxy(error))
|
|
348
|
-
return { name: "Error", message: "Proxy replay exception", stack: null };
|
|
349
|
-
const own = Object.getOwnPropertyDescriptors(error);
|
|
350
|
-
const prototype = Object.getPrototypeOf(error);
|
|
351
|
-
const inherited = prototype === null ? {} : Object.getOwnPropertyDescriptors(prototype);
|
|
352
|
-
const stringValue = (descriptor) => descriptor !== undefined &&
|
|
353
|
-
"value" in descriptor &&
|
|
354
|
-
typeof descriptor.value === "string"
|
|
355
|
-
? descriptor.value
|
|
356
|
-
: null;
|
|
357
|
-
return {
|
|
358
|
-
name: stringValue(own.name) ?? stringValue(inherited.name) ?? "Error",
|
|
359
|
-
message: stringValue(own.message) ?? "Unknown replay exception",
|
|
360
|
-
stack: stringValue(own.stack),
|
|
361
|
-
};
|
|
362
|
-
};
|
|
363
|
-
const bounded = (value, maximumBytes) => {
|
|
364
|
-
const bytes = Buffer.from(value);
|
|
365
|
-
if (bytes.byteLength <= maximumBytes)
|
|
366
|
-
return value;
|
|
367
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
368
|
-
for (let end = maximumBytes; end >= Math.max(0, maximumBytes - 3); end -= 1) {
|
|
369
|
-
try {
|
|
370
|
-
return decoder.decode(bytes.subarray(0, end));
|
|
371
|
-
}
|
|
372
|
-
catch {
|
|
373
|
-
/* try the preceding UTF-8 boundary */
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
return "";
|
|
377
|
-
};
|
|
378
|
-
void main().catch((error) => {
|
|
379
|
-
const message = error instanceof Error ? error.message : "Replay worker failed";
|
|
380
|
-
process.stderr.write(message);
|
|
381
|
-
process.exitCode = 70;
|
|
382
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { temporaryFilterHandle } from "./ReplaySeccompFile.js";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import { randomBytes } from "node:crypto";
|
|
4
|
-
import { readFile } from "node:fs/promises";
|
|
5
|
-
import { digestBytes, } from "../application/JavaScriptReplayPlanning.js";
|
|
6
|
-
import { linuxX64ReplaySeccompDigest } from "./LinuxSeccompPolicy.js";
|
|
7
|
-
import { resolveLinuxRuntimeClosure } from "./LinuxRuntimeClosure.js";
|
|
8
|
-
import { assertRuntimeCommitment, systemdArguments, } from "./LinuxJavaScriptReplaySandbox.js";
|
|
9
|
-
import { boundedCollector, killUnit, observeCleanup, observeUnitResult, } from "./ReplayProcessLifecycle.js";
|
|
10
|
-
import { commitOutcomes, compareOutcomes, terminationResult, workerRequest, } from "./ReplayOutcome.js";
|
|
11
|
-
import { parseReplayWorkerResponse, } from "./ReplayWorkerProtocol.js";
|
|
12
|
-
const isAborted = (signal) => signal?.aborted === true;
|
|
13
|
-
/** Run one prepared experiment under the exact Linux ADR-0002 boundary. */
|
|
14
|
-
export class LinuxJavaScriptReplayRunner {
|
|
15
|
-
async execute(prepared, policy, signal) {
|
|
16
|
-
if (isAborted(signal))
|
|
17
|
-
return terminationResult({
|
|
18
|
-
prepared,
|
|
19
|
-
stderr: "",
|
|
20
|
-
termination: "cancelled",
|
|
21
|
-
cleanup: { state: "complete", residual_resources: [] },
|
|
22
|
-
});
|
|
23
|
-
const unit = `rea-replay-${randomBytes(8).toString("hex")}.service`;
|
|
24
|
-
const closure = await validateReplayCommitments(prepared, policy);
|
|
25
|
-
const encoded = buildWorkerPayload(prepared);
|
|
26
|
-
const filter = await temporaryFilterHandle();
|
|
27
|
-
try {
|
|
28
|
-
const replayProcess = launchReplayProcess({
|
|
29
|
-
prepared,
|
|
30
|
-
policy,
|
|
31
|
-
encoded,
|
|
32
|
-
closure,
|
|
33
|
-
filterPath: filter.path,
|
|
34
|
-
unit,
|
|
35
|
-
signal,
|
|
36
|
-
});
|
|
37
|
-
try {
|
|
38
|
-
const collected = await replayProcess.completion;
|
|
39
|
-
if (replayProcess.terminationRequest !== undefined)
|
|
40
|
-
await replayProcess.terminationRequest;
|
|
41
|
-
const unitResult = await observeUnitResult(policy.systemctlPath, unit);
|
|
42
|
-
const cleanup = await observeCleanup(policy.systemctlPath, unit);
|
|
43
|
-
return resolveReplayResult({
|
|
44
|
-
prepared,
|
|
45
|
-
collected,
|
|
46
|
-
unitResult,
|
|
47
|
-
cleanup,
|
|
48
|
-
termination: replayProcess.termination,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
signal?.removeEventListener("abort", replayProcess.terminate);
|
|
53
|
-
if (replayProcess.timeout !== undefined)
|
|
54
|
-
clearTimeout(replayProcess.timeout);
|
|
55
|
-
if (replayProcess.child !== undefined &&
|
|
56
|
-
replayProcess.child.exitCode === null) {
|
|
57
|
-
replayProcess.requestTermination();
|
|
58
|
-
await replayProcess.terminationRequest;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
finally {
|
|
63
|
-
await filter.close();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const validateReplayCommitments = async (prepared, policy) => {
|
|
68
|
-
const closure = await resolveLinuxRuntimeClosure(policy.nodePath);
|
|
69
|
-
assertRuntimeCommitment(prepared, closure);
|
|
70
|
-
const workerPath = prepared.publicPlan.runtime.worker.path;
|
|
71
|
-
if (digestBytes(await readFile(workerPath)) !==
|
|
72
|
-
prepared.publicPlan.runtime.worker.sha256)
|
|
73
|
-
throw new TypeError("Replay worker changed after approval");
|
|
74
|
-
if (linuxX64ReplaySeccompDigest() !== prepared.publicPlan.sandbox.seccomp_sha256)
|
|
75
|
-
throw new TypeError("Replay seccomp policy changed after approval");
|
|
76
|
-
return closure;
|
|
77
|
-
};
|
|
78
|
-
const buildWorkerPayload = (prepared) => {
|
|
79
|
-
const request = workerRequest(prepared);
|
|
80
|
-
const encoded = Buffer.from(JSON.stringify(request));
|
|
81
|
-
if (encoded.byteLength > prepared.publicPlan.limits.protocol_bytes)
|
|
82
|
-
throw new RangeError("Replay worker protocol input exceeds the committed limit");
|
|
83
|
-
return encoded;
|
|
84
|
-
};
|
|
85
|
-
const launchReplayProcess = (options) => {
|
|
86
|
-
const { prepared, policy, encoded, closure, filterPath, unit, signal } = options;
|
|
87
|
-
const arguments_ = systemdArguments({
|
|
88
|
-
unit,
|
|
89
|
-
policy,
|
|
90
|
-
prepared,
|
|
91
|
-
workerPath: prepared.publicPlan.runtime.worker.path,
|
|
92
|
-
closure,
|
|
93
|
-
filterPath,
|
|
94
|
-
});
|
|
95
|
-
let child;
|
|
96
|
-
let timeout;
|
|
97
|
-
let termination;
|
|
98
|
-
let terminationRequest;
|
|
99
|
-
const requestTermination = () => {
|
|
100
|
-
terminationRequest ??= killUnit(policy.systemctlPath, unit);
|
|
101
|
-
child?.kill("SIGKILL");
|
|
102
|
-
};
|
|
103
|
-
const terminate = () => {
|
|
104
|
-
termination ??= "cancelled";
|
|
105
|
-
requestTermination();
|
|
106
|
-
};
|
|
107
|
-
const completion = new Promise((resolve, reject) => {
|
|
108
|
-
child = spawn(policy.systemdRunPath, arguments_, {
|
|
109
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
110
|
-
env: replayProcessEnvironment(),
|
|
111
|
-
});
|
|
112
|
-
const output = boundedCollector(prepared.publicPlan.limits.output_bytes);
|
|
113
|
-
const diagnostics = boundedCollector(prepared.publicPlan.limits.stderr_bytes);
|
|
114
|
-
child.stdout?.on("data", output.append);
|
|
115
|
-
child.stderr?.on("data", diagnostics.append);
|
|
116
|
-
child.once("error", reject);
|
|
117
|
-
child.once("close", (code, signalName) => resolve({
|
|
118
|
-
code,
|
|
119
|
-
signal: signalName,
|
|
120
|
-
stdout: output.value(),
|
|
121
|
-
stderr: diagnostics.value(),
|
|
122
|
-
outputExceeded: output.exceeded(),
|
|
123
|
-
}));
|
|
124
|
-
child.stdin?.end(encoded);
|
|
125
|
-
});
|
|
126
|
-
signal?.addEventListener("abort", terminate, { once: true });
|
|
127
|
-
if (isAborted(signal))
|
|
128
|
-
terminate();
|
|
129
|
-
timeout = setTimeout(() => {
|
|
130
|
-
termination ??= "timeout";
|
|
131
|
-
requestTermination();
|
|
132
|
-
}, prepared.publicPlan.limits.wall_time_ms);
|
|
133
|
-
timeout.unref();
|
|
134
|
-
if (child === undefined || timeout === undefined)
|
|
135
|
-
throw new TypeError("Replay process was not launched");
|
|
136
|
-
return {
|
|
137
|
-
child,
|
|
138
|
-
completion,
|
|
139
|
-
timeout,
|
|
140
|
-
terminate,
|
|
141
|
-
requestTermination,
|
|
142
|
-
get terminationRequest() {
|
|
143
|
-
return terminationRequest;
|
|
144
|
-
},
|
|
145
|
-
get termination() {
|
|
146
|
-
return termination;
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
const replayProcessEnvironment = () => ({
|
|
151
|
-
PATH: "/usr/bin:/bin",
|
|
152
|
-
LANG: "C",
|
|
153
|
-
LC_ALL: "C",
|
|
154
|
-
TZ: "UTC",
|
|
155
|
-
...(process.env.XDG_RUNTIME_DIR === undefined
|
|
156
|
-
? {}
|
|
157
|
-
: { XDG_RUNTIME_DIR: process.env.XDG_RUNTIME_DIR }),
|
|
158
|
-
...(process.env.DBUS_SESSION_BUS_ADDRESS === undefined
|
|
159
|
-
? {}
|
|
160
|
-
: { DBUS_SESSION_BUS_ADDRESS: process.env.DBUS_SESSION_BUS_ADDRESS }),
|
|
161
|
-
});
|
|
162
|
-
const resolveReplayResult = (options) => {
|
|
163
|
-
const { prepared, collected, unitResult, cleanup, termination } = options;
|
|
164
|
-
if (termination !== undefined)
|
|
165
|
-
return terminationResult({
|
|
166
|
-
prepared,
|
|
167
|
-
stderr: collected.stderr,
|
|
168
|
-
termination,
|
|
169
|
-
cleanup,
|
|
170
|
-
});
|
|
171
|
-
if (collected.outputExceeded)
|
|
172
|
-
return terminationResult({
|
|
173
|
-
prepared,
|
|
174
|
-
stderr: collected.stderr,
|
|
175
|
-
termination: "protocol_error",
|
|
176
|
-
cleanup,
|
|
177
|
-
limitation: "Worker stdout exceeded the committed bound",
|
|
178
|
-
});
|
|
179
|
-
if (collected.code !== 0)
|
|
180
|
-
return terminationResult({
|
|
181
|
-
prepared,
|
|
182
|
-
stderr: collected.stderr,
|
|
183
|
-
termination: collected.code === 137 || unitResult === "oom-kill" ? "oom" : "crash",
|
|
184
|
-
cleanup,
|
|
185
|
-
});
|
|
186
|
-
let response;
|
|
187
|
-
try {
|
|
188
|
-
const rawResponse = JSON.parse(collected.stdout);
|
|
189
|
-
response = parseReplayWorkerResponse(rawResponse, prepared.publicPlan.cases, prepared.publicPlan.right === undefined ? "single" : "differential");
|
|
190
|
-
}
|
|
191
|
-
catch {
|
|
192
|
-
return terminationResult({
|
|
193
|
-
prepared,
|
|
194
|
-
stderr: collected.stderr,
|
|
195
|
-
termination: "protocol_error",
|
|
196
|
-
cleanup,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
const outcomes = commitOutcomes(response.left);
|
|
200
|
-
const right = response.right === undefined ? undefined : commitOutcomes(response.right);
|
|
201
|
-
return {
|
|
202
|
-
plan_digest: prepared.publicPlan.plan_digest,
|
|
203
|
-
outcomes: [...outcomes, ...(right ?? [])],
|
|
204
|
-
...(right === undefined
|
|
205
|
-
? {}
|
|
206
|
-
: { comparison: compareOutcomes(outcomes, right) }),
|
|
207
|
-
stderr: collected.stderr,
|
|
208
|
-
termination: "completed",
|
|
209
|
-
cleanup,
|
|
210
|
-
limitations: [
|
|
211
|
-
"Controlled replay observes the isolated extracted modules, not the original application runtime.",
|
|
212
|
-
"Network and host filesystem access were unavailable; unsupported dependencies may change behavior.",
|
|
213
|
-
],
|
|
214
|
-
reproducer: null,
|
|
215
|
-
};
|
|
216
|
-
};
|