rea-agents 5.0.0 → 6.1.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 +168 -655
- package/bridge/android/ReaJadxBridge.java +14 -5
- package/bridge/ghidra/ReaGhidraBridge.java +173 -47
- package/bridge/hopper_bridge.py +310 -128
- package/bridge/mitmproxy/capture.py +208 -0
- package/bridge/native/rea_lldb_tracer.py +839 -0
- package/bridge/process/ProcessRunTokenReader.swift +297 -0
- package/bridge/process/ProcessRunTokenReaderMain.swift +35 -0
- package/bridge/pwndbg/core_context.py +101 -0
- package/bridge/pwndbg/launch.py +39 -0
- package/bridge/pwndbg/launch_impl.py +34 -0
- package/bridge/pwntools/decoder_runtime.py +59 -0
- package/bridge/pwntools/layout.py +39 -0
- package/bridge/pwntools/layout_impl.py +309 -0
- package/bridge/pwntools/recorded_crash.py +39 -0
- package/bridge/pwntools/recorded_crash_impl.py +147 -0
- package/dist/android/JadxConfiguration.js +196 -33
- package/dist/android/JadxMcpTransport.js +4 -0
- package/dist/android/JadxProtocol.js +6 -0
- package/dist/android/JadxProvider.js +20 -2
- 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/CallPathTracing.js +19 -3
- package/dist/application/CapabilityInventory.js +27 -3
- package/dist/application/ClientConfigurationDocument.js +871 -6
- package/dist/application/ClientRegistrationIdentity.js +26 -5
- package/dist/application/ClientRegistrationStatus.js +29 -14
- package/dist/application/DirectAnalysis.js +97 -33
- package/dist/application/Doctor.js +4 -2
- package/dist/application/DoctorScope.js +25 -13
- package/dist/application/EnhancedLiteralTracing.js +22 -25
- package/dist/application/EnhancedTools.js +13 -11
- package/dist/application/EvidenceBundleFiles.js +24 -12
- package/dist/application/FunctionAnalysisEvidence.js +2 -3
- package/dist/application/InventoryProjectionEvidence.js +4 -3
- package/dist/application/InvestigationProviders.js +3 -2
- package/dist/application/JsonFiles.js +50 -28
- package/dist/application/ProcedureAddressResolution.js +11 -0
- package/dist/application/ReconstructionCoverageService.js +7 -4
- package/dist/application/ReconstructionObligationCandidates.js +5 -1
- package/dist/application/ReconstructionObligationLedgerService.js +4 -3
- package/dist/application/Setup.js +13 -1
- package/dist/application/SetupClientConfiguration.js +10 -15
- package/dist/application/SetupHost.js +5 -2
- package/dist/application/SetupPlan.js +5 -3
- package/dist/application/SupportedClients.js +34 -1
- package/dist/application/Uninstall.js +4 -3
- package/dist/application/Update.js +18 -3
- package/dist/application/UpdateRuntime.js +46 -25
- package/dist/application/WebModuleTraceService.js +4 -2
- package/dist/application/WebNetworkCapturePort.js +1 -0
- package/dist/application/WebNetworkCaptureService.js +134 -0
- package/dist/application/WebRuntimeService.js +5 -3
- package/dist/application/WebScriptExportService.js +2 -2
- package/dist/application/WebSourceLocationService.js +4 -2
- package/dist/application/WindowsCapabilities.js +1 -1
- package/dist/application/WorkflowEvidence.js +82 -0
- package/dist/application/binary/AnalysisProviderEvaluation.js +21 -5
- package/dist/application/binary/AnalysisProviderRegistry.js +2 -0
- package/dist/application/binary/AnalysisSnapshotCache.js +52 -12
- package/dist/application/binary/BinarySession.js +131 -76
- package/dist/application/binary/BinarySessionOpen.js +19 -6
- package/dist/application/binary/BinarySessionRecords.js +45 -3
- package/dist/application/binary/BinarySessionStatus.js +17 -1
- package/dist/application/binary/CompositeProvider.js +13 -0
- package/dist/application/binary/LazyAnalysisProvider.js +3 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +59 -0
- package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +62 -0
- package/dist/application/evm/EvmInterfacePort.js +1 -0
- package/dist/application/evm/EvmInterfaceService.js +64 -0
- package/dist/application/investigation/EvidenceLedger.js +21 -7
- package/dist/application/investigation/InvestigationRecords.js +8 -0
- package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +25 -5
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +19 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +34 -14
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +5 -5
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +47 -27
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +39 -7
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +26 -2
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +80 -27
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +33 -12
- package/dist/application/javascript/JavaScriptModuleRelationships.js +37 -8
- package/dist/application/javascript/JavaScriptRecoveryService.js +4 -2
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +3 -1
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +149 -72
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +14 -15
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +41 -1
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +7 -7
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +5 -9
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +118 -12
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +27 -5
- package/dist/application/managed/ManagedApplicationGraphService.js +4 -3
- package/dist/application/managed/ManagedMemberComparisonService.js +7 -4
- package/dist/application/managed/ManagedNativeVerificationService.js +4 -3
- package/dist/application/managed/ManagedReconstructionService.js +4 -3
- package/dist/application/{ProcessCli.js → process/ProcessCli.js} +23 -15
- package/dist/application/{ProcessEvidence.js → process/ProcessEvidence.js} +8 -7
- package/dist/application/workflowInputError.js +18 -0
- package/dist/artifacts/ArtifactProvider.js +42 -5
- package/dist/artifacts/ArtifactProviderMetadata.js +2 -1
- package/dist/artifacts/MachOSliceArtifactReader.js +98 -14
- package/dist/artifacts/NativeDmgArtifactReader.js +13 -6
- package/dist/artifacts/ZipArtifactReader.js +3 -0
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +22 -3
- package/dist/artifacts/apple/DylibResolutionReader.js +259 -0
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +176 -56
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +195 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +36 -22
- package/dist/artifacts/apple/MachoLoadCommandReader.js +355 -0
- 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/{application → artifacts/extraction}/ArtifactExtraction.js +10 -10
- package/dist/{application → artifacts/inventory}/ArtifactGraphConstruction.js +16 -11
- package/dist/{application → artifacts/inventory}/ArtifactInventory.js +4 -4
- package/dist/{application/ArtifactInventory → artifacts/inventory}/classify.js +2 -2
- package/dist/{application/ArtifactInventory → artifacts/inventory}/reader.js +5 -5
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanCanonical.js +14 -17
- package/dist/{application/ArtifactInventory → artifacts/inventory}/scanReader.js +5 -5
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +6 -2
- package/dist/artifacts/readStableArtifact.js +20 -4
- package/dist/browser/CdpCaptureCompleteness.js +2 -0
- package/dist/browser/CdpCaptureEventHandlers.js +165 -12
- package/dist/browser/CdpCaptureEventTypes.js +5 -1
- package/dist/browser/CdpCaptureEvents.js +34 -0
- package/dist/browser/CdpConnection.js +30 -11
- package/dist/browser/CdpOptionalCommand.js +2 -3
- package/dist/browser/CdpPageCapture.js +23 -1
- package/dist/browser/PlaywrightElectronActiveActions.js +32 -23
- package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +130 -122
- package/dist/browser/WebSourceMapFetcher.js +426 -72
- package/dist/browser/assets/LocalWebScriptArtifacts.js +2 -2
- package/dist/browser/history/CaptureFailures.js +137 -0
- package/dist/browser/history/CaptureFormatError.js +10 -0
- package/dist/browser/history/CaptureRedaction.js +65 -0
- package/dist/browser/history/CaptureRelease.js +17 -0
- package/dist/browser/history/HarCapture.js +165 -0
- package/dist/browser/history/HarCaptureAdapter.js +20 -0
- package/dist/browser/history/HarCaptureProcess.js +57 -0
- package/dist/browser/history/HarJson.js +92 -0
- package/dist/browser/history/HarSchema.js +72 -0
- package/dist/browser/history/HistoricalCaptureDecoder.js +188 -0
- package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
- package/dist/browser/history/MitmproxyCaptureAdapter.js +42 -0
- package/dist/cli/analysisSelector.js +23 -0
- package/dist/cli/applicationCommands.js +2 -3
- package/dist/cli/artifactCommands.js +26 -1
- package/dist/cli/binaryDiagnosticsCommands.js +39 -0
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +78 -20
- package/dist/cli/electronCommands.js +21 -13
- package/dist/cli/evmCommands.js +24 -0
- package/dist/cli/firmwareCommands.js +6 -3
- package/dist/cli/javascriptApplicationAnalysis.js +20 -3
- package/dist/cli/jsonOutput.js +38 -0
- package/dist/cli/nativeCallCommands.js +34 -0
- package/dist/cli/processCommands.js +1 -1
- package/dist/cli/streamedJsonOutput.js +56 -0
- package/dist/cli/utilityCommands.js +2 -0
- package/dist/cli/webNetworkCaptureCommands.js +40 -0
- package/dist/cli/webRuntimeCommands.js +8 -8
- package/dist/cli.js +11 -4
- package/dist/cliBrowserScenarioCommands.js +2 -2
- package/dist/cliCommandNames.js +6 -1
- package/dist/cliJsonInput.js +35 -1
- package/dist/cliOutput.js +21 -6
- package/dist/composition/binaryDiagnostics.js +8 -0
- package/dist/composition/evm.js +4 -0
- package/dist/composition/webNetworkCaptures.js +6 -0
- package/dist/config/environment.js +4 -0
- package/dist/config/ghidraStartupTimeout.js +17 -0
- package/dist/config/mcpResponseBudget.js +22 -0
- package/dist/config/parseConfig.js +2 -1
- package/dist/contracts/artifactToolContracts.js +6 -0
- package/dist/contracts/browserCaptureToolInputSchema.js +43 -0
- package/dist/contracts/browserToolContracts.js +4 -3
- package/dist/contracts/enhancedInputs.js +5 -3
- package/dist/contracts/enhancedToolContracts.js +3 -3
- package/dist/contracts/errorSchemas.js +8 -1
- package/dist/contracts/evm/evmToolContracts.js +20 -0
- package/dist/contracts/hopperMemoryContracts.js +2 -5
- package/dist/contracts/investigationExamples.js +2 -2
- package/dist/contracts/javascript/electronToolContracts.js +1 -1
- package/dist/contracts/managed/managedToolContracts.js +8 -6
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +42 -0
- package/dist/contracts/native/nativeToolContracts.js +21 -3
- package/dist/contracts/officialToolContracts.js +26 -24
- package/dist/contracts/process/processCaptureExample.js +2 -0
- package/dist/contracts/promptContracts.js +3 -3
- package/dist/contracts/sessionLifecycleInputs.js +18 -5
- package/dist/contracts/sessionStatusContract.js +8 -2
- package/dist/contracts/sessionToolContracts.js +8 -3
- package/dist/contracts/sessionToolSchemas.js +8 -4
- package/dist/contracts/toolContractExamples.js +1 -2
- package/dist/contracts/toolContractHelpers.js +4 -1
- package/dist/contracts/toolContracts.js +6 -0
- package/dist/contracts/toolEffects.js +30 -1
- package/dist/contracts/toolOutputSchemaGroups.js +33 -28
- package/dist/contracts/toolOutputSchemaPrimitives.js +19 -1
- package/dist/contracts/toolSchemaMetadata.js +69 -10
- package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
- package/dist/domain/analysisErrorBase.js +22 -2
- package/dist/domain/analysisErrorCore.js +61 -5
- package/dist/domain/analysisErrorPresentation.js +95 -12
- package/dist/domain/analysisErrorProjection.js +148 -19
- package/dist/domain/analysisSnapshot.js +166 -2
- package/dist/domain/android/androidAnalysis.js +2 -4
- package/dist/domain/android/androidApplication.js +17 -9
- package/dist/domain/apple/appleApplication.js +41 -14
- package/dist/domain/apple/dyldEnvironment.js +73 -0
- package/dist/domain/apple/dyldPaths.js +81 -0
- package/dist/domain/apple/dylibResolution.js +478 -0
- package/dist/domain/apple/dylibResolutionFindings.js +77 -0
- package/dist/domain/apple/interfaceBuilderGraph.js +25 -13
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +13 -3
- package/dist/domain/apple/keyedArchive.js +9 -1
- package/dist/domain/apple/machoContainer.js +54 -0
- package/dist/domain/apple/plistNumbers.js +76 -0
- package/dist/domain/artifactIdentity.js +29 -0
- package/dist/domain/artifactInventoryEvidence.js +19 -24
- package/dist/domain/artifactPathSyntax.js +1 -1
- package/dist/domain/bridgeCandidateProjection.js +71 -0
- package/dist/domain/browserCompleteness.js +1 -0
- package/dist/domain/browserObservation.js +1 -1
- package/dist/domain/browserObservationError.js +24 -5
- package/dist/domain/browserObservationSchemas.js +13 -0
- package/dist/domain/browserScenarioValues.js +5 -2
- package/dist/domain/bundleComparison.js +3 -2
- package/dist/domain/callPathSchemas.js +1 -1
- package/dist/domain/canonicalDigest.js +13 -1
- 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/comparisonStatus.js +2 -30
- package/dist/domain/configurationErrors.js +1 -1
- package/dist/domain/conformanceTrustGate.js +0 -16
- package/dist/domain/evidence.js +78 -11
- package/dist/domain/evidenceBundle.js +42 -1
- package/dist/domain/evidenceErrors.js +12 -1
- package/dist/domain/evm/evmInterface.js +63 -0
- package/dist/domain/explicitSensitiveFailure.js +108 -0
- package/dist/domain/explicitSensitiveValues.js +10 -0
- package/dist/domain/firmware/firmwareAnalysis.js +10 -4
- 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 +37 -6
- package/dist/domain/javascript/electronStaticAnalysisValues.js +6 -12
- package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +71 -23
- package/dist/domain/javascript/javascriptApplicationGraph.js +13 -0
- package/dist/domain/javascript/javascriptAstValues.js +20 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +21 -5
- package/dist/domain/javascript/javascriptExportShapeVariants.js +0 -10
- package/dist/domain/javascript/javascriptRecovery.js +3 -8
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +97 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +6 -5
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +9 -17
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +22 -5
- package/dist/domain/javascript/javascriptSemanticGraph.js +34 -5
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +1 -0
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +25 -17
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -4
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
- package/dist/domain/javascript/javascriptSemanticValues.js +83 -11
- 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 +14 -4
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +66 -7
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +28 -16
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -2
- package/dist/domain/jsonSerialization.js +109 -0
- package/dist/domain/jsonValue.js +91 -3
- package/dist/domain/localPath.js +8 -0
- package/dist/domain/managed/managedApplicationGraph.js +10 -10
- package/dist/domain/managed/managedInspectionEvidence.js +16 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +5 -9
- package/dist/domain/managed/managedNativeVerification.js +3 -9
- package/dist/domain/native/binaryLayout.js +357 -0
- package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
- package/dist/domain/native/nativeCallObservation.js +186 -0
- package/dist/domain/native/nativeCallPartialObservation.js +33 -0
- package/dist/domain/native/objcSwiftMetadata.js +0 -39
- package/dist/domain/native/recordedCrash.js +266 -0
- package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
- package/dist/domain/{processCapture.js → process/processCapture.js} +143 -2
- package/dist/domain/{processCaptureExample.js → process/processCaptureExample.js} +5 -0
- package/dist/domain/process/processCaptureParsing.js +54 -0
- package/dist/domain/{processCaptureValidation.js → process/processCaptureValidation.js} +18 -2
- package/dist/domain/{processComparison.js → process/processComparison.js} +39 -5
- package/dist/domain/{processObservation.js → process/processObservation.js} +1 -1
- package/dist/domain/{processScenario.js → process/processScenario.js} +11 -10
- package/dist/domain/{processTraceSpecification.js → process/processTraceSpecification.js} +1 -1
- package/dist/domain/propertyListKeys.js +1 -1
- package/dist/domain/propertyListXmlText.js +19 -0
- package/dist/domain/providerAdapterError.js +1 -1
- package/dist/domain/providerOperationHealth.js +54 -0
- package/dist/domain/providerSelectionError.js +4 -2
- package/dist/domain/reconstructionVerification.js +9 -46
- package/dist/domain/reconstructionVerificationSchemas.js +3 -3
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +9 -46
- 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 +1 -0
- package/dist/domain/webNetworkCapture.js +118 -0
- package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
- package/dist/domain/webRuntime.js +19 -5
- package/dist/domain/webSourceLocation.js +1 -0
- package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
- package/dist/dotnet/ManagedMemberInspector.js +4 -2
- package/dist/dotnet/ManagedMemberInspectorCore.js +38 -32
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +23 -7
- package/dist/dotnet/ManagedMemberRows.js +14 -3
- package/dist/dotnet/ManagedMetadataHeaps.js +20 -2
- package/dist/dotnet/ManagedMetadataInventory.js +38 -28
- package/dist/dotnet/ManagedMetadataInventoryRows.js +24 -10
- package/dist/dotnet/ManagedMethodBodyReader.js +7 -1
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +15 -3
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +3 -1
- package/dist/dotnet/ManagedPeReader.js +11 -0
- package/dist/evm/EvmBytecodeCarrier.js +21 -0
- package/dist/evm/EvmWorkerLimits.js +40 -0
- package/dist/evm/EvmoleFailures.js +126 -0
- package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
- package/dist/evm/EvmoleInterfaceProvider.js +273 -0
- package/dist/evm/EvmoleInterfaceWorker.js +87 -0
- package/dist/evm/EvmoleRelease.js +16 -0
- package/dist/firmware/FirmwareCommand.js +1 -0
- package/dist/firmware/FirmwareFiles.js +1 -1
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraAnalysisProfile.js +5 -0
- package/dist/ghidra/GhidraClient.js +47 -14
- package/dist/ghidra/GhidraDiagnostics.js +7 -7
- package/dist/ghidra/GhidraFunctionValues.js +10 -7
- package/dist/ghidra/GhidraInstallation.js +18 -21
- package/dist/ghidra/GhidraInventoryValues.js +14 -4
- package/dist/ghidra/GhidraJavaLaunch.js +62 -0
- package/dist/ghidra/GhidraLauncher.js +34 -16
- package/dist/ghidra/GhidraProvider.js +2 -2
- package/dist/ghidra/GhidraProviderCapabilities.js +15 -3
- package/dist/ghidra/GhidraProviderClient.js +23 -12
- package/dist/ghidra/GhidraSessionError.js +11 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +47 -12
- package/dist/ghidra/GhidraTransport.js +20 -0
- package/dist/hopper/BridgeLauncher.js +33 -11
- package/dist/hopper/HopperAnalysisProfile.js +62 -4
- package/dist/hopper/HopperCleanup.js +15 -3
- package/dist/hopper/HopperClient.js +222 -14
- package/dist/hopper/HopperFileOffset.js +237 -0
- package/dist/hopper/HopperMachOImage.js +196 -0
- package/dist/hopper/HopperOperationStage.js +6 -0
- package/dist/hopper/HopperProvider.js +63 -9
- package/dist/hopper/HopperProviderCapabilities.js +19 -1
- package/dist/hopper/HopperRegexSearch.js +137 -0
- package/dist/hopper/HopperRegexWorker.js +27 -0
- package/dist/hopper/HopperRequestQueue.js +68 -19
- package/dist/hopper/HopperTargetLease.js +3 -2
- package/dist/hopper/LinuxPrivateDisplayProbe.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -1
- package/dist/inspector/V8InspectorCaptureProjection.js +8 -3
- package/dist/inspector/V8InspectorProvider.js +47 -11
- package/dist/javascript/recovery/WakaruCommand.js +3 -0
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +17 -0
- package/dist/javascript/sourceMaps/SourceMapFormat.js +79 -31
- package/dist/javascript/sourceMaps/TraceSourceMap.js +14 -28
- 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 +32 -16
- 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 +82 -84
- package/dist/native/LldbCallTracer.js +541 -0
- package/dist/native/LldbRetainedObservations.js +178 -0
- package/dist/native/NativeCallObservation.js +194 -0
- package/dist/native/NativeMacOSProvider.js +117 -20
- package/dist/native/NativeMacOSProviderMetadata.js +8 -3
- package/dist/native/SignatureTargetBinding.js +155 -0
- package/dist/native/parsers/lipo.js +71 -1
- package/dist/native/pwndbg/PwndbgCoreContext.js +180 -0
- package/dist/native/pwntools/PwntoolsDecoder.js +203 -0
- package/dist/native/pwntools/PwntoolsFailures.js +180 -0
- package/dist/native/pwntools/PwntoolsLayoutProvider.js +36 -0
- package/dist/native/pwntools/PwntoolsRecordedCrashProvider.js +75 -0
- package/dist/native/pwntools/PwntoolsRelease.js +19 -0
- package/dist/native/pwntools/PwntoolsResourceLimits.js +76 -0
- package/dist/native/pwntools/RecordedCrashSourceBindings.js +46 -0
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +103 -0
- package/dist/process/DarwinProcessRunTokenReader.js +293 -0
- package/dist/process/ExecFileOutput.js +20 -0
- package/dist/process/OwnedCommand.js +118 -0
- package/dist/process/ProcessOwnership.js +431 -51
- package/dist/process/ProcessOwnershipObservation.js +209 -27
- package/dist/process/ProviderProcess.js +68 -10
- package/dist/{application → process/capture}/ProcessCaptureCapability.js +15 -0
- package/dist/{application → process/capture}/ProcessCaptureError.js +18 -2
- package/dist/process/capture/ProcessCaptureLifecycle.js +681 -0
- package/dist/{application → process/capture}/ProcessHarness.js +195 -29
- package/dist/{application → process/capture}/ProcessSampling.js +2 -2
- package/dist/server/EvidenceMcpServer.js +146 -0
- package/dist/server/createServer.js +37 -8
- package/dist/server/promptCompletion.js +10 -3
- package/dist/server/registerAndroidTools.js +2 -4
- package/dist/server/registerApplicationTools/helpers.js +2 -4
- package/dist/server/registerArtifactComparisonTool.js +11 -7
- package/dist/server/registerBinaryDiagnosticsTools.js +15 -0
- package/dist/server/registerBrowserScenarioTool.js +2 -4
- package/dist/server/registerBrowserTools.js +2 -4
- package/dist/server/registerBundleComparisonTool.js +2 -3
- package/dist/server/registerCloseLifecycleTool.js +8 -18
- package/dist/server/registerElectronTools.js +2 -4
- package/dist/server/registerEnhancedTools.js +18 -59
- package/dist/server/registerEvidenceTools.js +3 -5
- package/dist/server/registerEvmTools.js +15 -0
- package/dist/server/registerFirmwareTools.js +2 -4
- package/dist/server/registerFunctionComparisonTool.js +10 -6
- package/dist/server/registerInvestigationTools.js +7 -7
- package/dist/server/registerJavaScriptRecoveryTool.js +2 -4
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +2 -4
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +2 -4
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +2 -4
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +2 -4
- package/dist/server/registerOfficialTools.js +2 -4
- package/dist/server/registerProcessComparisonTool.js +72 -46
- package/dist/server/registerRecordedCrashTools.js +15 -0
- package/dist/server/registerSessionRecordTools.js +5 -6
- package/dist/server/registerSessionStatusTool.js +17 -3
- package/dist/server/registerSessionTools.js +13 -5
- package/dist/server/registerWebModuleTool.js +2 -4
- package/dist/server/registerWebNetworkCaptureTool.js +26 -0
- package/dist/server/registerWebRuntimeTools.js +3 -7
- package/dist/server/registerWebScriptTool.js +2 -4
- package/dist/server/registerWebSourceLocationTool.js +2 -4
- package/dist/server/runDerivedOperation.js +15 -3
- package/dist/server/sessionAvailabilityPolicy.js +3 -1
- package/dist/server/sessionToolPolicies.js +1 -1
- package/dist/server/toolRegistrationOptions.js +2 -2
- package/dist/server/toolResult.js +63 -11
- package/dist/server/toolResultEncoding.js +33 -0
- package/install.sh +1 -1
- package/native/windows/build/manifest.json +2 -2
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +42 -9
- package/scripts/electron-active-hook-boundaries.cjs +18 -20
- package/scripts/electron-active-hook.cjs +241 -37
- package/scripts/rea.mjs +11 -3
- package/skills/reverse-engineer-anything/SKILL.md +32 -4
- package/skills/reverse-engineer-anything/references/javascript-applications.md +8 -1
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +29 -0
- package/third_party/README.md +60 -0
- package/third_party/evmole/LICENSE +21 -0
- package/third_party/evmole/README.md +22 -0
- package/third_party/pwndbg/LICENSE.md +21 -0
- package/third_party/pwndbg/README.md +23 -0
- package/third_party/pwntools/README.md +40 -0
- package/dist/application/AuthorizedArtifactInventory.js +0 -7
- package/dist/application/ProcessCaptureLifecycle.js +0 -299
- package/dist/application/StoreFileLock.js +0 -124
- package/dist/contracts/processCaptureExample.js +0 -2
- package/dist/domain/bytecodeProvider.js +0 -178
- package/dist/domain/customProtocolCapture.js +0 -137
- package/dist/domain/eventProcessTree.js +0 -225
- package/dist/domain/mobileApplicationInvestigation.js +0 -159
- package/dist/domain/packageAnalysis.js +0 -123
- package/dist/domain/peInspection.js +0 -197
- package/dist/domain/processCaptureParsing.js +0 -21
- package/dist/domain/protocolCapture.js +0 -217
- package/dist/domain/runtimeIdentification.js +0 -212
- package/dist/generatedMcpToolCatalog.js +0 -37
- package/dist/ghidra/GhidraDefaults.js +0 -2
- /package/dist/application/{ArtifactExtractionDestination.js → artifacts/ArtifactExtractionDestination.js} +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/policy.js +0 -0
- /package/dist/{application/ArtifactInventory → artifacts/inventory}/types.js +0 -0
- /package/dist/domain/{processEvidenceProvider.js → process/processEvidenceProvider.js} +0 -0
- /package/dist/domain/{processTraceComparison.js → process/processTraceComparison.js} +0 -0
- /package/dist/domain/{processTraceDimensionProjection.js → process/processTraceDimensionProjection.js} +0 -0
- /package/dist/domain/{processTraceEvaluation.js → process/processTraceEvaluation.js} +0 -0
- /package/dist/{application → process/capture}/FilesystemSnapshot.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureEnvironment.js +0 -0
- /package/dist/{application → process/capture}/ProcessCaptureJournal.js +0 -0
- /package/dist/{application → process/capture}/ProcessFilesystemEffects.js +0 -0
- /package/dist/{application → process/capture}/ProcessNormalization.js +0 -0
- /package/dist/{application → process/capture}/ProcessScenarioRuntimeValidation.js +0 -0
- /package/dist/{application → process/capture}/ProcessTimer.js +0 -0
- /package/dist/{application → process/capture}/TerminalRenderer.js +0 -0
|
@@ -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);
|