rea-agents 6.0.0 → 6.2.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 +26 -18
- package/bridge/android/ReaJadxBridge.java +14 -5
- package/bridge/ghidra/ReaGhidraBridge.java +205 -51
- package/bridge/hopper_bridge.py +314 -127
- package/bridge/mitmproxy/capture.py +0 -2
- package/bridge/native/rea_lldb_tracer.py +630 -94
- package/bridge/process/ProcessRunTokenReader.swift +39 -5
- package/bridge/pwntools/recorded_crash_impl.py +4 -0
- package/dist/android/JadxConfiguration.js +274 -31
- package/dist/android/JadxMcpTransport.js +18 -2
- package/dist/android/JadxProtocol.js +6 -0
- package/dist/android/JadxProvider.js +76 -37
- package/dist/android/JadxSession.js +23 -4
- package/dist/application/AnalysisContextQueries.js +8 -35
- package/dist/application/AnalysisDocument.js +32 -0
- package/dist/application/AppBundleExecutable.js +67 -21
- package/dist/application/BinaryTargetResolver.js +5 -3
- package/dist/application/BrowserEvidence.js +3 -8
- package/dist/application/BrowserScenarioEvidence.js +2 -18
- package/dist/application/CallPathTracing.js +19 -3
- package/dist/application/CapabilityInventory.js +48 -11
- package/dist/application/ClientConfigurationDocument.js +917 -8
- package/dist/application/ClientRegistrationIdentity.js +26 -5
- package/dist/application/ClientRegistrationStatus.js +29 -14
- package/dist/application/DirectAnalysis.js +56 -51
- package/dist/application/DirectAnalysisCleanup.js +72 -0
- package/dist/application/DirectAnalysisStatus.js +4 -5
- package/dist/application/Doctor.js +19 -21
- package/dist/application/DoctorDiagnostics.js +1 -2
- package/dist/application/DoctorScope.js +25 -13
- package/dist/application/EnhancedLiteralTracing.js +22 -25
- package/dist/application/EnhancedTools.js +64 -17
- package/dist/application/EvidenceBundleFiles.js +30 -13
- package/dist/application/FunctionAnalysisEvidence.js +2 -3
- package/dist/application/InventoryProjectionEvidence.js +4 -3
- package/dist/application/InvestigationProviders.js +11 -2
- package/dist/application/JsonFiles.js +83 -28
- package/dist/application/LinuxHopper.js +9 -6
- package/dist/application/MacHopper.js +15 -18
- package/dist/application/ProcedureAddressResolution.js +11 -0
- package/dist/application/RealHopperAssertions.js +0 -11
- package/dist/application/ReconstructionCoverageService.js +7 -4
- package/dist/application/ReconstructionObligationCandidates.js +1 -1
- package/dist/application/ReconstructionObligationLedgerService.js +4 -3
- package/dist/application/ReferenceSourceImportEntries.js +1 -1
- package/dist/application/Setup.js +21 -17
- package/dist/application/SetupClientConfiguration.js +10 -15
- package/dist/application/SetupHost.js +21 -29
- package/dist/application/SetupPlan.js +11 -9
- package/dist/application/SupportedClients.js +34 -1
- package/dist/application/Uninstall.js +82 -29
- package/dist/application/Update.js +18 -3
- package/dist/application/UpdateMaintenance.js +7 -5
- package/dist/application/UpdateRuntime.js +57 -36
- package/dist/application/WebModuleTraceService.js +4 -2
- package/dist/application/WebNetworkCaptureService.js +4 -2
- package/dist/application/WebRuntimeService.js +5 -3
- package/dist/application/WebScriptExportService.js +32 -6
- package/dist/application/WebSourceLocationService.js +4 -2
- package/dist/application/WorkflowEvidence.js +105 -0
- package/dist/application/XrefsAddressResolution.js +45 -0
- package/dist/application/analysisView/AnalysisViewService.js +76 -0
- package/dist/application/binary/AnalysisClientCleanup.js +30 -5
- package/dist/application/binary/AnalysisProviderEvaluation.js +22 -7
- package/dist/application/binary/AnalysisProviderRegistry.js +4 -6
- package/dist/application/binary/AnalysisSnapshotCache.js +13 -14
- package/dist/application/binary/BinarySession.js +161 -93
- package/dist/application/binary/BinarySessionComposition.js +1 -3
- package/dist/application/binary/BinarySessionExecution.js +3 -5
- package/dist/application/binary/BinarySessionOpen.js +4 -4
- package/dist/application/binary/BinarySessionRecords.js +26 -4
- package/dist/application/binary/BinarySessionStatus.js +18 -7
- package/dist/application/binary/CompositeProvider.js +16 -17
- package/dist/application/binary/LazyAnalysisProvider.js +8 -5
- package/dist/application/binary/SessionProviderRouter.js +27 -135
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +4 -2
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +4 -2
- package/dist/application/evm/EvmInterfaceService.js +4 -2
- package/dist/application/homebrew.js +48 -0
- package/dist/application/investigation/EvidenceLedger.js +21 -7
- package/dist/application/investigation/InvestigationRecords.js +8 -0
- package/dist/application/javascript/ElectronActiveEvidence.js +9 -13
- package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +21 -4
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +19 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +27 -15
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +5 -5
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +10 -7
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +44 -10
- package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +11 -3
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +9 -0
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +8 -5
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +12 -3
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +0 -1
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +49 -19
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +56 -8
- package/dist/application/javascript/JavaScriptModuleRelationships.js +38 -9
- package/dist/application/javascript/JavaScriptRecoveryService.js +4 -2
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +6 -4
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +2 -3
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +63 -61
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +1 -2
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +2 -3
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +1 -5
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +75 -46
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +2 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +64 -19
- package/dist/application/managed/ManagedApplicationGraphService.js +4 -3
- package/dist/application/managed/ManagedMemberComparisonService.js +9 -5
- package/dist/application/managed/ManagedNativeVerificationService.js +6 -4
- package/dist/application/managed/ManagedReconstructionService.js +4 -3
- package/dist/application/process/ProcessCli.js +25 -17
- package/dist/application/process/ProcessEvidence.js +4 -4
- package/dist/application/workflowInputError.js +18 -0
- package/dist/artifacts/ArtifactProvider.js +48 -13
- package/dist/artifacts/ArtifactReader.js +31 -0
- package/dist/artifacts/DirectoryArtifactReader.js +2 -1
- package/dist/artifacts/MachOSliceArtifactReader.js +106 -15
- package/dist/artifacts/NativeDmgArtifactReader.js +73 -21
- package/dist/artifacts/SafeOutputTree.js +16 -2
- package/dist/artifacts/ZipArtifactReader.js +11 -4
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +26 -5
- package/dist/artifacts/apple/DylibResolutionReader.js +17 -7
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +176 -56
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +195 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +55 -23
- package/dist/artifacts/apple/MachoLoadCommandReader.js +92 -31
- package/dist/artifacts/apple/NibArchive.js +81 -14
- package/dist/artifacts/apple/NibViewHierarchy.js +10 -3
- package/dist/artifacts/apple/PlistNumberLiterals.js +164 -0
- package/dist/artifacts/extraction/ArtifactExtraction.js +78 -21
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +79 -68
- package/dist/artifacts/inventory/ArtifactInventory.js +0 -1
- package/dist/artifacts/inventory/reader.js +3 -3
- package/dist/artifacts/inventory/scanCanonical.js +59 -38
- package/dist/artifacts/inventory/scanReader.js +5 -9
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +6 -2
- package/dist/browser/BrowserScenarioPartialObservation.js +106 -0
- package/dist/browser/CdpBrowserProvider.js +2 -3
- package/dist/browser/CdpCaptureCompleteness.js +2 -0
- package/dist/browser/CdpCaptureEventHandlers.js +78 -15
- package/dist/browser/CdpCaptureEventTypes.js +5 -1
- package/dist/browser/CdpCaptureEvents.js +25 -1
- package/dist/browser/CdpCaptureValues.js +20 -0
- package/dist/browser/CdpConnection.js +30 -11
- package/dist/browser/CdpElectronProvider.js +0 -2
- package/dist/browser/CdpElectronScriptEvents.js +2 -8
- package/dist/browser/CdpElectronScripts.js +2 -3
- package/dist/browser/CdpOptionalCommand.js +2 -3
- package/dist/browser/CdpPageCapture.js +23 -1
- package/dist/browser/CdpPageCaptureScripts.js +2 -3
- package/dist/browser/CdpSafeMetadata.js +10 -10
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +59 -44
- package/dist/browser/PlaywrightElectronActiveActions.js +34 -79
- package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +133 -130
- package/dist/browser/PlaywrightScenarioArtifacts.js +1 -1
- package/dist/browser/PlaywrightScenarioBrowser.js +139 -39
- package/dist/browser/PlaywrightScenarioEvents.js +1 -1
- package/dist/browser/PlaywrightScenarioSession.js +39 -22
- package/dist/browser/WebSourceMapFetcher.js +426 -72
- package/dist/browser/assets/LocalWebScriptArtifacts.js +2 -2
- package/dist/browser/assets/ScriptCaptureAdapters.js +1 -1
- package/dist/browser/history/CaptureFailures.js +41 -1
- package/dist/browser/history/CaptureRelease.js +5 -0
- package/dist/browser/history/HarCaptureAdapter.js +3 -3
- package/dist/browser/history/HarJson.js +3 -2
- package/dist/browser/history/HistoricalCaptureDecoder.js +4 -2
- package/dist/browser/history/MitmproxyCaptureAdapter.js +4 -2
- package/dist/catalogIdentity.js +0 -1
- package/dist/cli/analysisSelector.js +23 -0
- package/dist/cli/analysisViewCommands.js +36 -0
- package/dist/cli/applicationCommands.js +2 -3
- package/dist/cli/artifactCommands.js +11 -12
- package/dist/cli/coreAnalysisCommands.js +3 -3
- package/dist/cli/coreBinaryCommands.js +100 -37
- package/dist/cli/coreNativeCommands.js +9 -10
- package/dist/cli/electronCommands.js +10 -9
- package/dist/cli/interactiveSetup.js +6 -6
- package/dist/cli/javascriptApplicationAnalysis.js +7 -3
- package/dist/cli/jsonOutput.js +4 -99
- package/dist/cli/managedCommands.js +7 -8
- package/dist/cli/nativeCallCommands.js +3 -5
- package/dist/cli/omittableDefaults.js +50 -0
- package/dist/cli/processCommands.js +3 -2
- package/dist/cli/setupCommands.js +16 -15
- package/dist/cli/utilityCommands.js +9 -9
- package/dist/cli/webRuntimeCommands.js +8 -8
- package/dist/cli.js +18 -9
- package/dist/cliBrowserScenarioCommands.js +2 -2
- package/dist/cliCommandNames.js +1 -1
- package/dist/cliJsonInput.js +24 -5
- package/dist/cliOutput.js +0 -38
- package/dist/composition/auxiliaryAnalysisProviders.js +27 -23
- package/dist/composition/binary.js +9 -9
- package/dist/composition/browserScenario.js +2 -1
- package/dist/composition/directAnalysis.js +20 -13
- package/dist/composition/electronScenario.js +1 -1
- package/dist/composition/optionalObservationProviders.js +12 -7
- package/dist/config/environment.js +10 -0
- package/dist/config/ghidraStartupTimeout.js +12 -0
- package/dist/config/homeDirectory.js +12 -0
- package/dist/config/mcpResponseBudget.js +30 -0
- package/dist/config/parseConfig.js +8 -3
- package/dist/config/parsers.js +19 -22
- package/dist/contracts/analysisViewToolContracts.js +56 -0
- package/dist/contracts/applicationToolContracts.js +5 -4
- package/dist/contracts/artifactComparisonExample.js +2 -2
- package/dist/contracts/artifactToolContracts.js +1 -1
- package/dist/contracts/browserScenarioToolContracts.js +1 -1
- package/dist/contracts/browserToolContracts.js +19 -15
- package/dist/contracts/enhancedInputs.js +7 -5
- package/dist/contracts/enhancedToolContracts.js +7 -6
- package/dist/contracts/evm/evmToolContracts.js +1 -1
- package/dist/contracts/functionWorkflowToolContracts.js +1 -1
- package/dist/contracts/hopperMemoryContracts.js +2 -5
- package/dist/contracts/inputSchemaPresentation.js +90 -0
- package/dist/contracts/investigationExamples.js +4 -3
- package/dist/contracts/javascript/electronToolContracts.js +2 -2
- package/dist/contracts/javascript/javascriptApplicationWorkflowExamples.js +0 -20
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +245 -0
- package/dist/contracts/javascript/javascriptRuntimeObservationToolContracts.js +1 -1
- package/dist/contracts/managed/managedToolContracts.js +7 -14
- package/dist/contracts/managed/managedWorkflowToolContracts.js +1 -1
- package/dist/contracts/mobileApplicationGraphExamples.js +3 -3
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +1 -1
- package/dist/contracts/native/nativeToolContracts.js +5 -3
- package/dist/contracts/officialToolContracts.js +16 -16
- package/dist/contracts/promptContracts.js +5 -5
- package/dist/contracts/providerSelection.js +1 -1
- package/dist/contracts/sessionLifecycleInputs.js +3 -7
- package/dist/contracts/sessionStatusContract.js +2 -4
- package/dist/contracts/sessionToolContracts.js +18 -8
- package/dist/contracts/sessionToolSchemas.js +3 -19
- package/dist/contracts/toolContractExamples.js +0 -1
- package/dist/contracts/toolContractHelpers.js +4 -1
- package/dist/contracts/toolContracts.js +2 -0
- package/dist/contracts/toolEffects.js +1 -1
- package/dist/contracts/toolOutputSchemaGroups.js +160 -115
- package/dist/contracts/toolOutputSchemaPrimitives.js +28 -20
- package/dist/contracts/toolSchemaMetadata.js +41 -33
- package/dist/contracts/webNetworkCaptureToolContracts.js +2 -2
- package/dist/contracts/webRuntimeToolContracts.js +1 -1
- package/dist/contracts/webScriptToolContracts.js +1 -1
- package/dist/doctorRuntime.js +7 -5
- package/dist/domain/analysisErrorBase.js +8 -3
- package/dist/domain/analysisErrorCore.js +6 -1
- package/dist/domain/analysisErrorPresentation.js +90 -20
- package/dist/domain/analysisErrorProjection.js +130 -32
- package/dist/domain/analysisSnapshot.js +29 -31
- package/dist/domain/analysisView/analysisView.js +243 -0
- package/dist/domain/analysisView/analysisViewCoverage.js +19 -0
- package/dist/domain/analysisView/binaryLayoutView.js +159 -0
- package/dist/domain/analysisView/javascriptApplicationView.js +238 -0
- package/dist/domain/android/androidAnalysis.js +2 -4
- package/dist/domain/android/androidApplication.js +18 -10
- package/dist/domain/apple/appleApplication.js +42 -15
- package/dist/domain/apple/dyldEnvironment.js +73 -0
- package/dist/domain/apple/dylibResolution.js +130 -12
- package/dist/domain/apple/dylibResolutionFindings.js +9 -7
- package/dist/domain/apple/interfaceBuilderGraph.js +25 -14
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +13 -3
- package/dist/domain/apple/keyedArchive.js +35 -3
- package/dist/domain/apple/machoContainer.js +54 -0
- package/dist/domain/apple/plistNumbers.js +76 -0
- package/dist/domain/artifactComparison.js +15 -6
- package/dist/domain/artifactGraph.js +16 -3
- package/dist/domain/artifactIdentity.js +29 -0
- package/dist/domain/artifactInventoryEvidence.js +28 -40
- package/dist/domain/artifactOperationError.js +3 -3
- package/dist/domain/artifactPartialObservation.js +1 -0
- package/dist/domain/artifactPathSyntax.js +49 -0
- package/dist/domain/binaryTarget.js +39 -13
- package/dist/domain/bridgeCandidateProjection.js +71 -0
- package/dist/domain/browserCaptureComparison.js +13 -49
- package/dist/domain/browserCompleteness.js +1 -0
- package/dist/domain/browserNetworkEvidence.js +10 -4
- package/dist/domain/browserObservation.js +0 -1
- package/dist/domain/browserObservationError.js +24 -5
- package/dist/domain/browserObservationSchemas.js +14 -3
- package/dist/domain/browserScenario.js +0 -1
- package/dist/domain/browserScenarioCapture.js +1 -2
- package/dist/domain/browserScenarioDiff.js +0 -2
- package/dist/domain/browserScenarioDiffEvidence.js +0 -12
- package/dist/domain/browserScenarioDiffValues.js +2 -2
- package/dist/domain/browserScenarioValues.js +5 -10
- package/dist/domain/bundleComparison.js +3 -2
- package/dist/domain/callPath.js +8 -9
- package/dist/domain/callPathSchemas.js +2 -2
- package/dist/domain/canonicalJsonDigestSteps.js +133 -0
- package/dist/domain/canonicalOrdering.js +9 -5
- package/dist/domain/changedBehavior.js +9 -9
- package/dist/domain/comparisonSourceEvidence.js +40 -0
- package/dist/domain/completionLedgerGeneration.js +2 -1
- package/dist/domain/configurationErrors.js +13 -1
- package/dist/domain/conformancePackage.js +4 -3
- package/dist/domain/evidence.js +65 -36
- package/dist/domain/evidenceBundle.js +47 -8
- package/dist/domain/evidenceCompletionLedger.js +2 -1
- package/dist/domain/evidenceErrors.js +12 -1
- package/dist/domain/explicitSensitiveFailure.js +17 -1
- package/dist/domain/firmware/firmwareAnalysis.js +6 -7
- package/dist/domain/functionComparison.js +4 -5
- package/dist/domain/functionComparisonDimensions.js +120 -87
- package/dist/domain/functionComparisonNormalization.js +23 -34
- package/dist/domain/functionComparisonResults.js +1 -4
- package/dist/domain/functionComparisonSchemas.js +2 -8
- package/dist/domain/functionDossierEvidence.js +2 -37
- package/dist/domain/hopperErrors.js +23 -2
- package/dist/domain/hopperValues.js +51 -8
- package/dist/domain/immutableJson.js +114 -0
- package/dist/domain/inputIssueProjection.js +3 -0
- package/dist/domain/javascript/electronActiveObservation.js +47 -64
- package/dist/domain/javascript/electronObservation.js +14 -3
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +10 -9
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +2 -1
- package/dist/domain/javascript/electronStaticAnalysisNative.js +2 -1
- package/dist/domain/javascript/electronStaticAnalysisValues.js +6 -12
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +71 -23
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +2 -0
- package/dist/domain/javascript/javascriptApplicationGraph.js +39 -3
- package/dist/domain/javascript/javascriptApplicationGraphSchemas.js +9 -2
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +5 -2
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +2 -1
- package/dist/domain/javascript/javascriptAstValues.js +20 -0
- package/dist/{application/javascript/JavaScriptReturnShapeProjection.js → domain/javascript/javascriptExportReturnShapeProjection.js} +4 -4
- package/dist/domain/javascript/javascriptExportShapeComparison.js +7 -1
- package/dist/domain/javascript/javascriptExportShapeComparisonIdentity.js +6 -1
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +29 -1
- package/dist/domain/javascript/javascriptExportShapeSelection.js +5 -5
- package/dist/domain/javascript/javascriptExportShapeVariants.js +67 -14
- package/dist/domain/javascript/javascriptFeatureSeed.js +20 -0
- package/dist/domain/javascript/javascriptFeatureTraversal.js +0 -1
- package/dist/domain/javascript/javascriptNativeHandoff.js +1 -1
- package/dist/domain/javascript/javascriptRecovery.js +3 -8
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +0 -1
- package/dist/domain/javascript/javascriptRuntimeObservation.js +10 -2
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +1 -1
- package/dist/domain/javascript/javascriptRuntimeReconciliationParsing.js +3 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +0 -1
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +106 -5
- package/dist/domain/javascript/javascriptSemanticAsyncEffects.js +2 -1
- package/dist/domain/javascript/javascriptSemanticCalls.js +2 -1
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +2 -1
- package/dist/domain/javascript/javascriptSemanticCoverage.js +6 -5
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +9 -17
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +23 -6
- package/dist/domain/javascript/javascriptSemanticGraph.js +98 -43
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +1 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +77 -20
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +21 -27
- package/dist/domain/javascript/javascriptSemanticObjects.js +83 -42
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +18 -21
- package/dist/domain/javascript/javascriptSemanticProjection.js +2 -3
- package/dist/domain/javascript/javascriptSemanticPromises.js +2 -1
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -4
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
- package/dist/domain/javascript/javascriptSemanticResources.js +1 -1
- package/dist/domain/javascript/javascriptSemanticReturns.js +32 -17
- package/dist/domain/javascript/javascriptSemanticSlots.js +72 -0
- package/dist/domain/javascript/javascriptSemanticValues.js +126 -61
- package/dist/domain/javascript/javascriptSourceMapPaths.js +104 -0
- package/dist/domain/javascript/javascriptSourceParser.js +6 -2
- package/dist/domain/javascript/javascriptStaticAnalysis.js +22 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -3
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +16 -5
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +66 -7
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +28 -17
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -2
- package/dist/domain/javascript/sourceToBundleComparison.js +12 -3
- package/dist/domain/javascript/sourceToBundleSignals.js +47 -19
- package/dist/domain/jsonSerialization.js +109 -0
- package/dist/domain/jsonValue.js +90 -6
- package/dist/domain/localPath.js +6 -0
- package/dist/domain/managed/managedApplicationGraph.js +10 -10
- package/dist/domain/managed/managedArtifact.js +6 -4
- package/dist/domain/managed/managedInspectionEvidence.js +16 -0
- package/dist/domain/managed/managedMemberComparison.js +2 -9
- package/dist/domain/managed/managedMemberComparisonMatch.js +5 -9
- package/dist/domain/managed/managedNativeVerification.js +3 -11
- package/dist/domain/managed/managedNativeVerificationMatch.js +9 -3
- package/dist/domain/native/binaryLayout.js +2 -3
- package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
- package/dist/domain/native/nativeApiBoundary.js +1 -1
- package/dist/domain/native/nativeCallObservation.js +37 -13
- package/dist/domain/native/nativeCallPartialObservation.js +33 -0
- package/dist/domain/native/nativeInstruction.js +7 -0
- package/dist/domain/native/recordedCrash.js +2 -3
- package/dist/domain/offsetDateTime.js +17 -0
- package/dist/domain/process/processCapture.js +21 -16
- package/dist/domain/process/processCaptureCoverage.js +67 -0
- package/dist/domain/process/processCaptureExample.js +2 -1
- package/dist/domain/process/processCaptureParsing.js +1 -34
- package/dist/domain/process/processCaptureValidation.js +81 -13
- package/dist/domain/process/processComparison.js +79 -26
- package/dist/domain/process/processObservation.js +10 -2
- package/dist/domain/process/processScenario.js +35 -12
- package/dist/domain/process/processTraceComparison.js +0 -2
- package/dist/domain/process/processTraceDimensionProjection.js +1 -1
- package/dist/domain/process/processTraceEvaluation.js +15 -11
- package/dist/domain/process/processTraceSpecification.js +3 -4
- package/dist/domain/propertyListKeys.js +1 -1
- package/dist/domain/propertyListXmlText.js +19 -0
- package/dist/domain/providerAdapterError.js +3 -1
- package/dist/domain/providerOperationHealth.js +54 -0
- package/dist/domain/reconstructionCoverage.js +5 -2
- package/dist/domain/reconstructionObligationLedgerSchemas.js +2 -1
- package/dist/domain/reconstructionReadinessSchemas.js +2 -1
- package/dist/domain/reconstructionVerification.js +9 -46
- package/dist/domain/reconstructionVerificationSchemas.js +4 -3
- package/dist/domain/referenceSourceGraph.js +20 -21
- package/dist/domain/staticRuntimeCorrelation.js +8 -45
- package/dist/domain/stringPatterns.js +6 -0
- package/dist/domain/swiftSymbolClassification.js +61 -0
- package/dist/domain/symbolAnalysis.js +66 -18
- package/dist/domain/webBundleAnalysis.js +20 -8
- package/dist/domain/webBundleAnalyzerInspection.js +13 -8
- package/dist/domain/webBundleAnalyzerResult.js +41 -2
- package/dist/domain/webCaptureDiff.js +0 -1
- package/dist/domain/webCaptureDiffSchemas.js +6 -3
- package/dist/domain/webEventListeners.js +3 -2
- package/dist/domain/webExecution.js +3 -2
- package/dist/domain/webRuntime.js +19 -7
- package/dist/domain/webScriptExport.js +1 -1
- package/dist/domain/webSourceLocation.js +1 -0
- package/dist/dotnet/ManagedArtifactInspector.js +2 -19
- package/dist/dotnet/ManagedMemberInspector.js +12 -18
- package/dist/dotnet/ManagedMemberInspectorCore.js +47 -44
- package/dist/dotnet/ManagedMemberRows.js +75 -62
- package/dist/dotnet/ManagedMetadataInventory.js +16 -22
- package/dist/dotnet/ManagedMethodBodyReader.js +4 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +109 -94
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +12 -21
- package/dist/dotnet/ManagedReaderFailure.js +16 -0
- package/dist/dotnet/ManagedStaticProvider.js +3 -5
- package/dist/evaluation/AgentEvaluationFixtures.js +250 -0
- package/dist/evaluation/AgentEvaluationReport.js +28 -0
- package/dist/evaluation/CodexAgentEval.js +12 -8
- package/dist/evaluation/KnownAnswerEvaluation.js +281 -0
- package/dist/evm/EvmoleInterfaceProvider.js +2 -1
- package/dist/firmware/FirmwareCommand.js +9 -5
- package/dist/firmware/FirmwareFiles.js +1 -1
- package/dist/firmware/FirmwareProvider.js +4 -4
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +7 -5
- package/dist/ghidra/GhidraClient.js +126 -34
- package/dist/ghidra/GhidraClientStartup.js +0 -2
- package/dist/ghidra/GhidraDiagnostics.js +7 -7
- package/dist/ghidra/GhidraDoctor.js +6 -5
- package/dist/ghidra/GhidraFunctionValues.js +13 -12
- package/dist/ghidra/GhidraInstallation.js +58 -33
- package/dist/ghidra/GhidraInventoryValues.js +14 -4
- package/dist/ghidra/GhidraJavaLaunch.js +66 -0
- package/dist/ghidra/GhidraLauncher.js +47 -22
- package/dist/ghidra/GhidraProvider.js +6 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +20 -2
- package/dist/ghidra/GhidraProviderClient.js +36 -15
- package/dist/ghidra/GhidraSessionError.js +13 -7
- package/dist/ghidra/GhidraSessionRoot.js +39 -0
- package/dist/ghidra/GhidraTargetSnapshot.js +47 -12
- package/dist/ghidra/GhidraTransport.js +20 -0
- package/dist/ghidra/extensions/GhidraExtensions.js +17 -10
- package/dist/ghidra/extensions/nativeaot/NativeAotAdapter.js +8 -2
- package/dist/hopper/BridgeLauncher.js +65 -56
- package/dist/hopper/HopperAnalysisProfile.js +65 -12
- package/dist/hopper/HopperCleanup.js +63 -22
- package/dist/hopper/HopperClient.js +288 -59
- package/dist/hopper/HopperFileOffset.js +237 -0
- package/dist/hopper/HopperMachOImage.js +197 -0
- package/dist/hopper/HopperOperationStage.js +6 -0
- package/dist/hopper/HopperProvider.js +71 -19
- package/dist/hopper/HopperProviderCapabilities.js +19 -1
- package/dist/hopper/HopperRegexSearch.js +134 -0
- package/dist/hopper/HopperRegexWorker.js +27 -0
- package/dist/hopper/HopperRequestQueue.js +68 -19
- package/dist/hopper/HopperTargetLease.js +133 -49
- package/dist/hopper/LinuxPrivateDisplayProbe.js +6 -0
- package/dist/ida/IdaConfiguration.js +8 -3
- package/dist/ida/IdaInput.js +1 -7
- package/dist/ida/IdaMcpConnection.js +8 -4
- package/dist/ida/IdaOperationRunner.js +3 -3
- package/dist/ida/IdaProvider.js +8 -12
- package/dist/ida/IdaSessionClient.js +20 -18
- package/dist/ida/IdaWorkspace.js +12 -13
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -1
- package/dist/inspector/V8InspectorCaptureProjection.js +9 -4
- package/dist/inspector/V8InspectorProvider.js +82 -36
- package/dist/javascript/recovery/WakaruCommand.js +7 -2
- package/dist/javascript/recovery/WakaruExecution.js +5 -2
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +16 -0
- package/dist/javascript/sourceMaps/SourceMapFormat.js +79 -31
- package/dist/javascript/sourceMaps/TraceSourceMap.js +14 -28
- package/dist/main/shutdown.js +11 -3
- package/dist/main/startup.js +9 -2
- package/dist/main/transport.js +22 -2
- package/dist/main.js +11 -18
- package/dist/mcpDoctor.js +62 -2
- package/dist/native/AppleDispatchCoverage.js +47 -6
- package/dist/native/AppleDispatchDecodeFacts.js +6 -0
- package/dist/native/AppleDispatchMetadata.js +6 -3
- package/dist/native/AppleMachoFixups.js +48 -24
- package/dist/native/AppleMachoSelection.js +48 -22
- package/dist/native/AppleObjcCategories.js +6 -2
- package/dist/native/AppleObjcDispatchFacets.js +5 -2
- package/dist/native/AppleObjcProperties.js +2 -1
- package/dist/native/AppleSwiftDispatchFacets.js +27 -21
- package/dist/native/AppleSwiftVtables.js +21 -15
- package/dist/native/CommandRunner.js +87 -88
- package/dist/native/LldbCallTracer.js +372 -103
- package/dist/native/LldbRetainedObservations.js +178 -0
- package/dist/native/NativeCallObservation.js +62 -3
- package/dist/native/NativeMacOSProvider.js +122 -31
- package/dist/native/NativeUiHelperRuntime.js +11 -2
- package/dist/native/NativeUiObservation.js +2 -2
- package/dist/native/SignatureTargetBinding.js +155 -0
- package/dist/native/parsers/lipo.js +71 -1
- package/dist/native/pwndbg/PwndbgCoreContext.js +25 -5
- package/dist/native/pwntools/PwntoolsDecoder.js +2 -1
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +2 -0
- package/dist/process/DarwinProcessRunTokenReader.js +23 -10
- package/dist/process/ExecFileOutput.js +108 -6
- package/dist/process/OwnedCommand.js +7 -2
- package/dist/process/PrivateRuntimeRoot.js +10 -5
- package/dist/process/ProcessOwnership.js +204 -57
- package/dist/process/ProcessOwnershipObservation.js +60 -9
- package/dist/process/ProviderProcess.js +39 -10
- package/dist/process/capture/FilesystemSnapshot.js +50 -13
- package/dist/process/capture/ProcessCaptureError.js +15 -2
- package/dist/process/capture/ProcessCaptureLifecycle.js +235 -81
- package/dist/process/capture/ProcessFilesystemEffects.js +33 -3
- package/dist/process/capture/ProcessHarness.js +21 -25
- package/dist/process/capture/ProcessNormalization.js +20 -2
- package/dist/process/capture/ProcessSampling.js +25 -2
- package/dist/process/capture/TerminalRenderer.js +14 -0
- package/dist/process/snapshotEnvironment.js +14 -0
- package/dist/server/EvidenceMcpServer.js +157 -0
- package/dist/server/createServer.js +61 -41
- package/dist/server/mcpClientMetadata.js +12 -5
- package/dist/server/promptCompletion.js +3 -8
- package/dist/server/registerAnalysisViewTool.js +15 -0
- package/dist/server/registerAndroidTools.js +2 -5
- package/dist/server/registerApplicationTools/compareExportShapes.js +4 -5
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +4 -5
- package/dist/server/registerApplicationTools/compareVersions.js +4 -5
- package/dist/server/registerApplicationTools/coverage.js +1 -2
- package/dist/server/registerApplicationTools/helpers.js +1 -4
- package/dist/server/registerApplicationTools/obligationLedger.js +4 -5
- package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +3 -4
- package/dist/server/registerApplicationTools/traceFeature.js +4 -5
- package/dist/server/registerApplicationTools/traceSemantics.js +4 -5
- package/dist/server/registerArtifactComparisonTool.js +13 -10
- package/dist/server/registerBinaryDiagnosticsTools.js +2 -5
- package/dist/server/registerBrowserScenarioTool.js +3 -6
- package/dist/server/registerBrowserTools.js +13 -18
- package/dist/server/registerBundleComparisonTool.js +5 -7
- package/dist/server/registerCloseLifecycleTool.js +9 -20
- package/dist/server/registerElectronTools.js +10 -15
- package/dist/server/registerEnhancedTools.js +36 -77
- package/dist/server/registerEvidenceTools.js +3 -6
- package/dist/server/registerEvmTools.js +2 -5
- package/dist/server/registerFirmwareTools.js +2 -5
- package/dist/server/registerFunctionComparisonTool.js +15 -12
- package/dist/server/registerInvestigationTools.js +16 -17
- package/dist/server/registerJavaScriptRecoveryTool.js +2 -5
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +6 -8
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +5 -8
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +4 -7
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +6 -9
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +6 -9
- package/dist/server/registerOfficialTools.js +4 -21
- package/dist/server/registerProcessComparisonTool.js +74 -48
- package/dist/server/registerRecordedCrashTools.js +2 -5
- package/dist/server/registerSessionRecordTools.js +19 -24
- package/dist/server/registerSessionStatusTool.js +19 -6
- package/dist/server/registerSessionTools.js +20 -18
- package/dist/server/registerWebModuleTool.js +2 -5
- package/dist/server/registerWebNetworkCaptureTool.js +2 -5
- package/dist/server/registerWebRuntimeTools.js +4 -9
- package/dist/server/registerWebScriptTool.js +2 -5
- package/dist/server/registerWebSourceLocationTool.js +2 -5
- package/dist/server/runDerivedOperation.js +15 -3
- package/dist/server/sessionAvailabilityPolicy.js +0 -1
- package/dist/server/toolRegistrationOptions.js +2 -2
- package/dist/server/toolResult.js +75 -51
- package/dist/server/toolResultEncoding.js +34 -0
- package/dist/windows/WindowsNativeLoader.js +1 -0
- package/dist/windows/WindowsOwnedProcess.js +60 -15
- package/dist/windows/WindowsPrivateRuntime.js +7 -8
- package/install.sh +1 -1
- package/native/windows/README.md +3 -1
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +44 -30
- package/scripts/electron-active-hook-boundaries.cjs +18 -20
- package/scripts/electron-active-hook.cjs +241 -37
- package/scripts/rea.mjs +3 -6
- package/skills/reverse-engineer-anything/SKILL.md +12 -3
- package/skills/reverse-engineer-anything/references/android-applications.md +6 -3
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +8 -4
- package/skills/reverse-engineer-anything/references/javascript-applications.md +20 -3
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +9 -0
- package/dist/config.js +0 -1
- package/dist/contracts/browserCaptureToolInputSchema.js +0 -43
- package/dist/contracts/process/processCaptureExample.js +0 -2
- package/dist/contracts/toolOutputSchemas.js +0 -2
- package/dist/ghidra/GhidraDefaults.js +0 -2
- package/dist/main/reload.js +0 -12
- package/dist/main/state.js +0 -3
- package/dist/server/sessionToolPolicies.js +0 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { inferJsonShape } from "../domain/jsonShape.js";
|
|
2
2
|
import { safeResponseMetadata } from "./CdpSafeMetadata.js";
|
|
3
|
-
import { allowedSanitizedUrl, isHttpUrl, numberValue, recordValue, recordsValue, cdpStringValue, } from "./CdpCaptureValues.js";
|
|
3
|
+
import { allowedSanitizedUrl, isHttpUrl, numberValue, recordValue, recordsValue, scriptMetadataValues, cdpStringValue, } from "./CdpCaptureValues.js";
|
|
4
4
|
import { requestBodyShape, updateResponseBodyShape, } from "./CdpCaptureEventBodyShapes.js";
|
|
5
5
|
import { consolePrimitive, decodeBase64, exclusionReasonForUrl, executionContextKey, firstCallFrame, initiatorLocation, integerOrNull, isJsonMediaType, isMainFrameNavigation, } from "./CdpCaptureEventHelpers.js";
|
|
6
|
+
import { CDP_CAPTURE_SCRIPT_METADATA_LIMITS, } from "./CdpCaptureEventTypes.js";
|
|
6
7
|
export const handleExecutionContextCreated = (state, params) => {
|
|
7
8
|
const context = recordValue(params.context);
|
|
8
9
|
const identifier = numberValue(context?.id);
|
|
@@ -27,30 +28,67 @@ export const handleScriptParsed = (state, params) => {
|
|
|
27
28
|
state.completeness.exclude("scripts", "invalid_protocol_value");
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
31
|
+
const replacedBytes = state.scriptMetadataBytesById.get(scriptId) ?? 0;
|
|
32
|
+
state.scriptMetadataBudgetOmissionsById.delete(scriptId);
|
|
33
|
+
if (replacedBytes > 0) {
|
|
34
|
+
state.scripts.delete(scriptId);
|
|
35
|
+
state.scriptMetadataBytesById.delete(scriptId);
|
|
36
|
+
state.retainedScriptMetadataBytes -= replacedBytes;
|
|
37
|
+
}
|
|
30
38
|
if (sanitized === undefined) {
|
|
31
39
|
state.completeness.exclude("scripts", exclusionReasonForUrl(rawUrl));
|
|
32
40
|
return;
|
|
33
41
|
}
|
|
34
|
-
const
|
|
35
|
-
const script = {
|
|
42
|
+
const baseScript = {
|
|
36
43
|
scriptId,
|
|
37
44
|
rawUrl,
|
|
38
45
|
url: sanitized.url,
|
|
39
46
|
origin: sanitized.origin,
|
|
40
|
-
|
|
41
|
-
length: Math.max(0, Math.min(Number.MAX_SAFE_INTEGER, Math.trunc(numberValue(params.length) ?? 0))),
|
|
42
|
-
isModule: params.isModule === true,
|
|
47
|
+
...scriptMetadataValues(params),
|
|
43
48
|
language: cdpStringValue(params.scriptLanguage) ?? null,
|
|
44
|
-
sourceMapUrl: sourceMap.sanitized,
|
|
45
|
-
sourceMapRawUrl: sourceMap.raw,
|
|
46
49
|
executionContextKey: executionContextKey(params.executionContextId),
|
|
47
50
|
};
|
|
51
|
+
const baseBytes = scriptMetadataStringBytes(baseScript);
|
|
52
|
+
const sourceMapDeclared = typeof params.sourceMapURL === "string" && params.sourceMapURL.length > 0;
|
|
53
|
+
if (state.scripts.size >= CDP_CAPTURE_SCRIPT_METADATA_LIMITS.scripts ||
|
|
54
|
+
baseBytes >
|
|
55
|
+
CDP_CAPTURE_SCRIPT_METADATA_LIMITS.retainedBytes -
|
|
56
|
+
state.retainedScriptMetadataBytes) {
|
|
57
|
+
state.rejectedScriptMetadataBudgetCount += 1;
|
|
58
|
+
if (sourceMapDeclared)
|
|
59
|
+
state.rejectedSourceMapMetadataBudgetCount += 1;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const sourceMap = sourceMapForScript(params.sourceMapURL, rawUrl, state, CDP_CAPTURE_SCRIPT_METADATA_LIMITS.retainedBytes -
|
|
63
|
+
state.retainedScriptMetadataBytes -
|
|
64
|
+
baseBytes);
|
|
65
|
+
const { budgetExhausted, ...sourceMapFields } = sourceMap;
|
|
66
|
+
const script = { ...baseScript, ...sourceMapFields };
|
|
67
|
+
if (budgetExhausted)
|
|
68
|
+
state.scriptMetadataBudgetOmissionsById.set(scriptId, true);
|
|
69
|
+
const retainedBytes = baseBytes +
|
|
70
|
+
stringByteLength(sourceMap.sourceMapUrl) +
|
|
71
|
+
stringByteLength(sourceMap.sourceMapRawUrl);
|
|
72
|
+
state.retainedScriptMetadataBytes += retainedBytes;
|
|
73
|
+
state.scriptMetadataBytesById.set(scriptId, retainedBytes);
|
|
48
74
|
state.scripts.set(scriptId, script);
|
|
49
75
|
};
|
|
50
|
-
const
|
|
76
|
+
const scriptMetadataStringBytes = (script) => stringByteLength(script.scriptId) +
|
|
77
|
+
stringByteLength(script.rawUrl) +
|
|
78
|
+
stringByteLength(script.url) +
|
|
79
|
+
stringByteLength(script.origin) +
|
|
80
|
+
stringByteLength(script.hash) +
|
|
81
|
+
stringByteLength(script.language) +
|
|
82
|
+
stringByteLength(script.executionContextKey);
|
|
83
|
+
const stringByteLength = (value) => value === null ? 0 : Buffer.byteLength(value, "utf8");
|
|
84
|
+
const sourceMapForScript = (value, scriptUrl, state, remainingBytes) => {
|
|
51
85
|
const declaredUrl = cdpStringValue(value);
|
|
52
86
|
if (declaredUrl === undefined || declaredUrl === "")
|
|
53
|
-
return {
|
|
87
|
+
return {
|
|
88
|
+
sourceMapUrl: null,
|
|
89
|
+
sourceMapRawUrl: null,
|
|
90
|
+
budgetExhausted: false,
|
|
91
|
+
};
|
|
54
92
|
let rawUrl;
|
|
55
93
|
try {
|
|
56
94
|
rawUrl = new URL(declaredUrl, scriptUrl).href;
|
|
@@ -59,13 +97,34 @@ const sourceMapForScript = (value, scriptUrl, state) => {
|
|
|
59
97
|
// Unparseable URLs are recorded as unsupported, not as failures.
|
|
60
98
|
void cause;
|
|
61
99
|
state.completeness.exclude("source_maps", "unsupported_url");
|
|
62
|
-
return {
|
|
100
|
+
return {
|
|
101
|
+
sourceMapUrl: null,
|
|
102
|
+
sourceMapRawUrl: null,
|
|
103
|
+
budgetExhausted: false,
|
|
104
|
+
};
|
|
63
105
|
}
|
|
64
106
|
const sanitized = allowedSanitizedUrl(rawUrl, state.allowedOrigins);
|
|
65
|
-
if (sanitized !== undefined)
|
|
66
|
-
|
|
107
|
+
if (sanitized !== undefined) {
|
|
108
|
+
if (stringByteLength(rawUrl) + stringByteLength(sanitized.url) >
|
|
109
|
+
remainingBytes) {
|
|
110
|
+
return {
|
|
111
|
+
sourceMapUrl: null,
|
|
112
|
+
sourceMapRawUrl: null,
|
|
113
|
+
budgetExhausted: true,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
sourceMapUrl: sanitized.url,
|
|
118
|
+
sourceMapRawUrl: rawUrl,
|
|
119
|
+
budgetExhausted: false,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
67
122
|
state.completeness.exclude("source_maps", exclusionReasonForUrl(rawUrl));
|
|
68
|
-
return {
|
|
123
|
+
return {
|
|
124
|
+
sourceMapUrl: null,
|
|
125
|
+
sourceMapRawUrl: null,
|
|
126
|
+
budgetExhausted: false,
|
|
127
|
+
};
|
|
69
128
|
};
|
|
70
129
|
export const handleRequestWillBeSent = (state, params) => {
|
|
71
130
|
const requestId = cdpStringValue(params.requestId);
|
|
@@ -76,6 +135,11 @@ export const handleRequestWillBeSent = (state, params) => {
|
|
|
76
135
|
}
|
|
77
136
|
if (state.malformedRedirectRequestIds.has(requestId))
|
|
78
137
|
return;
|
|
138
|
+
const previous = state.network.get(requestId);
|
|
139
|
+
if (!Object.hasOwn(params, "redirectResponse") &&
|
|
140
|
+
previous !== undefined &&
|
|
141
|
+
preserveMalformedRedirectEvidence(state, requestId, previous))
|
|
142
|
+
return;
|
|
79
143
|
if (request === undefined) {
|
|
80
144
|
state.completeness.exclude("network_requests", "invalid_protocol_value");
|
|
81
145
|
state.network.delete(requestId);
|
|
@@ -89,7 +153,6 @@ export const handleRequestWillBeSent = (state, params) => {
|
|
|
89
153
|
state.networkRequestTimestamps.delete(requestId);
|
|
90
154
|
return;
|
|
91
155
|
}
|
|
92
|
-
const previous = state.network.get(requestId);
|
|
93
156
|
const redirectResponse = recordValue(params.redirectResponse);
|
|
94
157
|
if (Object.hasOwn(params, "redirectResponse") &&
|
|
95
158
|
redirectResponse === undefined &&
|
|
@@ -3,10 +3,15 @@ import * as bodyShapes from "./CdpCaptureEventBodyShapes.js";
|
|
|
3
3
|
import * as handlers from "./CdpCaptureEventHandlers.js";
|
|
4
4
|
import { isJsonMediaType } from "./CdpCaptureEventHelpers.js";
|
|
5
5
|
import { recordValue } from "./CdpCaptureValues.js";
|
|
6
|
-
export {} from "./CdpCaptureEventTypes.js";
|
|
7
6
|
/** Event accumulator that validates and normalizes payloads at ingestion. */
|
|
8
7
|
export class CdpCaptureEvents {
|
|
8
|
+
#scriptMetadataBudgetExclusionsRecorded = false;
|
|
9
9
|
scripts = new Map();
|
|
10
|
+
scriptMetadataBudgetOmissionsById = new Map();
|
|
11
|
+
rejectedScriptMetadataBudgetCount = 0;
|
|
12
|
+
rejectedSourceMapMetadataBudgetCount = 0;
|
|
13
|
+
scriptMetadataBytesById = new Map();
|
|
14
|
+
retainedScriptMetadataBytes = 0;
|
|
10
15
|
executionContextFrames = new Map();
|
|
11
16
|
network = new Map();
|
|
12
17
|
networkRequestTimestamps = new Map();
|
|
@@ -39,6 +44,12 @@ export class CdpCaptureEvents {
|
|
|
39
44
|
this.navigationDuringCapture = false;
|
|
40
45
|
this.committedDocument = undefined;
|
|
41
46
|
this.scripts.clear();
|
|
47
|
+
this.scriptMetadataBudgetOmissionsById.clear();
|
|
48
|
+
this.rejectedScriptMetadataBudgetCount = 0;
|
|
49
|
+
this.rejectedSourceMapMetadataBudgetCount = 0;
|
|
50
|
+
this.scriptMetadataBytesById.clear();
|
|
51
|
+
this.retainedScriptMetadataBytes = 0;
|
|
52
|
+
this.#scriptMetadataBudgetExclusionsRecorded = false;
|
|
42
53
|
this.executionContextFrames.clear();
|
|
43
54
|
this.network.clear();
|
|
44
55
|
this.networkRequestTimestamps.clear();
|
|
@@ -67,6 +78,19 @@ export class CdpCaptureEvents {
|
|
|
67
78
|
// compared against itself rather than the document we just left.
|
|
68
79
|
this.committedDocument = undefined;
|
|
69
80
|
}
|
|
81
|
+
/** Record final script metadata omissions after all scriptParsed replacements. */
|
|
82
|
+
recordScriptMetadataBudgetExclusions() {
|
|
83
|
+
if (this.#scriptMetadataBudgetExclusionsRecorded)
|
|
84
|
+
return;
|
|
85
|
+
this.#scriptMetadataBudgetExclusionsRecorded = true;
|
|
86
|
+
const omittedScripts = this.rejectedScriptMetadataBudgetCount;
|
|
87
|
+
const omittedSourceMaps = this.rejectedSourceMapMetadataBudgetCount +
|
|
88
|
+
this.scriptMetadataBudgetOmissionsById.size;
|
|
89
|
+
if (omittedScripts > 0)
|
|
90
|
+
this.completeness.exclude("scripts", "resource_budget_exhausted", omittedScripts);
|
|
91
|
+
if (omittedSourceMaps > 0)
|
|
92
|
+
this.completeness.exclude("source_maps", "resource_budget_exhausted", omittedSourceMaps);
|
|
93
|
+
}
|
|
70
94
|
ingest(event) {
|
|
71
95
|
const params = recordValue(event.params);
|
|
72
96
|
if (params === undefined)
|
|
@@ -13,12 +13,32 @@ export const recordsValue = (value) => Array.isArray(value)
|
|
|
13
13
|
: [];
|
|
14
14
|
export const cdpStringValue = (value) => typeof value === "string" ? value : undefined;
|
|
15
15
|
export const numberValue = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
16
|
+
/** Preserve partial script declarations; omitted or invalid fields remain unknown. */
|
|
17
|
+
export const scriptMetadataValues = (value) => {
|
|
18
|
+
const length = numberValue(value?.length);
|
|
19
|
+
return {
|
|
20
|
+
hash: cdpStringValue(value?.hash) ?? null,
|
|
21
|
+
length: length !== undefined && Number.isSafeInteger(length) && length >= 0
|
|
22
|
+
? length
|
|
23
|
+
: null,
|
|
24
|
+
isModule: typeof value?.isModule === "boolean" ? value.isModule : null,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
16
27
|
export const requiredRecord = (value) => {
|
|
17
28
|
const record = recordValue(value);
|
|
18
29
|
if (record === undefined)
|
|
19
30
|
throw new BrowserObservationError("inspect_web_page", "protocol_error");
|
|
20
31
|
return record;
|
|
21
32
|
};
|
|
33
|
+
/** Require producer source text; an absent source is distinct from an empty script. */
|
|
34
|
+
export const requiredScriptSource = (value, operation) => {
|
|
35
|
+
const source = cdpStringValue(recordValue(value)?.scriptSource);
|
|
36
|
+
if (source === undefined)
|
|
37
|
+
throw new BrowserObservationError(operation, "protocol_error", {
|
|
38
|
+
detail: "Debugger.getScriptSource returned malformed source text: scriptSource must be a string.",
|
|
39
|
+
});
|
|
40
|
+
return source;
|
|
41
|
+
};
|
|
22
42
|
export const isHttpUrl = (value) => {
|
|
23
43
|
if (value === undefined)
|
|
24
44
|
return false;
|
|
@@ -48,7 +48,7 @@ export class CdpConnection {
|
|
|
48
48
|
/** Subscribe to an unexpected transport loss while an operation is active. */
|
|
49
49
|
onDisconnect(listener) {
|
|
50
50
|
if (this.#closed) {
|
|
51
|
-
listener();
|
|
51
|
+
listener(this.#transportError(this.#transportFailure));
|
|
52
52
|
return () => undefined;
|
|
53
53
|
}
|
|
54
54
|
this.#disconnectListeners.add(listener);
|
|
@@ -85,6 +85,7 @@ export class CdpConnection {
|
|
|
85
85
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
86
86
|
this.#pending.set(id, {
|
|
87
87
|
method,
|
|
88
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
88
89
|
resolve,
|
|
89
90
|
reject,
|
|
90
91
|
removeAbort: () => signal?.removeEventListener("abort", onAbort),
|
|
@@ -171,17 +172,34 @@ export class CdpConnection {
|
|
|
171
172
|
const pending = this.#pending.get(id);
|
|
172
173
|
if (pending === undefined)
|
|
173
174
|
return;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
: null));
|
|
175
|
+
const hasResult = "result" in message;
|
|
176
|
+
const hasError = "error" in message;
|
|
177
|
+
if (("sessionId" in message &&
|
|
178
|
+
(typeof message.sessionId !== "string" ||
|
|
179
|
+
message.sessionId !== pending.sessionId)) ||
|
|
180
|
+
hasResult === hasError) {
|
|
181
|
+
this.#failPending("protocol_error");
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
if (hasResult) {
|
|
185
|
+
if (!isRecord(message.result)) {
|
|
186
|
+
this.#failPending("protocol_error");
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.#complete(id, pending);
|
|
190
|
+
pending.resolve(message.result);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const reported = message.error;
|
|
194
|
+
if (!isRecord(reported) ||
|
|
195
|
+
typeof reported.code !== "number" ||
|
|
196
|
+
!Number.isSafeInteger(reported.code) ||
|
|
197
|
+
typeof reported.message !== "string") {
|
|
198
|
+
this.#failPending("protocol_error");
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.#complete(id, pending);
|
|
202
|
+
pending.reject(new CdpCommandRejection(this.operation, pending.method, reported.code, reported.message));
|
|
185
203
|
}
|
|
186
204
|
#complete(id, pending) {
|
|
187
205
|
pending.removeAbort();
|
|
@@ -211,8 +229,9 @@ export class CdpConnection {
|
|
|
211
229
|
this.#failPending(reason);
|
|
212
230
|
if (wasClosed)
|
|
213
231
|
return;
|
|
232
|
+
const error = this.#transportError(reason);
|
|
214
233
|
for (const listener of this.#disconnectListeners)
|
|
215
|
-
listener();
|
|
234
|
+
listener(error);
|
|
216
235
|
this.#disconnectListeners.clear();
|
|
217
236
|
}
|
|
218
237
|
#transportError(reason) {
|
|
@@ -8,8 +8,6 @@ import { discoverCdpEndpoint, hasCdpTargetWebSocket, } from "./CdpEndpoint.js";
|
|
|
8
8
|
import { closeCdpTargetSession, openCdpTargetSession, } from "./CdpTargetSession.js";
|
|
9
9
|
import { inspectCdpElectronPage } from "./CdpElectronInspection.js";
|
|
10
10
|
import { authorizedElectronFile } from "./ElectronFileScope.js";
|
|
11
|
-
/** Public identity committed by passive Electron observations. */
|
|
12
|
-
export { CDP_ELECTRON_PROVIDER_IDENTITY } from "./providerIdentities.js";
|
|
13
11
|
import { CDP_ELECTRON_PROVIDER_IDENTITY } from "./providerIdentities.js";
|
|
14
12
|
const IDENTITY = CDP_ELECTRON_PROVIDER_IDENTITY;
|
|
15
13
|
/** Passive Electron provider for local file pages exposed by loopback CDP. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CdpCaptureCompleteness } from "./CdpCaptureCompleteness.js";
|
|
2
|
-
import { numberValue, recordValue, cdpStringValue, } from "./CdpCaptureValues.js";
|
|
2
|
+
import { numberValue, recordValue, scriptMetadataValues, cdpStringValue, } from "./CdpCaptureValues.js";
|
|
3
3
|
/** Retain script/frame metadata from passive Electron events. */
|
|
4
4
|
export const ingestElectronScriptEvent = (input) => {
|
|
5
5
|
if (input.event.method === "Runtime.executionContextsCleared") {
|
|
@@ -33,9 +33,7 @@ export const ingestElectronScriptEvent = (input) => {
|
|
|
33
33
|
input.scripts.push({
|
|
34
34
|
scriptId,
|
|
35
35
|
rawUrl,
|
|
36
|
-
|
|
37
|
-
length: nonnegativeInteger(value?.length),
|
|
38
|
-
isModule: value?.isModule === true,
|
|
36
|
+
...scriptMetadataValues(value),
|
|
39
37
|
language: cdpStringValue(value?.scriptLanguage) ?? null,
|
|
40
38
|
executionContextKey: executionContextKey(value?.executionContextId),
|
|
41
39
|
});
|
|
@@ -49,10 +47,6 @@ const retainExecutionContext = (event, frames) => {
|
|
|
49
47
|
return;
|
|
50
48
|
frames.set(contextKey, frameId);
|
|
51
49
|
};
|
|
52
|
-
const nonnegativeInteger = (value) => {
|
|
53
|
-
const number = numberValue(value);
|
|
54
|
-
return number === undefined ? 0 : Math.max(0, Math.trunc(number));
|
|
55
|
-
};
|
|
56
50
|
const executionContextKey = (value) => {
|
|
57
51
|
const identifier = numberValue(value);
|
|
58
52
|
return identifier !== undefined && Number.isSafeInteger(identifier)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { canonicalDigest } from "../domain/comparisonSemantics.js";
|
|
2
2
|
import { createWebTextArtifact } from "../domain/webContentArtifact.js";
|
|
3
3
|
import { CdpCaptureCompleteness } from "./CdpCaptureCompleteness.js";
|
|
4
|
-
import {
|
|
4
|
+
import { requiredScriptSource } from "./CdpCaptureValues.js";
|
|
5
5
|
import { authorizedElectronFile } from "./ElectronFileScope.js";
|
|
6
6
|
/** Normalize local script metadata and optionally approved source. */
|
|
7
7
|
export const captureElectronScripts = async (input) => {
|
|
@@ -54,8 +54,7 @@ const captureScriptSource = async (input, script) => {
|
|
|
54
54
|
reason: "source capture was not selected",
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
|
-
const
|
|
58
|
-
const text = cdpStringValue(result.scriptSource) ?? "";
|
|
57
|
+
const text = requiredScriptSource(await input.connection.send("Debugger.getScriptSource", { scriptId: script.scriptId }, input.sessionId, input.signal), "inspect_electron_page");
|
|
59
58
|
return {
|
|
60
59
|
source: {
|
|
61
60
|
included: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CdpCommandRejection } from "./CdpCommandRejection.js";
|
|
2
2
|
import { CdpConnection } from "./CdpConnection.js";
|
|
3
3
|
/** Execute an optional CDP method while preserving transport and cancellation failures. */
|
|
4
4
|
export const optionalCdpCommand = async (context, method, parameters, limitations) => {
|
|
@@ -6,8 +6,7 @@ export const optionalCdpCommand = async (context, method, parameters, limitation
|
|
|
6
6
|
return await context.connection.send(method, parameters, context.sessionId, context.signal);
|
|
7
7
|
}
|
|
8
8
|
catch (cause) {
|
|
9
|
-
if (!(cause instanceof
|
|
10
|
-
cause.reason !== "protocol_error")
|
|
9
|
+
if (!(cause instanceof CdpCommandRejection) || cause.code !== -32_601)
|
|
11
10
|
throw cause;
|
|
12
11
|
limitations.push(`${method} was unavailable from this browser target.`);
|
|
13
12
|
return undefined;
|
|
@@ -6,6 +6,7 @@ import { CdpCaptureEvents } from "./CdpCaptureEvents.js";
|
|
|
6
6
|
import { authorizedMainFrame } from "./CdpAuthorizedMainFrame.js";
|
|
7
7
|
import { captureStorage } from "./CdpCaptureStorage.js";
|
|
8
8
|
import { optionalCdpCommand } from "./CdpOptionalCommand.js";
|
|
9
|
+
import { CdpCommandRejection } from "./CdpCommandRejection.js";
|
|
9
10
|
import { captureAccessibility, captureDom, captureFrames, captureResources, mainFrameUrl, } from "./CdpCaptureDocuments.js";
|
|
10
11
|
import { allowedSanitizedUrl, delayWithCancellation, } from "./CdpCaptureValues.js";
|
|
11
12
|
import { captureScripts } from "./CdpPageCaptureScripts.js";
|
|
@@ -85,6 +86,7 @@ const captureAuthorizedPage = async (state) => {
|
|
|
85
86
|
if (state.events.navigationDuringCapture || completedUrl !== attachedUrl)
|
|
86
87
|
throw new BrowserObservationError("inspect_web_page", "target_changed");
|
|
87
88
|
await report(context.progress, 3, "Normalizing browser evidence");
|
|
89
|
+
state.events.recordScriptMetadataBudgetExclusions();
|
|
88
90
|
return {
|
|
89
91
|
inspection: normalizedInspection(state, {
|
|
90
92
|
attachedUrl,
|
|
@@ -105,7 +107,27 @@ const captureJsonResponseBodies = async (state) => {
|
|
|
105
107
|
const requestId = requestIds[index];
|
|
106
108
|
if (requestId === undefined)
|
|
107
109
|
continue;
|
|
108
|
-
const
|
|
110
|
+
const request = state.events.network.get(requestId);
|
|
111
|
+
if (request === undefined)
|
|
112
|
+
continue;
|
|
113
|
+
if (request.encoded_data_length === null) {
|
|
114
|
+
state.events.responseBodyUnavailable(requestId);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
let result;
|
|
118
|
+
try {
|
|
119
|
+
result = await optionalCdpCommand(state.context, "Network.getResponseBody", { requestId }, state.limitations);
|
|
120
|
+
}
|
|
121
|
+
catch (cause) {
|
|
122
|
+
if (!(cause instanceof CdpCommandRejection) ||
|
|
123
|
+
cause.command !== "Network.getResponseBody" ||
|
|
124
|
+
cause.code !== -32_000 ||
|
|
125
|
+
cause.reportedMessage === null)
|
|
126
|
+
throw cause;
|
|
127
|
+
state.events.responseBodyUnavailable(requestId);
|
|
128
|
+
state.limitations.push(`Response body unavailable for request ${requestId}: ${cause.userMessage}`);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
109
131
|
if (result !== undefined) {
|
|
110
132
|
state.events.ingestResponseBody(requestId, result);
|
|
111
133
|
continue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reconcileCapturedWebScript, stableWebScriptKey, } from "../domain/webInventory.js";
|
|
2
|
-
import {
|
|
2
|
+
import { requiredScriptSource, sourceExcluded, sourceResult, } from "./CdpCaptureValues.js";
|
|
3
3
|
export const captureScripts = async (options) => {
|
|
4
4
|
const { context, events, rawResources, resources, frameIds } = options;
|
|
5
5
|
const state = {
|
|
@@ -42,8 +42,7 @@ const buildScriptDraft = async (script, state) => {
|
|
|
42
42
|
};
|
|
43
43
|
const captureScriptSource = async (script, state) => {
|
|
44
44
|
const { context } = state;
|
|
45
|
-
const
|
|
46
|
-
const content = cdpStringValue(result.scriptSource) ?? "";
|
|
45
|
+
const content = requiredScriptSource(await context.connection.send("Debugger.getScriptSource", { scriptId: script.scriptId }, context.sessionId, context.signal), context.operation);
|
|
47
46
|
return sourceResult(content);
|
|
48
47
|
};
|
|
49
48
|
const keyAndBuildInventory = (drafts, scriptCount) => {
|
|
@@ -56,7 +56,7 @@ const parseCsp = (value, baseUrl, allowedOrigins) => {
|
|
|
56
56
|
for (const rawDirective of (value ?? "").split(";")) {
|
|
57
57
|
const [rawName, ...tokens] = rawDirective.trim().split(/\s+/u);
|
|
58
58
|
const name = (rawName ?? "").toLowerCase();
|
|
59
|
-
if (!/^[a-z][a-z0-9
|
|
59
|
+
if (!/^[a-z][a-z0-9\x2d]*$/u.test(name))
|
|
60
60
|
continue;
|
|
61
61
|
const sources = [];
|
|
62
62
|
for (const token of tokens) {
|
|
@@ -79,9 +79,9 @@ const parseCsp = (value, baseUrl, allowedOrigins) => {
|
|
|
79
79
|
};
|
|
80
80
|
const cspSource = (token, baseUrl, allowedOrigins) => {
|
|
81
81
|
const lower = token.toLowerCase();
|
|
82
|
-
if (/^'[a-z0-9
|
|
82
|
+
if (/^'[a-z0-9\x2d]+'$/u.test(lower))
|
|
83
83
|
return { kind: "keyword", value: lower };
|
|
84
|
-
if (/^[a-z][a-z0-9
|
|
84
|
+
if (/^[a-z][a-z0-9+.\x2d]*:$/u.test(lower))
|
|
85
85
|
return { kind: "scheme", value: lower };
|
|
86
86
|
const hostOrigin = cspHostSourceOrigin(token, baseUrl);
|
|
87
87
|
if (hostOrigin === undefined)
|
|
@@ -98,14 +98,14 @@ const cspSource = (token, baseUrl, allowedOrigins) => {
|
|
|
98
98
|
* `undefined` when the token is not a host-source at all.
|
|
99
99
|
*/
|
|
100
100
|
const cspHostSourceOrigin = (token, baseUrl) => {
|
|
101
|
-
const match = /^(?:([a-z][a-z0-9
|
|
101
|
+
const match = /^(?:([a-z][a-z0-9+.\x2d]*):\/\/)?([^\x2f?#]+)(?:\/[^?#]*)?$/iu.exec(token);
|
|
102
102
|
const authority = match?.[2];
|
|
103
103
|
if (authority === undefined || authority.length === 0)
|
|
104
104
|
return undefined;
|
|
105
105
|
const scheme = (match?.[1] ?? schemeOf(baseUrl))?.toLowerCase();
|
|
106
|
-
if (scheme === undefined || !/^[a-z][a-z0-9
|
|
106
|
+
if (scheme === undefined || !/^[a-z][a-z0-9+.\x2d]*$/u.test(scheme))
|
|
107
107
|
return undefined;
|
|
108
|
-
if (!/^(?:\*|(?:\*\.)?[a-z0-9
|
|
108
|
+
if (!/^(?:\*|(?:\*\.)?[a-z0-9\x2d]+(?:\.[a-z0-9\x2d]+)*\.?)(?::(?:\*|\d+))?$/iu.test(authority))
|
|
109
109
|
return undefined;
|
|
110
110
|
if (authority.includes("*"))
|
|
111
111
|
return null;
|
|
@@ -194,7 +194,7 @@ const linkParameters = (value) => {
|
|
|
194
194
|
const name = (separator < 0 ? raw : raw.slice(0, separator))
|
|
195
195
|
.trim()
|
|
196
196
|
.toLowerCase();
|
|
197
|
-
if (!/^[a-z][a-z0-9
|
|
197
|
+
if (!/^[a-z][a-z0-9\x2d]*$/u.test(name))
|
|
198
198
|
continue;
|
|
199
199
|
const parameter = separator < 0 ? "" : raw.slice(separator + 1).trim();
|
|
200
200
|
parameters.set(name, unquote(parameter));
|
|
@@ -221,7 +221,7 @@ const permissionFeatures = (value) => [
|
|
|
221
221
|
...new Set((value ?? "")
|
|
222
222
|
.split(",")
|
|
223
223
|
.map((entry) => entry.split("=", 1)[0]?.trim().toLowerCase() ?? "")
|
|
224
|
-
.filter((feature) => /^[a-z][a-z0-9
|
|
224
|
+
.filter((feature) => /^[a-z][a-z0-9\x2d]*$/u.test(feature))),
|
|
225
225
|
].sort();
|
|
226
226
|
const wellKnownHint = (url) => {
|
|
227
227
|
try {
|
|
@@ -259,7 +259,7 @@ const referrerPolicy = (value) => {
|
|
|
259
259
|
const token = raw.trim().toLowerCase();
|
|
260
260
|
if (token === "")
|
|
261
261
|
continue;
|
|
262
|
-
if (!/^[a-z
|
|
262
|
+
if (!/^[a-z\x2d]+$/u.test(token))
|
|
263
263
|
return null;
|
|
264
264
|
if (referrerPolicies.has(token))
|
|
265
265
|
policy = token;
|
|
@@ -268,7 +268,7 @@ const referrerPolicy = (value) => {
|
|
|
268
268
|
};
|
|
269
269
|
const policyToken = (value) => {
|
|
270
270
|
const token = (value ?? "").trim().toLowerCase();
|
|
271
|
-
return /^[a-z][a-z0-9_
|
|
271
|
+
return /^[a-z][a-z0-9_.\x2d]*$/u.test(token) ? token : null;
|
|
272
272
|
};
|
|
273
273
|
const nonnegativeInteger = (value) => {
|
|
274
274
|
const number = numberValue(value === undefined ? undefined : Number(value));
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { browserScenarioCaptureSchema,
|
|
1
|
+
import { browserScenarioCaptureSchema, } from "../domain/browserScenarioCapture.js";
|
|
2
|
+
import { classifyBrowserScenarioCompleteness, browserScenarioStepSchema, browserStepArtifactsSchema, } from "../domain/browserScenarioCaptureValues.js";
|
|
2
3
|
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
|
3
4
|
import { BrowserObservationError } from "../domain/browserObservationError.js";
|
|
4
5
|
import { ProviderAdapterError } from "../domain/providerAdapterError.js";
|
|
5
6
|
import { err, ok } from "../domain/result.js";
|
|
7
|
+
import { browserScenarioCleanupObservation, browserScenarioOperationFailure, browserScenarioCaptureData, } from "./BrowserScenarioPartialObservation.js";
|
|
6
8
|
const OPERATION = "capture_browser_scenario";
|
|
7
|
-
let defaultFactory;
|
|
8
|
-
const lazyPlaywrightFactory = {
|
|
9
|
-
async open(scenario, options) {
|
|
10
|
-
defaultFactory ??= import("./PlaywrightScenarioSession.js").then(({ PlaywrightScenarioSessionFactory }) => new PlaywrightScenarioSessionFactory());
|
|
11
|
-
return (await defaultFactory).open(scenario, options);
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export { PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY } from "./providerIdentities.js";
|
|
15
9
|
import { PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY } from "./providerIdentities.js";
|
|
16
10
|
const SNAPSHOT_KINDS = [
|
|
17
11
|
"screenshot",
|
|
@@ -147,7 +141,7 @@ const runScenario = async (factory, scenario, options) => {
|
|
|
147
141
|
const startedAt = Date.now();
|
|
148
142
|
const session = await factory.open(scenario, options.signal === undefined ? {} : { signal: options.signal });
|
|
149
143
|
const steps = [];
|
|
150
|
-
let
|
|
144
|
+
let operationOutcome = { ok: true };
|
|
151
145
|
try {
|
|
152
146
|
steps.push(await initialStep({
|
|
153
147
|
session,
|
|
@@ -169,49 +163,70 @@ const runScenario = async (factory, scenario, options) => {
|
|
|
169
163
|
failed ||= step.status !== "completed";
|
|
170
164
|
}
|
|
171
165
|
}
|
|
172
|
-
|
|
173
|
-
|
|
166
|
+
catch (cause) {
|
|
167
|
+
operationOutcome = { ok: false, cause };
|
|
168
|
+
}
|
|
169
|
+
let cleanupOutcome;
|
|
170
|
+
try {
|
|
171
|
+
cleanupOutcome = { ok: true, cleanup: await session.close() };
|
|
172
|
+
}
|
|
173
|
+
catch (cause) {
|
|
174
|
+
cleanupOutcome = { ok: false, cause };
|
|
174
175
|
}
|
|
175
|
-
|
|
176
|
+
if (!cleanupOutcome.ok) {
|
|
177
|
+
const cleanup = browserScenarioCleanupObservation(cleanupOutcome.cause);
|
|
178
|
+
const partialObservation = {
|
|
179
|
+
kind: "browser-scenario-observation",
|
|
180
|
+
capture: browserScenarioCaptureData({
|
|
181
|
+
session,
|
|
182
|
+
scenario,
|
|
183
|
+
startedAt,
|
|
184
|
+
steps,
|
|
185
|
+
cleanup: "incomplete",
|
|
186
|
+
limitations: [
|
|
187
|
+
"Scenario observations are partial because browser cleanup could not be confirmed.",
|
|
188
|
+
],
|
|
189
|
+
}),
|
|
190
|
+
};
|
|
191
|
+
if (!operationOutcome.ok)
|
|
192
|
+
throw browserScenarioOperationFailure(operationOutcome.cause, partialObservation, { cause: cleanupOutcome.cause });
|
|
193
|
+
throw new BrowserObservationError(OPERATION, "cleanup_failed", {
|
|
194
|
+
cause: cleanupOutcome.cause,
|
|
195
|
+
cleanup,
|
|
196
|
+
partialObservation,
|
|
197
|
+
detail: `Browser scenario cleanup could not be confirmed: ${cleanup.reason}. Collected steps and events are retained in partial_observation. Review the reported resources before retrying.`,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (!operationOutcome.ok)
|
|
201
|
+
throw browserScenarioOperationFailure(operationOutcome.cause, {
|
|
202
|
+
kind: "browser-scenario-observation",
|
|
203
|
+
capture: browserScenarioCaptureData({
|
|
204
|
+
session,
|
|
205
|
+
scenario,
|
|
206
|
+
startedAt,
|
|
207
|
+
steps,
|
|
208
|
+
cleanup: cleanupOutcome.cleanup,
|
|
209
|
+
limitations: [
|
|
210
|
+
"Scenario capture ended after an operation failed; uncollected steps are not represented.",
|
|
211
|
+
],
|
|
212
|
+
}),
|
|
213
|
+
});
|
|
176
214
|
const completeness = globalCompleteness(scenario, session, steps);
|
|
177
215
|
return browserScenarioCaptureSchema.parse({
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
},
|
|
185
|
-
scenario: {
|
|
186
|
-
start_origin: new URL(scenario.start_url.url).origin,
|
|
187
|
-
action_count: scenario.actions.length,
|
|
188
|
-
secret_references: scenario.secrets.map(({ secret_id: id }) => id).sort(),
|
|
189
|
-
network_content: scenario.capture.network,
|
|
190
|
-
},
|
|
191
|
-
duration_ms: Date.now() - startedAt,
|
|
192
|
-
steps,
|
|
193
|
-
events,
|
|
216
|
+
...browserScenarioCaptureData({
|
|
217
|
+
session,
|
|
218
|
+
scenario,
|
|
219
|
+
startedAt,
|
|
220
|
+
steps,
|
|
221
|
+
cleanup: cleanupOutcome.cleanup,
|
|
222
|
+
}),
|
|
194
223
|
completeness,
|
|
195
|
-
limitations: [
|
|
196
|
-
"Event sequence records provider receipt order; simultaneous browser causality is not inferred.",
|
|
197
|
-
"Network content is retained only when selected; response bytes are browser-decoded, not compressed wire bytes.",
|
|
198
|
-
"Request bytes are limited to what Playwright exposes; not_exposed does not establish body absence or multipart file coverage.",
|
|
199
|
-
"Network content reads settle within 5 seconds each and never wait for unfinished responses or refetch them.",
|
|
200
|
-
"Playwright scenario events do not expose request initiator stacks; receipt order does not prove causality.",
|
|
201
|
-
"Storage values are hashed only after declared-secret redaction.",
|
|
202
|
-
...(session.eventLimitations?.() ?? []),
|
|
203
|
-
...(session.mode === "connect"
|
|
204
|
-
? [
|
|
205
|
-
"CDP attachment cannot recover pre-attach events or guarantee launch-time context options.",
|
|
206
|
-
]
|
|
207
|
-
: []),
|
|
208
|
-
],
|
|
209
224
|
});
|
|
210
225
|
};
|
|
211
226
|
/** Controlled Playwright/CDP scenario driver with exact process ownership. */
|
|
212
227
|
export class PlaywrightBrowserScenarioProvider {
|
|
213
228
|
factory;
|
|
214
|
-
constructor(factory
|
|
229
|
+
constructor(factory) {
|
|
215
230
|
this.factory = factory;
|
|
216
231
|
}
|
|
217
232
|
identity() {
|