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,39 +1,112 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
import {
|
|
2
|
+
import { decodeValidatedSourceMapLeaves, isBeforeSourceMapLeafStop, resolveSourceMapSource, } from "../javascript/sourceMaps/DecodedSourceMap.js";
|
|
3
3
|
import { sanitizeBrowserUrl } from "../domain/browserObservation.js";
|
|
4
4
|
import { isUrlLikeModuleSpecifier } from "../domain/webBundleAnalyzerAst.js";
|
|
5
5
|
import { analyzeParsedJavaScriptReferences } from "../domain/javascript/javascriptSemanticAnalysis.js";
|
|
6
6
|
import { traverseJavaScriptAst } from "../domain/javascript/javascriptSemanticTraversal.js";
|
|
7
7
|
import { parseJavaScriptSource } from "../domain/javascript/javascriptSourceParser.js";
|
|
8
|
-
import { hasValidSourceMapContents } from "../domain/sourceMapContents.js";
|
|
9
8
|
import { webSourceMapsSchema } from "../domain/webBundleAnalysis.js";
|
|
10
9
|
import { createWebTextArtifact } from "../domain/webContentArtifact.js";
|
|
11
10
|
import { safeParseJson } from "../domain/safeJson.js";
|
|
12
|
-
import {
|
|
11
|
+
import { jsonParts } from "../domain/jsonSerialization.js";
|
|
12
|
+
import { inspectSourceMapValue, SourceMapFormatFailure, } from "../javascript/sourceMaps/SourceMapFormat.js";
|
|
13
|
+
import { WEB_SOURCE_MAP_LIMITS } from "../domain/webSourceLocation.js";
|
|
14
|
+
// Source maps are normally fetched as a small part of a larger inspection.
|
|
15
|
+
// Bound a stalled server to 30 seconds and bound raw map input retained for
|
|
16
|
+
// parsing to 64 MiB per inspection. Both limits apply at the network boundary;
|
|
17
|
+
// hitting either produces an explicit fetch_failed item, never truncated data.
|
|
18
|
+
const SOURCE_MAP_FETCH_TIMEOUT_MS = 30_000;
|
|
19
|
+
const SOURCE_MAP_RESPONSE_BYTES = 64 * 1024 * 1024;
|
|
20
|
+
const SOURCE_MAP_OUTPUT_BYTES = WEB_SOURCE_MAP_LIMITS.outputBytes;
|
|
21
|
+
const SOURCE_MAP_FAILURE_LIMITATION_RESERVE = 512;
|
|
22
|
+
const SOURCE_MAP_COLLECTION_ENVELOPE_RESERVE = 1_024;
|
|
13
23
|
/** Fetch and validate approved source maps without browser credentials. */
|
|
14
24
|
export const fetchWebSourceMaps = async (requests, input, signal, host = { fetch: globalThis.fetch }) => {
|
|
15
25
|
const items = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
const operationController = new AbortController();
|
|
27
|
+
const timeout = setTimeout(() => operationController.abort(new SourceMapDeadlineError()), host.timeoutMs ?? SOURCE_MAP_FETCH_TIMEOUT_MS);
|
|
28
|
+
const abortFromCaller = () => operationController.abort(signal?.reason);
|
|
29
|
+
signal?.addEventListener("abort", abortFromCaller, { once: true });
|
|
30
|
+
const operationSignal = operationController.signal;
|
|
31
|
+
const deadlineAt = Date.now() + (host.timeoutMs ?? SOURCE_MAP_FETCH_TIMEOUT_MS);
|
|
32
|
+
const budget = {
|
|
33
|
+
retainedBytes: 0,
|
|
34
|
+
deadlineAt,
|
|
35
|
+
decodedRecords: {
|
|
36
|
+
records: 0,
|
|
37
|
+
expandedBytes: SOURCE_MAP_COLLECTION_ENVELOPE_RESERVE,
|
|
38
|
+
resolvedSourceBytes: 0,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
let limitation;
|
|
42
|
+
try {
|
|
43
|
+
for (const request of requests) {
|
|
44
|
+
if (signal?.aborted === true)
|
|
45
|
+
throw signal.reason;
|
|
46
|
+
const reservation = sourceMapFailureReservation(request) + 1;
|
|
47
|
+
if (reservation >
|
|
48
|
+
SOURCE_MAP_OUTPUT_BYTES - budget.decodedRecords.expandedBytes) {
|
|
49
|
+
const unprocessed = requests.length - items.length;
|
|
50
|
+
limitation = `Source-map output budget was exhausted before processing ${String(unprocessed)} requested map${unprocessed === 1 ? "" : "s"}. Their results are unknown.`;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
const expandedBytesBeforeItem = budget.decodedRecords.expandedBytes;
|
|
54
|
+
budget.decodedRecords.expandedBytes += reservation;
|
|
55
|
+
if (operationSignal.aborted || Date.now() >= deadlineAt) {
|
|
56
|
+
items.push(emptySourceMapItem(request, "fetch_failed", "Source-map fetching exceeded its operation deadline."));
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const item = await fetchOne(request, input, operationSignal, host, budget);
|
|
60
|
+
if (item.artifact === null)
|
|
61
|
+
budget.decodedRecords.expandedBytes =
|
|
62
|
+
expandedBytesBeforeItem + reservation;
|
|
63
|
+
items.push(item);
|
|
64
|
+
}
|
|
20
65
|
}
|
|
21
|
-
|
|
66
|
+
finally {
|
|
67
|
+
clearTimeout(timeout);
|
|
68
|
+
signal?.removeEventListener("abort", abortFromCaller);
|
|
69
|
+
}
|
|
70
|
+
if (signal?.aborted === true)
|
|
71
|
+
throw signal.reason;
|
|
22
72
|
return webSourceMapsSchema.parse({
|
|
23
|
-
status: items
|
|
24
|
-
? "unavailable"
|
|
25
|
-
: retained === items.length &&
|
|
26
|
-
!items.some(({ status }) => status === "partial")
|
|
27
|
-
? "included"
|
|
28
|
-
: retained > 0
|
|
29
|
-
? "partial"
|
|
30
|
-
: "unavailable",
|
|
73
|
+
status: sourceMapsStatus(items, limitation !== undefined),
|
|
31
74
|
requested: requests.length,
|
|
32
75
|
processed: items.length,
|
|
33
76
|
items,
|
|
77
|
+
...(limitation === undefined ? {} : { limitation }),
|
|
34
78
|
});
|
|
35
79
|
};
|
|
36
|
-
const
|
|
80
|
+
const sourceMapsStatus = (items, omitted) => {
|
|
81
|
+
const retained = items.filter(({ status }) => status === "included" || status === "partial").length;
|
|
82
|
+
if (items.length === 0 || retained === 0)
|
|
83
|
+
return "unavailable";
|
|
84
|
+
if (omitted)
|
|
85
|
+
return "partial";
|
|
86
|
+
return retained === items.length &&
|
|
87
|
+
!items.some(({ status }) => status === "partial")
|
|
88
|
+
? "included"
|
|
89
|
+
: "partial";
|
|
90
|
+
};
|
|
91
|
+
class SourceMapDeadlineError extends Error {
|
|
92
|
+
constructor() {
|
|
93
|
+
super("Source-map fetching exceeded its operation deadline.");
|
|
94
|
+
this.name = "SourceMapDeadlineError";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
class SourceMapSizeLimitError extends Error {
|
|
98
|
+
constructor() {
|
|
99
|
+
super("Source-map response exceeded the retained-byte budget.");
|
|
100
|
+
this.name = "SourceMapSizeLimitError";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
class SourceMapEncodingError extends Error {
|
|
104
|
+
constructor() {
|
|
105
|
+
super("Source-map response is not valid UTF-8.");
|
|
106
|
+
this.name = "SourceMapEncodingError";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const fetchOne = async (request, input, signal, host, budget) => {
|
|
37
110
|
if (!approvedUrl(request.fetchUrl, input.allowed_origins))
|
|
38
111
|
return emptySourceMapItem(request, "policy_filtered", "Declared source-map URL is outside the approved exact origins.");
|
|
39
112
|
try {
|
|
@@ -45,24 +118,38 @@ const fetchOne = async (request, input, signal, host) => {
|
|
|
45
118
|
await response.body?.cancel();
|
|
46
119
|
return emptySourceMapItem(request, "fetch_failed", `Source-map server returned HTTP ${String(response.status)}.`);
|
|
47
120
|
}
|
|
48
|
-
|
|
121
|
+
checkOperation(undefined, signal, budget.deadlineAt);
|
|
122
|
+
return normalizeSourceMap(request, await readBoundedText(response, budget, host.maxResponseBytes ?? SOURCE_MAP_RESPONSE_BYTES, signal), fetchedUrl, {
|
|
123
|
+
signal,
|
|
124
|
+
deadlineAt: budget.deadlineAt,
|
|
125
|
+
budget: budget.decodedRecords,
|
|
126
|
+
});
|
|
49
127
|
}
|
|
50
128
|
catch (cause) {
|
|
51
|
-
if (signal?.aborted === true
|
|
129
|
+
if (signal?.aborted === true &&
|
|
130
|
+
!(signal.reason instanceof SourceMapDeadlineError))
|
|
52
131
|
throw cause;
|
|
53
|
-
|
|
132
|
+
if (cause instanceof SourceMapEncodingError)
|
|
133
|
+
return emptySourceMapItem(request, "invalid", cause.message);
|
|
134
|
+
return emptySourceMapItem(request, "fetch_failed", cause instanceof SourceMapSizeLimitError
|
|
135
|
+
? cause.message
|
|
136
|
+
: cause instanceof SourceMapDeadlineError
|
|
137
|
+
? cause.message
|
|
138
|
+
: "Source-map fetch or validation failed.");
|
|
54
139
|
}
|
|
55
140
|
};
|
|
56
141
|
const fetchFollowingApprovedRedirects = async (initialUrl, allowedOrigins, signal, host) => {
|
|
57
142
|
let current = initialUrl;
|
|
58
143
|
const visited = new Set();
|
|
59
144
|
for (;;) {
|
|
145
|
+
if (signal?.aborted === true)
|
|
146
|
+
throw signal.reason;
|
|
60
147
|
if (!approvedUrl(current, allowedOrigins))
|
|
61
148
|
return undefined;
|
|
62
149
|
if (visited.has(current))
|
|
63
150
|
throw new Error("source_map_redirect_loop");
|
|
64
151
|
visited.add(current);
|
|
65
|
-
const response = await host.fetch(current, {
|
|
152
|
+
const response = await promiseWithAbort(host.fetch(current, {
|
|
66
153
|
method: "GET",
|
|
67
154
|
headers: {
|
|
68
155
|
Accept: "application/json, application/source-map+json;q=0.9",
|
|
@@ -71,7 +158,11 @@ const fetchFollowingApprovedRedirects = async (initialUrl, allowedOrigins, signa
|
|
|
71
158
|
credentials: "omit",
|
|
72
159
|
referrerPolicy: "no-referrer",
|
|
73
160
|
...(signal === undefined ? {} : { signal }),
|
|
74
|
-
});
|
|
161
|
+
}), signal);
|
|
162
|
+
if (signal !== undefined && signalIsAborted(signal)) {
|
|
163
|
+
await response.body?.cancel(signal.reason).catch(() => undefined);
|
|
164
|
+
throw signal.reason;
|
|
165
|
+
}
|
|
75
166
|
if (response.status < 300 || response.status >= 400)
|
|
76
167
|
return { response, fetchedUrl: current };
|
|
77
168
|
const location = response.headers.get("location");
|
|
@@ -81,40 +172,205 @@ const fetchFollowingApprovedRedirects = async (initialUrl, allowedOrigins, signa
|
|
|
81
172
|
current = new URL(location, current).href;
|
|
82
173
|
}
|
|
83
174
|
};
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
175
|
+
const readBoundedText = async (response, budget, maxBytes, signal) => {
|
|
176
|
+
if (response.body === null)
|
|
177
|
+
return "";
|
|
178
|
+
const reader = response.body.getReader();
|
|
179
|
+
const chunks = [];
|
|
180
|
+
let bytes = 0;
|
|
87
181
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
182
|
+
for (;;) {
|
|
183
|
+
if (signal?.aborted === true)
|
|
184
|
+
throw signal.reason;
|
|
185
|
+
const { done, value } = await readWithAbort(reader, signal);
|
|
186
|
+
if (done)
|
|
187
|
+
break;
|
|
188
|
+
const nextBytes = value?.byteLength ?? 0;
|
|
189
|
+
if (budget.retainedBytes + bytes + nextBytes > maxBytes) {
|
|
190
|
+
await reader.cancel(new SourceMapSizeLimitError());
|
|
191
|
+
throw new SourceMapSizeLimitError();
|
|
192
|
+
}
|
|
193
|
+
if (value !== undefined)
|
|
194
|
+
chunks.push(value);
|
|
195
|
+
bytes += nextBytes;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
// Aborting cancels the reader in readWithAbort. It owns the pending read
|
|
200
|
+
// until that cancellation settles, so releasing the lock here can throw.
|
|
201
|
+
if (signal?.aborted !== true)
|
|
202
|
+
reader.releaseLock();
|
|
203
|
+
}
|
|
204
|
+
budget.retainedBytes += bytes;
|
|
205
|
+
const joined = new Uint8Array(bytes);
|
|
206
|
+
let offset = 0;
|
|
207
|
+
for (const chunk of chunks) {
|
|
208
|
+
joined.set(chunk, offset);
|
|
209
|
+
offset += chunk.byteLength;
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(joined);
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
throw new SourceMapEncodingError();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const readWithAbort = (reader, signal) => {
|
|
219
|
+
if (signal === undefined)
|
|
220
|
+
return reader.read();
|
|
221
|
+
if (signal.aborted)
|
|
222
|
+
return Promise.reject(signal.reason);
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
let settled = false;
|
|
225
|
+
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
226
|
+
const abort = () => {
|
|
227
|
+
if (settled)
|
|
228
|
+
return;
|
|
229
|
+
settled = true;
|
|
230
|
+
cleanup();
|
|
231
|
+
void reader.cancel(signal.reason).catch(() => undefined);
|
|
232
|
+
reject(signal.reason);
|
|
233
|
+
};
|
|
234
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
235
|
+
void reader.read().then((value) => {
|
|
236
|
+
if (settled)
|
|
237
|
+
return;
|
|
238
|
+
settled = true;
|
|
239
|
+
cleanup();
|
|
240
|
+
resolve(value);
|
|
241
|
+
}, (cause) => {
|
|
242
|
+
if (settled)
|
|
243
|
+
return;
|
|
244
|
+
settled = true;
|
|
245
|
+
cleanup();
|
|
246
|
+
void reader.cancel(cause).catch(() => undefined);
|
|
247
|
+
reject(cause);
|
|
101
248
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
const signalIsAborted = (signal) => signal?.aborted === true;
|
|
252
|
+
const promiseWithAbort = (promise, signal) => {
|
|
253
|
+
if (signal === undefined)
|
|
254
|
+
return promise;
|
|
255
|
+
if (signal.aborted)
|
|
256
|
+
return Promise.reject(signal.reason);
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
let settled = false;
|
|
259
|
+
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
260
|
+
const abort = () => {
|
|
261
|
+
if (settled)
|
|
262
|
+
return;
|
|
263
|
+
settled = true;
|
|
264
|
+
cleanup();
|
|
265
|
+
reject(signal.reason);
|
|
266
|
+
};
|
|
267
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
268
|
+
void promise.then((response) => {
|
|
269
|
+
if (settled || signal.aborted) {
|
|
270
|
+
void response.body?.cancel(signal.reason).catch(() => undefined);
|
|
271
|
+
if (!settled) {
|
|
272
|
+
settled = true;
|
|
273
|
+
cleanup();
|
|
274
|
+
reject(signal.reason);
|
|
275
|
+
}
|
|
107
276
|
return;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
277
|
+
}
|
|
278
|
+
settled = true;
|
|
279
|
+
cleanup();
|
|
280
|
+
resolve(response);
|
|
281
|
+
}, (cause) => {
|
|
282
|
+
if (settled)
|
|
283
|
+
return;
|
|
284
|
+
settled = true;
|
|
285
|
+
cleanup();
|
|
286
|
+
reject(cause);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
const normalizeSourceMap = (request, text, fetchedUrl, context) => {
|
|
291
|
+
const parsedJson = safeParseJson(text);
|
|
292
|
+
if (!parsedJson.ok)
|
|
293
|
+
return emptySourceMapItem(request, "invalid", "Source-map JSON is not a version 3 map.");
|
|
294
|
+
const retainedBytesBeforeMap = context.budget.expandedBytes;
|
|
295
|
+
try {
|
|
296
|
+
const check = () => checkOperation(undefined, context.signal, context.deadlineAt);
|
|
297
|
+
const inspected = inspectSourceMapValue(parsedJson.value, {
|
|
298
|
+
profile: "browser-collection",
|
|
299
|
+
budget: context.budget,
|
|
300
|
+
check,
|
|
116
301
|
});
|
|
117
|
-
|
|
302
|
+
context.budget.expandedBytes =
|
|
303
|
+
retainedBytesBeforeMap -
|
|
304
|
+
sourceMapFailureReservation(request) +
|
|
305
|
+
sourceMapSuccessReservation(request);
|
|
306
|
+
consumeExpandedBytes(context.budget, jsonBytes(text) +
|
|
307
|
+
artifactMetadataBytes("application/source-map+json", text) -
|
|
308
|
+
4);
|
|
309
|
+
const sourcesByRaw = new Map();
|
|
310
|
+
const resolvedByRoot = new Map();
|
|
311
|
+
preflightResolvedSourceBytes(inspected.leaves, fetchedUrl, context.budget, resolvedByRoot, sourcesByRaw, check);
|
|
312
|
+
check();
|
|
313
|
+
const decoded = decodeValidatedSourceMapLeaves(inspected.leaves, fetchedUrl, check);
|
|
314
|
+
const sourceJsonBytes = new Map();
|
|
315
|
+
const nameJsonBytes = new Map();
|
|
316
|
+
const originalSources = [];
|
|
317
|
+
for (const { leaf, resolvedSources } of decoded) {
|
|
318
|
+
for (const [index, rawSource] of leaf.map.sources.entries()) {
|
|
319
|
+
if ((index & 255) === 0)
|
|
320
|
+
check();
|
|
321
|
+
const resolved = resolvedSources[index] ?? rawSource ?? "[unknown-source]";
|
|
322
|
+
const sanitized = cachedSanitized(sourcesByRaw, resolved);
|
|
323
|
+
const content = leaf.map.sourcesContent?.[index] ?? null;
|
|
324
|
+
consumeExpandedBytes(context.budget, cachedJsonBytes(sourceJsonBytes, sanitized) +
|
|
325
|
+
sourceEntryOverheadBytes() +
|
|
326
|
+
(originalSources.length === 0 ? 0 : 1) +
|
|
327
|
+
(content === null
|
|
328
|
+
? 0
|
|
329
|
+
: jsonBytes(content) +
|
|
330
|
+
artifactMetadataBytes(sourceMediaType(rawSource), content) -
|
|
331
|
+
4));
|
|
332
|
+
originalSources.push({
|
|
333
|
+
source: sanitized,
|
|
334
|
+
artifact: content === null
|
|
335
|
+
? null
|
|
336
|
+
: createWebTextArtifact(content, sourceMediaType(rawSource)),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const mappings = [];
|
|
341
|
+
for (const { leaf, rows, resolvedSources } of decoded)
|
|
342
|
+
for (const [line, row] of rows.entries()) {
|
|
343
|
+
if ((line & 255) === 0)
|
|
344
|
+
check();
|
|
345
|
+
for (const segment of row) {
|
|
346
|
+
if (!isBeforeSourceMapLeafStop(leaf, line, segment[0]))
|
|
347
|
+
continue;
|
|
348
|
+
if (segment.length === 1)
|
|
349
|
+
continue;
|
|
350
|
+
const rawSource = leaf.map.sources[segment[1]];
|
|
351
|
+
const resolved = resolvedSources[segment[1]] ?? rawSource ?? "[unknown-source]";
|
|
352
|
+
const source = cachedSanitized(sourcesByRaw, resolved);
|
|
353
|
+
const name = segment.length === 5 ? (leaf.map.names[segment[4]] ?? null) : null;
|
|
354
|
+
const generatedLine = leaf.offset.line + line + 1;
|
|
355
|
+
const generatedColumn = segment[0] + (line === 0 ? leaf.offset.column : 0);
|
|
356
|
+
consumeExpandedBytes(context.budget, cachedJsonBytes(sourceJsonBytes, source) +
|
|
357
|
+
(name === null ? 4 : cachedJsonBytes(nameJsonBytes, name)) +
|
|
358
|
+
mappingRowBytes(generatedLine, generatedColumn, segment[2] + 1, segment[3]) +
|
|
359
|
+
(mappings.length === 0 ? 0 : 1));
|
|
360
|
+
mappings.push({
|
|
361
|
+
generated_line: generatedLine,
|
|
362
|
+
generated_column: generatedColumn,
|
|
363
|
+
source,
|
|
364
|
+
original_line: segment[2] + 1,
|
|
365
|
+
original_column: segment[3],
|
|
366
|
+
name,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const modules = originalModuleEdges(originalSources, check, (edge) => consumeExpandedBytes(context.budget, Buffer.byteLength(JSON.stringify(edge)) + 1));
|
|
371
|
+
check();
|
|
372
|
+
if (modules.incomplete.length > 0)
|
|
373
|
+
consumeExpandedBytes(context.budget, jsonBytes(`Module edges are incomplete: ${modules.incomplete.length} of ${originalSources.filter(({ artifact }) => artifact !== null).length} original sources could not be parsed in full (${modules.incomplete.join(", ")}).`) - 4);
|
|
118
374
|
const parsed = {
|
|
119
375
|
...sourceMapContext(request),
|
|
120
376
|
artifact: createWebTextArtifact(text, "application/source-map+json"),
|
|
@@ -122,6 +378,7 @@ const normalizeSourceMap = (request, text, fetchedUrl) => {
|
|
|
122
378
|
original_module_edges: modules.edges,
|
|
123
379
|
mappings,
|
|
124
380
|
};
|
|
381
|
+
check();
|
|
125
382
|
return modules.incomplete.length === 0
|
|
126
383
|
? { ...parsed, status: "included", limitation: null }
|
|
127
384
|
: {
|
|
@@ -131,18 +388,27 @@ const normalizeSourceMap = (request, text, fetchedUrl) => {
|
|
|
131
388
|
};
|
|
132
389
|
}
|
|
133
390
|
catch (cause) {
|
|
134
|
-
|
|
135
|
-
|
|
391
|
+
// Failed maps publish no artifact or mapping rows. Release their output
|
|
392
|
+
// reservation while keeping cumulative fetch and decoder-work accounting.
|
|
393
|
+
context.budget.expandedBytes = retainedBytesBeforeMap;
|
|
394
|
+
if (cause instanceof SourceMapFormatFailure && cause.reason === "limit")
|
|
395
|
+
return emptySourceMapItem(request, "fetch_failed", cause.message);
|
|
396
|
+
if (context.signal?.aborted === true ||
|
|
397
|
+
cause instanceof SourceMapDeadlineError)
|
|
398
|
+
throw cause;
|
|
399
|
+
return emptySourceMapItem(request, "invalid", "Source-map JSON mappings could not be decoded safely.");
|
|
136
400
|
}
|
|
137
401
|
};
|
|
138
|
-
const originalModuleEdges = (sources) => {
|
|
402
|
+
const originalModuleEdges = (sources, check, beforeEdge) => {
|
|
139
403
|
const edges = [];
|
|
140
404
|
const seen = new Set();
|
|
141
405
|
const incomplete = [];
|
|
142
406
|
for (const source of sources) {
|
|
407
|
+
check();
|
|
143
408
|
if (source.artifact === null)
|
|
144
409
|
continue;
|
|
145
410
|
const parsed = parseJavaScriptSource(source.artifact.text);
|
|
411
|
+
check();
|
|
146
412
|
if (parsed === null) {
|
|
147
413
|
incomplete.push(source.source);
|
|
148
414
|
continue;
|
|
@@ -154,6 +420,7 @@ const originalModuleEdges = (sources) => {
|
|
|
154
420
|
let unboundRequires;
|
|
155
421
|
traverseJavaScriptAst(parsed, {
|
|
156
422
|
enter: (node) => {
|
|
423
|
+
check();
|
|
157
424
|
const dependency = originalDependency(node);
|
|
158
425
|
if (dependency === null)
|
|
159
426
|
return;
|
|
@@ -171,33 +438,27 @@ const originalModuleEdges = (sources) => {
|
|
|
171
438
|
if (seen.has(key))
|
|
172
439
|
return;
|
|
173
440
|
seen.add(key);
|
|
174
|
-
|
|
441
|
+
const edge = {
|
|
175
442
|
from_source: source.source,
|
|
176
443
|
kind,
|
|
177
444
|
specifier,
|
|
178
445
|
resolved_source: resolveOriginalSource(specifier, source.source),
|
|
179
|
-
}
|
|
446
|
+
};
|
|
447
|
+
beforeEdge(edge);
|
|
448
|
+
edges.push(edge);
|
|
180
449
|
},
|
|
181
450
|
});
|
|
182
451
|
}
|
|
183
452
|
return { edges, incomplete };
|
|
184
453
|
};
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
const leaves = flattenSourceMapLeaves(parsed, { validateOffsets: true });
|
|
193
|
-
if (leaves === undefined)
|
|
194
|
-
return false;
|
|
195
|
-
return leaves.every(validSourceMapLeaf);
|
|
454
|
+
const checkOperation = (callerSignal, operationSignal, deadlineAt) => {
|
|
455
|
+
if (callerSignal?.aborted === true)
|
|
456
|
+
throw callerSignal.reason;
|
|
457
|
+
if (operationSignal?.aborted === true)
|
|
458
|
+
throw operationSignal.reason;
|
|
459
|
+
if (Date.now() >= deadlineAt)
|
|
460
|
+
throw new SourceMapDeadlineError();
|
|
196
461
|
};
|
|
197
|
-
const validSourceMapLeaf = (map) => typeof map.mappings === "string" &&
|
|
198
|
-
Array.isArray(map.sources) &&
|
|
199
|
-
Array.isArray(map.names) &&
|
|
200
|
-
hasValidSourceMapContents(map.sources.length, map.sourcesContent);
|
|
201
462
|
const approvedUrl = (value, allowedOrigins) => {
|
|
202
463
|
try {
|
|
203
464
|
const parsed = new URL(value);
|
|
@@ -235,6 +496,99 @@ const sanitizeSource = (value) => {
|
|
|
235
496
|
return value;
|
|
236
497
|
}
|
|
237
498
|
};
|
|
499
|
+
const preflightResolvedSourceBytes = (leaves, mapUrl, budget, resolvedByRoot, sanitizedByResolved, check) => {
|
|
500
|
+
let estimate = budget.expandedBytes;
|
|
501
|
+
let resolvedBytes = budget.resolvedSourceBytes;
|
|
502
|
+
for (const { map } of leaves) {
|
|
503
|
+
let sourcesForRoot = resolvedByRoot.get(map.sourceRoot ?? null);
|
|
504
|
+
if (sourcesForRoot === undefined) {
|
|
505
|
+
sourcesForRoot = new Map();
|
|
506
|
+
resolvedByRoot.set(map.sourceRoot ?? null, sourcesForRoot);
|
|
507
|
+
}
|
|
508
|
+
for (const source of map.sources) {
|
|
509
|
+
check();
|
|
510
|
+
const sourceKey = source ?? "";
|
|
511
|
+
let resolved = sourcesForRoot.get(sourceKey);
|
|
512
|
+
if (resolved === undefined)
|
|
513
|
+
resolved = resolveSourceMapSource(source, map.sourceRoot, mapUrl);
|
|
514
|
+
const bytes = Buffer.byteLength(resolved, "utf8");
|
|
515
|
+
if (bytes > SOURCE_MAP_RESPONSE_BYTES - resolvedBytes)
|
|
516
|
+
throw resolvedSourceLimitFailure();
|
|
517
|
+
resolvedBytes += bytes;
|
|
518
|
+
sourcesForRoot.set(sourceKey, resolved);
|
|
519
|
+
const sanitized = cachedSanitized(sanitizedByResolved, resolved);
|
|
520
|
+
estimate += jsonBytes(sanitized);
|
|
521
|
+
if (estimate > WEB_SOURCE_MAP_LIMITS.outputBytes)
|
|
522
|
+
throw expandedOutputFailure();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
budget.resolvedSourceBytes = resolvedBytes;
|
|
526
|
+
};
|
|
527
|
+
const consumeExpandedBytes = (budget, bytes) => {
|
|
528
|
+
if (bytes > WEB_SOURCE_MAP_LIMITS.outputBytes - budget.expandedBytes)
|
|
529
|
+
throw expandedOutputFailure();
|
|
530
|
+
budget.expandedBytes += bytes;
|
|
531
|
+
};
|
|
532
|
+
const expandedOutputFailure = () => new SourceMapFormatFailure("limit", `Expanded source-map evidence exceeds the ${WEB_SOURCE_MAP_LIMITS.outputBytes / (1024 * 1024)} MiB public representation budget.`);
|
|
533
|
+
const resolvedSourceLimitFailure = () => new SourceMapFormatFailure("limit", `Resolved source-map identities exceed the ${SOURCE_MAP_RESPONSE_BYTES / (1024 * 1024)} MiB decoder representation budget.`);
|
|
534
|
+
const jsonBytes = (value) => {
|
|
535
|
+
let bytes = 0;
|
|
536
|
+
for (const part of jsonParts(value))
|
|
537
|
+
bytes += Buffer.byteLength(part, "utf8");
|
|
538
|
+
return bytes;
|
|
539
|
+
};
|
|
540
|
+
const artifactMetadataBytes = (mediaType, text) => Buffer.byteLength(JSON.stringify({
|
|
541
|
+
sha256: "0".repeat(64),
|
|
542
|
+
bytes: Buffer.byteLength(text),
|
|
543
|
+
media_type: mediaType,
|
|
544
|
+
charset: "utf-8",
|
|
545
|
+
text: "",
|
|
546
|
+
})) - 2;
|
|
547
|
+
const sourceMapFailureReservation = (request) => {
|
|
548
|
+
const envelope = emptySourceMapItem({ ...request, declaredUrl: "", scriptKey: "" }, "fetch_failed", "x".repeat(SOURCE_MAP_FAILURE_LIMITATION_RESERVE));
|
|
549
|
+
return (Buffer.byteLength(JSON.stringify(envelope)) -
|
|
550
|
+
4 +
|
|
551
|
+
jsonBytes(request.declaredUrl) +
|
|
552
|
+
jsonBytes(request.scriptKey));
|
|
553
|
+
};
|
|
554
|
+
const sourceMapSuccessReservation = (request) => {
|
|
555
|
+
const context = sourceMapContext({
|
|
556
|
+
...request,
|
|
557
|
+
declaredUrl: "",
|
|
558
|
+
scriptKey: "",
|
|
559
|
+
});
|
|
560
|
+
const envelope = {
|
|
561
|
+
...context,
|
|
562
|
+
status: "included",
|
|
563
|
+
artifact: null,
|
|
564
|
+
original_sources: [],
|
|
565
|
+
original_module_edges: [],
|
|
566
|
+
mappings: [],
|
|
567
|
+
limitation: null,
|
|
568
|
+
};
|
|
569
|
+
return (Buffer.byteLength(JSON.stringify(envelope)) -
|
|
570
|
+
4 +
|
|
571
|
+
jsonBytes(request.declaredUrl) +
|
|
572
|
+
jsonBytes(request.scriptKey));
|
|
573
|
+
};
|
|
574
|
+
const sourceEntryOverheadBytes = () => Buffer.byteLength('{"source":,"artifact":null}');
|
|
575
|
+
const cachedJsonBytes = (cache, value) => {
|
|
576
|
+
const cached = cache.get(value);
|
|
577
|
+
if (cached !== undefined)
|
|
578
|
+
return cached;
|
|
579
|
+
const bytes = jsonBytes(value);
|
|
580
|
+
cache.set(value, bytes);
|
|
581
|
+
return bytes;
|
|
582
|
+
};
|
|
583
|
+
const cachedSanitized = (cache, value) => {
|
|
584
|
+
const cached = cache.get(value);
|
|
585
|
+
if (cached !== undefined)
|
|
586
|
+
return cached;
|
|
587
|
+
const sanitized = sanitizeSource(value);
|
|
588
|
+
cache.set(value, sanitized);
|
|
589
|
+
return sanitized;
|
|
590
|
+
};
|
|
591
|
+
const mappingRowBytes = (generatedLine, generatedColumn, originalLine, originalColumn) => Buffer.byteLength(`{"generated_line":${String(generatedLine)},"generated_column":${String(generatedColumn)},"source":,"original_line":${String(originalLine)},"original_column":${String(originalColumn)},"name":}`);
|
|
238
592
|
const resolveOriginalSource = (specifier, base) => {
|
|
239
593
|
if (!isUrlLikeModuleSpecifier(specifier))
|
|
240
594
|
return null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lstat, realpath } from "node:fs/promises";
|
|
2
|
-
import { dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
|
4
4
|
import { readStableArtifact } from "../../artifacts/readStableArtifact.js";
|
|
5
5
|
import { normalizeArtifactPath } from "../../artifacts/ArtifactPaths.js";
|
|
@@ -31,7 +31,7 @@ export class LocalWebScriptArtifacts {
|
|
|
31
31
|
const portable = normalizeArtifactPath(selected.content.relative_path);
|
|
32
32
|
if (portable !== selected.content.relative_path)
|
|
33
33
|
throw new ArtifactReaderFailure("path", `Selected source path changes during normalization: ${selected.content.relative_path}`);
|
|
34
|
-
const root = dirname(input.manifest_path);
|
|
34
|
+
const root = resolve(dirname(input.manifest_path));
|
|
35
35
|
const sourcePath = join(root, "files", portable);
|
|
36
36
|
targetPath = sourcePath;
|
|
37
37
|
await assertContained(root, sourcePath);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { webPageInspectionSchema } from "../../domain/
|
|
1
|
+
import { webPageInspectionSchema } from "../../domain/browserObservationSchemas.js";
|
|
2
2
|
import { browserScenarioCaptureSchema } from "../../domain/browserScenarioCapture.js";
|
|
3
3
|
import { parseEvidence } from "../../domain/evidence.js";
|
|
4
4
|
import { pageScripts } from "./PageScriptCapture.js";
|