reverseport 0.0.0-stage → 1.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/DISCLAIMER.md +136 -0
- package/LICENSE +22 -0
- package/README.md +289 -2
- package/RESPONSIBLE-USE.md +22 -0
- package/THIRD_PARTY_NOTICES.md +130 -0
- package/bin/reverseport.mjs +136 -0
- package/bridge/android/ReaJadxBridge.java +270 -0
- package/bridge/ghidra/ReaGhidraAnalysisOptions.java +38 -0
- package/bridge/ghidra/ReaGhidraApplySeeds.java +151 -0
- package/bridge/ghidra/ReaGhidraBridge.java +3858 -0
- package/bridge/ghidra/ReaGhidraBundleActivator.java +14 -0
- package/bridge/ghidra/ReaGhidraExtensions.java +113 -0
- package/bridge/ghidra/ReaGhidraMipsSoftFloat.java +176 -0
- package/bridge/ghidra/ReaGhidraNoReturnFix.java +123 -0
- package/bridge/ghidra/ReaGhidraPrepareCom.java +32 -0
- package/bridge/ghidra/ReaGhidraPrepareRaw.java +36 -0
- package/bridge/hopper_bridge.py +1162 -0
- package/bridge/mitmproxy/capture.py +208 -0
- package/bridge/native/NativeUIChildren.swift +27 -0
- package/bridge/native/ReaNativeUI.swift +171 -0
- package/bridge/native/rea_lldb_tracer.py +839 -0
- package/bridge/process/ProcessRunTokenReader.swift +339 -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 +314 -0
- package/bridge/pwntools/recorded_crash.py +39 -0
- package/bridge/pwntools/recorded_crash_impl.py +147 -0
- package/dist/adb/AdbConfiguration.js +88 -0
- package/dist/adb/AdbDeviceOutput.js +191 -0
- package/dist/adb/AdbDirectoryListing.js +80 -0
- package/dist/adb/AdbHostFileName.js +34 -0
- package/dist/adb/AdbProvider.js +1227 -0
- package/dist/adb/AdbShellOutput.js +267 -0
- package/dist/android/AndroidTargetSnapshot.js +118 -0
- package/dist/android/JadxAnalysis.js +201 -0
- package/dist/android/JadxConfiguration.js +320 -0
- package/dist/android/JadxMcpTransport.js +188 -0
- package/dist/android/JadxProtocol.js +115 -0
- package/dist/android/JadxProvider.js +337 -0
- package/dist/android/JadxRelease.js +27 -0
- package/dist/android/JadxSession.js +172 -0
- package/dist/apktool/ApktoolConfiguration.js +120 -0
- package/dist/apktool/ApktoolDecodeOutput.js +142 -0
- package/dist/apktool/ApktoolProvider.js +522 -0
- package/dist/application/AnalysisContextQueries.js +128 -0
- package/dist/application/AnalysisDocument.js +32 -0
- package/dist/application/AnalysisProvider.js +27 -0
- package/dist/application/AppBundleExecutable.js +192 -0
- package/dist/application/BinaryTargetResolver.js +356 -0
- package/dist/application/BrowserEvidence.js +127 -0
- package/dist/application/BrowserObservationPort.js +1 -0
- package/dist/application/BrowserObservationService.js +86 -0
- package/dist/application/BrowserScenarioCapturePort.js +1 -0
- package/dist/application/BrowserScenarioCaptureService.js +17 -0
- package/dist/application/BrowserScenarioEvidence.js +28 -0
- package/dist/application/CallPathTracing.js +182 -0
- package/dist/application/CapabilityClientRequirements.js +17 -0
- package/dist/application/CapabilityInventory.js +525 -0
- package/dist/application/ClientConfigPath.js +35 -0
- package/dist/application/ClientConfigurationDocument.js +1196 -0
- package/dist/application/ClientConfigurationFiles.js +91 -0
- package/dist/application/ClientRegistrationEnvironment.js +39 -0
- package/dist/application/ClientRegistrationIdentity.js +80 -0
- package/dist/application/ClientRegistrationStatus.js +233 -0
- package/dist/application/DirectAnalysis.js +371 -0
- package/dist/application/DirectAnalysisCleanup.js +71 -0
- package/dist/application/DirectAnalysisDependencies.js +1 -0
- package/dist/application/DirectAnalysisStatus.js +22 -0
- package/dist/application/Doctor.js +349 -0
- package/dist/application/DoctorDiagnostics.js +169 -0
- package/dist/application/DoctorProviderIds.js +2 -0
- package/dist/application/DoctorScope.js +113 -0
- package/dist/application/DshCordisPatch.js +342 -0
- package/dist/application/DshCordisYaml.js +155 -0
- package/dist/application/EnhancedLiteralTracing.js +88 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +428 -0
- package/dist/application/EvidenceBundleCommands.js +70 -0
- package/dist/application/EvidenceBundleFiles.js +79 -0
- package/dist/application/EvidenceInputResolver.js +30 -0
- package/dist/application/FunctionAnalysisEvidence.js +34 -0
- package/dist/application/GeminiClientSettings.js +139 -0
- package/dist/application/HermesClientHome.js +115 -0
- package/dist/application/HopperDownload.js +39 -0
- package/dist/application/InventoryProjectionEvidence.js +44 -0
- package/dist/application/InvestigationProviders.js +130 -0
- package/dist/application/JsonFiles.js +225 -0
- package/dist/application/JsonInputFile.js +410 -0
- package/dist/application/LinuxHopper.js +232 -0
- package/dist/application/MacHopper.js +235 -0
- package/dist/application/MipsElfMetadata.js +175 -0
- package/dist/application/MipsElfSharedLoad.js +164 -0
- package/dist/application/OptionalObservationProviders.js +3 -0
- package/dist/application/ProcedureAddressResolution.js +11 -0
- package/dist/application/ProgressReporter.js +30 -0
- package/dist/application/ProviderOperationExecution.js +31 -0
- package/dist/application/RealHopperAssertions.js +135 -0
- package/dist/application/ReconstructionCoverageService.js +22 -0
- package/dist/application/ReconstructionObligationAuthority.js +72 -0
- package/dist/application/ReconstructionObligationCandidates.js +286 -0
- package/dist/application/ReconstructionObligationLedgerDiagnostics.js +47 -0
- package/dist/application/ReconstructionObligationLedgerEvaluation.js +238 -0
- package/dist/application/ReconstructionObligationLedgerProjection.js +15 -0
- package/dist/application/ReconstructionObligationLedgerService.js +54 -0
- package/dist/application/ReconstructionObligationOriginalCases.js +34 -0
- package/dist/application/ReconstructionObligationPolicies.js +132 -0
- package/dist/application/ReferenceSourceImport.js +200 -0
- package/dist/application/ReferenceSourceImportEntries.js +151 -0
- package/dist/application/ReferenceSourceImportPolicy.js +125 -0
- package/dist/application/ReferenceSourceImportTypes.js +47 -0
- package/dist/application/ReferenceSourceVcsAdapter.js +180 -0
- package/dist/application/RegularFileRead.js +120 -0
- package/dist/application/Setup.js +408 -0
- package/dist/application/SetupClientConfiguration.js +314 -0
- package/dist/application/SetupClients.js +44 -0
- package/dist/application/SetupHost.js +203 -0
- package/dist/application/SetupInstallFailure.js +77 -0
- package/dist/application/SetupPlan.js +210 -0
- package/dist/application/SetupRegistrationEnvironment.js +5 -0
- package/dist/application/SetupSkill.js +248 -0
- package/dist/application/SetupTypes.js +17 -0
- package/dist/application/SupportedClients.js +469 -0
- package/dist/application/TypeScriptEmittedSourceCandidates.js +23 -0
- package/dist/application/Uninstall.js +452 -0
- package/dist/application/UninstallFailure.js +14 -0
- package/dist/application/Update.js +137 -0
- package/dist/application/UpdateFailure.js +17 -0
- package/dist/application/UpdateMaintenance.js +111 -0
- package/dist/application/UpdateRuntime.js +264 -0
- package/dist/application/Utf8JsonInput.js +71 -0
- package/dist/application/ValidateSelectedWebScript.js +27 -0
- package/dist/application/WebModulePorts.js +1 -0
- package/dist/application/WebModuleTraceService.js +214 -0
- package/dist/application/WebNetworkCapturePort.js +1 -0
- package/dist/application/WebNetworkCaptureService.js +134 -0
- package/dist/application/WebRuntimePort.js +1 -0
- package/dist/application/WebRuntimeService.js +75 -0
- package/dist/application/WebScriptArtifactPort.js +1 -0
- package/dist/application/WebScriptExportService.js +214 -0
- package/dist/application/WebSourceLocationPorts.js +1 -0
- package/dist/application/WebSourceLocationService.js +177 -0
- package/dist/application/WindowsCapabilities.js +87 -0
- package/dist/application/WorkflowEvidence.js +105 -0
- package/dist/application/XrefsAddressResolution.js +45 -0
- package/dist/application/adb/AdbDeviceAnalysisPort.js +1 -0
- package/dist/application/adb/AdbDeviceAnalysisService.js +13 -0
- package/dist/application/analysisView/AnalysisViewService.js +133 -0
- package/dist/application/android/AndroidAnalysisPort.js +1 -0
- package/dist/application/android/AndroidAnalysisService.js +37 -0
- package/dist/application/android/AndroidApplicationService.js +17 -0
- package/dist/application/android/AndroidSearchEvidenceSummary.js +100 -0
- package/dist/application/apktool/ApktoolResourceAnalysisPort.js +1 -0
- package/dist/application/apktool/ApktoolResourceAnalysisService.js +13 -0
- package/dist/application/apple/AppleApplicationService.js +17 -0
- package/dist/application/artifacts/ArtifactExtractionDestination.js +5 -0
- package/dist/application/binary/AbortablePromise.js +28 -0
- package/dist/application/binary/AnalysisClientCleanup.js +15 -0
- package/dist/application/binary/AnalysisProviderEvaluation.js +77 -0
- package/dist/application/binary/AnalysisProviderRegistry.js +235 -0
- package/dist/application/binary/AnalysisSnapshotCache.js +232 -0
- package/dist/application/binary/AnalysisSnapshotFiles.js +96 -0
- package/dist/application/binary/BinarySession.js +605 -0
- package/dist/application/binary/BinarySessionComposition.js +9 -0
- package/dist/application/binary/BinarySessionExecution.js +66 -0
- package/dist/application/binary/BinarySessionOpen.js +66 -0
- package/dist/application/binary/BinarySessionPort.js +1 -0
- package/dist/application/binary/BinarySessionRecords.js +216 -0
- package/dist/application/binary/BinarySessionStatus.js +219 -0
- package/dist/application/binary/BinaryTargetSummary.js +9 -0
- package/dist/application/binary/CompositeProvider.js +103 -0
- package/dist/application/binary/LazyAnalysisProvider.js +105 -0
- package/dist/application/binary/SessionProviderRouter.js +118 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutPort.js +1 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +60 -0
- package/dist/application/binaryDiagnostics/PeResourcesPort.js +1 -0
- package/dist/application/binaryDiagnostics/PeResourcesService.js +111 -0
- package/dist/application/binaryDiagnostics/RecordedCrashPort.js +1 -0
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +63 -0
- package/dist/application/evm/EvmInterfacePort.js +1 -0
- package/dist/application/evm/EvmInterfaceService.js +67 -0
- package/dist/application/firmware/FirmwareAnalysisPort.js +1 -0
- package/dist/application/firmware/FirmwareAnalysisService.js +38 -0
- package/dist/application/go/GoBinaryPort.js +1 -0
- package/dist/application/go/GoBinaryService.js +77 -0
- package/dist/application/harmony/HarmonyApplicationService.js +17 -0
- package/dist/application/homebrew.js +67 -0
- package/dist/application/investigation/EvidenceLedger.js +338 -0
- package/dist/application/investigation/InspectEvidenceBundle.js +18 -0
- package/dist/application/investigation/InvestigationRecordPort.js +1 -0
- package/dist/application/investigation/InvestigationRecords.js +65 -0
- package/dist/application/investigation/UnknownEvidence.js +37 -0
- package/dist/application/javascript/ElectronActiveEvidence.js +29 -0
- package/dist/application/javascript/ElectronActiveObservationPort.js +1 -0
- package/dist/application/javascript/ElectronActiveObservationService.js +51 -0
- package/dist/application/javascript/ElectronBoundaryAnalysis.js +118 -0
- package/dist/application/javascript/ElectronBoundaryGraph.js +11 -0
- package/dist/application/javascript/ElectronBoundaryGraphCallPaths.js +134 -0
- package/dist/application/javascript/ElectronBoundaryGraphContext.js +63 -0
- package/dist/application/javascript/ElectronBoundaryGraphIpc.js +261 -0
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +102 -0
- package/dist/application/javascript/ElectronBoundaryGraphWindows.js +224 -0
- package/dist/application/javascript/ElectronEvidence.js +37 -0
- package/dist/application/javascript/ElectronObservationPort.js +1 -0
- package/dist/application/javascript/ElectronObservationService.js +26 -0
- package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +49 -0
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +173 -0
- package/dist/application/javascript/JavaScriptApplicationService.js +170 -0
- package/dist/application/javascript/JavaScriptApplicationWorkflowEvidence.js +67 -0
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +194 -0
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +431 -0
- package/dist/application/javascript/JavaScriptArtifactAnalysisTypes.js +1 -0
- package/dist/application/javascript/JavaScriptArtifactGraphAccumulator.js +89 -0
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +193 -0
- package/dist/application/javascript/JavaScriptArtifactGraphBundlers.js +229 -0
- package/dist/application/javascript/JavaScriptArtifactGraphContext.js +194 -0
- package/dist/application/javascript/JavaScriptArtifactGraphDocuments.js +160 -0
- package/dist/application/javascript/JavaScriptArtifactGraphEvidence.js +85 -0
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +349 -0
- package/dist/application/javascript/JavaScriptArtifactGraphStructure.js +424 -0
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +836 -0
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +245 -0
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +12 -0
- package/dist/application/javascript/JavaScriptJsonModules.js +40 -0
- package/dist/application/javascript/JavaScriptModuleRelationships.js +304 -0
- package/dist/application/javascript/JavaScriptRecoveryPort.js +1 -0
- package/dist/application/javascript/JavaScriptRecoveryService.js +77 -0
- package/dist/application/javascript/JavaScriptRuntimeObservationEvidence.js +36 -0
- package/dist/application/javascript/JavaScriptRuntimeObservationPort.js +1 -0
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +28 -0
- package/dist/application/javascript/JavaScriptRuntimeReconciliationEvidence.js +24 -0
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +52 -0
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +163 -0
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +527 -0
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +165 -0
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +156 -0
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +216 -0
- package/dist/application/javascript/JavaScriptSemanticGraphElectronProjection.js +61 -0
- package/dist/application/javascript/JavaScriptSemanticGraphEvidence.js +86 -0
- package/dist/application/javascript/JavaScriptSemanticGraphFingerprintProjection.js +25 -0
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +183 -0
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +112 -0
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +144 -0
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +58 -0
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +136 -0
- package/dist/application/javascript/JavaScriptSemanticTraceService.js +41 -0
- package/dist/application/jeb/JebAnalysisPort.js +1 -0
- package/dist/application/jeb/JebAnalysisService.js +13 -0
- package/dist/application/managed/ManagedApplicationGraphService.js +55 -0
- package/dist/application/managed/ManagedMemberComparisonService.js +125 -0
- package/dist/application/managed/ManagedNativeVerificationService.js +40 -0
- package/dist/application/managed/ManagedReconstructionService.js +59 -0
- package/dist/application/native/NativeApiInspection.js +77 -0
- package/dist/application/native/NativeCallRoutes.js +73 -0
- package/dist/application/native/NativeDispatchMetadataInspection.js +33 -0
- package/dist/application/native/NativeUiActionTrace.js +427 -0
- package/dist/application/native/NativeValueTrace.js +340 -0
- package/dist/application/process/ProcessCli.js +190 -0
- package/dist/application/process/ProcessEvidence.js +30 -0
- package/dist/application/wasm/WasmArtifactPort.js +1 -0
- package/dist/application/wasm/WasmArtifactService.js +72 -0
- package/dist/application/workflowInputError.js +18 -0
- package/dist/artifacts/ArtifactHash.js +29 -0
- package/dist/artifacts/ArtifactPaths.js +167 -0
- package/dist/artifacts/ArtifactProvider.js +280 -0
- package/dist/artifacts/ArtifactProviderMetadata.js +34 -0
- package/dist/artifacts/ArtifactReader.js +77 -0
- package/dist/artifacts/ArtifactResourceScope.js +103 -0
- package/dist/artifacts/AsarArtifactReader.js +518 -0
- package/dist/artifacts/AsarEntryStream.js +76 -0
- package/dist/artifacts/AsarHeader.js +24 -0
- package/dist/artifacts/DirectoryArtifactReader.js +292 -0
- package/dist/artifacts/MachOSliceArtifactReader.js +342 -0
- package/dist/artifacts/NativeDmgArtifactReader.js +508 -0
- package/dist/artifacts/NativeDmgOwnership.js +109 -0
- package/dist/artifacts/SafeOutputTree.js +394 -0
- package/dist/artifacts/SafeOutputTreeCleanup.js +45 -0
- package/dist/artifacts/SafeOutputTreeCreationFailure.js +20 -0
- package/dist/artifacts/SafeOutputTreeIdentity.js +42 -0
- package/dist/artifacts/SafeOutputTreeReadback.js +33 -0
- package/dist/artifacts/StreamBytes.js +10 -0
- package/dist/artifacts/ZipArtifactReader.js +222 -0
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +190 -0
- package/dist/artifacts/apple/DylibResolutionReader.js +269 -0
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +500 -0
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +233 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +163 -0
- package/dist/artifacts/apple/MachoLoadCommandReader.js +393 -0
- package/dist/artifacts/apple/NibArchive.js +338 -0
- package/dist/artifacts/apple/NibViewHierarchy.js +157 -0
- package/dist/artifacts/apple/PlistNumberLiterals.js +164 -0
- package/dist/artifacts/extraction/ArtifactExtraction.js +253 -0
- package/dist/artifacts/hostExecutableMarking.js +16 -0
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +343 -0
- package/dist/artifacts/inventory/ArtifactInventory.js +16 -0
- package/dist/artifacts/inventory/classify.js +94 -0
- package/dist/artifacts/inventory/hashStableRootArtifact.js +70 -0
- package/dist/artifacts/inventory/reader.js +40 -0
- package/dist/artifacts/inventory/scanCanonical.js +213 -0
- package/dist/artifacts/inventory/scanReader.js +169 -0
- package/dist/artifacts/inventory/types.js +3 -0
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +317 -0
- package/dist/artifacts/javascript/JavaScriptArtifactReader.js +6 -0
- package/dist/artifacts/javascript/JavaScriptSourceAnalysis.js +3 -0
- package/dist/artifacts/readStableArtifact.js +68 -0
- package/dist/browser/BrowserProcessStartup.js +89 -0
- package/dist/browser/BrowserScenarioPartialObservation.js +127 -0
- package/dist/browser/BrowserScenarioSecrets.js +137 -0
- package/dist/browser/BrowserScenarioSessionPort.js +1 -0
- package/dist/browser/CdpAuthorizedMainFrame.js +16 -0
- package/dist/browser/CdpAuthorizedTarget.js +22 -0
- package/dist/browser/CdpBrowserProvider.js +276 -0
- package/dist/browser/CdpCaptureCompleteness.js +92 -0
- package/dist/browser/CdpCaptureDocuments.js +375 -0
- package/dist/browser/CdpCaptureDomSvg.js +210 -0
- package/dist/browser/CdpCaptureEventBodyShapes.js +55 -0
- package/dist/browser/CdpCaptureEventHandlers.js +463 -0
- package/dist/browser/CdpCaptureEventHelpers.js +84 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +5 -0
- package/dist/browser/CdpCaptureEvents.js +199 -0
- package/dist/browser/CdpCaptureStorage.js +86 -0
- package/dist/browser/CdpCaptureStorageFingerprints.js +320 -0
- package/dist/browser/CdpCaptureValues.js +91 -0
- package/dist/browser/CdpCommandRejection.js +17 -0
- package/dist/browser/CdpConnection.js +303 -0
- package/dist/browser/CdpElectronInspection.js +253 -0
- package/dist/browser/CdpElectronProvider.js +115 -0
- package/dist/browser/CdpElectronScriptEvents.js +55 -0
- package/dist/browser/CdpElectronScripts.js +65 -0
- package/dist/browser/CdpElectronWorkers.js +57 -0
- package/dist/browser/CdpEndpoint.js +217 -0
- package/dist/browser/CdpObservationSession.js +332 -0
- package/dist/browser/CdpOptionalCommand.js +14 -0
- package/dist/browser/CdpPageCapture.js +278 -0
- package/dist/browser/CdpPageCaptureScripts.js +79 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpSafeMetadata.js +284 -0
- package/dist/browser/CdpScreenshot.js +110 -0
- package/dist/browser/CdpTargetEvents.js +8 -0
- package/dist/browser/CdpTargetSession.js +65 -0
- package/dist/browser/CdpWebMcpDiscovery.js +361 -0
- package/dist/browser/ElectronFileScope.js +135 -0
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +301 -0
- package/dist/browser/PlaywrightElectronActiveActions.js +257 -0
- package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +293 -0
- package/dist/browser/PlaywrightExecutionBoundary.js +53 -0
- package/dist/browser/PlaywrightScenarioActions.js +58 -0
- package/dist/browser/PlaywrightScenarioArtifacts.js +162 -0
- package/dist/browser/PlaywrightScenarioBrowser.js +412 -0
- package/dist/browser/PlaywrightScenarioEvents.js +253 -0
- package/dist/browser/PlaywrightScenarioSession.js +279 -0
- package/dist/browser/PlaywrightScenarioStorage.js +507 -0
- package/dist/browser/PngVisualDiff.js +380 -0
- package/dist/browser/WebSourceMapFetcher.js +718 -0
- package/dist/browser/assets/LocalWebScriptArtifacts.js +89 -0
- package/dist/browser/assets/PageScriptCapture.js +32 -0
- package/dist/browser/assets/PublishWebScripts.js +140 -0
- package/dist/browser/assets/ScenarioScriptCapture.js +73 -0
- package/dist/browser/assets/ScriptCaptureAdapters.js +57 -0
- package/dist/browser/assets/WebArtifactReads.js +78 -0
- package/dist/browser/assets/WebSourceLocationArtifacts.js +41 -0
- package/dist/browser/execution/CdpEventListeners.js +79 -0
- package/dist/browser/execution/CdpExecutionCapture.js +135 -0
- package/dist/browser/execution/CdpExecutionCollection.js +57 -0
- package/dist/browser/execution/CdpExecutionWindow.js +100 -0
- package/dist/browser/execution/CdpListenerSelector.js +22 -0
- package/dist/browser/execution/CdpPreciseCoverage.js +45 -0
- package/dist/browser/execution/CdpRuntimeInitiator.js +18 -0
- package/dist/browser/execution/CdpRuntimeProtocol.js +106 -0
- package/dist/browser/execution/CdpRuntimeRequests.js +81 -0
- package/dist/browser/execution/CdpRuntimeSession.js +163 -0
- package/dist/browser/execution/CdpRuntimeSources.js +223 -0
- package/dist/browser/execution/CdpWebRuntimeProvider.js +51 -0
- package/dist/browser/history/CaptureFailures.js +153 -0
- package/dist/browser/history/CaptureFormatError.js +10 -0
- package/dist/browser/history/CaptureRedaction.js +68 -0
- package/dist/browser/history/CaptureRelease.js +23 -0
- package/dist/browser/history/HarCapture.js +179 -0
- package/dist/browser/history/HarCaptureAdapter.js +23 -0
- package/dist/browser/history/HarCaptureProcess.js +49 -0
- package/dist/browser/history/HarJson.js +92 -0
- package/dist/browser/history/HarSchema.js +72 -0
- package/dist/browser/history/HistoricalCaptureDecoder.js +198 -0
- package/dist/browser/history/HistoricalCaptureFormatAdapter.js +1 -0
- package/dist/browser/history/MitmproxyCaptureAdapter.js +46 -0
- package/dist/browser/modules/NativeModuleResolver.js +277 -0
- package/dist/browser/modules/WebModuleArtifacts.js +41 -0
- package/dist/browser/network/PlaywrightNetworkContent.js +71 -0
- package/dist/browser/network/PlaywrightScenarioNetwork.js +180 -0
- package/dist/browser/providerIdentities.js +24 -0
- package/dist/catalogIdentity.js +65 -0
- package/dist/cli/adbCommands.js +337 -0
- package/dist/cli/analysisSelector.js +23 -0
- package/dist/cli/analysisViewCommands.js +74 -0
- package/dist/cli/androidCommands.js +91 -0
- package/dist/cli/apktoolCommands.js +53 -0
- package/dist/cli/applicationCommands.js +173 -0
- package/dist/cli/artifactCommands.js +160 -0
- package/dist/cli/binaryDiagnosticsCommands.js +57 -0
- package/dist/cli/browserAdvancedCommands.js +189 -0
- package/dist/cli/browserCommands.js +125 -0
- package/dist/cli/commandCancellation.js +24 -0
- package/dist/cli/coreAnalysisCommands.js +7 -0
- package/dist/cli/coreBinaryCommands.js +283 -0
- package/dist/cli/coreNativeCommands.js +269 -0
- package/dist/cli/electronCommands.js +150 -0
- package/dist/cli/evmCommands.js +33 -0
- package/dist/cli/firmwareCommands.js +61 -0
- package/dist/cli/goCommands.js +21 -0
- package/dist/cli/interactiveSetup.js +236 -0
- package/dist/cli/javascriptApplicationAnalysis.js +34 -0
- package/dist/cli/javascriptRecoveryCommands.js +59 -0
- package/dist/cli/jebCommands.js +99 -0
- package/dist/cli/jsonOutput.js +46 -0
- package/dist/cli/managedCommands.js +129 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/nativeCallCommands.js +33 -0
- package/dist/cli/omittableDefaults.js +50 -0
- package/dist/cli/options.js +33 -0
- package/dist/cli/processCommands.js +25 -0
- package/dist/cli/referenceSourceImportStatus.js +22 -0
- package/dist/cli/setupCommands.js +189 -0
- package/dist/cli/streamedJsonOutput.js +134 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +226 -0
- package/dist/cli/wasmCommands.js +44 -0
- package/dist/cli/webModuleCommands.js +60 -0
- package/dist/cli/webNetworkCaptureCommands.js +40 -0
- package/dist/cli/webRuntimeCommands.js +60 -0
- package/dist/cli/webScriptCommands.js +50 -0
- package/dist/cli/webSourceLocationCommands.js +54 -0
- package/dist/cli-runtime/AnalysisProvider-CeyX2u-b.js +25 -0
- package/dist/cli-runtime/AnalysisSnapshotFiles-BuK_ymw5.js +523 -0
- package/dist/cli-runtime/ArtifactReader-BXkffc1D.js +55 -0
- package/dist/cli-runtime/ArtifactResourceScope-CZqLEfbb.js +108 -0
- package/dist/cli-runtime/AsarHeader-CnzOzYEH.js +31 -0
- package/dist/cli-runtime/BinaryTargetResolver-CKRfFhLj.js +965 -0
- package/dist/cli-runtime/BoundedFileBytes-BU30odTm.js +39 -0
- package/dist/cli-runtime/ClientConfigPath-c6jr6INc.js +36 -0
- package/dist/cli-runtime/ClientConfigurationDocument-D0ZqgTCv.js +1522 -0
- package/dist/cli-runtime/ClientRegistrationStatus-DGpwJ4ry.js +422 -0
- package/dist/cli-runtime/DirectAnalysis-DW3MvxW0.js +500 -0
- package/dist/cli-runtime/Doctor-CzwYS9nB.js +862 -0
- package/dist/cli-runtime/ElectronFileScope-C1hUEp36.js +1419 -0
- package/dist/cli-runtime/ExecFileOutput-Czbj-HpV.js +106 -0
- package/dist/cli-runtime/IdaConfiguration-rEjpuRQ1.js +854 -0
- package/dist/cli-runtime/InterfaceBuilderDecodeBudget-DT74BY9z.js +225 -0
- package/dist/cli-runtime/InventoryProjectionEvidence-Dt4Og45O.js +49 -0
- package/dist/cli-runtime/InvestigationProviders-D-QCy-4c.js +117 -0
- package/dist/cli-runtime/JavaScriptApplicationEvidenceGraph-CODAjVru.js +160 -0
- package/dist/cli-runtime/JavaScriptApplicationWorkflowEvidence-CCtwSg8r.js +75 -0
- package/dist/cli-runtime/JavaScriptWorkerMemoryLimit-CJeBSMPx.js +83 -0
- package/dist/cli-runtime/JsonFiles-Ce_O5NcH.js +708 -0
- package/dist/cli-runtime/ManagedSnapshot-DthWfmy9.js +3622 -0
- package/dist/cli-runtime/OwnedCommand-CnK8-h3N.js +106 -0
- package/dist/cli-runtime/PrivateRuntimeRoot-KNg6qLwo.js +237 -0
- package/dist/cli-runtime/ProcessOwnership-AOJaszxt.js +1310 -0
- package/dist/cli-runtime/ProviderDeadline-BSbNOmuW.js +89 -0
- package/dist/cli-runtime/RegularFile-CL6meBxi.js +114 -0
- package/dist/cli-runtime/RegularFileRead-BMh5FMXd.js +115 -0
- package/dist/cli-runtime/SafeOutputTree-D8z2Zrnu.js +512 -0
- package/dist/cli-runtime/SetupHost-CzzRF89z.js +842 -0
- package/dist/cli-runtime/SupportedClients-BrZ2qZVg.js +671 -0
- package/dist/cli-runtime/UninstallFailure-1blyKXHE.js +22 -0
- package/dist/cli-runtime/Update-DF55X_N2.js +143 -0
- package/dist/cli-runtime/UpdateFailure-BcFNxEZZ.js +24 -0
- package/dist/cli-runtime/WindowsBatchCommand-5gT-d7O4.js +45 -0
- package/dist/cli-runtime/ZipArtifactReader-Db65WuM_.js +380 -0
- package/dist/cli-runtime/analysisErrorCleanup-DaUQNiQd.js +32 -0
- package/dist/cli-runtime/analysisErrorPresentation-DZrKL8kS.js +331 -0
- package/dist/cli-runtime/application__DirectAnalysisStatus-OZFIFjZr.js +93 -0
- package/dist/cli-runtime/application__EnhancedTools-C__HAdqG.js +1728 -0
- package/dist/cli-runtime/application__FunctionAnalysisEvidence-fWSgvV74.js +41 -0
- package/dist/cli-runtime/application__ReconstructionCoverageService-DlNt-4TY.js +32 -0
- package/dist/cli-runtime/application__ReconstructionObligationLedgerService-CEpbUv-7.js +813 -0
- package/dist/cli-runtime/application__Setup-BExVGpqG.js +540 -0
- package/dist/cli-runtime/application__Uninstall-BVgWDCPN.js +349 -0
- package/dist/cli-runtime/application__UpdateRuntime-Dj6UIhHQ.js +358 -0
- package/dist/cli-runtime/application__android__AndroidApplicationService-CyynwW6Z.js +31 -0
- package/dist/cli-runtime/application__apple__AppleApplicationService-BNPcWeL8.js +31 -0
- package/dist/cli-runtime/application__harmony__HarmonyApplicationService-W66PwMvx.js +31 -0
- package/dist/cli-runtime/application__javascript__ElectronActiveObservationService-D8VbeCxz.js +85 -0
- package/dist/cli-runtime/application__javascript__ElectronObservationService-FmXFG4f2.js +63 -0
- package/dist/cli-runtime/application__javascript__JavaScriptApplicationService-D-dVrmAY.js +10467 -0
- package/dist/cli-runtime/application__javascript__JavaScriptApplicationWorkflowService-Cb0jmh8J.js +2284 -0
- package/dist/cli-runtime/application__javascript__JavaScriptRuntimeReconciliationService-D55gO7Gq.js +88 -0
- package/dist/cli-runtime/application__javascript__JavaScriptSemanticTraceService-DivM-Ym-.js +298 -0
- package/dist/cli-runtime/artifactOperationError-Wd0PRLIZ.js +27 -0
- package/dist/cli-runtime/artifacts__ArtifactProvider-B_4h3RAw.js +2091 -0
- package/dist/cli-runtime/binary-9Gt3vJ1P.js +12990 -0
- package/dist/cli-runtime/browserObservationError-D73SM55P.js +40 -0
- package/dist/cli-runtime/browserScenario-CTNr5ISp.js +5543 -0
- package/dist/cli-runtime/catalogIdentity-EYVhBUYJ.js +339 -0
- package/dist/cli-runtime/cli.js +28528 -0
- package/dist/cli-runtime/cliOutput-CoDmWVu5.js +98 -0
- package/dist/cli-runtime/cliOutput.js +5 -0
- package/dist/cli-runtime/composition__browserScenario-DNr3A_BM.js +2318 -0
- package/dist/cli-runtime/composition__electronObservation-DNw1f38M.js +550 -0
- package/dist/cli-runtime/composition__electronScenario-Cu7PX270.js +586 -0
- package/dist/cli-runtime/configurationErrors-ByuF6gMR.js +49 -0
- package/dist/cli-runtime/doctorRuntime-D5y43lEp.js +162 -0
- package/dist/cli-runtime/dosMz-pwwUuxyC.js +65 -0
- package/dist/cli-runtime/dotnet__ManagedStaticProvider-BSnWggeb.js +5 -0
- package/dist/cli-runtime/enhancedInputs-K8C_o3b4.js +56 -0
- package/dist/cli-runtime/javascriptApplicationGraph-DUWeec4O.js +940 -0
- package/dist/cli-runtime/javascriptExportReturnShapeProjection-BVbnAdOd.js +78 -0
- package/dist/cli-runtime/javascriptExportShapeComparisonSchemas-BzSil7ft.js +1153 -0
- package/dist/cli-runtime/javascriptRuntimeObservation-9xTNoKY2.js +1215 -0
- package/dist/cli-runtime/javascriptRuntimeReconciliation-CneBtMvx.js +1437 -0
- package/dist/cli-runtime/javascriptRuntimeReconciliationSchemas-D1Mrb_Y0.js +245 -0
- package/dist/cli-runtime/javascriptSemanticTraceSchemas-BHItrqIA.js +126 -0
- package/dist/cli-runtime/lipo-BCA3wVyN.js +365 -0
- package/dist/cli-runtime/logger-CKq3JfbZ.js +34 -0
- package/dist/cli-runtime/machoContainer-DxxkB2b0.js +52 -0
- package/dist/cli-runtime/managedApplicationGraph-BqOr01E6.js +1116 -0
- package/dist/cli-runtime/managedToolContracts-BSy4TRaK.js +80 -0
- package/dist/cli-runtime/mcpDoctor.js +342 -0
- package/dist/cli-runtime/mcpStartupPolicy-Bb7TMLzn.js +18 -0
- package/dist/cli-runtime/native__NativeMacOSProvider-BIG9iCcj.js +4415 -0
- package/dist/cli-runtime/plistValue-KM-SqiXe.js +47 -0
- package/dist/cli-runtime/propertyListKeys-DejfMb-U.js +86 -0
- package/dist/cli-runtime/providerAdapterError-SRSE_gzN.js +27 -0
- package/dist/cli-runtime/providerCleanupError-Do66qCEp.js +27 -0
- package/dist/cli-runtime/providerIdentities-Ao1XTvwx.js +31 -0
- package/dist/cli-runtime/providerOperationHealth-DSTcYPJe.js +577 -0
- package/dist/cli-runtime/providerStartupTimeout-Be8B1Ro8.js +16 -0
- package/dist/cli-runtime/readFileHandleChunks-dp60iZ6v.js +38 -0
- package/dist/cli-runtime/reconstructionObligationLedgerSchemas-dvp6PEnZ.js +15839 -0
- package/dist/cli-runtime/rolldown-runtime-DXoylpqc.js +121 -0
- package/dist/cli-runtime/runtimeVersion-CMGd0bDu.js +23 -0
- package/dist/cli-runtime/safeJson-DKKACtdy.js +25 -0
- package/dist/cli-runtime/scanCanonical-Bi6si9nb.js +2773 -0
- package/dist/cli-runtime/snapshotEnvironment-B5Ai0mha.js +678 -0
- package/dist/cli-runtime/streamedJsonOutput-VYlQZsM7.js +654 -0
- package/dist/cli-runtime/streamedJsonOutput.js +5 -0
- package/dist/cli-runtime/toolContracts-C7pvYKxF.js +4516 -0
- package/dist/cli-runtime/toolEffects-DW31yTSx.js +7004 -0
- package/dist/cli-runtime/workflowInputError-26EGiDpx.js +26 -0
- package/dist/cli.js +91 -0
- package/dist/cliBrowserContext.js +11 -0
- package/dist/cliBrowserScenarioCommands.js +73 -0
- package/dist/cliCommandNames.js +205 -0
- package/dist/cliEvidenceCommands.js +51 -0
- package/dist/cliJavaScriptRuntimeCommands.js +69 -0
- package/dist/cliJsonInput.js +129 -0
- package/dist/cliLogging.js +48 -0
- package/dist/cliObservationOptions.js +73 -0
- package/dist/cliOutput.js +97 -0
- package/dist/composition/adb.js +3 -0
- package/dist/composition/android.js +3 -0
- package/dist/composition/apktool.js +3 -0
- package/dist/composition/auxiliaryAnalysisProviders.js +35 -0
- package/dist/composition/binary.js +25 -0
- package/dist/composition/binaryDiagnostics.js +12 -0
- package/dist/composition/browserObservation.js +3 -0
- package/dist/composition/browserScenario.js +4 -0
- package/dist/composition/directAnalysis.js +44 -0
- package/dist/composition/electronObservation.js +3 -0
- package/dist/composition/electronScenario.js +3 -0
- package/dist/composition/evm.js +4 -0
- package/dist/composition/firmware.js +3 -0
- package/dist/composition/go.js +4 -0
- package/dist/composition/javascriptAnalysisWorkerProcess.js +48 -0
- package/dist/composition/javascriptRecovery.js +3 -0
- package/dist/composition/javascriptRuntimeObservation.js +3 -0
- package/dist/composition/jeb.js +6 -0
- package/dist/composition/optionalObservationProviders.js +54 -0
- package/dist/composition/wasm.js +4 -0
- package/dist/composition/webModules.js +5 -0
- package/dist/composition/webNetworkCaptures.js +6 -0
- package/dist/composition/webRuntime.js +4 -0
- package/dist/composition/webSourceLocations.js +5 -0
- package/dist/config/environment.js +73 -0
- package/dist/config/ghidraDisabledAnalyzers.js +25 -0
- package/dist/config/ghidraLanguageOverride.js +9 -0
- package/dist/config/homeDirectory.js +12 -0
- package/dist/config/mcpInputSchemaProfile.js +27 -0
- package/dist/config/mcpResponseBudget.js +30 -0
- package/dist/config/parseConfig.js +93 -0
- package/dist/config/parsers.js +30 -0
- package/dist/config/providerStartupTimeout.js +13 -0
- package/dist/config/types.js +1 -0
- package/dist/contracts/adb/adbToolContracts.js +353 -0
- package/dist/contracts/advertisedInputExamples.js +48 -0
- package/dist/contracts/analysisDetail.js +13 -0
- package/dist/contracts/analysisSearchContract.js +14 -0
- package/dist/contracts/analysisViewApiSurfaceExample.js +68 -0
- package/dist/contracts/analysisViewToolContracts.js +76 -0
- package/dist/contracts/android/androidToolContracts.js +77 -0
- package/dist/contracts/apktool/apktoolToolContracts.js +33 -0
- package/dist/contracts/applicationToolContracts.js +261 -0
- package/dist/contracts/artifactComparisonExample.js +86 -0
- package/dist/contracts/artifactToolContracts.js +68 -0
- package/dist/contracts/browserProviderToolContracts.js +7 -0
- package/dist/contracts/browserScenarioToolContracts.js +32 -0
- package/dist/contracts/browserToolContracts.js +256 -0
- package/dist/contracts/compactInputSchema.js +256 -0
- package/dist/contracts/enhancedInputs.js +74 -0
- package/dist/contracts/enhancedToolContracts.js +32 -0
- package/dist/contracts/errorSchemas.js +87 -0
- package/dist/contracts/evidenceInputContracts.js +13 -0
- package/dist/contracts/evm/evmToolContracts.js +20 -0
- package/dist/contracts/firmware/firmwareToolContracts.js +38 -0
- package/dist/contracts/functionComparisonExample.js +51 -0
- package/dist/contracts/functionInstructionContract.js +6 -0
- package/dist/contracts/functionWorkflowToolContracts.js +29 -0
- package/dist/contracts/go/goToolContracts.js +20 -0
- package/dist/contracts/hopperMemoryContracts.js +19 -0
- package/dist/contracts/inputSchemaPresentation.js +181 -0
- package/dist/contracts/investigationExamples.js +116 -0
- package/dist/contracts/javascript/applicationWorkflowInputContracts.js +52 -0
- package/dist/contracts/javascript/electronToolContracts.js +118 -0
- package/dist/contracts/javascript/javascriptApplicationWorkflowExamples.js +85 -0
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +248 -0
- package/dist/contracts/javascript/javascriptRecoveryToolContracts.js +35 -0
- package/dist/contracts/javascript/javascriptRuntimeObservationToolContracts.js +40 -0
- package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +242 -0
- package/dist/contracts/jeb/jebToolContracts.js +64 -0
- package/dist/contracts/managed/managedToolContracts.js +87 -0
- package/dist/contracts/managed/managedWorkflowExamples.js +281 -0
- package/dist/contracts/managed/managedWorkflowToolContracts.js +165 -0
- package/dist/contracts/mobileApplicationGraphExamples.js +117 -0
- package/dist/contracts/native/binaryDiagnosticsToolContracts.js +65 -0
- package/dist/contracts/native/nativeToolContracts.js +77 -0
- package/dist/contracts/officialToolContracts.js +69 -0
- package/dist/contracts/promptContracts.js +253 -0
- package/dist/contracts/providerSelection.js +29 -0
- package/dist/contracts/reconstructionReadinessExample.js +438 -0
- package/dist/contracts/sessionLifecycleInputs.js +63 -0
- package/dist/contracts/sessionStatusContract.js +17 -0
- package/dist/contracts/sessionToolContracts.js +61 -0
- package/dist/contracts/sessionToolSchemas.js +51 -0
- package/dist/contracts/toolContractExamples.js +77 -0
- package/dist/contracts/toolContractHelpers.js +22 -0
- package/dist/contracts/toolContractTypes.js +18 -0
- package/dist/contracts/toolContracts.js +60 -0
- package/dist/contracts/toolEffects.js +544 -0
- package/dist/contracts/toolOutputSchemaGroups.js +411 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +532 -0
- package/dist/contracts/toolSchemaMetadata.js +197 -0
- package/dist/contracts/unknownContractExamples.js +31 -0
- package/dist/contracts/wasm/wasmToolContracts.js +24 -0
- package/dist/contracts/webNetworkCaptureToolContracts.js +24 -0
- package/dist/contracts/webRuntimeToolContracts.js +43 -0
- package/dist/contracts/webScriptToolContracts.js +68 -0
- package/dist/doctorRuntime.js +53 -0
- package/dist/domain/adb/adbDeviceAnalysis.js +583 -0
- package/dist/domain/analysisErrorBase.js +58 -0
- package/dist/domain/analysisErrorCleanup.js +29 -0
- package/dist/domain/analysisErrorCore.js +123 -0
- package/dist/domain/analysisErrorPresentation.js +372 -0
- package/dist/domain/analysisErrorProjection.js +454 -0
- package/dist/domain/analysisProfile.js +50 -0
- package/dist/domain/analysisSnapshot.js +538 -0
- package/dist/domain/analysisView/WebNetworkApiSurfaceAccumulator.js +362 -0
- package/dist/domain/analysisView/analysisView.js +340 -0
- package/dist/domain/analysisView/analysisViewCoverage.js +19 -0
- package/dist/domain/analysisView/binaryLayoutView.js +161 -0
- package/dist/domain/analysisView/javascriptApplicationView.js +245 -0
- package/dist/domain/analysisView/nativeFunctionView.js +155 -0
- package/dist/domain/analysisView/webNetworkApiSurfaceView.js +108 -0
- package/dist/domain/android/androidAnalysis.js +143 -0
- package/dist/domain/android/androidApplication.js +144 -0
- package/dist/domain/android/androidPartialObservation.js +36 -0
- package/dist/domain/apktool/apktoolResourceAnalysis.js +75 -0
- package/dist/domain/apple/appleApplication.js +315 -0
- package/dist/domain/apple/appleAssetCatalog.js +127 -0
- package/dist/domain/apple/appleBundleAnatomy.js +303 -0
- package/dist/domain/apple/dyldEnvironment.js +73 -0
- package/dist/domain/apple/dyldPaths.js +89 -0
- package/dist/domain/apple/dylibResolution.js +485 -0
- package/dist/domain/apple/dylibResolutionFindings.js +77 -0
- package/dist/domain/apple/interfaceBuilderGraph.js +403 -0
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +430 -0
- package/dist/domain/apple/keyedArchive.js +214 -0
- package/dist/domain/apple/machoContainer.js +54 -0
- package/dist/domain/apple/plistNumbers.js +76 -0
- package/dist/domain/apple/plistValue.js +35 -0
- package/dist/domain/artifactComparison.js +348 -0
- package/dist/domain/artifactGraph.js +213 -0
- package/dist/domain/artifactIdentity.js +57 -0
- package/dist/domain/artifactInspection.js +279 -0
- package/dist/domain/artifactIntegrityPolicy.js +10 -0
- package/dist/domain/artifactInventoryEvidence.js +166 -0
- package/dist/domain/artifactInventorySnapshot.js +1 -0
- package/dist/domain/artifactOperationError.js +20 -0
- package/dist/domain/artifactPartialObservation.js +1 -0
- package/dist/domain/artifactPathSyntax.js +75 -0
- package/dist/domain/binaryTarget.js +233 -0
- package/dist/domain/binaryTargetTypes.js +10 -0
- package/dist/domain/bridgeCandidateProjection.js +71 -0
- package/dist/domain/browserCaptureComparison.js +21 -0
- package/dist/domain/browserCompleteness.js +103 -0
- package/dist/domain/browserNetworkEvidence.js +92 -0
- package/dist/domain/browserObservation.js +187 -0
- package/dist/domain/browserObservationError.js +44 -0
- package/dist/domain/browserObservationErrors.js +1 -0
- package/dist/domain/browserObservationSchemas.js +327 -0
- package/dist/domain/browserScenario.js +61 -0
- package/dist/domain/browserScenarioCapture.js +76 -0
- package/dist/domain/browserScenarioCaptureValues.js +292 -0
- package/dist/domain/browserScenarioDiff.js +266 -0
- package/dist/domain/browserScenarioDiffEvidence.js +73 -0
- package/dist/domain/browserScenarioDiffValues.js +140 -0
- package/dist/domain/browserScenarioNormalization.js +40 -0
- package/dist/domain/browserScenarioValues.js +268 -0
- package/dist/domain/browserSession.js +55 -0
- package/dist/domain/bundleComparison.js +243 -0
- package/dist/domain/callPath.js +301 -0
- package/dist/domain/callPathSchemas.js +89 -0
- package/dist/domain/canonicalDigest.js +83 -0
- package/dist/domain/canonicalJsonDigestSteps.js +155 -0
- package/dist/domain/canonicalOrdering.js +3 -0
- package/dist/domain/changedBehavior.js +282 -0
- package/dist/domain/compactStringIdentity.js +9 -0
- package/dist/domain/comparisonSemantics.js +12 -0
- package/dist/domain/comparisonSourceEvidence.js +40 -0
- package/dist/domain/comparisonStatus.js +11 -0
- package/dist/domain/completionLedgerGeneration.js +186 -0
- package/dist/domain/configurationErrors.js +37 -0
- package/dist/domain/conformancePackage.js +200 -0
- package/dist/domain/conformanceReplay.js +132 -0
- package/dist/domain/conformanceTrustGate.js +319 -0
- package/dist/domain/digests.js +27 -0
- package/dist/domain/dosCom.js +8 -0
- package/dist/domain/dosMz.js +83 -0
- package/dist/domain/emptyArraySchema.js +3 -0
- package/dist/domain/evidence.js +305 -0
- package/dist/domain/evidenceBundle.js +413 -0
- package/dist/domain/evidenceCompletionLedger.js +113 -0
- package/dist/domain/evidenceErrors.js +46 -0
- package/dist/domain/evidenceRecordSummary.js +144 -0
- package/dist/domain/evm/evmInterface.js +61 -0
- package/dist/domain/explicitSensitiveFailure.js +108 -0
- package/dist/domain/explicitSensitiveValues.js +10 -0
- package/dist/domain/firmware/firmwareAnalysis.js +128 -0
- package/dist/domain/functionComparison.js +38 -0
- package/dist/domain/functionComparisonDimensions.js +199 -0
- package/dist/domain/functionComparisonNormalization.js +150 -0
- package/dist/domain/functionComparisonResults.js +54 -0
- package/dist/domain/functionComparisonSchemas.js +88 -0
- package/dist/domain/functionDossierEvidence.js +20 -0
- package/dist/domain/go/goBinary.js +96 -0
- package/dist/domain/harmony/harmonyApplication.js +169 -0
- package/dist/domain/hopperErrors.js +98 -0
- package/dist/domain/hopperStartupFailure.js +64 -0
- package/dist/domain/hopperValues.js +368 -0
- package/dist/domain/immutableJson.js +114 -0
- package/dist/domain/inputIssueProjection.js +94 -0
- package/dist/domain/javascript/electronActiveObservation.js +237 -0
- package/dist/domain/javascript/electronObservation.js +122 -0
- package/dist/domain/javascript/electronStaticAnalysis.js +9 -0
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +187 -0
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +197 -0
- package/dist/domain/javascript/electronStaticAnalysisNative.js +199 -0
- package/dist/domain/javascript/electronStaticAnalysisTypes.js +1 -0
- package/dist/domain/javascript/electronStaticAnalysisValues.js +134 -0
- package/dist/domain/javascript/electronWrappedCallPaths.js +399 -0
- package/dist/domain/javascript/htmlArtifactReferences.js +40 -0
- package/dist/domain/javascript/javascriptAnalysisResourceControls.js +65 -0
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +146 -0
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +175 -0
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +400 -0
- package/dist/domain/javascript/javascriptApplicationGraph.js +378 -0
- package/dist/domain/javascript/javascriptApplicationGraphSchemas.js +126 -0
- package/dist/domain/javascript/javascriptApplicationProjectionResources.js +43 -0
- package/dist/domain/javascript/javascriptApplicationVersionComparison.js +104 -0
- package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +211 -0
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +324 -0
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +199 -0
- package/dist/domain/javascript/javascriptArtifactFiles.js +1 -0
- package/dist/domain/javascript/javascriptAstFingerprint.js +153 -0
- package/dist/domain/javascript/javascriptAstValues.js +99 -0
- package/dist/domain/javascript/javascriptBootstrap.js +94 -0
- package/dist/domain/javascript/javascriptElectronMemberWrites.js +119 -0
- package/dist/domain/javascript/javascriptExportReturnShapeProjection.js +81 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +161 -0
- package/dist/domain/javascript/javascriptExportShapeComparisonIdentity.js +16 -0
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +302 -0
- package/dist/domain/javascript/javascriptExportShapeSelection.js +130 -0
- package/dist/domain/javascript/javascriptExportShapeVariants.js +333 -0
- package/dist/domain/javascript/javascriptFeatureSeed.js +193 -0
- package/dist/domain/javascript/javascriptFeatureTrace.js +177 -0
- package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +131 -0
- package/dist/domain/javascript/javascriptFeatureTraversal.js +61 -0
- package/dist/domain/javascript/javascriptIntrinsicInvocation.js +93 -0
- package/dist/domain/javascript/javascriptModuleInterop.js +617 -0
- package/dist/domain/javascript/javascriptModuleSemanticIr.js +15 -0
- package/dist/domain/javascript/javascriptNativeHandoff.js +90 -0
- package/dist/domain/javascript/javascriptPackageImportAliases.js +58 -0
- package/dist/domain/javascript/javascriptRecovery.js +90 -0
- package/dist/domain/javascript/javascriptRpcEndpoints.js +253 -0
- package/dist/domain/javascript/javascriptRuntimeLoadState.js +98 -0
- package/dist/domain/javascript/javascriptRuntimeObservation.js +136 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliation.js +46 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationActive.js +74 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +212 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +163 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationInputValidation.js +28 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +270 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationParsing.js +39 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +126 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationRuntime.js +334 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +234 -0
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +206 -0
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +910 -0
- package/dist/domain/javascript/javascriptSemanticAsyncEffects.js +246 -0
- package/dist/domain/javascript/javascriptSemanticCallResolution.js +127 -0
- package/dist/domain/javascript/javascriptSemanticCallableResults.js +42 -0
- package/dist/domain/javascript/javascriptSemanticCalls.js +272 -0
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +224 -0
- package/dist/domain/javascript/javascriptSemanticCoverage.js +32 -0
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +182 -0
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +299 -0
- package/dist/domain/javascript/javascriptSemanticDerivedAnalysis.js +52 -0
- package/dist/domain/javascript/javascriptSemanticFileProjection.js +1 -0
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +187 -0
- package/dist/domain/javascript/javascriptSemanticGraph.js +575 -0
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +316 -0
- package/dist/domain/javascript/javascriptSemanticGraphSerialization.js +12 -0
- package/dist/domain/javascript/javascriptSemanticIr.js +31 -0
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +139 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +865 -0
- package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +190 -0
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +104 -0
- package/dist/domain/javascript/javascriptSemanticObjectReferences.js +381 -0
- package/dist/domain/javascript/javascriptSemanticObjects.js +164 -0
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +38 -0
- package/dist/domain/javascript/javascriptSemanticProjection.js +571 -0
- package/dist/domain/javascript/javascriptSemanticPromises.js +321 -0
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +100 -0
- package/dist/domain/javascript/javascriptSemanticProvenance.js +29 -0
- package/dist/domain/javascript/javascriptSemanticQuery.js +175 -0
- package/dist/domain/javascript/javascriptSemanticQueryAssessment.js +45 -0
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +63 -0
- package/dist/domain/javascript/javascriptSemanticQueryRelations.js +15 -0
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +95 -0
- package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +34 -0
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
- package/dist/domain/javascript/javascriptSemanticResources.js +129 -0
- package/dist/domain/javascript/javascriptSemanticReturnedReferences.js +219 -0
- package/dist/domain/javascript/javascriptSemanticReturns.js +159 -0
- package/dist/domain/javascript/javascriptSemanticSlots.js +72 -0
- package/dist/domain/javascript/javascriptSemanticState.js +116 -0
- package/dist/domain/javascript/javascriptSemanticTraceSchemas.js +15 -0
- package/dist/domain/javascript/javascriptSemanticTraversal.js +80 -0
- package/dist/domain/javascript/javascriptSemanticValueTypes.js +1 -0
- package/dist/domain/javascript/javascriptSemanticValues.js +581 -0
- package/dist/domain/javascript/javascriptSourceAnalysis.js +1 -0
- package/dist/domain/javascript/javascriptSourceMapPaths.js +114 -0
- package/dist/domain/javascript/javascriptSourceParser.js +50 -0
- package/dist/domain/javascript/javascriptSourceSelection.js +11 -0
- package/dist/domain/javascript/javascriptStaticAnalysis.js +142 -0
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +239 -0
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +271 -0
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +86 -0
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +561 -0
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +21 -0
- package/dist/domain/javascript/javascriptStaticAnalysisTypes.js +2 -0
- package/dist/domain/javascript/javascriptSymbolicBindings.js +795 -0
- package/dist/domain/javascript/javascriptSymbolicControlFlow.js +40 -0
- package/dist/domain/javascript/javascriptSymbolicValues.js +34 -0
- package/dist/domain/javascript/sourceToBundleComparison.js +261 -0
- package/dist/domain/javascript/sourceToBundleComparisonSchemas.js +109 -0
- package/dist/domain/javascript/sourceToBundleSignals.js +231 -0
- package/dist/domain/jeb/jebAnalysis.js +114 -0
- package/dist/domain/jsonSerialization.js +163 -0
- package/dist/domain/jsonShape.js +141 -0
- package/dist/domain/jsonValue.js +96 -0
- package/dist/domain/localPath.js +24 -0
- package/dist/domain/managed/managedApplicationGraph.js +221 -0
- package/dist/domain/managed/managedApplicationGraphCoverage.js +48 -0
- package/dist/domain/managed/managedApplicationGraphNodes.js +367 -0
- package/dist/domain/managed/managedArtifact.js +465 -0
- package/dist/domain/managed/managedInspectionEvidence.js +28 -0
- package/dist/domain/managed/managedMemberComparison.js +211 -0
- package/dist/domain/managed/managedMemberComparisonCoverage.js +71 -0
- package/dist/domain/managed/managedMemberComparisonItems.js +304 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +204 -0
- package/dist/domain/managed/managedNativeVerification.js +35 -0
- package/dist/domain/managed/managedNativeVerificationMatch.js +276 -0
- package/dist/domain/managed/managedNativeVerificationSchemas.js +180 -0
- package/dist/domain/managed/managedReconstruction.js +190 -0
- package/dist/domain/mobileApplicationGraphProjection.js +61 -0
- package/dist/domain/native/binaryLayout.js +354 -0
- package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
- package/dist/domain/native/nativeAotPe.js +1408 -0
- package/dist/domain/native/nativeApiBoundary.js +140 -0
- package/dist/domain/native/nativeCallObservation.js +186 -0
- package/dist/domain/native/nativeCallPartialObservation.js +33 -0
- package/dist/domain/native/nativeDataType.js +53 -0
- package/dist/domain/native/nativeFunctionAnnotations.js +43 -0
- package/dist/domain/native/nativeInspection.js +174 -0
- package/dist/domain/native/nativeInstruction.js +125 -0
- package/dist/domain/native/nativeInvestigationGraph.js +364 -0
- package/dist/domain/native/nativeLoadImage.js +112 -0
- package/dist/domain/native/nativeMetadataRecovery.js +128 -0
- package/dist/domain/native/nativeUiObservation.js +137 -0
- package/dist/domain/native/nativeValueFlow.js +72 -0
- package/dist/domain/native/nativeValueTrace.js +64 -0
- package/dist/domain/native/objcSwiftMetadata.js +419 -0
- package/dist/domain/native/peResources.js +100 -0
- package/dist/domain/native/recordedCrash.js +263 -0
- package/dist/domain/native/recordedCrashNoteCoverage.js +73 -0
- package/dist/domain/nativeConvention.js +33 -0
- package/dist/domain/offsetDateTime.js +17 -0
- package/dist/domain/peMachine.js +36 -0
- package/dist/domain/process/processCapture.js +412 -0
- package/dist/domain/process/processCaptureCoverage.js +70 -0
- package/dist/domain/process/processCaptureExample.js +132 -0
- package/dist/domain/process/processCaptureParsing.js +21 -0
- package/dist/domain/process/processCaptureValidation.js +246 -0
- package/dist/domain/process/processComparison.js +315 -0
- package/dist/domain/process/processEvidenceProvider.js +11 -0
- package/dist/domain/process/processObservation.js +140 -0
- package/dist/domain/process/processScenario.js +247 -0
- package/dist/domain/process/processTraceComparison.js +34 -0
- package/dist/domain/process/processTraceDimensionProjection.js +35 -0
- package/dist/domain/process/processTraceEvaluation.js +320 -0
- package/dist/domain/process/processTraceSpecification.js +382 -0
- package/dist/domain/propertyListKeys.js +107 -0
- package/dist/domain/propertyListXmlText.js +19 -0
- package/dist/domain/providerAdapterError.js +19 -0
- package/dist/domain/providerCleanupError.js +18 -0
- package/dist/domain/providerConfigurationRefusal.js +12 -0
- package/dist/domain/providerOperationHealth.js +54 -0
- package/dist/domain/providerSelectionError.js +46 -0
- package/dist/domain/rawBinary.js +93 -0
- package/dist/domain/reconstructionCoverage.js +325 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +234 -0
- package/dist/domain/reconstructionCoverageInput.js +7 -0
- package/dist/domain/reconstructionObligationLedgerIntegrity.js +114 -0
- package/dist/domain/reconstructionObligationLedgerSchemas.js +347 -0
- package/dist/domain/reconstructionReadiness.js +116 -0
- package/dist/domain/reconstructionReadinessFindingHelpers.js +17 -0
- package/dist/domain/reconstructionReadinessIntegrityFindings.js +118 -0
- package/dist/domain/reconstructionReadinessJourneyFindings.js +193 -0
- package/dist/domain/reconstructionReadinessSchemas.js +268 -0
- package/dist/domain/reconstructionUnknowns.js +91 -0
- package/dist/domain/reconstructionVerification.js +218 -0
- package/dist/domain/reconstructionVerificationSchemas.js +141 -0
- package/dist/domain/recordedTransportUrl.js +51 -0
- package/dist/domain/referenceSourceClassification.js +385 -0
- package/dist/domain/referenceSourceGraph.js +380 -0
- package/dist/domain/referenceSourceImportParsing.js +238 -0
- package/dist/domain/referenceSourcePathIdentity.js +22 -0
- package/dist/domain/referenceSourcePolicy.js +1 -0
- package/dist/domain/referenceSourceRequireBindings.js +137 -0
- package/dist/domain/relationshipCoverage.js +20 -0
- package/dist/domain/residualUnknown.js +252 -0
- package/dist/domain/result.js +4 -0
- package/dist/domain/runtimeVersion.js +15 -0
- package/dist/domain/safeJson.js +13 -0
- package/dist/domain/sourceMapContents.js +6 -0
- package/dist/domain/sourceMapEnvelope.js +44 -0
- package/dist/domain/staticRuntimeCorrelation.js +334 -0
- package/dist/domain/stringPatterns.js +6 -0
- package/dist/domain/swiftSymbolClassification.js +66 -0
- package/dist/domain/symbolAnalysis.js +122 -0
- package/dist/domain/unicodeCodePointOrder.js +23 -0
- package/dist/domain/unknownRegistryError.js +10 -0
- package/dist/domain/wasm/wasmArtifact.js +105 -0
- package/dist/domain/webBundleAnalysis.js +192 -0
- package/dist/domain/webBundleAnalyzer.js +15 -0
- package/dist/domain/webBundleAnalyzerAst.js +49 -0
- package/dist/domain/webBundleAnalyzerInspection.js +315 -0
- package/dist/domain/webBundleAnalyzerResult.js +142 -0
- package/dist/domain/webCaptureDiff.js +423 -0
- package/dist/domain/webCaptureDiffSchemas.js +84 -0
- package/dist/domain/webContentArtifact.js +38 -0
- package/dist/domain/webEventListeners.js +29 -0
- package/dist/domain/webExecution.js +75 -0
- package/dist/domain/webInventory.js +62 -0
- package/dist/domain/webMcpDiscovery.js +53 -0
- package/dist/domain/webModuleImports.js +99 -0
- package/dist/domain/webModuleTrace.js +101 -0
- package/dist/domain/webNetworkCapture.js +142 -0
- package/dist/domain/webNetworkCaptureCoordinates.js +58 -0
- package/dist/domain/webRuntime.js +80 -0
- package/dist/domain/webScreenshot.js +132 -0
- package/dist/domain/webScriptArtifacts.js +37 -0
- package/dist/domain/webScriptExport.js +84 -0
- package/dist/domain/webScriptExportError.js +19 -0
- package/dist/domain/webScriptExportPlan.js +104 -0
- package/dist/domain/webSourceLocation.js +118 -0
- package/dist/domain/webSourcePosition.js +21 -0
- package/dist/domain/zipPackageFormat.js +52 -0
- package/dist/domain/zodCollectionSteps.js +24 -0
- package/dist/dotnet/ManagedArtifactInspector.js +308 -0
- package/dist/dotnet/ManagedDecodeBudget.js +138 -0
- package/dist/dotnet/ManagedExceptionRegionValidation.js +41 -0
- package/dist/dotnet/ManagedMemberInspector.js +173 -0
- package/dist/dotnet/ManagedMemberInspectorCore.js +446 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +468 -0
- package/dist/dotnet/ManagedMemberOwnership.js +71 -0
- package/dist/dotnet/ManagedMemberPointers.js +62 -0
- package/dist/dotnet/ManagedMemberRows.js +227 -0
- package/dist/dotnet/ManagedMetadataHeaps.js +179 -0
- package/dist/dotnet/ManagedMetadataInventory.js +99 -0
- package/dist/dotnet/ManagedMetadataInventoryRows.js +295 -0
- package/dist/dotnet/ManagedMetadataLayout.js +270 -0
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +155 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +314 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +128 -0
- package/dist/dotnet/ManagedPeReader.js +233 -0
- package/dist/dotnet/ManagedReaderFailure.js +27 -0
- package/dist/dotnet/ManagedSnapshot.js +88 -0
- package/dist/dotnet/ManagedStaticProvider.js +158 -0
- package/dist/dotnet/ManagedStaticProviderMetadata.js +33 -0
- package/dist/evaluation/AgentEvaluationFixtures.js +250 -0
- package/dist/evaluation/AgentEvaluationReport.js +32 -0
- package/dist/evaluation/CodexAgentEval.js +188 -0
- package/dist/evaluation/KnownAnswerEvaluation.js +323 -0
- package/dist/evm/EvmBytecodeCarrier.js +21 -0
- package/dist/evm/EvmWorkerLimits.js +40 -0
- package/dist/evm/EvmoleFailures.js +124 -0
- package/dist/evm/EvmoleInterfaceAdapter.js +53 -0
- package/dist/evm/EvmoleInterfaceProvider.js +339 -0
- package/dist/evm/EvmoleInterfaceWorker.js +87 -0
- package/dist/evm/EvmoleRelease.js +16 -0
- package/dist/filesystem/OwnedDirectoryHandle.js +29 -0
- package/dist/filesystem/OwnedFileHandle.js +36 -0
- package/dist/filesystem/OwnedStagedOutput.js +138 -0
- package/dist/filesystem/RegularFile.js +73 -0
- package/dist/filesystem/StableFileHash.js +46 -0
- package/dist/filesystem/readFileHandleChunks.js +35 -0
- package/dist/firmware/FirmwareCommand.js +190 -0
- package/dist/firmware/FirmwareFiles.js +206 -0
- package/dist/firmware/FirmwareProvider.js +388 -0
- package/dist/firmware/FirmwarePublication.js +105 -0
- package/dist/firmware/FirmwareRelease.js +33 -0
- package/dist/firmware/FirmwareReports.js +287 -0
- package/dist/firmware/FirmwareVersion.js +80 -0
- package/dist/generatedPackageMetadata.js +9 -0
- package/dist/ghidra/GhidraAnalysisProfile.js +219 -0
- package/dist/ghidra/GhidraAnalysisSeeds.js +211 -0
- package/dist/ghidra/GhidraClient.js +725 -0
- package/dist/ghidra/GhidraClientStartup.js +27 -0
- package/dist/ghidra/GhidraClientTypes.js +1 -0
- package/dist/ghidra/GhidraClientWire.js +38 -0
- package/dist/ghidra/GhidraDiagnostics.js +53 -0
- package/dist/ghidra/GhidraDoctor.js +88 -0
- package/dist/ghidra/GhidraFunctionValues.js +328 -0
- package/dist/ghidra/GhidraInstallation.js +443 -0
- package/dist/ghidra/GhidraInstallationPolicy.js +140 -0
- package/dist/ghidra/GhidraInventoryValues.js +262 -0
- package/dist/ghidra/GhidraJavaLaunch.js +66 -0
- package/dist/ghidra/GhidraLanguageCatalog.js +99 -0
- package/dist/ghidra/GhidraLauncher.js +490 -0
- package/dist/ghidra/GhidraLoadImageAttest.js +103 -0
- package/dist/ghidra/GhidraLoadImageValues.js +260 -0
- package/dist/ghidra/GhidraMipsProfile.js +187 -0
- package/dist/ghidra/GhidraProvider.js +250 -0
- package/dist/ghidra/GhidraProviderCapabilities.js +208 -0
- package/dist/ghidra/GhidraProviderClient.js +613 -0
- package/dist/ghidra/GhidraPspExtension.js +144 -0
- package/dist/ghidra/GhidraPspProfile.js +50 -0
- package/dist/ghidra/GhidraRawBinaryLanguage.js +18 -0
- package/dist/ghidra/GhidraRequestQueue.js +115 -0
- package/dist/ghidra/GhidraResponseBuffer.js +31 -0
- package/dist/ghidra/GhidraResponseRouter.js +24 -0
- package/dist/ghidra/GhidraSessionError.js +180 -0
- package/dist/ghidra/GhidraSessionRoot.js +39 -0
- package/dist/ghidra/GhidraSessionValues.js +86 -0
- package/dist/ghidra/GhidraSocketConnection.js +83 -0
- package/dist/ghidra/GhidraTargetSnapshot.js +79 -0
- package/dist/ghidra/GhidraTransport.js +101 -0
- package/dist/ghidra/extensions/GhidraExtensionFailures.js +20 -0
- package/dist/ghidra/extensions/GhidraExtensions.js +177 -0
- package/dist/ghidra/extensions/nativeaot/NativeAotAdapter.js +27 -0
- package/dist/ghidra/extensions/nativeaot/NativeAotReport.js +100 -0
- package/dist/ghidra/protocol.js +46 -0
- package/dist/go/GoBinaryContainer.js +125 -0
- package/dist/go/GoBinaryImage.js +172 -0
- package/dist/go/GoBinaryProvider.js +137 -0
- package/dist/go/GoElfImage.js +149 -0
- package/dist/go/GoMachoImage.js +113 -0
- package/dist/go/GoModuleText.js +217 -0
- package/dist/go/GoPeImage.js +102 -0
- package/dist/hopper/BridgeLauncher.js +305 -0
- package/dist/hopper/HopperAnalysisProfile.js +168 -0
- package/dist/hopper/HopperCleanup.js +245 -0
- package/dist/hopper/HopperClient.js +767 -0
- package/dist/hopper/HopperDiagnostics.js +14 -0
- package/dist/hopper/HopperFileOffset.js +237 -0
- package/dist/hopper/HopperMachOImage.js +200 -0
- package/dist/hopper/HopperOperationStage.js +6 -0
- package/dist/hopper/HopperProcessDiagnostic.js +26 -0
- package/dist/hopper/HopperProvider.js +269 -0
- package/dist/hopper/HopperProviderCapabilities.js +91 -0
- package/dist/hopper/HopperRegexSearch.js +134 -0
- package/dist/hopper/HopperRegexWorker.js +27 -0
- package/dist/hopper/HopperRequestQueue.js +261 -0
- package/dist/hopper/HopperResponseStream.js +44 -0
- package/dist/hopper/HopperSessionValues.js +30 -0
- package/dist/hopper/HopperSocketConnection.js +31 -0
- package/dist/hopper/HopperTargetLease.js +233 -0
- package/dist/hopper/LinuxPrivateDisplayDiagnostic.js +64 -0
- package/dist/hopper/LinuxPrivateDisplayProbe.js +224 -0
- package/dist/hopper/protocol.js +88 -0
- package/dist/ida/IdaBusyHealth.js +44 -0
- package/dist/ida/IdaCallGraph.js +134 -0
- package/dist/ida/IdaConfiguration.js +61 -0
- package/dist/ida/IdaDoctor.js +53 -0
- package/dist/ida/IdaInput.js +56 -0
- package/dist/ida/IdaMcpConnection.js +115 -0
- package/dist/ida/IdaOperationRunner.js +376 -0
- package/dist/ida/IdaProtocolValues.js +208 -0
- package/dist/ida/IdaProvider.js +136 -0
- package/dist/ida/IdaProviderCapabilities.js +64 -0
- package/dist/ida/IdaSessionClient.js +444 -0
- package/dist/ida/IdaWorkspace.js +55 -0
- package/dist/identity.js +25 -0
- package/dist/inspector/JavaScriptRuntimeScope.js +89 -0
- package/dist/inspector/V8InspectorCaptureProjection.js +197 -0
- package/dist/inspector/V8InspectorEndpoint.js +70 -0
- package/dist/inspector/V8InspectorProvider.js +378 -0
- package/dist/inspector/providerIdentity.js +6 -0
- package/dist/javascript/analysis/JavaScriptAnalysisTransfer.js +337 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorker.js +574 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerProtocol.js +64 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerSchemas.js +558 -0
- package/dist/javascript/analysis/JavaScriptAnalysisWorkerServer.js +121 -0
- package/dist/javascript/recovery/RecoveryFiles.js +175 -0
- package/dist/javascript/recovery/WakaruCommand.js +137 -0
- package/dist/javascript/recovery/WakaruExecution.js +115 -0
- package/dist/javascript/recovery/WakaruProvider.js +218 -0
- package/dist/javascript/recovery/WakaruPublication.js +126 -0
- package/dist/javascript/recovery/WakaruRelease.js +36 -0
- package/dist/javascript/recovery/WakaruReport.js +140 -0
- package/dist/javascript/recovery/WakaruVersion.js +24 -0
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
- package/dist/javascript/sourceMaps/SourceMapCodecProcess.js +37 -0
- package/dist/javascript/sourceMaps/SourceMapCodecProtocol.js +20 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +223 -0
- package/dist/javascript/sourceMaps/SourceMapDecoder.js +135 -0
- package/dist/javascript/sourceMaps/SourceMapFormat.js +238 -0
- package/dist/javascript/sourceMaps/TraceSourceMap.js +152 -0
- package/dist/jeb/JebMcpConnection.js +186 -0
- package/dist/jeb/JebMcpEndpoint.js +40 -0
- package/dist/jeb/JebProvider.js +297 -0
- package/dist/logger.js +14 -0
- package/dist/main/messages.js +4 -0
- package/dist/main/shutdown.js +102 -0
- package/dist/main/startup.js +21 -0
- package/dist/main/transport.js +72 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +92 -0
- package/dist/mcp/AnalysisSnapshotFiles-DbgHi36O.js +1225 -0
- package/dist/mcp/ArtifactProvider-BNxKlaKX.js +2090 -0
- package/dist/mcp/ArtifactProviderMetadata--hy-wyJK.js +76 -0
- package/dist/mcp/ArtifactReader-OyM03Gjn.js +55 -0
- package/dist/mcp/ArtifactResourceScope-CBR5q4aK.js +108 -0
- package/dist/mcp/AsarHeader-WsPgoooH.js +31 -0
- package/dist/mcp/BinaryTargetResolver-DbiUzRLh.js +1073 -0
- package/dist/mcp/BoundedFileBytes-CJPW_TzE.js +68 -0
- package/dist/mcp/CdpConnection-CM0tkVfW.js +557 -0
- package/dist/mcp/CdpOptionalCommand-H8_fL7Q_.js +120 -0
- package/dist/mcp/CdpTargetSession-OYD1d6XM.js +647 -0
- package/dist/mcp/DirectAnalysis-BWAu8Ro5.js +395 -0
- package/dist/mcp/DirectAnalysisStatus-DofNPhKd.js +33 -0
- package/dist/mcp/ElectronFileScope-DEayib6K.js +110 -0
- package/dist/mcp/InterfaceBuilderDecodeBudget-CUrOtfNo.js +401 -0
- package/dist/mcp/ManagedStaticProvider-CXE93Bow.js +4460 -0
- package/dist/mcp/NativeMacOSProvider-BbITFLHW.js +4408 -0
- package/dist/mcp/NativeMacOSProviderMetadata-mxDhaNJf.js +281 -0
- package/dist/mcp/ProcedureAddressResolution-Gnjf9Hya.js +19 -0
- package/dist/mcp/ProcessOwnership-nOFZsmD3.js +1411 -0
- package/dist/mcp/WorkflowEvidence-DJyEy3K0.js +94 -0
- package/dist/mcp/analysisErrorCore-BqyeMw3_.js +201 -0
- package/dist/mcp/analysisErrorProjection-B7pHef2y.js +724 -0
- package/dist/mcp/artifactOperationError-B_jxO8at.js +27 -0
- package/dist/mcp/artifactToolContracts-TXegBBr1.js +159 -0
- package/dist/mcp/browserObservation-BCgaDRyQ.js +4398 -0
- package/dist/mcp/browserObservationError-BKBEX85K.js +40 -0
- package/dist/mcp/browserObservationSchemas-yzRJ90-E.js +573 -0
- package/dist/mcp/browserScenario-z7jveI9P.js +2319 -0
- package/dist/mcp/browserScenarioCapture-BvnKTmtZ.js +460 -0
- package/dist/mcp/canonicalDigest-Bi_0_zGi.js +71 -0
- package/dist/mcp/digests-Dugt3H71.js +199 -0
- package/dist/mcp/electronActiveObservation-lDvQTMR0.js +226 -0
- package/dist/mcp/electronObservation-DjQQYGw4.js +556 -0
- package/dist/mcp/electronObservation-DuhMHCmQ.js +112 -0
- package/dist/mcp/electronScenario-9mLG6h-g.js +586 -0
- package/dist/mcp/emptyArraySchema-DEEefG2V.js +140 -0
- package/dist/mcp/enhancedInputs-CLdEXv88.js +56 -0
- package/dist/mcp/interfaceBuilderGraph-BOKqQzjK.js +2613 -0
- package/dist/mcp/javascriptRuntimeObservation-C_wglsz_.js +661 -0
- package/dist/mcp/javascriptRuntimeObservation-CxQ1UT_y.js +121 -0
- package/dist/mcp/lipo-Do-2eBrl.js +465 -0
- package/dist/mcp/localPath-AxvW9aPe.js +19 -0
- package/dist/mcp/logger-CZ4Hlc6u.js +34 -0
- package/dist/mcp/machoContainer-9En6pSkd.js +813 -0
- package/dist/mcp/main-WQSCuTNt.js +52791 -0
- package/dist/mcp/main.js +6 -0
- package/dist/mcp/managedToolContracts-o5LHFwHc.js +81 -0
- package/dist/mcp/plistValue-DsU7z4yF.js +47 -0
- package/dist/mcp/propertyListKeys-cX-BUv2y.js +197 -0
- package/dist/mcp/providerAdapterError-CdPaQ6-Z.js +27 -0
- package/dist/mcp/providerCleanupError-DvE79aUX.js +49 -0
- package/dist/mcp/providerIdentities--ptAh481.js +31 -0
- package/dist/mcp/providerIdentity-BCQ5n5tw.js +16 -0
- package/dist/mcp/providerOperationHealth-CUeCJZiP.js +212 -0
- package/dist/mcp/rolldown-runtime-BjeaiXFo.js +121 -0
- package/dist/mcp/safeJson-NeGfpkrI.js +25 -0
- package/dist/mcp/scanCanonical-2GN0h-BE.js +3647 -0
- package/dist/mcp/serverIdentity-rOY69sxc.js +633 -0
- package/dist/mcp/sourceMapEnvelope-D8Zezqyi.js +252 -0
- package/dist/mcp/toolContracts-CrfYDTUz.js +14561 -0
- package/dist/mcp/toolOutputSchemaGroups-ChxVLGoy.js +11114 -0
- package/dist/mcp/unicodeCodePointOrder-BezCbTpg.js +26 -0
- package/dist/mcp/webContentArtifact-DUBgMzVO.js +185 -0
- package/dist/mcp/webRuntime-C2Tx-fgS.js +74 -0
- package/dist/mcp/webSourceLocation-Dnkpf0R2.js +8532 -0
- package/dist/mcpDoctor.js +360 -0
- package/dist/mcpStartupPolicy.js +14 -0
- package/dist/native/AppleDispatchCoverage.js +112 -0
- package/dist/native/AppleDispatchDecodeFacts.js +6 -0
- package/dist/native/AppleDispatchMetadata.js +176 -0
- package/dist/native/AppleMachoFixups.js +372 -0
- package/dist/native/AppleMachoSelection.js +234 -0
- package/dist/native/AppleObjcCategories.js +63 -0
- package/dist/native/AppleObjcDispatchFacets.js +260 -0
- package/dist/native/AppleObjcProperties.js +79 -0
- package/dist/native/AppleObjcProtocols.js +89 -0
- package/dist/native/AppleSwiftDispatchFacets.js +156 -0
- package/dist/native/AppleSwiftVtables.js +92 -0
- package/dist/native/CommandRunner.js +240 -0
- package/dist/native/LldbCallTracer.js +713 -0
- package/dist/native/LldbRetainedObservations.js +178 -0
- package/dist/native/NativeCallObservation.js +195 -0
- package/dist/native/NativeMacOSProvider.js +701 -0
- package/dist/native/NativeMacOSProviderMetadata.js +46 -0
- package/dist/native/NativeMachoInspection.js +273 -0
- package/dist/native/NativeUiHelperRuntime.js +66 -0
- package/dist/native/NativeUiObservation.js +183 -0
- package/dist/native/NativeUiOutputBudget.js +8 -0
- package/dist/native/SignatureTargetBinding.js +155 -0
- package/dist/native/parsers/codesign.js +93 -0
- package/dist/native/parsers/demangle.js +30 -0
- package/dist/native/parsers/dyldInfo.js +60 -0
- package/dist/native/parsers/echoedPath.js +14 -0
- package/dist/native/parsers/lipo.js +177 -0
- package/dist/native/parsers/machoUuid.js +150 -0
- package/dist/native/parsers/otool.js +379 -0
- package/dist/native/parsers/plist.js +187 -0
- package/dist/native/pe/PeResourceLayout.js +120 -0
- package/dist/native/pe/PeResourceParser.js +286 -0
- package/dist/native/pe/PeResourcesProvider.js +63 -0
- package/dist/native/pwndbg/PwndbgCoreContext.js +180 -0
- package/dist/native/pwntools/PwntoolsDecoder.js +206 -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/BoundedFileBytes.js +40 -0
- package/dist/process/DarwinProcessRunTokenReader.js +376 -0
- package/dist/process/ExecFileOutput.js +124 -0
- package/dist/process/JavaScriptWorkerMemoryLimit.js +25 -0
- package/dist/process/OwnedCommand.js +131 -0
- package/dist/process/PendingOperations.js +61 -0
- package/dist/process/PrivateRuntimeRoot.js +61 -0
- package/dist/process/ProcessCommandIdentity.js +19 -0
- package/dist/process/ProcessOwnership.js +636 -0
- package/dist/process/ProcessOwnershipIdentity.js +13 -0
- package/dist/process/ProcessOwnershipObservation.js +407 -0
- package/dist/process/ProcessOwnershipProcessTree.js +35 -0
- package/dist/process/ProcessRunTokenObservations.js +48 -0
- package/dist/process/ProviderDeadline.js +91 -0
- package/dist/process/ProviderDiagnosticRedaction.js +17 -0
- package/dist/process/ProviderProcess.js +381 -0
- package/dist/process/ProviderRunLineage.js +21 -0
- package/dist/process/WindowsAuthority.js +51 -0
- package/dist/process/WindowsBatchCommand.js +46 -0
- package/dist/process/boundedUtf8Text.js +13 -0
- package/dist/process/capture/FilesystemSnapshot.js +268 -0
- package/dist/process/capture/ProcessCaptureCapability.js +65 -0
- package/dist/process/capture/ProcessCaptureEnvironment.js +9 -0
- package/dist/process/capture/ProcessCaptureError.js +74 -0
- package/dist/process/capture/ProcessCaptureJournal.js +61 -0
- package/dist/process/capture/ProcessCaptureLifecycle.js +1050 -0
- package/dist/process/capture/ProcessCaptureProgress.js +62 -0
- package/dist/process/capture/ProcessFilesystemEffects.js +81 -0
- package/dist/process/capture/ProcessHarness.js +602 -0
- package/dist/process/capture/ProcessNormalization.js +88 -0
- package/dist/process/capture/ProcessSampling.js +415 -0
- package/dist/process/capture/ProcessScenarioRuntimeValidation.js +79 -0
- package/dist/process/capture/ProcessTimer.js +39 -0
- package/dist/process/capture/TerminalRenderer.js +124 -0
- package/dist/process/snapshotEnvironment.js +14 -0
- package/dist/reference/ReferenceSourceReader.js +73 -0
- package/dist/reference/ReferenceSourceReaderEntries.js +273 -0
- package/dist/reference/ReferenceSourceReaderErrors.js +54 -0
- package/dist/reference/ReferenceSourceReaderFile.js +147 -0
- package/dist/reference/ReferenceSourceReaderPaths.js +8 -0
- package/dist/reference/ReferenceSourceReaderTypes.js +1 -0
- package/dist/reference/ReferenceSourceReaderValidate.js +81 -0
- package/dist/server/EvidenceMcpServer.js +216 -0
- package/dist/server/admittedToolOperation.js +9 -0
- package/dist/server/analysisAdmission.js +8 -0
- package/dist/server/contractToolHandler.js +21 -0
- package/dist/server/createServer.js +344 -0
- package/dist/server/lifecycleProgress.js +10 -0
- package/dist/server/mcpClientMetadata.js +42 -0
- package/dist/server/mcpProgress.js +26 -0
- package/dist/server/promptCompletion.js +141 -0
- package/dist/server/recordDerivedEvidence.js +10 -0
- package/dist/server/registerAdbTools.js +36 -0
- package/dist/server/registerAnalysisViewTool.js +10 -0
- package/dist/server/registerAndroidTools.js +31 -0
- package/dist/server/registerApktoolTools.js +14 -0
- package/dist/server/registerApplicationTools/compareExportShapes.js +29 -0
- package/dist/server/registerApplicationTools/compareSourceToBundle.js +29 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/coverage.js +13 -0
- package/dist/server/registerApplicationTools/helpers.js +37 -0
- package/dist/server/registerApplicationTools/obligationLedger.js +23 -0
- package/dist/server/registerApplicationTools/projectMobileApplicationGraph.js +50 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/traceSemantics.js +25 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +19 -0
- package/dist/server/registerArtifactComparisonTool.js +71 -0
- package/dist/server/registerArtifactTools.js +14 -0
- package/dist/server/registerBinaryDiagnosticsTools.js +26 -0
- package/dist/server/registerBrowserScenarioTool.js +26 -0
- package/dist/server/registerBrowserTools.js +58 -0
- package/dist/server/registerBundleComparisonTool.js +54 -0
- package/dist/server/registerCloseLifecycleTool.js +55 -0
- package/dist/server/registerElectronTools.js +70 -0
- package/dist/server/registerEnhancedTools.js +169 -0
- package/dist/server/registerEvidenceTools.js +68 -0
- package/dist/server/registerEvmTools.js +9 -0
- package/dist/server/registerFirmwareTools.js +11 -0
- package/dist/server/registerFunctionComparisonTool.js +86 -0
- package/dist/server/registerGoTools.js +9 -0
- package/dist/server/registerInvestigationTools/helpers.js +46 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +168 -0
- package/dist/server/registerJavaScriptRecoveryTool.js +9 -0
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +27 -0
- package/dist/server/registerJebTools.js +16 -0
- package/dist/server/registerManagedTools.js +40 -0
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +53 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +7 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +27 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +27 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +41 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +62 -0
- package/dist/server/registerManagedWorkflowTools.js +11 -0
- package/dist/server/registerOfficialTools.js +74 -0
- package/dist/server/registerPeResourcesTool.js +9 -0
- package/dist/server/registerProcessComparisonTool.js +156 -0
- package/dist/server/registerPrompts.js +73 -0
- package/dist/server/registerRecordedCrashTools.js +9 -0
- package/dist/server/registerSessionRecordTools.js +90 -0
- package/dist/server/registerSessionStatusTool.js +61 -0
- package/dist/server/registerSessionTools.js +217 -0
- package/dist/server/registerWasmTools.js +9 -0
- package/dist/server/registerWebModuleTool.js +9 -0
- package/dist/server/registerWebNetworkCaptureTool.js +20 -0
- package/dist/server/registerWebRuntimeTools.js +27 -0
- package/dist/server/registerWebScriptTool.js +18 -0
- package/dist/server/registerWebSourceLocationTool.js +9 -0
- package/dist/server/runDerivedOperation.js +55 -0
- package/dist/server/sessionAvailabilityPolicy.js +29 -0
- package/dist/server/sessionEvidence.js +11 -0
- package/dist/server/toolLogging.js +11 -0
- package/dist/server/toolRegistrationOptions.js +9 -0
- package/dist/server/toolResult.js +119 -0
- package/dist/server/toolResultEncoding.js +34 -0
- package/dist/serverIdentity.js +69 -0
- package/dist/wasm/WabtArtifactProvider.js +313 -0
- package/dist/wasm/WabtFailures.js +62 -0
- package/dist/wasm/WabtOutput.js +60 -0
- package/dist/wasm/WabtRelease.js +12 -0
- package/dist/wasm/WabtWat.js +184 -0
- package/dist/wasm/WasmGlueAdapter.js +51 -0
- package/dist/windows/WindowsNativeLoader.js +124 -0
- package/dist/windows/WindowsOwnedProcess.js +265 -0
- package/dist/windows/WindowsPrivateRuntime.js +143 -0
- package/hooks/hooks.json +17 -0
- package/install.sh +172 -0
- package/licenses/Apache-2.0.txt +202 -0
- package/licenses/GCC-Runtime-Library-Exception-3.1.txt +73 -0
- package/licenses/GPL-3.0.txt +674 -0
- package/licenses/MIT-template.txt +18 -0
- package/licenses/MinGW-w64-runtime.txt +240 -0
- package/licenses/Node-22.19.0-LICENSE.txt +2666 -0
- package/licenses/README.md +54 -0
- package/licenses/cfworker-MIT.txt +21 -0
- package/licenses/digfox-MIT.txt +21 -0
- package/licenses/dotnet-runtime-MIT.txt +23 -0
- package/licenses/ghidra-12.1.4-DISCLAIMER.txt +13 -0
- package/licenses/ghidra-12.1.4-LICENSE.txt +201 -0
- package/licenses/ghidra-12.1.4-NOTICE.txt +49 -0
- package/licenses/nativeaot-parser-MIT.txt +28 -0
- package/licenses/npm-dependencies.txt +2812 -0
- package/licenses/npm-runtime-notices.txt +6632 -0
- package/licenses/rea-jev-MIT.txt +21 -0
- package/licenses/rea-lab-MIT.txt +21 -0
- package/licenses/upstream-sources.json +62 -0
- package/licenses/xterm-MIT.txt +21 -0
- package/native/windows/README.md +156 -0
- package/native/windows/build/manifest.json +9 -0
- package/native/windows/build/rea-windows-x64.node +0 -0
- package/package.json +371 -4
- package/port/cli.mjs +210 -0
- package/port/hooks/guard.mjs +140 -0
- package/port/knowledge/engines.json +67 -0
- package/port/knowledge/footprints.json +189 -0
- package/port/knowledge/maps/godot-godot-csharp.json +38 -0
- package/port/knowledge/maps/godot-threejs.json +42 -0
- package/port/knowledge/maps/godot-unity.json +62 -0
- package/port/knowledge/maps/godot-unreal.json +48 -0
- package/port/knowledge/maps/unity-godot.json +52 -0
- package/port/knowledge/maps/unity-unreal.json +33 -0
- package/port/knowledge/systems.json +1554 -0
- package/port/mcp.mjs +62 -0
- package/port/plugin/mcp-launch.mjs +19 -0
- package/port/server.mjs +129 -0
- package/port/src/agent.mjs +257 -0
- package/port/src/archive.mjs +324 -0
- package/port/src/binary.mjs +606 -0
- package/port/src/blueprint.mjs +225 -0
- package/port/src/compare.mjs +165 -0
- package/port/src/connect.mjs +58 -0
- package/port/src/convert.mjs +134 -0
- package/port/src/formats.mjs +229 -0
- package/port/src/graph.mjs +275 -0
- package/port/src/knowledge.mjs +90 -0
- package/port/src/lookup.mjs +615 -0
- package/port/src/main-module.mjs +10 -0
- package/port/src/plan.mjs +606 -0
- package/port/src/porters.mjs +360 -0
- package/port/src/proofcase.mjs +343 -0
- package/port/src/relay.mjs +493 -0
- package/port/src/scan.mjs +189 -0
- package/port/src/scene.mjs +338 -0
- package/port/src/stashpad.mjs +114 -0
- package/port/src/symbols.mjs +201 -0
- package/port/src/tools.mjs +198 -0
- package/port/src/util.mjs +162 -0
- package/port/src/workspace.mjs +39 -0
- package/port/templates/unity/ReversePortSceneBuilder.cs +258 -0
- package/scripts/electron-active-hook-boundaries.cjs +392 -0
- package/scripts/electron-active-hook.cjs +673 -0
- package/scripts/hopper-demo-x11.py +787 -0
- package/scripts/prepack.mjs +60 -0
- package/scripts/prepare.mjs +28 -0
- package/scripts/rea.mjs +110 -0
- package/scripts/verify-windows-native-artifact.mjs +39 -0
- package/skills/build-inspector/SKILL.md +44 -0
- package/skills/godot-port/SKILL.md +42 -0
- package/skills/port-project/SKILL.md +59 -0
- package/skills/port-verify/SKILL.md +35 -0
- package/skills/proof-case/SKILL.md +52 -0
- package/skills/rebuild/SKILL.md +66 -0
- package/skills/reverse-engineer/SKILL.md +67 -0
- package/skills/reverse-engineer-anything/SKILL.md +204 -0
- package/skills/reverse-engineer-anything/references/android-applications.md +34 -0
- package/skills/reverse-engineer-anything/references/connection-and-recovery.md +130 -0
- package/skills/reverse-engineer-anything/references/evidence-workflows.md +54 -0
- package/skills/reverse-engineer-anything/references/godot-source.md +37 -0
- package/skills/reverse-engineer-anything/references/javascript-applications.md +175 -0
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +252 -0
- package/skills/reverse-engineer-anything/references/porting-and-rebuilds.md +92 -0
- package/skills/reverse-engineer-anything/references/runtime-observation.md +28 -0
- package/skills/reverse-engineer-anything/references/unity-source.md +32 -0
- package/skills/troubleshoot/SKILL.md +27 -0
- package/skills/unity-to-godot/SKILL.md +37 -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/third_party/wabt/README.md +24 -0
|
@@ -0,0 +1,3647 @@
|
|
|
1
|
+
import { t as __esmMin } from "./rolldown-runtime-BjeaiXFo.js";
|
|
2
|
+
import { n as readFatSliceDeclarations, r as validateFatSlice, t as init_machoContainer } from "./machoContainer-9En6pSkd.js";
|
|
3
|
+
import { Gn as artifactInventoryResultSchema, J as hasZipSignature, Kn as init_artifactGraph, X as isZipPackageFormat, Y as init_zipPackageFormat, Z as zipPackageFormatForPath, at as init_artifactIdentity, et as artifactContradictionId, it as artifactManifestId, lt as occurrenceIdForLocation, nt as artifactGraphDigest, q as ZIP_NON_ENTRY_TAIL_LIMITATION, rt as artifactIdForContent, st as logicalPathNfc, tt as artifactEdgeId } from "./toolOutputSchemaGroups-ChxVLGoy.js";
|
|
4
|
+
import { b as execFileOutputFailure, x as init_ExecFileOutput, y as execFileOutput } from "./ProcessOwnership-nOFZsmD3.js";
|
|
5
|
+
import { r as init_unicodeCodePointOrder, t as compareUnicodeCodePoints } from "./unicodeCodePointOrder-BezCbTpg.js";
|
|
6
|
+
import { A as init_dosMz, M as parseDosMzHeader, j as mzWindowsHeaderOffset } from "./InterfaceBuilderDecodeBudget-CUrOtfNo.js";
|
|
7
|
+
import { d as sameRegularFileState, f as OwnedFileHandle, l as init_RegularFile, o as NonRegularFileReadError, p as init_OwnedFileHandle, s as RegularFileAdmissionFailure, u as openRegularFile } from "./propertyListKeys-cX-BUv2y.js";
|
|
8
|
+
import { i as readFileHandleChunks, r as init_readFileHandleChunks } from "./ArtifactProviderMetadata--hy-wyJK.js";
|
|
9
|
+
import { n as init_canonicalDigest, t as digestCanonicalValue } from "./canonicalDigest-Bi_0_zGi.js";
|
|
10
|
+
import { a as sameArtifactSourceIdentity, i as sameArtifactEntry, n as copyArtifactEntry, r as init_ArtifactReader, t as ArtifactReaderFailure } from "./ArtifactReader-OyM03Gjn.js";
|
|
11
|
+
import { c as init_CommandRunner, n as lipoSubtypeBits, r as parseLipoArchitectures, s as XcrunCommandRunner, t as init_lipo } from "./lipo-Do-2eBrl.js";
|
|
12
|
+
import { n as admitAsarHeader, r as init_AsarHeader } from "./AsarHeader-WsPgoooH.js";
|
|
13
|
+
import { constants, createWriteStream } from "node:fs";
|
|
14
|
+
import { basename, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import { tmpdir } from "node:os";
|
|
17
|
+
import { lstat, mkdir, mkdtemp, open, opendir, readdir, realpath, rm, rmdir, unlink } from "node:fs/promises";
|
|
18
|
+
import { once } from "node:events";
|
|
19
|
+
import { PassThrough, Readable, Transform } from "node:stream";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
import { pipeline } from "node:stream/promises";
|
|
22
|
+
import { parse } from "plist";
|
|
23
|
+
import { Reader, ZipReader } from "@zip.js/zip.js";
|
|
24
|
+
import { listPackage, statFile, uncache } from "@electron/asar";
|
|
25
|
+
|
|
26
|
+
//#region dist/artifacts/ZipArtifactReader.js
|
|
27
|
+
var ZIP_UTF8_DECODER, NodeFileReader, ZipArtifactReader, projectZipEntry, decodeZipEntryText, zipEntryPath, decodeStrictZipUtf8, extractStream, isSymlink, abortIfNeeded$5, toError;
|
|
28
|
+
function init_ZipArtifactReader() {
|
|
29
|
+
return (init_ZipArtifactReader = __esmMin((() => {
|
|
30
|
+
init_ArtifactReader();
|
|
31
|
+
init_OwnedFileHandle();
|
|
32
|
+
init_RegularFile();
|
|
33
|
+
ZIP_UTF8_DECODER = new TextDecoder("utf-8", {
|
|
34
|
+
fatal: true,
|
|
35
|
+
ignoreBOM: true
|
|
36
|
+
});
|
|
37
|
+
NodeFileReader = class extends Reader {
|
|
38
|
+
path;
|
|
39
|
+
maximumReadBytes;
|
|
40
|
+
admitted;
|
|
41
|
+
#handle;
|
|
42
|
+
#owner;
|
|
43
|
+
#initPromise;
|
|
44
|
+
#ownsHandle;
|
|
45
|
+
constructor(path, maximumReadBytes, admitted) {
|
|
46
|
+
super(path);
|
|
47
|
+
this.path = path;
|
|
48
|
+
this.maximumReadBytes = maximumReadBytes;
|
|
49
|
+
this.admitted = admitted;
|
|
50
|
+
this.#ownsHandle = admitted === undefined;
|
|
51
|
+
}
|
|
52
|
+
init() {
|
|
53
|
+
this.#initPromise ??= this.#initialize();
|
|
54
|
+
return this.#initPromise;
|
|
55
|
+
}
|
|
56
|
+
async #initialize() {
|
|
57
|
+
try {
|
|
58
|
+
const handle = this.admitted?.handle ?? await openRegularFile(this.path, { symlinks: "reject" });
|
|
59
|
+
this.#handle = handle;
|
|
60
|
+
if (this.#ownsHandle) this.#owner = new OwnedFileHandle(handle);
|
|
61
|
+
} catch (cause) {
|
|
62
|
+
if (cause instanceof RegularFileAdmissionFailure) {
|
|
63
|
+
this.#owner = cause.owner;
|
|
64
|
+
const primary = cause.cause instanceof NonRegularFileReadError ? new ArtifactReaderFailure("format", `ZIP source is not a regular file: ${this.path}`, { cause: cause.cause }) : cause.cause;
|
|
65
|
+
throw ArtifactReaderFailure.withCleanup(primary, ArtifactReaderFailure.cleanupObservation(cause.cleanupCause, this.path));
|
|
66
|
+
}
|
|
67
|
+
if (cause instanceof NonRegularFileReadError) throw new ArtifactReaderFailure("format", `ZIP source is not a regular file: ${this.path}`, { cause });
|
|
68
|
+
throw cause;
|
|
69
|
+
}
|
|
70
|
+
const metadata = await this.#handle.stat();
|
|
71
|
+
if (!metadata.isFile() || this.admitted !== undefined && !sameRegularFileState(this.admitted.initial, metadata)) throw new ArtifactReaderFailure("integrity", `ZIP source identity changed before reading: ${this.path}`);
|
|
72
|
+
this.size = metadata.size;
|
|
73
|
+
}
|
|
74
|
+
async readUint8Array(index, length) {
|
|
75
|
+
const handle = this.#handle;
|
|
76
|
+
if (handle === undefined) throw new Error("ZIP reader is not initialized");
|
|
77
|
+
const readBytes = Math.min(length, this.size - index);
|
|
78
|
+
if (this.maximumReadBytes !== undefined && readBytes > this.maximumReadBytes) throw new ArtifactReaderFailure("limit", `ZIP metadata read requires ${readBytes} bytes, exceeding the ${this.maximumReadBytes}-byte read budget`);
|
|
79
|
+
const bytes = Buffer.alloc(readBytes);
|
|
80
|
+
const read = await handle.read(bytes, 0, bytes.length, index);
|
|
81
|
+
return bytes.subarray(0, read.bytesRead);
|
|
82
|
+
}
|
|
83
|
+
async closeHandle() {
|
|
84
|
+
if (!this.#ownsHandle) return;
|
|
85
|
+
await this.#initPromise?.catch(() => undefined);
|
|
86
|
+
if (this.#owner === undefined) return;
|
|
87
|
+
await this.#owner.close();
|
|
88
|
+
this.#owner = undefined;
|
|
89
|
+
this.#handle = undefined;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
ZipArtifactReader = class {
|
|
93
|
+
format;
|
|
94
|
+
#source;
|
|
95
|
+
#reader;
|
|
96
|
+
#entries = new Map();
|
|
97
|
+
/** Optionally bound each metadata read before allocating its backing buffer. */
|
|
98
|
+
constructor(path, format, maximumMetadataReadBytes, admitted) {
|
|
99
|
+
this.format = format;
|
|
100
|
+
this.#source = new NodeFileReader(path, maximumMetadataReadBytes, admitted);
|
|
101
|
+
this.#reader = new ZipReader(this.#source, {
|
|
102
|
+
checkSignature: true,
|
|
103
|
+
checkOverlappingEntry: true,
|
|
104
|
+
filenameValidation: "tolerant"
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async *entries(signal) {
|
|
108
|
+
let index = 0;
|
|
109
|
+
for await (const entry of this.#reader.getEntriesGenerator({ decodeText: decodeZipEntryText })) {
|
|
110
|
+
abortIfNeeded$5(signal);
|
|
111
|
+
const metadata = projectZipEntry(entry, index++);
|
|
112
|
+
const stored = this.#entries.get(metadata.adapterKey);
|
|
113
|
+
if (stored !== undefined && !sameArtifactEntry(metadata, stored.metadata)) throw new ArtifactReaderFailure("integrity", `ZIP member identity changed during enumeration: ${entry.filename}`);
|
|
114
|
+
if (stored === undefined) this.#entries.set(metadata.adapterKey, {
|
|
115
|
+
source: entry,
|
|
116
|
+
metadata: copyArtifactEntry(metadata)
|
|
117
|
+
});
|
|
118
|
+
yield metadata;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
open(entry, signal) {
|
|
122
|
+
abortIfNeeded$5(signal);
|
|
123
|
+
const stored = this.#entries.get(entry.adapterKey);
|
|
124
|
+
if (stored === undefined || !sameArtifactEntry(entry, stored.metadata)) return Promise.reject(new ArtifactReaderFailure("integrity", "ZIP entry metadata does not match this reader's inventory"));
|
|
125
|
+
const source = stored.source;
|
|
126
|
+
if (source.directory || isSymlink(source)) return Promise.reject(new ArtifactReaderFailure("format", "ZIP entry is not a regular file"));
|
|
127
|
+
if (source.encrypted) return Promise.reject(new ArtifactReaderFailure("unavailable", "Encrypted ZIP entry is unsupported"));
|
|
128
|
+
return Promise.resolve(extractStream(source, signal));
|
|
129
|
+
}
|
|
130
|
+
async close() {
|
|
131
|
+
await this.#reader.close().catch(() => undefined);
|
|
132
|
+
await this.#source.closeHandle();
|
|
133
|
+
}
|
|
134
|
+
provenance() {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
projectZipEntry = (entry, index) => {
|
|
139
|
+
const symlink = isSymlink(entry);
|
|
140
|
+
return {
|
|
141
|
+
path: zipEntryPath(entry),
|
|
142
|
+
kind: entry.directory ? "directory" : symlink ? "symlink" : "file",
|
|
143
|
+
declaredSize: entry.directory ? null : entry.uncompressedSize,
|
|
144
|
+
compressedSize: entry.directory ? null : entry.compressedSize,
|
|
145
|
+
executable: entry.executable,
|
|
146
|
+
encrypted: entry.encrypted,
|
|
147
|
+
byteOffset: null,
|
|
148
|
+
declaredSha256: null,
|
|
149
|
+
unpacked: false,
|
|
150
|
+
limitations: symlink ? ["Archive symlink target was not read."] : [],
|
|
151
|
+
adapterKey: `zip-entry:${index}`
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
decodeZipEntryText = (bytes, encoding, type) => {
|
|
155
|
+
if (type !== "filename" || encoding !== "utf-8") return undefined;
|
|
156
|
+
return decodeStrictZipUtf8(bytes, "ZIP filename is not valid UTF-8");
|
|
157
|
+
};
|
|
158
|
+
zipEntryPath = (entry) => {
|
|
159
|
+
const field = entry.extraFieldUnicodePath;
|
|
160
|
+
if (field?.valid !== true) return entry.filename;
|
|
161
|
+
return decodeStrictZipUtf8(field.data.subarray(5), "ZIP Unicode Path extra field is not valid UTF-8");
|
|
162
|
+
};
|
|
163
|
+
decodeStrictZipUtf8 = (bytes, message) => {
|
|
164
|
+
try {
|
|
165
|
+
return ZIP_UTF8_DECODER.decode(bytes);
|
|
166
|
+
} catch (cause) {
|
|
167
|
+
throw new ArtifactReaderFailure("format", message, { cause });
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
extractStream = (entry, signal) => {
|
|
171
|
+
const output = new PassThrough();
|
|
172
|
+
const controller = new AbortController();
|
|
173
|
+
const onAbort = () => {
|
|
174
|
+
controller.abort(signal?.reason);
|
|
175
|
+
output.destroy(new ArtifactReaderFailure("cancelled", "ZIP operation cancelled"));
|
|
176
|
+
};
|
|
177
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
178
|
+
output.once("close", () => {
|
|
179
|
+
signal?.removeEventListener("abort", onAbort);
|
|
180
|
+
controller.abort();
|
|
181
|
+
});
|
|
182
|
+
const writable = new WritableStream({
|
|
183
|
+
write: async (chunk) => {
|
|
184
|
+
abortIfNeeded$5(signal);
|
|
185
|
+
if (!output.write(Buffer.from(chunk))) await once(output, "drain", { signal: controller.signal });
|
|
186
|
+
},
|
|
187
|
+
close: () => {
|
|
188
|
+
output.end();
|
|
189
|
+
},
|
|
190
|
+
abort: (reason) => {
|
|
191
|
+
output.destroy(toError(reason));
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
void entry.getData(writable, {
|
|
195
|
+
signal: controller.signal,
|
|
196
|
+
checkSignature: true,
|
|
197
|
+
checkOverlappingEntry: true,
|
|
198
|
+
onprogress: () => abortIfNeeded$5(signal)
|
|
199
|
+
}).catch((cause) => output.destroy(toError(cause)));
|
|
200
|
+
return output;
|
|
201
|
+
};
|
|
202
|
+
isSymlink = (entry) => entry.unixMode !== undefined && (entry.unixMode & 61440) === 40960;
|
|
203
|
+
abortIfNeeded$5 = (signal) => {
|
|
204
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "ZIP operation cancelled");
|
|
205
|
+
};
|
|
206
|
+
toError = (cause) => cause instanceof Error ? cause : new Error("ZIP extraction failed");
|
|
207
|
+
})))();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region dist/artifacts/ArtifactPaths.js
|
|
212
|
+
var DRIVE_OR_UNC, ENGLISH_UNICODE_CASE_NOTE, ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION, DESTINATION_CASE_COLLISION_PREFIX, normalizeArtifactPath, ArtifactPathRegistry, emptyCaseNode, englishCaseFold, annotateEnglishUnicodeCaseCollisions, caseCollisionLimitation, destinationCaseCollisionMessage, englishUnicodeCaseCollisions, collisionsAlong;
|
|
213
|
+
function init_ArtifactPaths() {
|
|
214
|
+
return (init_ArtifactPaths = __esmMin((() => {
|
|
215
|
+
init_artifactIdentity();
|
|
216
|
+
init_unicodeCodePointOrder();
|
|
217
|
+
init_ArtifactReader();
|
|
218
|
+
DRIVE_OR_UNC = /^(?:[A-Za-z]:|\\|\/\/)/u;
|
|
219
|
+
ENGLISH_UNICODE_CASE_NOTE = "This comparison is not a filesystem observation.";
|
|
220
|
+
ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION = `Logical archive names collide under English (en-US) Unicode case folding; a case-insensitive destination cannot store both spellings. ${ENGLISH_UNICODE_CASE_NOTE}`;
|
|
221
|
+
DESTINATION_CASE_COLLISION_PREFIX = "Destination filesystem cannot store both ";
|
|
222
|
+
normalizeArtifactPath = (input) => {
|
|
223
|
+
if (input.includes("\0") || input.includes("\\") || input.startsWith("/") || DRIVE_OR_UNC.test(input)) throw new ArtifactReaderFailure("path", `Artifact path is absolute or unsafe: ${JSON.stringify(input)}`);
|
|
224
|
+
const normalized = logicalPathNfc(input).replace(/\/+$/u, "");
|
|
225
|
+
const parts = normalized.split("/");
|
|
226
|
+
if (normalized.length === 0 || parts.some((part) => part === "" || part === "." || part === "..") || posix.normalize(normalized) !== normalized) throw new ArtifactReaderFailure("path", `Artifact path is not normalized: ${JSON.stringify(input)}`);
|
|
227
|
+
return normalized;
|
|
228
|
+
};
|
|
229
|
+
ArtifactPathRegistry = class {
|
|
230
|
+
#root = {
|
|
231
|
+
kind: undefined,
|
|
232
|
+
children: new Map()
|
|
233
|
+
};
|
|
234
|
+
add(path, kind) {
|
|
235
|
+
const parts = path.split("/");
|
|
236
|
+
let node = this.#root;
|
|
237
|
+
for (const [index, part] of parts.entries()) {
|
|
238
|
+
if (node.kind !== undefined && node.kind !== "directory") throw new ArtifactReaderFailure("path", `Artifact prefix conflict: ${path}`);
|
|
239
|
+
let child = node.children.get(part);
|
|
240
|
+
if (child === undefined) {
|
|
241
|
+
child = {
|
|
242
|
+
kind: undefined,
|
|
243
|
+
children: new Map()
|
|
244
|
+
};
|
|
245
|
+
node.children.set(part, child);
|
|
246
|
+
}
|
|
247
|
+
node = child;
|
|
248
|
+
if (index === parts.length - 1) {
|
|
249
|
+
if (node.kind !== undefined) throw new ArtifactReaderFailure("path", `Artifact path collision: ${path}`);
|
|
250
|
+
if (kind !== "directory" && node.children.size > 0) throw new ArtifactReaderFailure("path", `Artifact prefix conflict: ${path}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
node.kind = kind;
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
emptyCaseNode = () => ({
|
|
257
|
+
bySpelling: new Map(),
|
|
258
|
+
spellingsByFold: new Map(),
|
|
259
|
+
terminals: []
|
|
260
|
+
});
|
|
261
|
+
englishCaseFold = (part) => part.toLocaleLowerCase("en-US");
|
|
262
|
+
annotateEnglishUnicodeCaseCollisions = (occurrences) => {
|
|
263
|
+
const collisions = englishUnicodeCaseCollisions(occurrences.map(({ logical_path }) => logical_path));
|
|
264
|
+
if (collisions.size === 0) return undefined;
|
|
265
|
+
for (const occurrence of occurrences) for (const collision of collisions.get(occurrence.logical_path) ?? []) occurrence.limitations.push(caseCollisionLimitation(occurrence.logical_path, collision));
|
|
266
|
+
return ENGLISH_UNICODE_CASE_INVENTORY_LIMITATION;
|
|
267
|
+
};
|
|
268
|
+
caseCollisionLimitation = (path, { prefix, other, additional }) => {
|
|
269
|
+
const others = additional === 0 ? other : `${other} and ${String(additional)} other spelling${additional === 1 ? "" : "s"}`;
|
|
270
|
+
const subject = prefix === path ? `Logical path ${path} collides` : `Logical path ${path} is under ${prefix}, which collides`;
|
|
271
|
+
return `${subject} under English (en-US) Unicode case folding with ${others}; a case-insensitive destination cannot store both. ${ENGLISH_UNICODE_CASE_NOTE}`;
|
|
272
|
+
};
|
|
273
|
+
destinationCaseCollisionMessage = (requestedPath, existingNames) => {
|
|
274
|
+
const slash = requestedPath.lastIndexOf("/");
|
|
275
|
+
const segment = slash < 0 ? requestedPath : requestedPath.slice(slash + 1);
|
|
276
|
+
if (existingNames.includes(segment)) return undefined;
|
|
277
|
+
const folded = englishCaseFold(segment);
|
|
278
|
+
const existing = existingNames.filter((name) => englishCaseFold(name) === folded).sort(compareUnicodeCodePoints)[0];
|
|
279
|
+
if (existing === undefined) return undefined;
|
|
280
|
+
const parent = slash < 0 ? "" : requestedPath.slice(0, slash + 1);
|
|
281
|
+
return `${DESTINATION_CASE_COLLISION_PREFIX}${requestedPath} and ${parent}${existing}; inventory retains both logical names.`;
|
|
282
|
+
};
|
|
283
|
+
englishUnicodeCaseCollisions = (paths) => {
|
|
284
|
+
const root = emptyCaseNode();
|
|
285
|
+
for (const path of paths) {
|
|
286
|
+
if (path.length === 0 || path === ".") continue;
|
|
287
|
+
let node = root;
|
|
288
|
+
for (const part of path.split("/")) {
|
|
289
|
+
let child = node.bySpelling.get(part);
|
|
290
|
+
if (child === undefined) {
|
|
291
|
+
const folded = englishCaseFold(part);
|
|
292
|
+
const spellings = node.spellingsByFold.get(folded);
|
|
293
|
+
if (spellings === undefined) node.spellingsByFold.set(folded, [part]);
|
|
294
|
+
else spellings.push(part);
|
|
295
|
+
child = emptyCaseNode();
|
|
296
|
+
node.bySpelling.set(part, child);
|
|
297
|
+
}
|
|
298
|
+
node = child;
|
|
299
|
+
}
|
|
300
|
+
node.terminals.push(path);
|
|
301
|
+
}
|
|
302
|
+
const collisions = new Map();
|
|
303
|
+
const pending = [{
|
|
304
|
+
node: root,
|
|
305
|
+
prefix: undefined,
|
|
306
|
+
chain: undefined
|
|
307
|
+
}];
|
|
308
|
+
for (let item = pending.pop(); item !== undefined; item = pending.pop()) {
|
|
309
|
+
const { node, prefix, chain } = item;
|
|
310
|
+
if (chain !== undefined) for (const path of node.terminals) collisions.set(path, collisionsAlong(chain));
|
|
311
|
+
for (const spellings of node.spellingsByFold.values()) spellings.sort(compareUnicodeCodePoints);
|
|
312
|
+
for (const [spelling, child] of node.bySpelling) {
|
|
313
|
+
const childPrefix = prefix === undefined ? spelling : `${prefix}/${spelling}`;
|
|
314
|
+
const spellings = node.spellingsByFold.get(englishCaseFold(spelling)) ?? [];
|
|
315
|
+
const other = spellings[0] === spelling ? spellings[1] : spellings[0];
|
|
316
|
+
pending.push({
|
|
317
|
+
node: child,
|
|
318
|
+
prefix: childPrefix,
|
|
319
|
+
chain: other === undefined ? chain : {
|
|
320
|
+
collision: {
|
|
321
|
+
prefix: childPrefix,
|
|
322
|
+
other: prefix === undefined ? other : `${prefix}/${other}`,
|
|
323
|
+
additional: spellings.length - 2
|
|
324
|
+
},
|
|
325
|
+
parent: chain
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return collisions;
|
|
331
|
+
};
|
|
332
|
+
collisionsAlong = (chain) => {
|
|
333
|
+
const collisions = [];
|
|
334
|
+
let link = chain;
|
|
335
|
+
while (link !== undefined) {
|
|
336
|
+
collisions.push(link.collision);
|
|
337
|
+
link = link.parent;
|
|
338
|
+
}
|
|
339
|
+
return collisions.reverse();
|
|
340
|
+
};
|
|
341
|
+
})))();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region dist/artifacts/StreamBytes.js
|
|
346
|
+
var streamChunkToBuffer;
|
|
347
|
+
function init_StreamBytes() {
|
|
348
|
+
return (init_StreamBytes = __esmMin((() => {
|
|
349
|
+
streamChunkToBuffer = (value) => {
|
|
350
|
+
if (Buffer.isBuffer(value)) return value;
|
|
351
|
+
if (value instanceof Uint8Array) return Buffer.from(value);
|
|
352
|
+
if (typeof value === "string") return Buffer.from(value);
|
|
353
|
+
throw new TypeError("Readable stream emitted a non-byte chunk");
|
|
354
|
+
};
|
|
355
|
+
})))();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region dist/artifacts/SafeOutputTreeCreationFailure.js
|
|
360
|
+
var SafeOutputTreeCreationFailure, errorMessage;
|
|
361
|
+
function init_SafeOutputTreeCreationFailure() {
|
|
362
|
+
return (init_SafeOutputTreeCreationFailure = __esmMin((() => {
|
|
363
|
+
init_ArtifactReader();
|
|
364
|
+
SafeOutputTreeCreationFailure = class extends ArtifactReaderFailure {
|
|
365
|
+
tree;
|
|
366
|
+
constructor(cause, tree) {
|
|
367
|
+
const primary = cause instanceof ArtifactReaderFailure ? cause : new ArtifactReaderFailure("io", errorMessage(cause), { cause });
|
|
368
|
+
super(primary.reason, primary.message, {
|
|
369
|
+
cause: primary,
|
|
370
|
+
...primary.cleanup === undefined ? {} : { cleanup: primary.cleanup },
|
|
371
|
+
...primary.partialObservation === undefined ? {} : { partialObservation: primary.partialObservation }
|
|
372
|
+
}, primary.details);
|
|
373
|
+
this.name = "SafeOutputTreeCreationFailure";
|
|
374
|
+
this.tree = tree;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
errorMessage = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
378
|
+
})))();
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region dist/artifacts/SafeOutputTreeIdentity.js
|
|
383
|
+
var readDirectoryIdentity, assertPathIdentity, assertHandleIdentity, readFileIdentity, assertFilePathIdentity, isAbsent, replacedDirectory, isNotFound;
|
|
384
|
+
function init_SafeOutputTreeIdentity() {
|
|
385
|
+
return (init_SafeOutputTreeIdentity = __esmMin((() => {
|
|
386
|
+
init_ArtifactReader();
|
|
387
|
+
readDirectoryIdentity = async (path) => {
|
|
388
|
+
const metadata = await lstat(path, { bigint: true });
|
|
389
|
+
if (!metadata.isDirectory()) throw replacedDirectory(path);
|
|
390
|
+
return {
|
|
391
|
+
dev: metadata.dev,
|
|
392
|
+
ino: metadata.ino
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
assertPathIdentity = async (path, expected) => {
|
|
396
|
+
const metadata = await lstat(path, { bigint: true });
|
|
397
|
+
if (!metadata.isDirectory() || metadata.dev !== expected.dev || metadata.ino !== expected.ino) throw replacedDirectory(path);
|
|
398
|
+
};
|
|
399
|
+
assertHandleIdentity = async (handle, expected, path) => {
|
|
400
|
+
const metadata = await handle.stat({ bigint: true });
|
|
401
|
+
if (!metadata.isDirectory() || metadata.dev !== expected.dev || metadata.ino !== expected.ino) throw replacedDirectory(path);
|
|
402
|
+
};
|
|
403
|
+
readFileIdentity = async (handle, path) => {
|
|
404
|
+
const metadata = await handle.stat({ bigint: true });
|
|
405
|
+
if (!metadata.isFile()) throw new ArtifactReaderFailure("path", `Extraction file identity changed: ${path}`);
|
|
406
|
+
return {
|
|
407
|
+
dev: metadata.dev,
|
|
408
|
+
ino: metadata.ino
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
assertFilePathIdentity = async (path, expected) => {
|
|
412
|
+
const metadata = await lstat(path, { bigint: true });
|
|
413
|
+
if (!metadata.isFile() || metadata.dev !== expected.dev || metadata.ino !== expected.ino) throw new ArtifactReaderFailure("path", `Extraction file identity changed: ${path}`);
|
|
414
|
+
};
|
|
415
|
+
isAbsent = async (path) => lstat(path).then(() => false, (cause) => {
|
|
416
|
+
if (isNotFound(cause)) return true;
|
|
417
|
+
throw cause;
|
|
418
|
+
});
|
|
419
|
+
replacedDirectory = (path) => new ArtifactReaderFailure("path", `Extraction directory identity changed: ${path}`);
|
|
420
|
+
isNotFound = (cause) => cause instanceof Error && "code" in cause && cause.code === "ENOENT";
|
|
421
|
+
})))();
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region dist/artifacts/SafeOutputTreeReadback.js
|
|
426
|
+
var hashOutputFile;
|
|
427
|
+
function init_SafeOutputTreeReadback() {
|
|
428
|
+
return (init_SafeOutputTreeReadback = __esmMin((() => {
|
|
429
|
+
init_readFileHandleChunks();
|
|
430
|
+
init_StreamBytes();
|
|
431
|
+
init_ArtifactReader();
|
|
432
|
+
init_SafeOutputTreeIdentity();
|
|
433
|
+
hashOutputFile = async (owner, path, identity, options) => {
|
|
434
|
+
const admittedIdentity = await readFileIdentity(owner.handle, path);
|
|
435
|
+
await assertFilePathIdentity(path, identity);
|
|
436
|
+
if (admittedIdentity.dev !== identity.dev || admittedIdentity.ino !== identity.ino) throw new ArtifactReaderFailure("path", `Extraction file identity changed: ${path}`);
|
|
437
|
+
const hash = createHash("sha256");
|
|
438
|
+
let bytes = 0;
|
|
439
|
+
try {
|
|
440
|
+
for await (const raw of readFileHandleChunks(owner.handle, options)) {
|
|
441
|
+
if (options.signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact extraction cancelled");
|
|
442
|
+
const chunk = streamChunkToBuffer(raw);
|
|
443
|
+
bytes += chunk.length;
|
|
444
|
+
if (bytes > options.maximum) throw new ArtifactReaderFailure("integrity", "Readback exceeded the bytes written");
|
|
445
|
+
hash.update(chunk);
|
|
446
|
+
}
|
|
447
|
+
} catch (cause) {
|
|
448
|
+
if (options.signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact extraction cancelled", { cause });
|
|
449
|
+
throw cause;
|
|
450
|
+
}
|
|
451
|
+
await assertFilePathIdentity(path, identity);
|
|
452
|
+
return {
|
|
453
|
+
sha256: hash.digest("hex"),
|
|
454
|
+
bytes
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
})))();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region dist/artifacts/SafeOutputTreeCleanup.js
|
|
462
|
+
var removeOwnedTree, removeFiles, requireEmpty;
|
|
463
|
+
function init_SafeOutputTreeCleanup() {
|
|
464
|
+
return (init_SafeOutputTreeCleanup = __esmMin((() => {
|
|
465
|
+
init_ArtifactReader();
|
|
466
|
+
init_SafeOutputTreeIdentity();
|
|
467
|
+
removeOwnedTree = async (input) => {
|
|
468
|
+
const { outputRoot, rootIdentity, directories, files } = input;
|
|
469
|
+
const filesByDirectory = new Map();
|
|
470
|
+
for (const entry of files) {
|
|
471
|
+
const directory = dirname(entry[0]);
|
|
472
|
+
const group = filesByDirectory.get(directory) ?? [];
|
|
473
|
+
group.push(entry);
|
|
474
|
+
filesByDirectory.set(directory, group);
|
|
475
|
+
}
|
|
476
|
+
const postorder = [...directories].sort(([left], [right]) => right.slice(outputRoot.length).split(sep).length - left.slice(outputRoot.length).split(sep).length);
|
|
477
|
+
for (const [path, identity] of postorder) {
|
|
478
|
+
await removeFiles(path, identity, filesByDirectory.get(path) ?? [], files);
|
|
479
|
+
const parentPath = dirname(path);
|
|
480
|
+
const parentIdentity = parentPath === outputRoot ? rootIdentity : directories.get(parentPath);
|
|
481
|
+
if (parentIdentity === undefined) throw replacedDirectory(parentPath);
|
|
482
|
+
await assertPathIdentity(parentPath, parentIdentity);
|
|
483
|
+
await assertPathIdentity(path, identity);
|
|
484
|
+
await requireEmpty(path);
|
|
485
|
+
await rmdir(path);
|
|
486
|
+
directories.delete(path);
|
|
487
|
+
}
|
|
488
|
+
await removeFiles(outputRoot, rootIdentity, filesByDirectory.get(outputRoot) ?? [], files);
|
|
489
|
+
await assertPathIdentity(outputRoot, rootIdentity);
|
|
490
|
+
await requireEmpty(outputRoot);
|
|
491
|
+
await rmdir(outputRoot);
|
|
492
|
+
};
|
|
493
|
+
removeFiles = async (directory, identity, filesInDirectory, retainedFiles) => {
|
|
494
|
+
for (const [path, fileIdentity] of filesInDirectory) {
|
|
495
|
+
await assertPathIdentity(directory, identity);
|
|
496
|
+
await assertFilePathIdentity(path, fileIdentity);
|
|
497
|
+
await unlink(path);
|
|
498
|
+
retainedFiles.delete(path);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
requireEmpty = async (directory) => {
|
|
502
|
+
if ((await readdir(directory)).length > 0) throw new ArtifactReaderFailure("path", `Unowned entries remain in extraction directory: ${directory}`);
|
|
503
|
+
};
|
|
504
|
+
})))();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region dist/artifacts/SafeOutputTree.js
|
|
509
|
+
var SafeOutputTree, isDefined, isRejected, writeAll, normalizeDestinationPath, abortIfNeeded$4, isAlreadyExists, throwIfDestinationCaseCollision;
|
|
510
|
+
function init_SafeOutputTree() {
|
|
511
|
+
return (init_SafeOutputTree = __esmMin((() => {
|
|
512
|
+
init_OwnedFileHandle();
|
|
513
|
+
init_StreamBytes();
|
|
514
|
+
init_ArtifactPaths();
|
|
515
|
+
init_ArtifactReader();
|
|
516
|
+
init_SafeOutputTreeCreationFailure();
|
|
517
|
+
init_SafeOutputTreeReadback();
|
|
518
|
+
init_SafeOutputTreeCleanup();
|
|
519
|
+
init_SafeOutputTreeIdentity();
|
|
520
|
+
SafeOutputTree = class SafeOutputTree {
|
|
521
|
+
platform;
|
|
522
|
+
#registry = new ArtifactPathRegistry();
|
|
523
|
+
#outputRoot;
|
|
524
|
+
#rootIdentity;
|
|
525
|
+
#nestedDirectories = new Map();
|
|
526
|
+
#unknownDirectories = new Set();
|
|
527
|
+
#ownedFiles = new Map();
|
|
528
|
+
#openFiles = new Map();
|
|
529
|
+
#openHandles = new Set();
|
|
530
|
+
#published = false;
|
|
531
|
+
#cleanup = { status: "not-required" };
|
|
532
|
+
constructor(outputRoot, platform) {
|
|
533
|
+
this.platform = platform;
|
|
534
|
+
this.#outputRoot = outputRoot;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Exclusively create the absent destination as this operation's owned tree.
|
|
538
|
+
*
|
|
539
|
+
* POSIX mode bits and directory `fchmod`/`fsync` have no Windows equivalent:
|
|
540
|
+
* `mkdir` already applies the requested mode, so the redundant handle
|
|
541
|
+
* `chmod` is skipped there to avoid an `EPERM` on the directory descriptor.
|
|
542
|
+
*/
|
|
543
|
+
static async create(outputRoot, platform = process.platform) {
|
|
544
|
+
if (!isAbsolute(outputRoot)) throw new ArtifactReaderFailure("path", "Extraction output root must be absolute");
|
|
545
|
+
const requested = resolve(outputRoot);
|
|
546
|
+
const name = basename(requested);
|
|
547
|
+
if (name === "." || name === "..") throw new ArtifactReaderFailure("path", "Invalid extraction output root");
|
|
548
|
+
const parent = await realpath(dirname(requested)).catch((cause) => {
|
|
549
|
+
throw new ArtifactReaderFailure("unavailable", "Extraction output parent is unavailable", { cause });
|
|
550
|
+
});
|
|
551
|
+
const canonicalOutput = join(parent, name);
|
|
552
|
+
await mkdir(canonicalOutput, { mode: 448 }).catch((cause) => {
|
|
553
|
+
if (isAlreadyExists(cause)) throw new ArtifactReaderFailure("path", "Extraction output root already exists", { cause });
|
|
554
|
+
throw cause;
|
|
555
|
+
});
|
|
556
|
+
const tree = new SafeOutputTree(canonicalOutput, platform);
|
|
557
|
+
try {
|
|
558
|
+
const rootIdentity = await readDirectoryIdentity(canonicalOutput);
|
|
559
|
+
tree.#rootIdentity = rootIdentity;
|
|
560
|
+
if (platform !== "win32") {
|
|
561
|
+
const stagingHandle = tree.#trackHandle(await open(canonicalOutput, constants.O_RDONLY | constants.O_DIRECTORY));
|
|
562
|
+
let setup = { kind: "ready" };
|
|
563
|
+
try {
|
|
564
|
+
await assertHandleIdentity(stagingHandle.handle, rootIdentity, canonicalOutput);
|
|
565
|
+
await stagingHandle.handle.chmod(448);
|
|
566
|
+
} catch (cause) {
|
|
567
|
+
setup = {
|
|
568
|
+
kind: "failed",
|
|
569
|
+
cause
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
try {
|
|
573
|
+
await tree.#closeHandle(stagingHandle);
|
|
574
|
+
} catch (closeCause) {
|
|
575
|
+
if (setup.kind === "failed") throw ArtifactReaderFailure.withCleanup(setup.cause, ArtifactReaderFailure.cleanupObservation(closeCause, canonicalOutput));
|
|
576
|
+
throw closeCause;
|
|
577
|
+
}
|
|
578
|
+
if (setup.kind === "failed") throw setup.cause;
|
|
579
|
+
}
|
|
580
|
+
await assertPathIdentity(canonicalOutput, rootIdentity);
|
|
581
|
+
return tree;
|
|
582
|
+
} catch (cause) {
|
|
583
|
+
throw new SafeOutputTreeCreationFailure(cause, tree);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
get outputRoot() {
|
|
587
|
+
return this.#outputRoot;
|
|
588
|
+
}
|
|
589
|
+
/** The output was durably committed, even if descriptor cleanup later failed. */
|
|
590
|
+
get published() {
|
|
591
|
+
return this.#published;
|
|
592
|
+
}
|
|
593
|
+
get cleanup() {
|
|
594
|
+
return structuredClone(this.#cleanup);
|
|
595
|
+
}
|
|
596
|
+
/** Stream one regular file with exact byte and digest verification. */
|
|
597
|
+
async write(relativePath, source, expected, signal) {
|
|
598
|
+
try {
|
|
599
|
+
this.#assertWritable();
|
|
600
|
+
if (!Number.isSafeInteger(expected.bytes) || expected.bytes < 0) throw new ArtifactReaderFailure("format", `Invalid expected extraction size for ${relativePath}`);
|
|
601
|
+
const path = normalizeDestinationPath(relativePath, this.platform);
|
|
602
|
+
this.#registry.add(path, "file");
|
|
603
|
+
const lineage = await this.#prepareParent(path);
|
|
604
|
+
const parent = lineage.at(-1);
|
|
605
|
+
if (parent === undefined) throw replacedDirectory(this.#outputRoot);
|
|
606
|
+
const fileName = path.slice(path.lastIndexOf("/") + 1);
|
|
607
|
+
const destination = join(parent.path, fileName);
|
|
608
|
+
const handle = await open(destination, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW, 384).catch(async (cause) => {
|
|
609
|
+
await throwIfDestinationCaseCollision(parent.path, path, cause);
|
|
610
|
+
throw new ArtifactReaderFailure("path", `Could not exclusively create extraction path: ${path}`, { cause });
|
|
611
|
+
});
|
|
612
|
+
const ownedHandle = this.#trackHandle(handle);
|
|
613
|
+
this.#openFiles.set(destination, ownedHandle);
|
|
614
|
+
const fileIdentity = await readFileIdentity(ownedHandle.handle, destination);
|
|
615
|
+
await assertFilePathIdentity(destination, fileIdentity);
|
|
616
|
+
this.#ownedFiles.set(destination, fileIdentity);
|
|
617
|
+
const hash = createHash("sha256");
|
|
618
|
+
let bytes = 0;
|
|
619
|
+
await this.#assertLineage(lineage);
|
|
620
|
+
for await (const raw of source) {
|
|
621
|
+
abortIfNeeded$4(signal);
|
|
622
|
+
const chunk = streamChunkToBuffer(raw);
|
|
623
|
+
if (chunk.length > expected.bytes - bytes) throw new ArtifactReaderFailure("integrity", `Extracted content exceeds the inventoried size: ${path}`);
|
|
624
|
+
bytes += chunk.length;
|
|
625
|
+
hash.update(chunk);
|
|
626
|
+
await writeAll(ownedHandle.handle, chunk);
|
|
627
|
+
}
|
|
628
|
+
if (bytes !== expected.bytes) throw new ArtifactReaderFailure("integrity", `Extracted content size disagrees with inventory: ${path}`);
|
|
629
|
+
const sha256 = hash.digest("hex");
|
|
630
|
+
if (sha256 !== expected.sha256) throw new ArtifactReaderFailure("integrity", `Extracted content disagrees with inventory: ${path}`);
|
|
631
|
+
await this.#assertLineage(lineage);
|
|
632
|
+
await assertFilePathIdentity(destination, fileIdentity);
|
|
633
|
+
await ownedHandle.handle.sync();
|
|
634
|
+
await this.#closeFileHandle(destination, ownedHandle);
|
|
635
|
+
const readbackHandle = this.#trackHandle(await open(destination, constants.O_RDONLY | constants.O_NOFOLLOW));
|
|
636
|
+
const readback = await hashOutputFile(readbackHandle, destination, fileIdentity, {
|
|
637
|
+
maximum: bytes,
|
|
638
|
+
signal
|
|
639
|
+
});
|
|
640
|
+
await this.#closeHandle(readbackHandle);
|
|
641
|
+
await this.#assertLineage(lineage);
|
|
642
|
+
await assertFilePathIdentity(destination, fileIdentity);
|
|
643
|
+
if (readback.sha256 !== sha256 || readback.bytes !== bytes) throw new ArtifactReaderFailure("integrity", `Durable readback verification failed: ${path}`);
|
|
644
|
+
return {
|
|
645
|
+
relativePath: path,
|
|
646
|
+
sha256,
|
|
647
|
+
bytesWritten: bytes
|
|
648
|
+
};
|
|
649
|
+
} catch (cause) {
|
|
650
|
+
try {
|
|
651
|
+
source.destroy();
|
|
652
|
+
} catch {}
|
|
653
|
+
throw cause;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
/** Sync the owned output tree and prevent further writes through this instance. */
|
|
657
|
+
async commit() {
|
|
658
|
+
this.#assertWritable();
|
|
659
|
+
await this.#assertOwnedDirectories();
|
|
660
|
+
if (this.platform === "win32") {
|
|
661
|
+
this.#published = true;
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
const parent = this.#trackHandle(await open(dirname(this.#outputRoot), constants.O_RDONLY | constants.O_DIRECTORY));
|
|
665
|
+
let output;
|
|
666
|
+
let sync = { kind: "synced" };
|
|
667
|
+
try {
|
|
668
|
+
output = this.#trackHandle(await open(this.#outputRoot, constants.O_RDONLY | constants.O_DIRECTORY));
|
|
669
|
+
await assertHandleIdentity(output.handle, this.#requireRootIdentity(), this.#outputRoot);
|
|
670
|
+
await output.handle.sync();
|
|
671
|
+
await parent.handle.sync();
|
|
672
|
+
this.#published = true;
|
|
673
|
+
} catch (cause) {
|
|
674
|
+
sync = {
|
|
675
|
+
kind: "failed",
|
|
676
|
+
cause
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
const closeResults = await Promise.allSettled([parent, output].filter(isDefined).map((handle) => this.#closeHandle(handle)));
|
|
680
|
+
const closeFailures = closeResults.filter(isRejected).map(({ reason }) => reason);
|
|
681
|
+
if (closeFailures.length > 0) {
|
|
682
|
+
const closeFailure = new AggregateError(closeFailures, "Extraction output directory handles could not be closed");
|
|
683
|
+
const cleanup = ArtifactReaderFailure.cleanupObservation(closeFailure, this.#outputRoot);
|
|
684
|
+
if (sync.kind === "failed") throw ArtifactReaderFailure.withCleanup(new ArtifactReaderFailure("path", "Could not durably sync extraction output", { cause: sync.cause }), cleanup);
|
|
685
|
+
throw ArtifactReaderFailure.withCleanup(closeFailure, cleanup);
|
|
686
|
+
}
|
|
687
|
+
if (sync.kind === "failed") throw new ArtifactReaderFailure("path", "Could not durably sync extraction output", { cause: sync.cause });
|
|
688
|
+
}
|
|
689
|
+
/** Remove only this operation's unsealed tree and verify absence. */
|
|
690
|
+
async rollback() {
|
|
691
|
+
if (this.#published) {
|
|
692
|
+
await this.#closePendingHandles();
|
|
693
|
+
return structuredClone(this.#cleanup);
|
|
694
|
+
}
|
|
695
|
+
if (this.#cleanup.status === "complete") return structuredClone(this.#cleanup);
|
|
696
|
+
this.#cleanup = {
|
|
697
|
+
status: "incomplete",
|
|
698
|
+
residualPaths: [basename(this.#outputRoot)]
|
|
699
|
+
};
|
|
700
|
+
let removalFailure;
|
|
701
|
+
try {
|
|
702
|
+
await this.#admitPendingFiles();
|
|
703
|
+
await this.#closePendingHandles();
|
|
704
|
+
await this.#assertOwnedDirectories();
|
|
705
|
+
await removeOwnedTree({
|
|
706
|
+
outputRoot: this.#outputRoot,
|
|
707
|
+
rootIdentity: this.#requireRootIdentity(),
|
|
708
|
+
directories: this.#nestedDirectories,
|
|
709
|
+
files: this.#ownedFiles
|
|
710
|
+
});
|
|
711
|
+
} catch (cause) {
|
|
712
|
+
removalFailure = cause;
|
|
713
|
+
}
|
|
714
|
+
const absent = removalFailure === undefined && await isAbsent(this.#outputRoot);
|
|
715
|
+
this.#cleanup = absent ? {
|
|
716
|
+
status: "complete",
|
|
717
|
+
residualPaths: []
|
|
718
|
+
} : {
|
|
719
|
+
status: "incomplete",
|
|
720
|
+
residualPaths: [basename(this.#outputRoot)]
|
|
721
|
+
};
|
|
722
|
+
if (!absent) throw new ArtifactReaderFailure("integrity", `Extraction output cleanup could not be verified${removalFailure === undefined ? "" : `: ${removalFailure instanceof Error ? removalFailure.message : String(removalFailure)}`}`, {
|
|
723
|
+
cause: removalFailure,
|
|
724
|
+
cleanup: {
|
|
725
|
+
reason: removalFailure instanceof Error ? removalFailure.message : "Extraction output root remains after rollback",
|
|
726
|
+
resources: [this.#outputRoot]
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
return structuredClone(this.#cleanup);
|
|
730
|
+
}
|
|
731
|
+
async #prepareParent(relativePath) {
|
|
732
|
+
const parts = relativePath.split("/");
|
|
733
|
+
if (parts.pop() === undefined) throw new ArtifactReaderFailure("path", "Invalid extraction path");
|
|
734
|
+
let current = this.#outputRoot;
|
|
735
|
+
let logicalParent = "";
|
|
736
|
+
const lineage = [{
|
|
737
|
+
path: this.#outputRoot,
|
|
738
|
+
identity: this.#requireRootIdentity()
|
|
739
|
+
}];
|
|
740
|
+
if (parts.length === 0) await assertPathIdentity(this.#outputRoot, this.#requireRootIdentity());
|
|
741
|
+
for (const part of parts) {
|
|
742
|
+
const parent = lineage.at(-1);
|
|
743
|
+
if (parent === undefined) throw replacedDirectory(this.#outputRoot);
|
|
744
|
+
const logicalPath = logicalParent.length === 0 ? part : `${logicalParent}/${part}`;
|
|
745
|
+
current = join(current, part);
|
|
746
|
+
await assertPathIdentity(parent.path, parent.identity);
|
|
747
|
+
let created = true;
|
|
748
|
+
await mkdir(current, { mode: 448 }).catch((cause) => {
|
|
749
|
+
if (!isAlreadyExists(cause)) throw cause;
|
|
750
|
+
created = false;
|
|
751
|
+
});
|
|
752
|
+
if (!created) {
|
|
753
|
+
await throwIfDestinationCaseCollision(parent.path, logicalPath);
|
|
754
|
+
const identity = this.#nestedDirectories.get(current);
|
|
755
|
+
if (identity === undefined) throw replacedDirectory(current);
|
|
756
|
+
await assertPathIdentity(current, identity);
|
|
757
|
+
} else {
|
|
758
|
+
try {
|
|
759
|
+
const identity = await readDirectoryIdentity(current);
|
|
760
|
+
this.#nestedDirectories.set(current, identity);
|
|
761
|
+
} catch (cause) {
|
|
762
|
+
this.#unknownDirectories.add(current);
|
|
763
|
+
throw cause;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
await assertPathIdentity(parent.path, parent.identity);
|
|
767
|
+
const identity = this.#nestedDirectories.get(current);
|
|
768
|
+
if (identity === undefined) throw replacedDirectory(current);
|
|
769
|
+
await assertPathIdentity(current, identity);
|
|
770
|
+
lineage.push({
|
|
771
|
+
path: current,
|
|
772
|
+
identity
|
|
773
|
+
});
|
|
774
|
+
logicalParent = logicalPath;
|
|
775
|
+
}
|
|
776
|
+
return lineage;
|
|
777
|
+
}
|
|
778
|
+
async #assertLineage(lineage) {
|
|
779
|
+
for (const { path, identity } of lineage) await assertPathIdentity(path, identity);
|
|
780
|
+
}
|
|
781
|
+
async #assertOwnedDirectories() {
|
|
782
|
+
const rootIdentity = this.#requireRootIdentity();
|
|
783
|
+
await assertPathIdentity(this.#outputRoot, rootIdentity);
|
|
784
|
+
for (const [path, identity] of this.#nestedDirectories) await assertPathIdentity(path, identity);
|
|
785
|
+
if (this.#unknownDirectories.size > 0) throw new ArtifactReaderFailure("path", `Extraction directory ownership is unknown: ${[...this.#unknownDirectories].join(", ")}`);
|
|
786
|
+
}
|
|
787
|
+
#requireRootIdentity() {
|
|
788
|
+
if (this.#rootIdentity === undefined) throw new ArtifactReaderFailure("path", `Extraction output root identity is unknown: ${this.#outputRoot}`);
|
|
789
|
+
return this.#rootIdentity;
|
|
790
|
+
}
|
|
791
|
+
#assertWritable() {
|
|
792
|
+
if (this.#published) throw new ArtifactReaderFailure("integrity", "Extraction tree is already committed");
|
|
793
|
+
if (this.#cleanup.status !== "not-required") throw new ArtifactReaderFailure("integrity", "Extraction tree cleanup has already started");
|
|
794
|
+
}
|
|
795
|
+
#trackHandle(handle) {
|
|
796
|
+
const owner = new OwnedFileHandle(handle);
|
|
797
|
+
this.#openHandles.add(owner);
|
|
798
|
+
return owner;
|
|
799
|
+
}
|
|
800
|
+
async #closeHandle(owner) {
|
|
801
|
+
await owner.close();
|
|
802
|
+
this.#openHandles.delete(owner);
|
|
803
|
+
}
|
|
804
|
+
async #closePendingHandles() {
|
|
805
|
+
const failures = [];
|
|
806
|
+
for (const owner of this.#openHandles) {
|
|
807
|
+
try {
|
|
808
|
+
await this.#closeHandle(owner);
|
|
809
|
+
} catch (cause) {
|
|
810
|
+
failures.push(cause);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
if (failures.length > 0) throw new AggregateError(failures, "Output tree handles remain open");
|
|
814
|
+
}
|
|
815
|
+
async #closeFileHandle(path, owner) {
|
|
816
|
+
await this.#closeHandle(owner);
|
|
817
|
+
this.#openFiles.delete(path);
|
|
818
|
+
}
|
|
819
|
+
async #admitPendingFiles() {
|
|
820
|
+
for (const [path, owner] of this.#openFiles) {
|
|
821
|
+
let identity = this.#ownedFiles.get(path);
|
|
822
|
+
if (identity === undefined) {
|
|
823
|
+
identity = await readFileIdentity(owner.handle, path);
|
|
824
|
+
await assertFilePathIdentity(path, identity);
|
|
825
|
+
this.#ownedFiles.set(path, identity);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
isDefined = (value) => value !== undefined;
|
|
831
|
+
isRejected = (result) => result.status === "rejected";
|
|
832
|
+
writeAll = async (handle, chunk) => {
|
|
833
|
+
let offset = 0;
|
|
834
|
+
while (offset < chunk.length) {
|
|
835
|
+
const { bytesWritten } = await handle.write(chunk, offset, chunk.length - offset);
|
|
836
|
+
if (bytesWritten === 0) throw new ArtifactReaderFailure("unavailable", "Extraction output stopped accepting bytes");
|
|
837
|
+
offset += bytesWritten;
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
normalizeDestinationPath = (relativePath, platform) => {
|
|
841
|
+
const path = normalizeArtifactPath(relativePath);
|
|
842
|
+
if (platform === "win32" && path.includes(":")) throw new ArtifactReaderFailure("path", `Windows destination cannot materialize artifact path as a regular file: ${path}; ':' denotes alternate data stream syntax.`);
|
|
843
|
+
return path;
|
|
844
|
+
};
|
|
845
|
+
abortIfNeeded$4 = (signal) => {
|
|
846
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact extraction cancelled");
|
|
847
|
+
};
|
|
848
|
+
isAlreadyExists = (cause) => cause instanceof Error && "code" in cause && cause.code === "EEXIST";
|
|
849
|
+
throwIfDestinationCaseCollision = async (parentDirectory, logicalPath, cause) => {
|
|
850
|
+
const names = await readdir(parentDirectory).catch(() => undefined);
|
|
851
|
+
if (names === undefined) return;
|
|
852
|
+
const message = destinationCaseCollisionMessage(logicalPath, names);
|
|
853
|
+
if (message === undefined) return;
|
|
854
|
+
throw new ArtifactReaderFailure("path", message, cause === undefined ? undefined : { cause });
|
|
855
|
+
};
|
|
856
|
+
})))();
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region dist/artifacts/AsarEntryStream.js
|
|
861
|
+
var closeAsarHandle, readValidatedAsarEntry, abortIfNeeded$3, asarFailure$1, isFilesystemFailure$1;
|
|
862
|
+
function init_AsarEntryStream() {
|
|
863
|
+
return (init_AsarEntryStream = __esmMin((() => {
|
|
864
|
+
init_ArtifactReader();
|
|
865
|
+
closeAsarHandle = async (close, signal) => {
|
|
866
|
+
await close();
|
|
867
|
+
abortIfNeeded$3(signal);
|
|
868
|
+
};
|
|
869
|
+
readValidatedAsarEntry = (source, expectedBytes, entryPath, archivePath, signal) => {
|
|
870
|
+
const output = Readable.from((async function* () {
|
|
871
|
+
let observedBytes = 0;
|
|
872
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
873
|
+
try {
|
|
874
|
+
while (true) {
|
|
875
|
+
abortIfNeeded$3(signal);
|
|
876
|
+
const next = await iterator.next();
|
|
877
|
+
if (next.done) break;
|
|
878
|
+
const chunk = next.value;
|
|
879
|
+
if (!Buffer.isBuffer(chunk) && !(chunk instanceof Uint8Array)) throw new ArtifactReaderFailure("format", `ASAR entry did not return bytes: ${entryPath}`);
|
|
880
|
+
observedBytes += Buffer.isBuffer(chunk) ? chunk.length : chunk.byteLength;
|
|
881
|
+
if (expectedBytes !== undefined && observedBytes > expectedBytes) throw new ArtifactReaderFailure("integrity", `ASAR entry exceeded its declared size: ${entryPath}`);
|
|
882
|
+
yield chunk;
|
|
883
|
+
}
|
|
884
|
+
if (expectedBytes !== undefined && observedBytes !== expectedBytes) throw new ArtifactReaderFailure("integrity", `ASAR entry size disagrees with its header: ${entryPath}`);
|
|
885
|
+
} catch (cause) {
|
|
886
|
+
throw asarFailure$1(archivePath, `read ${entryPath}`, cause);
|
|
887
|
+
} finally {
|
|
888
|
+
try {
|
|
889
|
+
await iterator.return?.();
|
|
890
|
+
} catch {}
|
|
891
|
+
if (!source.destroyed) source.destroy();
|
|
892
|
+
}
|
|
893
|
+
})());
|
|
894
|
+
const closeSource = () => {
|
|
895
|
+
signal?.removeEventListener("abort", onAbort);
|
|
896
|
+
if (!source.destroyed) source.destroy();
|
|
897
|
+
};
|
|
898
|
+
const onAbort = () => {
|
|
899
|
+
closeSource();
|
|
900
|
+
output.destroy(new ArtifactReaderFailure("cancelled", "ASAR operation cancelled"));
|
|
901
|
+
};
|
|
902
|
+
output.once("close", closeSource);
|
|
903
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
904
|
+
if (signal?.aborted === true) onAbort();
|
|
905
|
+
return output;
|
|
906
|
+
};
|
|
907
|
+
abortIfNeeded$3 = (signal) => {
|
|
908
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "ASAR operation cancelled");
|
|
909
|
+
};
|
|
910
|
+
asarFailure$1 = (path, operation, cause) => {
|
|
911
|
+
if (cause instanceof ArtifactReaderFailure) return cause;
|
|
912
|
+
if (isFilesystemFailure$1(cause)) return new ArtifactReaderFailure("io", `Could not ${operation} ASAR at ${path}: ${cause.message}`, { cause });
|
|
913
|
+
return new ArtifactReaderFailure("format", `Malformed ASAR during ${operation}: ${path}`, { cause });
|
|
914
|
+
};
|
|
915
|
+
isFilesystemFailure$1 = (cause) => cause instanceof Error && "errno" in cause && typeof cause.errno === "number" && "syscall" in cause && typeof cause.syscall === "string";
|
|
916
|
+
})))();
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region dist/artifacts/AsarArtifactReader.js
|
|
921
|
+
var AsarArtifactReader, defaultRemoveSnapshot, asarUnpackedEntryFailure, isAsarFileMetadata, parseArchiveOffset, abortIfNeeded$2, waitForOperation, orderAsarListing, toArtifactPath, asarFailure, isFilesystemFailure, isMissingFile;
|
|
922
|
+
function init_AsarArtifactReader() {
|
|
923
|
+
return (init_AsarArtifactReader = __esmMin((() => {
|
|
924
|
+
init_ArtifactReader();
|
|
925
|
+
init_AsarEntryStream();
|
|
926
|
+
init_AsarHeader();
|
|
927
|
+
init_OwnedFileHandle();
|
|
928
|
+
init_readFileHandleChunks();
|
|
929
|
+
init_unicodeCodePointOrder();
|
|
930
|
+
AsarArtifactReader = class {
|
|
931
|
+
path;
|
|
932
|
+
options;
|
|
933
|
+
format = "asar";
|
|
934
|
+
#archiveSize;
|
|
935
|
+
#headerSize;
|
|
936
|
+
#entries = new Map();
|
|
937
|
+
#ownedHandles = new Map();
|
|
938
|
+
#snapshot;
|
|
939
|
+
#snapshotRoot;
|
|
940
|
+
#snapshotOperation = Promise.resolve();
|
|
941
|
+
constructor(path, options = {}) {
|
|
942
|
+
this.path = path;
|
|
943
|
+
this.options = options;
|
|
944
|
+
}
|
|
945
|
+
async *entries(signal) {
|
|
946
|
+
let paths;
|
|
947
|
+
try {
|
|
948
|
+
await this.prepareContainer(undefined, signal);
|
|
949
|
+
paths = await this.#withSnapshotOperation(async () => {
|
|
950
|
+
const snapshotPath = this.#snapshotPath();
|
|
951
|
+
this.#resetArchiveState();
|
|
952
|
+
this.#entries.clear();
|
|
953
|
+
const admitted = await this.#admitHeader(snapshotPath);
|
|
954
|
+
this.#archiveSize = admitted.archiveBytes;
|
|
955
|
+
this.#headerSize = admitted.headerBytes;
|
|
956
|
+
abortIfNeeded$2(signal);
|
|
957
|
+
const ordered = orderAsarListing(listPackage(snapshotPath, { isPack: false }));
|
|
958
|
+
const archiveMetadata = await lstat(snapshotPath);
|
|
959
|
+
if (!archiveMetadata.isFile() || archiveMetadata.isSymbolicLink()) throw new ArtifactReaderFailure("format", "ASAR container is not a regular file");
|
|
960
|
+
this.#archiveSize = archiveMetadata.size;
|
|
961
|
+
return ordered;
|
|
962
|
+
}, signal);
|
|
963
|
+
} catch (cause) {
|
|
964
|
+
throw asarFailure(this.path, "inventory", cause);
|
|
965
|
+
}
|
|
966
|
+
for (const { listed, path } of paths) {
|
|
967
|
+
abortIfNeeded$2(signal);
|
|
968
|
+
if (path.length === 0) continue;
|
|
969
|
+
const providerPath = listed.startsWith(sep) ? listed.slice(sep.length) : listed;
|
|
970
|
+
let metadata;
|
|
971
|
+
try {
|
|
972
|
+
metadata = statFile(this.#snapshotPath(), providerPath, false);
|
|
973
|
+
} catch (cause) {
|
|
974
|
+
throw asarFailure(this.path, `stat ${path}`, cause);
|
|
975
|
+
}
|
|
976
|
+
const kind = "files" in metadata ? "directory" : "link" in metadata ? "symlink" : "file";
|
|
977
|
+
const entry = {
|
|
978
|
+
path,
|
|
979
|
+
kind,
|
|
980
|
+
declaredSize: "size" in metadata ? metadata.size : null,
|
|
981
|
+
compressedSize: null,
|
|
982
|
+
executable: "executable" in metadata && metadata.executable,
|
|
983
|
+
encrypted: false,
|
|
984
|
+
byteOffset: null,
|
|
985
|
+
declaredSha256: "integrity" in metadata && metadata.integrity.algorithm === "SHA256" && /^[a-f0-9]{64}$/u.test(metadata.integrity.hash) ? metadata.integrity.hash : null,
|
|
986
|
+
unpacked: "unpacked" in metadata && metadata.unpacked === true,
|
|
987
|
+
limitations: kind === "symlink" ? ["ASAR symlink target was not followed or disclosed."] : [],
|
|
988
|
+
adapterKey: providerPath
|
|
989
|
+
};
|
|
990
|
+
if (kind === "file" && isAsarFileMetadata(metadata)) this.#entries.set(providerPath, {
|
|
991
|
+
metadata,
|
|
992
|
+
entry: copyArtifactEntry(entry)
|
|
993
|
+
});
|
|
994
|
+
yield entry;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
async #admitHeader(snapshotPath) {
|
|
998
|
+
const headerHandle = await this.#openOwned(snapshotPath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
999
|
+
let admission;
|
|
1000
|
+
try {
|
|
1001
|
+
admission = {
|
|
1002
|
+
ok: true,
|
|
1003
|
+
value: await admitAsarHeader(headerHandle)
|
|
1004
|
+
};
|
|
1005
|
+
} catch (cause) {
|
|
1006
|
+
admission = {
|
|
1007
|
+
ok: false,
|
|
1008
|
+
cause
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
try {
|
|
1012
|
+
await this.#closeOwnedHandle(headerHandle);
|
|
1013
|
+
} catch (cleanupCause) {
|
|
1014
|
+
if (!admission.ok) throw ArtifactReaderFailure.withCleanup(admission.cause, ArtifactReaderFailure.cleanupObservation(cleanupCause, snapshotPath));
|
|
1015
|
+
throw cleanupCause;
|
|
1016
|
+
}
|
|
1017
|
+
if (!admission.ok) throw admission.cause;
|
|
1018
|
+
return admission.value;
|
|
1019
|
+
}
|
|
1020
|
+
async open(entry, signal) {
|
|
1021
|
+
return this.#withSnapshotOperation(() => this.#openEntry(entry, signal), signal);
|
|
1022
|
+
}
|
|
1023
|
+
async #openEntry(entry, signal) {
|
|
1024
|
+
abortIfNeeded$2(signal);
|
|
1025
|
+
const state = this.#entries.get(entry.adapterKey);
|
|
1026
|
+
if (state === undefined && entry.kind !== "file") throw new ArtifactReaderFailure("format", "ASAR entry is not a regular file");
|
|
1027
|
+
if (state === undefined) throw new ArtifactReaderFailure("integrity", `ASAR entry was not produced by this reader: ${entry.path}`);
|
|
1028
|
+
if (!sameArtifactEntry(entry, state.entry)) throw new ArtifactReaderFailure("integrity", `ASAR entry metadata changed since inventory: ${state.entry.path}`);
|
|
1029
|
+
if (state.entry.unpacked) return this.#openUnpackedStream(state.entry, signal);
|
|
1030
|
+
return this.#openPackedStream(state, signal);
|
|
1031
|
+
}
|
|
1032
|
+
async #openPackedStream(state, signal) {
|
|
1033
|
+
const { metadata, entry: producedEntry } = state;
|
|
1034
|
+
const archiveSize = this.#archiveSize;
|
|
1035
|
+
const headerSize = this.#headerSize;
|
|
1036
|
+
const offset = metadata.offset === undefined ? undefined : parseArchiveOffset(metadata.offset);
|
|
1037
|
+
const start = offset === undefined || headerSize === undefined ? undefined : 8 + headerSize + offset;
|
|
1038
|
+
if (archiveSize === undefined || start === undefined || !Number.isSafeInteger(start) || metadata.size < 0 || !Number.isSafeInteger(metadata.size) || start > archiveSize || metadata.size > archiveSize - start) throw new ArtifactReaderFailure("format", `ASAR entry range is outside its container: ${producedEntry.path}`);
|
|
1039
|
+
const snapshotPath = this.#snapshotPath();
|
|
1040
|
+
let handle;
|
|
1041
|
+
try {
|
|
1042
|
+
const openedHandle = await this.#openOwned(snapshotPath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
1043
|
+
handle = openedHandle;
|
|
1044
|
+
const observed = await openedHandle.stat();
|
|
1045
|
+
abortIfNeeded$2(signal);
|
|
1046
|
+
if (!observed.isFile() || observed.size !== archiveSize) throw new ArtifactReaderFailure("integrity", `ASAR container changed before read: ${producedEntry.path}`);
|
|
1047
|
+
if (metadata.size === 0) {
|
|
1048
|
+
handle = undefined;
|
|
1049
|
+
await closeAsarHandle(() => this.#closeOwnedHandle(openedHandle), signal);
|
|
1050
|
+
return Readable.from([]);
|
|
1051
|
+
}
|
|
1052
|
+
const source = this.#ownedReadStream(openedHandle, {
|
|
1053
|
+
start,
|
|
1054
|
+
end: start + metadata.size - 1,
|
|
1055
|
+
signal
|
|
1056
|
+
});
|
|
1057
|
+
handle = undefined;
|
|
1058
|
+
const output = readValidatedAsarEntry(source, metadata.size, producedEntry.path, this.path, signal);
|
|
1059
|
+
this.#setOwnedOutput(openedHandle, output);
|
|
1060
|
+
return output;
|
|
1061
|
+
} catch (cause) {
|
|
1062
|
+
const failure = asarFailure(this.path, `read ${producedEntry.path}`, cause);
|
|
1063
|
+
if (handle !== undefined) {
|
|
1064
|
+
try {
|
|
1065
|
+
await this.#closeOwnedHandle(handle);
|
|
1066
|
+
} catch (cleanupCause) {
|
|
1067
|
+
throw ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, snapshotPath));
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
throw failure;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
/** Capture once per reader lifetime; bind all interpretation to these exact bytes. */
|
|
1074
|
+
async prepareContainer(expectedSha256, signal) {
|
|
1075
|
+
await this.#withSnapshotOperation(async () => {
|
|
1076
|
+
abortIfNeeded$2(signal);
|
|
1077
|
+
if (this.#snapshot === undefined && this.#snapshotRoot !== undefined) await this.#closeSnapshot();
|
|
1078
|
+
if (this.#snapshot === undefined) await this.#captureSnapshot(signal);
|
|
1079
|
+
if (expectedSha256 !== undefined && this.#snapshot?.sha256 !== expectedSha256) throw new ArtifactReaderFailure("integrity", `ASAR container changed before interpretation: ${this.path}`);
|
|
1080
|
+
}, signal);
|
|
1081
|
+
}
|
|
1082
|
+
/** Read the same captured container that supplies headers and packed members. */
|
|
1083
|
+
async openContainer(signal) {
|
|
1084
|
+
await this.prepareContainer(undefined, signal);
|
|
1085
|
+
return this.#withSnapshotOperation(async () => {
|
|
1086
|
+
abortIfNeeded$2(signal);
|
|
1087
|
+
const snapshotPath = this.#snapshotPath();
|
|
1088
|
+
const handle = await this.#openOwned(snapshotPath, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
1089
|
+
return this.#ownedReadStream(handle, { signal });
|
|
1090
|
+
}, signal);
|
|
1091
|
+
}
|
|
1092
|
+
async close() {
|
|
1093
|
+
await this.#withSnapshotOperation(() => this.#closeSnapshot());
|
|
1094
|
+
}
|
|
1095
|
+
async #captureSnapshot(signal) {
|
|
1096
|
+
let inputHandle;
|
|
1097
|
+
try {
|
|
1098
|
+
this.#snapshotRoot = await mkdtemp(join(tmpdir(), "rea-asar-snapshot-"));
|
|
1099
|
+
const snapshotPath = join(this.#snapshotRoot, "container.asar");
|
|
1100
|
+
const hash = createHash("sha256");
|
|
1101
|
+
inputHandle = await this.#openOwned(this.path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
1102
|
+
const source = this.#ownedReadStream(inputHandle, {
|
|
1103
|
+
signal,
|
|
1104
|
+
releaseOnClose: false
|
|
1105
|
+
});
|
|
1106
|
+
const digesting = new Transform({ transform(chunk, _encoding, callback) {
|
|
1107
|
+
hash.update(chunk);
|
|
1108
|
+
callback(null, chunk);
|
|
1109
|
+
} });
|
|
1110
|
+
await pipeline(source, digesting, createWriteStream(snapshotPath, {
|
|
1111
|
+
flags: "wx",
|
|
1112
|
+
mode: 384
|
|
1113
|
+
}), signal === undefined ? {} : { signal });
|
|
1114
|
+
const completedInput = inputHandle;
|
|
1115
|
+
inputHandle = undefined;
|
|
1116
|
+
await this.#closeOwnedHandle(completedInput);
|
|
1117
|
+
this.#snapshot = {
|
|
1118
|
+
path: snapshotPath,
|
|
1119
|
+
sha256: hash.digest("hex")
|
|
1120
|
+
};
|
|
1121
|
+
} catch (cause) {
|
|
1122
|
+
let failure = signal?.aborted === true ? new ArtifactReaderFailure("cancelled", "ASAR operation cancelled", { cause }) : asarFailure(this.path, "snapshot", cause);
|
|
1123
|
+
if (inputHandle !== undefined) {
|
|
1124
|
+
const failedInput = inputHandle;
|
|
1125
|
+
inputHandle = undefined;
|
|
1126
|
+
try {
|
|
1127
|
+
await this.#closeOwnedHandle(failedInput);
|
|
1128
|
+
} catch (cleanupCause) {
|
|
1129
|
+
failure = ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.path));
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
try {
|
|
1133
|
+
if (this.#ownedHandles.size === 0) await this.#closeSnapshot();
|
|
1134
|
+
} catch (cleanupCause) {
|
|
1135
|
+
throw ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.#snapshotRoot ?? this.path));
|
|
1136
|
+
}
|
|
1137
|
+
throw failure;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
async #closeSnapshot() {
|
|
1141
|
+
await this.#closeOwnedHandles();
|
|
1142
|
+
const root = this.#snapshotRoot;
|
|
1143
|
+
if (root !== undefined) {
|
|
1144
|
+
try {
|
|
1145
|
+
await (this.options.removeSnapshot ?? defaultRemoveSnapshot)(root);
|
|
1146
|
+
if (this.#snapshotRoot === root) this.#snapshotRoot = undefined;
|
|
1147
|
+
} catch (cause) {
|
|
1148
|
+
throw ArtifactReaderFailure.withCleanup(cause, {
|
|
1149
|
+
reason: `Could not remove ASAR snapshot: ${root}`,
|
|
1150
|
+
resources: [root]
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
if (root === undefined || this.#snapshotRoot === undefined) {
|
|
1155
|
+
if (this.#snapshot !== undefined) uncache(this.#snapshot.path);
|
|
1156
|
+
this.#snapshot = undefined;
|
|
1157
|
+
this.#resetArchiveState();
|
|
1158
|
+
this.#entries.clear();
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
async #withSnapshotOperation(operation, signal) {
|
|
1162
|
+
const previous = this.#snapshotOperation;
|
|
1163
|
+
let release;
|
|
1164
|
+
this.#snapshotOperation = new Promise((resolve) => {
|
|
1165
|
+
release = resolve;
|
|
1166
|
+
});
|
|
1167
|
+
try {
|
|
1168
|
+
await waitForOperation(previous, signal);
|
|
1169
|
+
} catch (cause) {
|
|
1170
|
+
void previous.then(release, release);
|
|
1171
|
+
throw cause;
|
|
1172
|
+
}
|
|
1173
|
+
try {
|
|
1174
|
+
abortIfNeeded$2(signal);
|
|
1175
|
+
return await operation();
|
|
1176
|
+
} finally {
|
|
1177
|
+
release();
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
#snapshotPath() {
|
|
1181
|
+
if (this.#snapshot === undefined) throw new ArtifactReaderFailure("integrity", "ASAR snapshot is not available");
|
|
1182
|
+
return this.#snapshot.path;
|
|
1183
|
+
}
|
|
1184
|
+
provenance() {
|
|
1185
|
+
return [];
|
|
1186
|
+
}
|
|
1187
|
+
async #openUnpackedStream(entry, signal) {
|
|
1188
|
+
const unpackedRoot = `${this.path}.unpacked`;
|
|
1189
|
+
let handle;
|
|
1190
|
+
try {
|
|
1191
|
+
const rootMetadata = await lstat(unpackedRoot);
|
|
1192
|
+
if (!rootMetadata.isDirectory() || rootMetadata.isSymbolicLink()) throw new ArtifactReaderFailure("path", "ASAR unpacked companion is not a regular directory");
|
|
1193
|
+
const canonicalRoot = await realpath(unpackedRoot);
|
|
1194
|
+
const candidate = join(unpackedRoot, entry.adapterKey);
|
|
1195
|
+
const canonical = await realpath(candidate);
|
|
1196
|
+
const relativePath = relative(canonicalRoot, canonical);
|
|
1197
|
+
if (relativePath === ".." || relativePath.startsWith(`..${sep}`) || isAbsolute(relativePath)) throw new ArtifactReaderFailure("path", `ASAR unpacked entry escaped its companion directory: ${entry.path}`);
|
|
1198
|
+
const pathMetadata = await lstat(candidate);
|
|
1199
|
+
if (!pathMetadata.isFile() || pathMetadata.isSymbolicLink()) throw new ArtifactReaderFailure("path", `ASAR unpacked entry is not a regular file: ${entry.path}`);
|
|
1200
|
+
handle = await (this.options.openUnpackedFile ?? open)(canonical, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
1201
|
+
const openedHandle = handle;
|
|
1202
|
+
this.#adoptHandle(openedHandle, canonical);
|
|
1203
|
+
const openedMetadata = await openedHandle.stat();
|
|
1204
|
+
if (!openedMetadata.isFile() || openedMetadata.dev !== pathMetadata.dev || openedMetadata.ino !== pathMetadata.ino) {
|
|
1205
|
+
throw new ArtifactReaderFailure("integrity", `ASAR unpacked entry changed before read: ${entry.path}`, {}, {
|
|
1206
|
+
logicalPath: entry.path,
|
|
1207
|
+
declaredSha256: entry.declaredSha256,
|
|
1208
|
+
calculatedSha256: null,
|
|
1209
|
+
unpacked: true
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
abortIfNeeded$2(signal);
|
|
1213
|
+
const source = this.#ownedReadStream(openedHandle, { start: 0 });
|
|
1214
|
+
handle = undefined;
|
|
1215
|
+
const output = readValidatedAsarEntry(source, undefined, entry.path, this.path, signal);
|
|
1216
|
+
this.#setOwnedOutput(openedHandle, output);
|
|
1217
|
+
return output;
|
|
1218
|
+
} catch (cause) {
|
|
1219
|
+
let failure = asarUnpackedEntryFailure(this.path, entry, cause);
|
|
1220
|
+
if (handle !== undefined && this.#ownedHandles.has(handle)) {
|
|
1221
|
+
try {
|
|
1222
|
+
await this.#closeOwnedHandle(handle);
|
|
1223
|
+
} catch (cleanupCause) {
|
|
1224
|
+
failure = ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.#ownedHandles.get(handle)?.path ?? entry.path));
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
throw failure;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
async #closeOwnedHandle(handle) {
|
|
1231
|
+
const owned = this.#ownedHandles.get(handle);
|
|
1232
|
+
if (owned === undefined) return;
|
|
1233
|
+
owned.output?.destroy();
|
|
1234
|
+
owned.source?.destroy();
|
|
1235
|
+
try {
|
|
1236
|
+
await owned.owner.close();
|
|
1237
|
+
} catch (cause) {
|
|
1238
|
+
throw ArtifactReaderFailure.withCleanup(cause, ArtifactReaderFailure.cleanupObservation(cause, owned.path));
|
|
1239
|
+
}
|
|
1240
|
+
this.#ownedHandles.delete(handle);
|
|
1241
|
+
}
|
|
1242
|
+
async #closeOwnedHandles() {
|
|
1243
|
+
let failure;
|
|
1244
|
+
for (const [handle, owned] of this.#ownedHandles) {
|
|
1245
|
+
try {
|
|
1246
|
+
await this.#closeOwnedHandle(handle);
|
|
1247
|
+
} catch (cause) {
|
|
1248
|
+
failure = ArtifactReaderFailure.withCleanup(failure ?? cause, ArtifactReaderFailure.cleanupObservation(cause, owned.path));
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
if (failure !== undefined) throw failure;
|
|
1252
|
+
}
|
|
1253
|
+
async #openOwned(path, flags) {
|
|
1254
|
+
const handle = await (this.options.openFile ?? open)(path, flags);
|
|
1255
|
+
this.#adoptHandle(handle, path);
|
|
1256
|
+
return handle;
|
|
1257
|
+
}
|
|
1258
|
+
#adoptHandle(handle, path) {
|
|
1259
|
+
this.#ownedHandles.set(handle, {
|
|
1260
|
+
path,
|
|
1261
|
+
owner: new OwnedFileHandle(handle)
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
#ownedReadStream(handle, options) {
|
|
1265
|
+
const { releaseOnClose, ...readOptions } = options;
|
|
1266
|
+
const source = readFileHandleChunks(handle, readOptions);
|
|
1267
|
+
const owned = this.#ownedHandles.get(handle);
|
|
1268
|
+
if (owned === undefined) throw new ArtifactReaderFailure("integrity", "ASAR handle has no owner");
|
|
1269
|
+
owned.source = source;
|
|
1270
|
+
owned.output = source;
|
|
1271
|
+
if (releaseOnClose !== false) source.once("close", () => {
|
|
1272
|
+
void this.#closeOwnedHandle(handle).catch(() => undefined);
|
|
1273
|
+
});
|
|
1274
|
+
return source;
|
|
1275
|
+
}
|
|
1276
|
+
#setOwnedOutput(handle, output) {
|
|
1277
|
+
const owned = this.#ownedHandles.get(handle);
|
|
1278
|
+
if (owned !== undefined) owned.output = output;
|
|
1279
|
+
}
|
|
1280
|
+
#resetArchiveState() {
|
|
1281
|
+
this.#archiveSize = undefined;
|
|
1282
|
+
this.#headerSize = undefined;
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
defaultRemoveSnapshot = (path) => rm(path, {
|
|
1286
|
+
recursive: true,
|
|
1287
|
+
force: true
|
|
1288
|
+
});
|
|
1289
|
+
asarUnpackedEntryFailure = (archivePath, entry, cause) => {
|
|
1290
|
+
if (cause instanceof ArtifactReaderFailure) return cause;
|
|
1291
|
+
if (entry.unpacked && isMissingFile(cause)) return new ArtifactReaderFailure("unavailable", `ASAR unpacked entry bytes are unavailable: ${entry.path}`, { cause }, {
|
|
1292
|
+
logicalPath: entry.path,
|
|
1293
|
+
declaredSha256: entry.declaredSha256,
|
|
1294
|
+
calculatedSha256: null,
|
|
1295
|
+
unpacked: true
|
|
1296
|
+
});
|
|
1297
|
+
return asarFailure(archivePath, `read ${entry.path}`, cause);
|
|
1298
|
+
};
|
|
1299
|
+
isAsarFileMetadata = (metadata) => "size" in metadata && typeof metadata.size === "number" && !("files" in metadata) && !("link" in metadata);
|
|
1300
|
+
parseArchiveOffset = (value) => {
|
|
1301
|
+
if (!/^(?:0|[1-9][0-9]*)$/u.test(value)) return undefined;
|
|
1302
|
+
const offset = Number(value);
|
|
1303
|
+
return Number.isSafeInteger(offset) ? offset : undefined;
|
|
1304
|
+
};
|
|
1305
|
+
abortIfNeeded$2 = (signal) => {
|
|
1306
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "ASAR operation cancelled");
|
|
1307
|
+
};
|
|
1308
|
+
waitForOperation = async (operation, signal) => {
|
|
1309
|
+
if (signal === undefined) return operation;
|
|
1310
|
+
abortIfNeeded$2(signal);
|
|
1311
|
+
await new Promise((resolve, reject) => {
|
|
1312
|
+
const removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
1313
|
+
const onAbort = () => {
|
|
1314
|
+
removeAbortListener();
|
|
1315
|
+
reject(new ArtifactReaderFailure("cancelled", "ASAR operation cancelled"));
|
|
1316
|
+
};
|
|
1317
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1318
|
+
operation.then(() => {
|
|
1319
|
+
removeAbortListener();
|
|
1320
|
+
resolve();
|
|
1321
|
+
}, (cause) => {
|
|
1322
|
+
removeAbortListener();
|
|
1323
|
+
reject(cause);
|
|
1324
|
+
});
|
|
1325
|
+
});
|
|
1326
|
+
};
|
|
1327
|
+
orderAsarListing = (listed, separator = sep) => listed.map((entry) => ({
|
|
1328
|
+
listed: entry,
|
|
1329
|
+
path: toArtifactPath(entry, separator)
|
|
1330
|
+
})).sort((left, right) => compareUnicodeCodePoints(left.path, right.path));
|
|
1331
|
+
toArtifactPath = (listed, separator) => {
|
|
1332
|
+
const portable = separator === "\\" ? listed.replaceAll("\\", "/") : listed;
|
|
1333
|
+
return portable.replace(/^\/+|\/+$/gu, "");
|
|
1334
|
+
};
|
|
1335
|
+
asarFailure = (path, operation, cause) => {
|
|
1336
|
+
if (cause instanceof ArtifactReaderFailure) return cause;
|
|
1337
|
+
if (isFilesystemFailure(cause)) return new ArtifactReaderFailure("io", `Could not ${operation} ASAR at ${path}: ${cause.message}`, { cause });
|
|
1338
|
+
return new ArtifactReaderFailure("format", `Malformed ASAR during ${operation}: ${path}`, { cause });
|
|
1339
|
+
};
|
|
1340
|
+
isFilesystemFailure = (cause) => cause instanceof Error && "errno" in cause && typeof cause.errno === "number" && "syscall" in cause && typeof cause.syscall === "string";
|
|
1341
|
+
isMissingFile = (cause) => typeof cause === "object" && cause !== null && "code" in cause && cause.code === "ENOENT";
|
|
1342
|
+
})))();
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
//#endregion
|
|
1346
|
+
//#region dist/artifacts/hostExecutableMarking.js
|
|
1347
|
+
var windowsLaunchableExtensions, hostExecutableMarking;
|
|
1348
|
+
function init_hostExecutableMarking() {
|
|
1349
|
+
return (init_hostExecutableMarking = __esmMin((() => {
|
|
1350
|
+
windowsLaunchableExtensions = new Set([
|
|
1351
|
+
".bat",
|
|
1352
|
+
".cmd",
|
|
1353
|
+
".com",
|
|
1354
|
+
".exe"
|
|
1355
|
+
]);
|
|
1356
|
+
hostExecutableMarking = (path, metadata, platform = process.platform) => platform === "win32" ? metadata.isFile() && windowsLaunchableExtensions.has(extname(path).toLowerCase()) : typeof metadata.mode === "bigint" ? (metadata.mode & 73n) !== 0n : (metadata.mode & 73) !== 0;
|
|
1357
|
+
})))();
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
//#endregion
|
|
1361
|
+
//#region dist/filesystem/OwnedDirectoryHandle.js
|
|
1362
|
+
var OwnedDirectoryHandle;
|
|
1363
|
+
function init_OwnedDirectoryHandle() {
|
|
1364
|
+
return (init_OwnedDirectoryHandle = __esmMin((() => {
|
|
1365
|
+
OwnedDirectoryHandle = class {
|
|
1366
|
+
handle;
|
|
1367
|
+
#state = { kind: "open" };
|
|
1368
|
+
constructor(handle) {
|
|
1369
|
+
this.handle = handle;
|
|
1370
|
+
}
|
|
1371
|
+
close() {
|
|
1372
|
+
if (this.#state.kind === "closed") return Promise.resolve();
|
|
1373
|
+
if (this.#state.kind === "closing") return this.#state.attempt;
|
|
1374
|
+
if (this.#state.kind === "failed") return Promise.reject(this.#state.cause);
|
|
1375
|
+
const attempt = Promise.resolve().then(async () => {
|
|
1376
|
+
try {
|
|
1377
|
+
await this.handle.close();
|
|
1378
|
+
this.#state = { kind: "closed" };
|
|
1379
|
+
} catch (cause) {
|
|
1380
|
+
this.#state = {
|
|
1381
|
+
kind: "failed",
|
|
1382
|
+
cause
|
|
1383
|
+
};
|
|
1384
|
+
throw cause;
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1387
|
+
this.#state = {
|
|
1388
|
+
kind: "closing",
|
|
1389
|
+
attempt
|
|
1390
|
+
};
|
|
1391
|
+
return attempt;
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
})))();
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
//#endregion
|
|
1398
|
+
//#region dist/artifacts/DirectoryArtifactReader.js
|
|
1399
|
+
var DirectoryArtifactReader, artifactEntry, safeArtifactSize, directoryIoFailure, failureMessage$1, mapStableFileRead, withDirectoryIoContext, abortIfNeeded$1, assertContainedDirectory;
|
|
1400
|
+
function init_DirectoryArtifactReader() {
|
|
1401
|
+
return (init_DirectoryArtifactReader = __esmMin((() => {
|
|
1402
|
+
init_ArtifactReader();
|
|
1403
|
+
init_hostExecutableMarking();
|
|
1404
|
+
init_OwnedDirectoryHandle();
|
|
1405
|
+
init_OwnedFileHandle();
|
|
1406
|
+
init_readFileHandleChunks();
|
|
1407
|
+
DirectoryArtifactReader = class {
|
|
1408
|
+
format = "directory";
|
|
1409
|
+
#rootPromise;
|
|
1410
|
+
#rootPath;
|
|
1411
|
+
#directories = new Set();
|
|
1412
|
+
#files = new Map();
|
|
1413
|
+
constructor(root) {
|
|
1414
|
+
this.#rootPath = root;
|
|
1415
|
+
}
|
|
1416
|
+
/** Enumerate entries, optionally restricting descent while retaining directories. */
|
|
1417
|
+
async *entries(signal, descendInto) {
|
|
1418
|
+
const root = await this.#resolveRoot();
|
|
1419
|
+
const pending = [root];
|
|
1420
|
+
while (pending.length > 0) {
|
|
1421
|
+
abortIfNeeded$1(signal);
|
|
1422
|
+
const directory = pending.pop();
|
|
1423
|
+
if (directory === undefined) break;
|
|
1424
|
+
await withDirectoryIoContext("inspect directory", directory, () => assertContainedDirectory(root, directory));
|
|
1425
|
+
for await (const entry of this.#readDirectory(directory, pending, signal, descendInto)) yield entry;
|
|
1426
|
+
await withDirectoryIoContext("inspect directory", directory, () => assertContainedDirectory(root, directory));
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
async #resolveRoot() {
|
|
1430
|
+
return (this.#rootPromise ??= realpath(this.#rootPath)).catch((cause) => {
|
|
1431
|
+
throw directoryIoFailure("resolve artifact root", this.#rootPath, cause);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
async *#readDirectory(directory, pending, signal, descendInto) {
|
|
1435
|
+
const root = await this.#resolveRoot();
|
|
1436
|
+
const handle = new OwnedDirectoryHandle(await opendir(directory).catch((cause) => {
|
|
1437
|
+
throw directoryIoFailure("open directory", directory, cause);
|
|
1438
|
+
}));
|
|
1439
|
+
this.#directories.add(handle);
|
|
1440
|
+
const childDirectories = [];
|
|
1441
|
+
let traversal = { kind: "complete" };
|
|
1442
|
+
try {
|
|
1443
|
+
for (;;) {
|
|
1444
|
+
const child = await handle.handle.read();
|
|
1445
|
+
if (child === null) break;
|
|
1446
|
+
abortIfNeeded$1(signal);
|
|
1447
|
+
const absolute = join(directory, child.name);
|
|
1448
|
+
const metadata = await lstat(absolute, { bigint: true }).catch((cause) => {
|
|
1449
|
+
throw directoryIoFailure("inspect entry", absolute, cause);
|
|
1450
|
+
});
|
|
1451
|
+
const path = relative(root, absolute).split(sep).join("/");
|
|
1452
|
+
const entry = artifactEntry(path, absolute, metadata);
|
|
1453
|
+
if (entry === undefined) continue;
|
|
1454
|
+
yield entry;
|
|
1455
|
+
if (entry.kind === "directory" && (descendInto?.(path) ?? true)) childDirectories.push(absolute);
|
|
1456
|
+
}
|
|
1457
|
+
} catch (cause) {
|
|
1458
|
+
traversal = {
|
|
1459
|
+
kind: "failed",
|
|
1460
|
+
cause: cause instanceof ArtifactReaderFailure ? cause : directoryIoFailure("read directory", directory, cause)
|
|
1461
|
+
};
|
|
1462
|
+
} finally {
|
|
1463
|
+
await this.#finishDirectory(handle, directory, traversal);
|
|
1464
|
+
}
|
|
1465
|
+
if (traversal.kind === "failed") throw traversal.cause;
|
|
1466
|
+
childDirectories.reverse();
|
|
1467
|
+
pending.push(...childDirectories);
|
|
1468
|
+
}
|
|
1469
|
+
async #finishDirectory(handle, path, traversal) {
|
|
1470
|
+
try {
|
|
1471
|
+
await handle.close();
|
|
1472
|
+
this.#directories.delete(handle);
|
|
1473
|
+
} catch (cause) {
|
|
1474
|
+
const closeFailure = directoryIoFailure("close directory", path, cause);
|
|
1475
|
+
if (traversal.kind === "failed") throw ArtifactReaderFailure.withCleanup(traversal.cause, ArtifactReaderFailure.cleanupObservation(closeFailure, path));
|
|
1476
|
+
throw closeFailure;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
async open(entry, signal) {
|
|
1480
|
+
abortIfNeeded$1(signal);
|
|
1481
|
+
if (entry.kind !== "file") throw new ArtifactReaderFailure("format", "Only regular files can be opened");
|
|
1482
|
+
const fileHandle = await open(entry.adapterKey, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK).catch((cause) => {
|
|
1483
|
+
throw directoryIoFailure("open entry", entry.adapterKey, cause);
|
|
1484
|
+
});
|
|
1485
|
+
const owner = new OwnedFileHandle(fileHandle);
|
|
1486
|
+
this.#files.set(owner, entry.adapterKey);
|
|
1487
|
+
try {
|
|
1488
|
+
const observed = await owner.handle.stat({ bigint: true }).catch((cause) => {
|
|
1489
|
+
throw directoryIoFailure("inspect opened entry", entry.adapterKey, cause);
|
|
1490
|
+
});
|
|
1491
|
+
if (!observed.isFile() || !sameArtifactSourceIdentity(entry.sourceIdentity, observed)) {
|
|
1492
|
+
throw new ArtifactReaderFailure("integrity", `Directory entry changed before open: ${entry.path}`);
|
|
1493
|
+
}
|
|
1494
|
+
abortIfNeeded$1(signal);
|
|
1495
|
+
const source = Readable.from(mapStableFileRead(owner.handle, entry, signal), { objectMode: false });
|
|
1496
|
+
source.once("close", () => {
|
|
1497
|
+
void this.#closeFile(owner).catch(() => undefined);
|
|
1498
|
+
});
|
|
1499
|
+
return source;
|
|
1500
|
+
} catch (cause) {
|
|
1501
|
+
try {
|
|
1502
|
+
await this.#closeFile(owner);
|
|
1503
|
+
} catch (closeCause) {
|
|
1504
|
+
throw ArtifactReaderFailure.withCleanup(cause, ArtifactReaderFailure.cleanupObservation(directoryIoFailure("close opened entry", entry.adapterKey, closeCause), entry.adapterKey));
|
|
1505
|
+
}
|
|
1506
|
+
throw cause;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
async close() {
|
|
1510
|
+
const failures = [];
|
|
1511
|
+
for (const [owner, path] of this.#files) {
|
|
1512
|
+
try {
|
|
1513
|
+
await this.#closeFile(owner);
|
|
1514
|
+
} catch (cause) {
|
|
1515
|
+
failures.push(directoryIoFailure("close opened entry", path, cause));
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
for (const owner of this.#directories) {
|
|
1519
|
+
try {
|
|
1520
|
+
await owner.close();
|
|
1521
|
+
this.#directories.delete(owner);
|
|
1522
|
+
} catch (cause) {
|
|
1523
|
+
failures.push(directoryIoFailure("close directory", owner.handle.path, cause));
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
if (failures.length > 0) {
|
|
1527
|
+
const reason = failures.map(failureMessage$1).join("; ");
|
|
1528
|
+
throw new ArtifactReaderFailure("io", `Directory artifact cleanup failed: ${reason}`, {
|
|
1529
|
+
cause: new AggregateError(failures),
|
|
1530
|
+
cleanup: {
|
|
1531
|
+
reason,
|
|
1532
|
+
resources: [...this.#files.values(), ...[...this.#directories].map((owner) => owner.handle.path)]
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
async #closeFile(owner) {
|
|
1538
|
+
await owner.close();
|
|
1539
|
+
this.#files.delete(owner);
|
|
1540
|
+
}
|
|
1541
|
+
provenance() {
|
|
1542
|
+
return [];
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
artifactEntry = (path, absolute, metadata) => {
|
|
1546
|
+
const kind = metadata.isSymbolicLink() ? "symlink" : metadata.isDirectory() ? "directory" : metadata.isFile() ? "file" : undefined;
|
|
1547
|
+
if (kind === undefined) return undefined;
|
|
1548
|
+
return {
|
|
1549
|
+
path,
|
|
1550
|
+
kind,
|
|
1551
|
+
declaredSize: kind === "file" ? safeArtifactSize(metadata.size) : null,
|
|
1552
|
+
compressedSize: null,
|
|
1553
|
+
executable: hostExecutableMarking(absolute, metadata),
|
|
1554
|
+
encrypted: false,
|
|
1555
|
+
byteOffset: null,
|
|
1556
|
+
declaredSha256: null,
|
|
1557
|
+
unpacked: false,
|
|
1558
|
+
limitations: kind === "symlink" ? ["Symlink target was not followed or disclosed."] : [],
|
|
1559
|
+
adapterKey: absolute,
|
|
1560
|
+
...kind === "file" ? { sourceIdentity: {
|
|
1561
|
+
device: metadata.dev,
|
|
1562
|
+
inode: metadata.ino,
|
|
1563
|
+
size: metadata.size,
|
|
1564
|
+
mode: metadata.mode,
|
|
1565
|
+
mtimeNs: metadata.mtimeNs,
|
|
1566
|
+
ctimeNs: metadata.ctimeNs
|
|
1567
|
+
} } : {}
|
|
1568
|
+
};
|
|
1569
|
+
};
|
|
1570
|
+
safeArtifactSize = (size) => {
|
|
1571
|
+
if (size < 0n || size > BigInt(Number.MAX_SAFE_INTEGER)) return null;
|
|
1572
|
+
return Number(size);
|
|
1573
|
+
};
|
|
1574
|
+
directoryIoFailure = (operation, path, cause) => {
|
|
1575
|
+
if (cause instanceof ArtifactReaderFailure) return cause;
|
|
1576
|
+
const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? ` (${cause.code})` : "";
|
|
1577
|
+
const detail = failureMessage$1(cause);
|
|
1578
|
+
return new ArtifactReaderFailure("io", `Could not ${operation} at ${path}${code}: ${detail}`, { cause });
|
|
1579
|
+
};
|
|
1580
|
+
failureMessage$1 = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
1581
|
+
mapStableFileRead = async function* (handle, entry, signal) {
|
|
1582
|
+
let bytes = 0n;
|
|
1583
|
+
try {
|
|
1584
|
+
const expectedBytes = entry.sourceIdentity?.size;
|
|
1585
|
+
if (expectedBytes === undefined) throw new ArtifactReaderFailure("integrity", `Directory entry has no captured file state: ${entry.path}`);
|
|
1586
|
+
for await (const chunk of readFileHandleChunks(handle, {
|
|
1587
|
+
end: expectedBytes,
|
|
1588
|
+
signal
|
|
1589
|
+
})) {
|
|
1590
|
+
abortIfNeeded$1(signal);
|
|
1591
|
+
bytes += BigInt(chunk.length);
|
|
1592
|
+
yield chunk;
|
|
1593
|
+
}
|
|
1594
|
+
abortIfNeeded$1(signal);
|
|
1595
|
+
const [opened, current] = await Promise.all([handle.stat({ bigint: true }), lstat(entry.adapterKey, { bigint: true })]);
|
|
1596
|
+
abortIfNeeded$1(signal);
|
|
1597
|
+
if (!opened.isFile() || !current.isFile() || !sameArtifactSourceIdentity(entry.sourceIdentity, opened) || !sameArtifactSourceIdentity(entry.sourceIdentity, current) || bytes !== expectedBytes) throw new ArtifactReaderFailure("integrity", `Directory entry changed during read: ${entry.path}`);
|
|
1598
|
+
} catch (cause) {
|
|
1599
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Directory artifact read cancelled", { cause });
|
|
1600
|
+
if (cause instanceof Error && "code" in cause && [
|
|
1601
|
+
"ENOENT",
|
|
1602
|
+
"ENOTDIR",
|
|
1603
|
+
"ELOOP"
|
|
1604
|
+
].includes(String(cause.code))) throw new ArtifactReaderFailure("integrity", `Directory entry changed during read: ${entry.path}`, { cause });
|
|
1605
|
+
if (!(cause instanceof ArtifactReaderFailure)) throw directoryIoFailure("validate read entry", entry.adapterKey, cause);
|
|
1606
|
+
throw cause;
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
withDirectoryIoContext = async (operation, path, action) => {
|
|
1610
|
+
try {
|
|
1611
|
+
return await action();
|
|
1612
|
+
} catch (cause) {
|
|
1613
|
+
throw directoryIoFailure(operation, path, cause);
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
abortIfNeeded$1 = (signal) => {
|
|
1617
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact traversal cancelled");
|
|
1618
|
+
};
|
|
1619
|
+
assertContainedDirectory = async (root, directory) => {
|
|
1620
|
+
const canonical = await realpath(directory);
|
|
1621
|
+
const fromRoot = relative(root, canonical);
|
|
1622
|
+
const metadata = await lstat(directory);
|
|
1623
|
+
if (metadata.isSymbolicLink() || !metadata.isDirectory() || fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) throw new ArtifactReaderFailure("path", "Directory traversal escaped or changed its artifact root");
|
|
1624
|
+
};
|
|
1625
|
+
})))();
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
//#endregion
|
|
1629
|
+
//#region dist/artifacts/ArtifactHash.js
|
|
1630
|
+
var ARTIFACT_CLASSIFICATION_PREFIX_BYTES, abortIfNeeded, hashReadable;
|
|
1631
|
+
function init_ArtifactHash() {
|
|
1632
|
+
return (init_ArtifactHash = __esmMin((() => {
|
|
1633
|
+
init_ArtifactReader();
|
|
1634
|
+
init_StreamBytes();
|
|
1635
|
+
ARTIFACT_CLASSIFICATION_PREFIX_BYTES = 8192;
|
|
1636
|
+
abortIfNeeded = (signal) => {
|
|
1637
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Artifact inventory cancelled");
|
|
1638
|
+
};
|
|
1639
|
+
hashReadable = async (stream, signal) => {
|
|
1640
|
+
const hash = createHash("sha256");
|
|
1641
|
+
const prefixes = [];
|
|
1642
|
+
let prefixBytes = 0;
|
|
1643
|
+
let bytes = 0;
|
|
1644
|
+
for await (const raw of stream) {
|
|
1645
|
+
abortIfNeeded(signal);
|
|
1646
|
+
const chunk = streamChunkToBuffer(raw);
|
|
1647
|
+
bytes += chunk.length;
|
|
1648
|
+
hash.update(chunk);
|
|
1649
|
+
if (prefixBytes < 8192) {
|
|
1650
|
+
const selected = chunk.subarray(0, ARTIFACT_CLASSIFICATION_PREFIX_BYTES - prefixBytes);
|
|
1651
|
+
prefixes.push(selected);
|
|
1652
|
+
prefixBytes += selected.length;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
return {
|
|
1656
|
+
sha256: hash.digest("hex"),
|
|
1657
|
+
bytes,
|
|
1658
|
+
prefix: Buffer.concat(prefixes)
|
|
1659
|
+
};
|
|
1660
|
+
};
|
|
1661
|
+
})))();
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
//#endregion
|
|
1665
|
+
//#region dist/artifacts/inventory/ArtifactGraphConstruction.js
|
|
1666
|
+
var indexOccurrencesByPath, createOccurrence, noteUnreadContainerSuffix, containerSuffixFamily, materializeDirectoryNodes, createRootNode, createArtifactNode, rootOccurrenceFor, rekeyOccurrences, createArtifactEdges, resolveOccurrenceParents, classifyArtifactPath, classifyArtifactContent, hasAsarHeader, artifactRoleForFormat, classifyArtifactBytes, relationFor, depth;
|
|
1667
|
+
function init_ArtifactGraphConstruction() {
|
|
1668
|
+
return (init_ArtifactGraphConstruction = __esmMin((() => {
|
|
1669
|
+
init_unicodeCodePointOrder();
|
|
1670
|
+
init_canonicalDigest();
|
|
1671
|
+
init_artifactIdentity();
|
|
1672
|
+
init_zipPackageFormat();
|
|
1673
|
+
init_dosMz();
|
|
1674
|
+
indexOccurrencesByPath = (occurrences) => {
|
|
1675
|
+
const byPath = new Map();
|
|
1676
|
+
for (const occurrence of occurrences) if (!byPath.has(occurrence.logical_path)) byPath.set(occurrence.logical_path, occurrence);
|
|
1677
|
+
return byPath;
|
|
1678
|
+
};
|
|
1679
|
+
createOccurrence = (entry, path, parent) => {
|
|
1680
|
+
const role = entry.kind === "directory" ? {
|
|
1681
|
+
kind: path.toLowerCase().endsWith(".framework") ? "framework" : "container",
|
|
1682
|
+
format: "directory"
|
|
1683
|
+
} : containerSuffixFamily(path) === undefined ? classifyArtifactPath(path) : {
|
|
1684
|
+
kind: "unknown",
|
|
1685
|
+
format: "unknown"
|
|
1686
|
+
};
|
|
1687
|
+
return {
|
|
1688
|
+
occurrence_id: `occ_${digestCanonicalValue({
|
|
1689
|
+
path,
|
|
1690
|
+
kind: entry.kind
|
|
1691
|
+
}, "Artifact")}`,
|
|
1692
|
+
artifact_id: null,
|
|
1693
|
+
parent_occurrence_id: parent,
|
|
1694
|
+
logical_path: path,
|
|
1695
|
+
entry_kind: entry.kind,
|
|
1696
|
+
artifact_kind: role.kind,
|
|
1697
|
+
artifact_format: role.format,
|
|
1698
|
+
declared_size: entry.declaredSize,
|
|
1699
|
+
compressed_size: entry.compressedSize,
|
|
1700
|
+
executable: entry.executable,
|
|
1701
|
+
encrypted: entry.encrypted,
|
|
1702
|
+
hash_status: entry.encrypted ? "unavailable" : "not-hashed",
|
|
1703
|
+
source_location: entry.byteOffset === null || entry.declaredSize === null ? null : {
|
|
1704
|
+
offset: entry.byteOffset,
|
|
1705
|
+
length: entry.declaredSize
|
|
1706
|
+
},
|
|
1707
|
+
limitations: [...entry.limitations]
|
|
1708
|
+
};
|
|
1709
|
+
};
|
|
1710
|
+
noteUnreadContainerSuffix = (occurrence) => {
|
|
1711
|
+
if (occurrence.entry_kind === "directory") return;
|
|
1712
|
+
const family = containerSuffixFamily(occurrence.logical_path);
|
|
1713
|
+
if (family === undefined) return;
|
|
1714
|
+
occurrence.limitations.push(`The path suffix suggests ${family.toUpperCase()}, but these bytes were not read, so the container family is unknown.`);
|
|
1715
|
+
};
|
|
1716
|
+
containerSuffixFamily = (path) => {
|
|
1717
|
+
const lower = path.toLowerCase();
|
|
1718
|
+
return lower.endsWith(".asar") ? "asar" : zipPackageFormatForPath(lower);
|
|
1719
|
+
};
|
|
1720
|
+
materializeDirectoryNodes = (occurrences, nodes) => {
|
|
1721
|
+
const directories = occurrences.filter(({ entry_kind: kind }) => kind === "directory").sort((left, right) => depth(right.logical_path) - depth(left.logical_path));
|
|
1722
|
+
const childrenByParent = new Map();
|
|
1723
|
+
for (const occurrence of occurrences) {
|
|
1724
|
+
if (occurrence.parent_occurrence_id === null) continue;
|
|
1725
|
+
const children = childrenByParent.get(occurrence.parent_occurrence_id);
|
|
1726
|
+
if (children === undefined) childrenByParent.set(occurrence.parent_occurrence_id, [occurrence]);
|
|
1727
|
+
else children.push(occurrence);
|
|
1728
|
+
}
|
|
1729
|
+
for (const directory of directories) {
|
|
1730
|
+
const children = (childrenByParent.get(directory.occurrence_id) ?? []).map(({ logical_path, artifact_id, entry_kind }) => ({
|
|
1731
|
+
name: logical_path.slice(directory.logical_path.length + 1),
|
|
1732
|
+
artifact_id,
|
|
1733
|
+
entry_kind
|
|
1734
|
+
})).sort((left, right) => compareUnicodeCodePoints(left.name, right.name));
|
|
1735
|
+
const node = createArtifactNode({
|
|
1736
|
+
sha256: digestCanonicalValue({
|
|
1737
|
+
kind: "directory",
|
|
1738
|
+
children
|
|
1739
|
+
}, "Artifact"),
|
|
1740
|
+
size: 0,
|
|
1741
|
+
format: "directory",
|
|
1742
|
+
contentState: "virtual"
|
|
1743
|
+
});
|
|
1744
|
+
nodes.set(node.artifact_id, node);
|
|
1745
|
+
directory.artifact_id = node.artifact_id;
|
|
1746
|
+
directory.hash_status = "verified";
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
createRootNode = (input) => createArtifactNode({
|
|
1750
|
+
sha256: input.digest?.sha256 ?? digestCanonicalValue({
|
|
1751
|
+
kind: "directory-root",
|
|
1752
|
+
children: input.occurrences.map(({ logical_path, artifact_id }) => ({
|
|
1753
|
+
logical_path,
|
|
1754
|
+
artifact_id
|
|
1755
|
+
})).sort((left, right) => compareUnicodeCodePoints(left.logical_path, right.logical_path))
|
|
1756
|
+
}, "Artifact"),
|
|
1757
|
+
size: input.digest?.bytes ?? 0,
|
|
1758
|
+
format: input.digest === null ? "directory" : classifyArtifactBytes(input.digest.prefix, input.digest.bytes),
|
|
1759
|
+
contentState: "materialized"
|
|
1760
|
+
});
|
|
1761
|
+
createArtifactNode = (input) => ({
|
|
1762
|
+
artifact_id: artifactIdForContent(input.sha256),
|
|
1763
|
+
format: input.format,
|
|
1764
|
+
sha256: input.sha256,
|
|
1765
|
+
size: input.size,
|
|
1766
|
+
media_type: null,
|
|
1767
|
+
architecture: null,
|
|
1768
|
+
content_state: input.contentState,
|
|
1769
|
+
limitations: []
|
|
1770
|
+
});
|
|
1771
|
+
rootOccurrenceFor = (node, metadata) => ({
|
|
1772
|
+
occurrence_id: occurrenceIdForLocation({
|
|
1773
|
+
rootArtifactId: node.artifact_id,
|
|
1774
|
+
logicalPath: ".",
|
|
1775
|
+
entryKind: metadata.format === "directory" ? "directory" : "file"
|
|
1776
|
+
}),
|
|
1777
|
+
artifact_id: node.artifact_id,
|
|
1778
|
+
parent_occurrence_id: null,
|
|
1779
|
+
logical_path: ".",
|
|
1780
|
+
entry_kind: metadata.format === "directory" ? "directory" : "file",
|
|
1781
|
+
artifact_kind: metadata.format === "directory" || isZipPackageFormat(metadata.format) || [
|
|
1782
|
+
"asar",
|
|
1783
|
+
"dmg",
|
|
1784
|
+
"pkg"
|
|
1785
|
+
].includes(metadata.format) ? "container" : artifactRoleForFormat(metadata.path, metadata.format).kind,
|
|
1786
|
+
artifact_format: metadata.format,
|
|
1787
|
+
declared_size: metadata.size,
|
|
1788
|
+
compressed_size: null,
|
|
1789
|
+
executable: metadata.executable,
|
|
1790
|
+
encrypted: false,
|
|
1791
|
+
hash_status: "verified",
|
|
1792
|
+
source_location: null,
|
|
1793
|
+
limitations: []
|
|
1794
|
+
});
|
|
1795
|
+
rekeyOccurrences = (rootArtifactId, occurrences) => {
|
|
1796
|
+
const replacements = new Map();
|
|
1797
|
+
for (const occurrence of occurrences) replacements.set(occurrence.occurrence_id, occurrenceIdForLocation({
|
|
1798
|
+
rootArtifactId,
|
|
1799
|
+
logicalPath: occurrence.logical_path,
|
|
1800
|
+
entryKind: occurrence.entry_kind
|
|
1801
|
+
}));
|
|
1802
|
+
for (const occurrence of occurrences) {
|
|
1803
|
+
occurrence.occurrence_id = replacements.get(occurrence.occurrence_id) ?? occurrence.occurrence_id;
|
|
1804
|
+
if (occurrence.parent_occurrence_id !== null) occurrence.parent_occurrence_id = replacements.get(occurrence.parent_occurrence_id) ?? occurrence.parent_occurrence_id;
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
createArtifactEdges = (rootArtifactId, occurrences, producer) => {
|
|
1808
|
+
const byId = new Map(occurrences.map((item) => [item.occurrence_id, item]));
|
|
1809
|
+
const byPath = indexOccurrencesByPath(occurrences);
|
|
1810
|
+
const edges = [];
|
|
1811
|
+
for (const occurrence of occurrences) {
|
|
1812
|
+
if (occurrence.parent_occurrence_id === null || occurrence.artifact_id === null) continue;
|
|
1813
|
+
const mappedSource = occurrence.logical_path.toLowerCase().endsWith(".map") ? byPath.get(occurrence.logical_path.slice(0, -".map".length)) : undefined;
|
|
1814
|
+
const parentArtifactId = mappedSource?.artifact_id ?? byId.get(occurrence.parent_occurrence_id)?.artifact_id ?? rootArtifactId;
|
|
1815
|
+
const semantic = {
|
|
1816
|
+
parent_artifact_id: parentArtifactId,
|
|
1817
|
+
relation: occurrence.entry_kind === "slice" ? "slice-of" : relationFor(occurrence.logical_path),
|
|
1818
|
+
occurrence_id: occurrence.occurrence_id
|
|
1819
|
+
};
|
|
1820
|
+
edges.push({
|
|
1821
|
+
edge_id: artifactEdgeId(semantic, occurrence),
|
|
1822
|
+
...semantic,
|
|
1823
|
+
producer: occurrence.entry_kind === "slice" ? producer ?? null : null,
|
|
1824
|
+
ordinal: edges.length
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
return edges;
|
|
1828
|
+
};
|
|
1829
|
+
resolveOccurrenceParents = (occurrences, byPath, expandedContainerIds) => {
|
|
1830
|
+
const root = { children: new Map() };
|
|
1831
|
+
for (const occurrence of byPath.values()) {
|
|
1832
|
+
if (occurrence.entry_kind !== "directory" && !expandedContainerIds.has(occurrence.occurrence_id)) continue;
|
|
1833
|
+
let branch = root;
|
|
1834
|
+
for (const segment of occurrence.logical_path.split("/")) {
|
|
1835
|
+
let child = branch.children.get(segment);
|
|
1836
|
+
if (child === undefined) {
|
|
1837
|
+
child = { children: new Map() };
|
|
1838
|
+
branch.children.set(segment, child);
|
|
1839
|
+
}
|
|
1840
|
+
branch = child;
|
|
1841
|
+
}
|
|
1842
|
+
branch.occurrence = occurrence;
|
|
1843
|
+
}
|
|
1844
|
+
for (const occurrence of occurrences) {
|
|
1845
|
+
const path = occurrence.logical_path;
|
|
1846
|
+
let branch = root;
|
|
1847
|
+
let parent;
|
|
1848
|
+
for (let start = 0;;) {
|
|
1849
|
+
const slash = path.indexOf("/", start);
|
|
1850
|
+
if (slash < 0) break;
|
|
1851
|
+
const segment = path.slice(start, slash);
|
|
1852
|
+
const child = branch.children.get(segment);
|
|
1853
|
+
if (child === undefined) break;
|
|
1854
|
+
branch = child;
|
|
1855
|
+
parent = branch.occurrence ?? parent;
|
|
1856
|
+
start = slash + 1;
|
|
1857
|
+
}
|
|
1858
|
+
occurrence.parent_occurrence_id = parent?.occurrence_id ?? null;
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
classifyArtifactPath = (path) => {
|
|
1862
|
+
const lower = path.toLowerCase();
|
|
1863
|
+
if (lower.endsWith(".map")) return {
|
|
1864
|
+
kind: "source-map",
|
|
1865
|
+
format: "source-map"
|
|
1866
|
+
};
|
|
1867
|
+
if (/\.(?:m?js|cjs)$/u.test(lower)) return {
|
|
1868
|
+
kind: "javascript",
|
|
1869
|
+
format: "javascript-bundle"
|
|
1870
|
+
};
|
|
1871
|
+
if (/\.framework(?:\/|$)/u.test(lower)) return {
|
|
1872
|
+
kind: "framework",
|
|
1873
|
+
format: "file"
|
|
1874
|
+
};
|
|
1875
|
+
if (/\.(?:node|dylib|so)$/u.test(lower)) return {
|
|
1876
|
+
kind: lower.endsWith(".node") ? "native-addon" : "dynamic-library",
|
|
1877
|
+
format: "file"
|
|
1878
|
+
};
|
|
1879
|
+
if (lower.endsWith(".plist")) return {
|
|
1880
|
+
kind: "plist",
|
|
1881
|
+
format: "plist"
|
|
1882
|
+
};
|
|
1883
|
+
if (lower.endsWith(".entitlements")) return {
|
|
1884
|
+
kind: "entitlements",
|
|
1885
|
+
format: "entitlements"
|
|
1886
|
+
};
|
|
1887
|
+
return {
|
|
1888
|
+
kind: "resource",
|
|
1889
|
+
format: "file"
|
|
1890
|
+
};
|
|
1891
|
+
};
|
|
1892
|
+
classifyArtifactContent = (path, prefix, fileSize = prefix.length) => {
|
|
1893
|
+
const format = classifyArtifactBytes(prefix, fileSize);
|
|
1894
|
+
if (format === "file" && path.toLowerCase().endsWith(".asar") && hasAsarHeader(prefix)) return {
|
|
1895
|
+
kind: "container",
|
|
1896
|
+
format: "asar"
|
|
1897
|
+
};
|
|
1898
|
+
return artifactRoleForFormat(path, format);
|
|
1899
|
+
};
|
|
1900
|
+
hasAsarHeader = (prefix) => {
|
|
1901
|
+
if (prefix.length < 17 || prefix.readUInt32LE(0) !== 4) return false;
|
|
1902
|
+
const headerSize = prefix.readUInt32LE(4);
|
|
1903
|
+
const payloadSize = prefix.readUInt32LE(8);
|
|
1904
|
+
if (headerSize < 16 || payloadSize !== headerSize - 4) return false;
|
|
1905
|
+
const stringLength = prefix.readUInt32LE(12);
|
|
1906
|
+
return stringLength >= 2 && stringLength <= payloadSize - 4 && prefix[16] === 123;
|
|
1907
|
+
};
|
|
1908
|
+
artifactRoleForFormat = (path, format) => {
|
|
1909
|
+
const byPath = classifyArtifactPath(path);
|
|
1910
|
+
if (format === "file" || format === byPath.format) return byPath;
|
|
1911
|
+
if (format === "unknown") return {
|
|
1912
|
+
kind: "unknown",
|
|
1913
|
+
format
|
|
1914
|
+
};
|
|
1915
|
+
if (format === "zip") return {
|
|
1916
|
+
kind: "container",
|
|
1917
|
+
format: zipPackageFormatForPath(path) ?? format
|
|
1918
|
+
};
|
|
1919
|
+
if (format === "plist") return {
|
|
1920
|
+
kind: "plist",
|
|
1921
|
+
format
|
|
1922
|
+
};
|
|
1923
|
+
return {
|
|
1924
|
+
kind: ["native-addon", "dynamic-library"].includes(byPath.kind) ? byPath.kind : "executable",
|
|
1925
|
+
format
|
|
1926
|
+
};
|
|
1927
|
+
};
|
|
1928
|
+
classifyArtifactBytes = (prefix, fileSize = prefix.length) => {
|
|
1929
|
+
if (hasZipSignature(prefix)) return "zip";
|
|
1930
|
+
if (prefix.subarray(0, 8).equals(Buffer.from("bplist00"))) return "plist";
|
|
1931
|
+
if (prefix.length >= 4) {
|
|
1932
|
+
const magic = prefix.readUInt32BE(0);
|
|
1933
|
+
if ([
|
|
1934
|
+
3405691582,
|
|
1935
|
+
3199925962,
|
|
1936
|
+
3405691583,
|
|
1937
|
+
3216703178
|
|
1938
|
+
].includes(magic)) return "mach-o-universal";
|
|
1939
|
+
if ([
|
|
1940
|
+
4277009102,
|
|
1941
|
+
4277009103,
|
|
1942
|
+
3472551422,
|
|
1943
|
+
3489328638
|
|
1944
|
+
].includes(magic)) return "mach-o";
|
|
1945
|
+
if (prefix.subarray(0, 4).equals(Buffer.from([
|
|
1946
|
+
127,
|
|
1947
|
+
69,
|
|
1948
|
+
76,
|
|
1949
|
+
70
|
|
1950
|
+
]))) return "elf";
|
|
1951
|
+
}
|
|
1952
|
+
if (prefix.length >= 2 && prefix[0] === 77 && prefix[1] === 90) {
|
|
1953
|
+
if (!Number.isSafeInteger(fileSize) || fileSize < prefix.length || prefix.length < Math.min(fileSize, 64)) return "unknown";
|
|
1954
|
+
const windowsOffset = mzWindowsHeaderOffset(prefix);
|
|
1955
|
+
if (windowsOffset !== null) {
|
|
1956
|
+
if (windowsOffset >= 64 && windowsOffset <= prefix.length - 4 && prefix.subarray(windowsOffset, windowsOffset + 4).equals(Buffer.from([
|
|
1957
|
+
80,
|
|
1958
|
+
69,
|
|
1959
|
+
0,
|
|
1960
|
+
0
|
|
1961
|
+
]))) return "pe";
|
|
1962
|
+
} else if (parseDosMzHeader(prefix, fileSize).ok) return "dos-mz";
|
|
1963
|
+
return "unknown";
|
|
1964
|
+
}
|
|
1965
|
+
return "file";
|
|
1966
|
+
};
|
|
1967
|
+
relationFor = (path) => {
|
|
1968
|
+
const lower = path.toLowerCase();
|
|
1969
|
+
if (lower.endsWith(".map")) return "maps-source";
|
|
1970
|
+
if (lower.includes(".framework/")) return "embeds";
|
|
1971
|
+
return "contains";
|
|
1972
|
+
};
|
|
1973
|
+
depth = (path) => path.split("/").length;
|
|
1974
|
+
})))();
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
//#endregion
|
|
1978
|
+
//#region dist/artifacts/inventory/hashStableRootArtifact.js
|
|
1979
|
+
var openRootArtifact, hashStableRootArtifact, hashStableRootArtifactHandle;
|
|
1980
|
+
function init_hashStableRootArtifact() {
|
|
1981
|
+
return (init_hashStableRootArtifact = __esmMin((() => {
|
|
1982
|
+
init_readFileHandleChunks();
|
|
1983
|
+
init_OwnedFileHandle();
|
|
1984
|
+
init_ArtifactReader();
|
|
1985
|
+
init_RegularFile();
|
|
1986
|
+
init_ArtifactHash();
|
|
1987
|
+
openRootArtifact = async (path, resourceScope, signal) => {
|
|
1988
|
+
try {
|
|
1989
|
+
return new OwnedFileHandle(await openRegularFile(path, {
|
|
1990
|
+
symlinks: "reject",
|
|
1991
|
+
signal
|
|
1992
|
+
}));
|
|
1993
|
+
} catch (cause) {
|
|
1994
|
+
const primary = cause instanceof RegularFileAdmissionFailure ? cause.cause : cause;
|
|
1995
|
+
const failure = primary instanceof NonRegularFileReadError ? new ArtifactReaderFailure("format", `Artifact root is not a regular file: ${path}`, { cause: primary }) : primary;
|
|
1996
|
+
if (cause instanceof RegularFileAdmissionFailure) {
|
|
1997
|
+
const resource = `root artifact descriptor for ${path}`;
|
|
1998
|
+
const cleanup = await resourceScope.release({
|
|
1999
|
+
kind: "file-handle",
|
|
2000
|
+
resource,
|
|
2001
|
+
handle: cause.owner
|
|
2002
|
+
});
|
|
2003
|
+
if (cleanup.kind === "failed") throw ArtifactReaderFailure.withCleanup(failure, ArtifactReaderFailure.cleanupObservation(cleanup.cause, resource));
|
|
2004
|
+
}
|
|
2005
|
+
throw failure;
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
hashStableRootArtifact = async (path, resourceScope, signal) => {
|
|
2009
|
+
const owner = await openRootArtifact(path, resourceScope, signal);
|
|
2010
|
+
const handle = owner.handle;
|
|
2011
|
+
let outcome;
|
|
2012
|
+
try {
|
|
2013
|
+
const initial = await handle.stat();
|
|
2014
|
+
outcome = {
|
|
2015
|
+
kind: "completed",
|
|
2016
|
+
value: await hashStableRootArtifactHandle(path, handle, initial, signal)
|
|
2017
|
+
};
|
|
2018
|
+
} catch (cause) {
|
|
2019
|
+
outcome = {
|
|
2020
|
+
kind: "failed",
|
|
2021
|
+
cause
|
|
2022
|
+
};
|
|
2023
|
+
}
|
|
2024
|
+
const resource = `root artifact descriptor for ${path}`;
|
|
2025
|
+
const cleanup = await resourceScope.release({
|
|
2026
|
+
kind: "file-handle",
|
|
2027
|
+
resource,
|
|
2028
|
+
handle: owner
|
|
2029
|
+
});
|
|
2030
|
+
if (cleanup.kind === "failed") throw ArtifactReaderFailure.withCleanup(outcome.kind === "failed" ? outcome.cause : cleanup.cause, ArtifactReaderFailure.cleanupObservation(cleanup.cause, resource));
|
|
2031
|
+
if (outcome.kind === "failed") throw outcome.cause;
|
|
2032
|
+
return outcome.value;
|
|
2033
|
+
};
|
|
2034
|
+
hashStableRootArtifactHandle = async (path, handle, initial, signal) => {
|
|
2035
|
+
const digest = await hashReadable(readFileHandleChunks(handle, {
|
|
2036
|
+
start: 0,
|
|
2037
|
+
end: initial.size
|
|
2038
|
+
}), signal);
|
|
2039
|
+
abortIfNeeded(signal);
|
|
2040
|
+
const [opened, currentPath] = await Promise.all([handle.stat(), lstat(path)]);
|
|
2041
|
+
if (!sameRegularFileState(initial, opened) || !sameRegularFileState(initial, currentPath) || digest.bytes !== initial.size) throw new ArtifactReaderFailure("integrity", `Root artifact changed during inventory: ${path}`);
|
|
2042
|
+
return digest;
|
|
2043
|
+
};
|
|
2044
|
+
})))();
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
//#endregion
|
|
2048
|
+
//#region dist/artifacts/inventory/classify.js
|
|
2049
|
+
var classifyAndHashRoot, classifyAndHashRootForInventory, classifyRootFormat, zipRootPackageFormat, hasKolyTrailer;
|
|
2050
|
+
function init_classify() {
|
|
2051
|
+
return (init_classify = __esmMin((() => {
|
|
2052
|
+
init_RegularFile();
|
|
2053
|
+
init_ArtifactGraphConstruction();
|
|
2054
|
+
init_ArtifactHash();
|
|
2055
|
+
init_zipPackageFormat();
|
|
2056
|
+
init_ArtifactReader();
|
|
2057
|
+
init_hashStableRootArtifact();
|
|
2058
|
+
classifyAndHashRoot = async (path, directory, expectedMetadata, options) => {
|
|
2059
|
+
return options.resourceScope.run(async () => {
|
|
2060
|
+
const result = await classifyAndHashRootForInventory(path, directory, expectedMetadata, options);
|
|
2061
|
+
const rootSource = result.rootSource;
|
|
2062
|
+
if (rootSource !== undefined) {
|
|
2063
|
+
const owner = {
|
|
2064
|
+
kind: "file-handle",
|
|
2065
|
+
handle: rootSource.owner,
|
|
2066
|
+
resource: `root artifact descriptor for ${path}`
|
|
2067
|
+
};
|
|
2068
|
+
const cleanupAttempt = await options.resourceScope.release(owner);
|
|
2069
|
+
if (cleanupAttempt.kind === "failed") throw ArtifactReaderFailure.withCleanup(cleanupAttempt.cause, ArtifactReaderFailure.cleanupObservation(cleanupAttempt.cause, owner.resource));
|
|
2070
|
+
}
|
|
2071
|
+
return {
|
|
2072
|
+
format: result.format,
|
|
2073
|
+
digest: result.digest
|
|
2074
|
+
};
|
|
2075
|
+
});
|
|
2076
|
+
};
|
|
2077
|
+
classifyAndHashRootForInventory = async (path, directory, expectedMetadata, options) => {
|
|
2078
|
+
if (directory) return {
|
|
2079
|
+
format: "directory",
|
|
2080
|
+
digest: null,
|
|
2081
|
+
rootSource: undefined
|
|
2082
|
+
};
|
|
2083
|
+
const ownedHandle = await openRootArtifact(path, options.resourceScope, options.signal);
|
|
2084
|
+
const handle = ownedHandle.handle;
|
|
2085
|
+
const owner = {
|
|
2086
|
+
kind: "file-handle",
|
|
2087
|
+
handle: ownedHandle,
|
|
2088
|
+
resource: `root artifact descriptor for ${path}`
|
|
2089
|
+
};
|
|
2090
|
+
let outcome;
|
|
2091
|
+
try {
|
|
2092
|
+
const initial = await handle.stat();
|
|
2093
|
+
if (!sameRegularFileState(expectedMetadata, initial)) throw new ArtifactReaderFailure("integrity", `Root artifact changed before inventory: ${path}`);
|
|
2094
|
+
const format = await classifyRootFormat(path, handle);
|
|
2095
|
+
const digest = await hashStableRootArtifactHandle(path, handle, initial, options.signal);
|
|
2096
|
+
const retainSource = isZipPackageFormat(format) || format === "mach-o-universal";
|
|
2097
|
+
outcome = {
|
|
2098
|
+
kind: "completed",
|
|
2099
|
+
value: {
|
|
2100
|
+
format,
|
|
2101
|
+
digest,
|
|
2102
|
+
rootSource: retainSource ? {
|
|
2103
|
+
handle,
|
|
2104
|
+
initial,
|
|
2105
|
+
owner: ownedHandle
|
|
2106
|
+
} : undefined
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
} catch (cause) {
|
|
2110
|
+
outcome = {
|
|
2111
|
+
kind: "failed",
|
|
2112
|
+
cause
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
if (outcome.kind === "failed" || outcome.value.rootSource === undefined) {
|
|
2116
|
+
const cleanupAttempt = await options.resourceScope.release(owner);
|
|
2117
|
+
if (cleanupAttempt.kind === "failed") throw ArtifactReaderFailure.withCleanup(outcome.kind === "failed" ? outcome.cause : cleanupAttempt.cause, ArtifactReaderFailure.cleanupObservation(cleanupAttempt.cause, owner.resource));
|
|
2118
|
+
}
|
|
2119
|
+
if (outcome.kind === "failed") throw outcome.cause;
|
|
2120
|
+
return outcome.value;
|
|
2121
|
+
};
|
|
2122
|
+
classifyRootFormat = async (path, handle) => {
|
|
2123
|
+
const magic = Buffer.alloc(ARTIFACT_CLASSIFICATION_PREFIX_BYTES);
|
|
2124
|
+
const observed = await handle.read(magic, 0, magic.length, 0);
|
|
2125
|
+
const prefix = magic.subarray(0, observed.bytesRead);
|
|
2126
|
+
const lower = path.toLowerCase();
|
|
2127
|
+
if (hasZipSignature(prefix)) return zipRootPackageFormat(lower);
|
|
2128
|
+
if (lower.endsWith(".pkg") && prefix.subarray(0, 4).equals(Buffer.from("xar!"))) return "pkg";
|
|
2129
|
+
if (lower.endsWith(".dmg") && await hasKolyTrailer(handle)) return "dmg";
|
|
2130
|
+
return classifyArtifactContent(path, prefix, (await handle.stat()).size).format;
|
|
2131
|
+
};
|
|
2132
|
+
zipRootPackageFormat = (lower) => lower.endsWith(".app") ? "app-pack" : zipPackageFormatForPath(lower) ?? "zip";
|
|
2133
|
+
hasKolyTrailer = async (handle) => {
|
|
2134
|
+
const size = (await handle.stat()).size;
|
|
2135
|
+
if (size < 512) return false;
|
|
2136
|
+
const trailer = Buffer.alloc(4);
|
|
2137
|
+
const read = await handle.read(trailer, 0, trailer.length, size - 512);
|
|
2138
|
+
return read.bytesRead === 4 && trailer.equals(Buffer.from("koly"));
|
|
2139
|
+
};
|
|
2140
|
+
})))();
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
//#endregion
|
|
2144
|
+
//#region dist/artifacts/apple/MachoLoadCommandReader.js
|
|
2145
|
+
var MAX_LOAD_COMMAND_BYTES, MAX_FAT_ARCHITECTURES, KNOWN_CPU_TYPES, MH_MAGIC, MH_MAGIC_64, MH_CIGAM, MH_CIGAM_64, FAT_MAGIC, FAT_MAGIC_64, FAT_CIGAM, FAT_CIGAM_64, LC_ID_DYLIB, LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LAZY_LOAD_DYLIB, LC_LOAD_UPWARD_DYLIB, LC_RPATH, LC_DYLD_ENVIRONMENT, LC_CODE_SIGNATURE, LC_VERSION_MIN_MACOSX, LC_VERSION_MIN_IPHONEOS, LC_VERSION_MIN_TVOS, LC_VERSION_MIN_WATCHOS, LC_BUILD_VERSION, PLATFORM_MACOS, PLATFORM_IOS, PLATFORM_TVOS, PLATFORM_WATCHOS, PLATFORM_IOSSIMULATOR, PLATFORM_TVOSSIMULATOR, PLATFORM_WATCHOSSIMULATOR, CPU_TYPE_I386, CPU_TYPE_X86_64, legacyVersionMinPlatform, DYLIB_USE_MARKER, DYLIB_USE_WEAK_LINK, DYLIB_USE_REEXPORT, DYLIB_USE_UPWARD, DYLIB_USE_DELAYED_INIT, DEPENDENCY_COMMANDS, MachoFormatIssue, hasMachoMagic, readMachoImage, readFatSlices, readSlice, decodeCommands, decodeCommand, decodeDependency, commandString, readExact, CPU_ARCH_ABI64, CPU_ARCH_ABI64_32, CPU_TYPE_X86, CPU_TYPE_ARM, CPU_SUBTYPE_MASK, CPU_SUBTYPE_ARM64E, CPU_SUBTYPE_ARM64E_X1, CPU_SUBTYPE_X86_64_H, architectureName, fileTypeName, version, swap, viewOf;
|
|
2146
|
+
function init_MachoLoadCommandReader() {
|
|
2147
|
+
return (init_MachoLoadCommandReader = __esmMin((() => {
|
|
2148
|
+
init_machoContainer();
|
|
2149
|
+
MAX_LOAD_COMMAND_BYTES = 16 * 1024 * 1024;
|
|
2150
|
+
MAX_FAT_ARCHITECTURES = 128;
|
|
2151
|
+
KNOWN_CPU_TYPES = [
|
|
2152
|
+
7,
|
|
2153
|
+
16777223,
|
|
2154
|
+
12,
|
|
2155
|
+
16777228,
|
|
2156
|
+
33554444,
|
|
2157
|
+
18,
|
|
2158
|
+
16777234
|
|
2159
|
+
];
|
|
2160
|
+
MH_MAGIC = 4277009102;
|
|
2161
|
+
MH_MAGIC_64 = 4277009103;
|
|
2162
|
+
MH_CIGAM = 3472551422;
|
|
2163
|
+
MH_CIGAM_64 = 3489328638;
|
|
2164
|
+
FAT_MAGIC = 3405691582;
|
|
2165
|
+
FAT_MAGIC_64 = 3405691583;
|
|
2166
|
+
FAT_CIGAM = 3199925962;
|
|
2167
|
+
FAT_CIGAM_64 = 3216703178;
|
|
2168
|
+
LC_ID_DYLIB = 13;
|
|
2169
|
+
LC_LOAD_DYLIB = 12;
|
|
2170
|
+
LC_LOAD_WEAK_DYLIB = 2147483672;
|
|
2171
|
+
LC_REEXPORT_DYLIB = 2147483679;
|
|
2172
|
+
LC_LAZY_LOAD_DYLIB = 32;
|
|
2173
|
+
LC_LOAD_UPWARD_DYLIB = 2147483683;
|
|
2174
|
+
LC_RPATH = 2147483676;
|
|
2175
|
+
LC_DYLD_ENVIRONMENT = 39;
|
|
2176
|
+
LC_CODE_SIGNATURE = 29;
|
|
2177
|
+
LC_VERSION_MIN_MACOSX = 36;
|
|
2178
|
+
LC_VERSION_MIN_IPHONEOS = 37;
|
|
2179
|
+
LC_VERSION_MIN_TVOS = 47;
|
|
2180
|
+
LC_VERSION_MIN_WATCHOS = 48;
|
|
2181
|
+
LC_BUILD_VERSION = 50;
|
|
2182
|
+
PLATFORM_MACOS = 1;
|
|
2183
|
+
PLATFORM_IOS = 2;
|
|
2184
|
+
PLATFORM_TVOS = 3;
|
|
2185
|
+
PLATFORM_WATCHOS = 4;
|
|
2186
|
+
PLATFORM_IOSSIMULATOR = 7;
|
|
2187
|
+
PLATFORM_TVOSSIMULATOR = 8;
|
|
2188
|
+
PLATFORM_WATCHOSSIMULATOR = 9;
|
|
2189
|
+
CPU_TYPE_I386 = 7;
|
|
2190
|
+
CPU_TYPE_X86_64 = 16777223;
|
|
2191
|
+
legacyVersionMinPlatform = (command, cpuType) => {
|
|
2192
|
+
const isIntel = cpuType === CPU_TYPE_I386 || cpuType === CPU_TYPE_X86_64;
|
|
2193
|
+
switch (command) {
|
|
2194
|
+
case LC_VERSION_MIN_MACOSX: return PLATFORM_MACOS;
|
|
2195
|
+
case LC_VERSION_MIN_IPHONEOS: return isIntel ? PLATFORM_IOSSIMULATOR : PLATFORM_IOS;
|
|
2196
|
+
case LC_VERSION_MIN_TVOS: return cpuType === CPU_TYPE_X86_64 ? PLATFORM_TVOSSIMULATOR : PLATFORM_TVOS;
|
|
2197
|
+
case LC_VERSION_MIN_WATCHOS: return isIntel ? PLATFORM_WATCHOSSIMULATOR : PLATFORM_WATCHOS;
|
|
2198
|
+
default: return undefined;
|
|
2199
|
+
}
|
|
2200
|
+
};
|
|
2201
|
+
DYLIB_USE_MARKER = 443815936;
|
|
2202
|
+
DYLIB_USE_WEAK_LINK = 1;
|
|
2203
|
+
DYLIB_USE_REEXPORT = 2;
|
|
2204
|
+
DYLIB_USE_UPWARD = 4;
|
|
2205
|
+
DYLIB_USE_DELAYED_INIT = 8;
|
|
2206
|
+
DEPENDENCY_COMMANDS = new Map([
|
|
2207
|
+
[LC_LOAD_DYLIB, "LC_LOAD_DYLIB"],
|
|
2208
|
+
[LC_LOAD_WEAK_DYLIB, "LC_LOAD_WEAK_DYLIB"],
|
|
2209
|
+
[LC_REEXPORT_DYLIB, "LC_REEXPORT_DYLIB"],
|
|
2210
|
+
[LC_LAZY_LOAD_DYLIB, "LC_LAZY_LOAD_DYLIB"],
|
|
2211
|
+
[LC_LOAD_UPWARD_DYLIB, "LC_LOAD_UPWARD_DYLIB"]
|
|
2212
|
+
]);
|
|
2213
|
+
MachoFormatIssue = class extends Error {
|
|
2214
|
+
status;
|
|
2215
|
+
constructor(status, message) {
|
|
2216
|
+
super(message);
|
|
2217
|
+
this.status = status;
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
hasMachoMagic = (head) => {
|
|
2221
|
+
if (head.byteLength < 4) return false;
|
|
2222
|
+
const magic = new DataView(head.buffer, head.byteOffset, head.byteLength).getUint32(0, false);
|
|
2223
|
+
return [
|
|
2224
|
+
MH_MAGIC,
|
|
2225
|
+
MH_MAGIC_64,
|
|
2226
|
+
MH_CIGAM,
|
|
2227
|
+
MH_CIGAM_64,
|
|
2228
|
+
FAT_MAGIC,
|
|
2229
|
+
FAT_MAGIC_64,
|
|
2230
|
+
FAT_CIGAM,
|
|
2231
|
+
FAT_CIGAM_64
|
|
2232
|
+
].includes(magic);
|
|
2233
|
+
};
|
|
2234
|
+
readMachoImage = async (readAt, size) => {
|
|
2235
|
+
try {
|
|
2236
|
+
const head = await readAt(0, Math.min(size, 8));
|
|
2237
|
+
if (head.byteLength < 8) return hasMachoMagic(head) ? {
|
|
2238
|
+
status: "malformed",
|
|
2239
|
+
reason: "Mach-O header is truncated"
|
|
2240
|
+
} : { status: "not-mach-o" };
|
|
2241
|
+
const view = viewOf(head);
|
|
2242
|
+
const magic = view.getUint32(0, false);
|
|
2243
|
+
if ([
|
|
2244
|
+
FAT_MAGIC,
|
|
2245
|
+
FAT_MAGIC_64,
|
|
2246
|
+
FAT_CIGAM,
|
|
2247
|
+
FAT_CIGAM_64
|
|
2248
|
+
].includes(magic)) {
|
|
2249
|
+
const littleEndian = magic === FAT_CIGAM || magic === FAT_CIGAM_64;
|
|
2250
|
+
const count = view.getUint32(4, littleEndian);
|
|
2251
|
+
const wide = magic === FAT_MAGIC_64 || magic === FAT_CIGAM_64;
|
|
2252
|
+
if (count === 0) return {
|
|
2253
|
+
status: "malformed",
|
|
2254
|
+
reason: "FAT header declares no architectures"
|
|
2255
|
+
};
|
|
2256
|
+
if (count > MAX_FAT_ARCHITECTURES || 8 + count * (wide ? 32 : 20) > size) return { status: "not-mach-o" };
|
|
2257
|
+
const tableBytes = await readExact(readAt, 8, count * (wide ? 32 : 20), "FAT table");
|
|
2258
|
+
const declarations = readFatSliceDeclarations(tableBytes, {
|
|
2259
|
+
count,
|
|
2260
|
+
wide,
|
|
2261
|
+
littleEndian
|
|
2262
|
+
});
|
|
2263
|
+
if (declarations.status !== "parsed") throw new MachoFormatIssue("malformed", declarations.reason);
|
|
2264
|
+
if (!declarations.slices.some(({ cpuType }) => KNOWN_CPU_TYPES.includes(cpuType))) {
|
|
2265
|
+
let hasMachOSliceHeader = false;
|
|
2266
|
+
for (const declaration of declarations.slices) {
|
|
2267
|
+
if (validateFatSlice(declaration, size, 8 + count * (wide ? 32 : 20)) !== null) continue;
|
|
2268
|
+
const bytes = await readAt(declaration.offset, 4);
|
|
2269
|
+
if (bytes.byteLength < 4) continue;
|
|
2270
|
+
const sliceMagic = viewOf(bytes).getUint32(0, false);
|
|
2271
|
+
if ([
|
|
2272
|
+
MH_MAGIC,
|
|
2273
|
+
MH_MAGIC_64,
|
|
2274
|
+
MH_CIGAM,
|
|
2275
|
+
MH_CIGAM_64
|
|
2276
|
+
].includes(sliceMagic)) {
|
|
2277
|
+
hasMachOSliceHeader = true;
|
|
2278
|
+
break;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
if (!hasMachOSliceHeader) return { status: "not-mach-o" };
|
|
2282
|
+
}
|
|
2283
|
+
return {
|
|
2284
|
+
status: "parsed",
|
|
2285
|
+
slices: await readFatSlices(readAt, size, 8 + count * (wide ? 32 : 20), declarations.slices)
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
if (magic === MH_CIGAM || magic === MH_CIGAM_64) return {
|
|
2289
|
+
status: "parsed",
|
|
2290
|
+
slices: [await readSlice(readAt, 0, size)]
|
|
2291
|
+
};
|
|
2292
|
+
if (magic === MH_MAGIC || magic === MH_MAGIC_64) throw new MachoFormatIssue("unsupported", "big-endian Mach-O images are not supported");
|
|
2293
|
+
return { status: "not-mach-o" };
|
|
2294
|
+
} catch (cause) {
|
|
2295
|
+
if (cause instanceof MachoFormatIssue) return {
|
|
2296
|
+
status: cause.status,
|
|
2297
|
+
reason: cause.message
|
|
2298
|
+
};
|
|
2299
|
+
throw cause;
|
|
2300
|
+
}
|
|
2301
|
+
};
|
|
2302
|
+
readFatSlices = async (readAt, size, tableEnd, declarations) => {
|
|
2303
|
+
const slices = [];
|
|
2304
|
+
for (const declaration of declarations) {
|
|
2305
|
+
const { offset, size: length, cpuType, cpuSubtype } = declaration;
|
|
2306
|
+
const rangeIssue = validateFatSlice(declaration, size, tableEnd);
|
|
2307
|
+
if (rangeIssue !== null) throw new MachoFormatIssue(rangeIssue.includes("unsupported") ? "unsupported" : "malformed", rangeIssue);
|
|
2308
|
+
const slice = await readSlice(readAt, offset, length, {
|
|
2309
|
+
fatCpuType: cpuType,
|
|
2310
|
+
fatCpuSubtype: cpuSubtype,
|
|
2311
|
+
alignmentExponent: declaration.alignmentExponent
|
|
2312
|
+
});
|
|
2313
|
+
const identityIssue = validateFatSlice(declaration, size, tableEnd, {
|
|
2314
|
+
cpuType: slice.cpu_type,
|
|
2315
|
+
cpuSubtype: slice.cpu_subtype
|
|
2316
|
+
});
|
|
2317
|
+
if (identityIssue !== null) throw new MachoFormatIssue("malformed", identityIssue);
|
|
2318
|
+
slices.push(slice);
|
|
2319
|
+
}
|
|
2320
|
+
return slices;
|
|
2321
|
+
};
|
|
2322
|
+
readSlice = async (readAt, base, length, fat = null) => {
|
|
2323
|
+
const header = viewOf(await readExact(readAt, base, 28, "Mach-O header"));
|
|
2324
|
+
const magic = header.getUint32(0, true);
|
|
2325
|
+
if (magic === MH_MAGIC_64 || magic === MH_MAGIC) {
|
|
2326
|
+
const wide = magic === MH_MAGIC_64;
|
|
2327
|
+
const headerSize = wide ? 32 : 28;
|
|
2328
|
+
const commandCount = header.getUint32(16, true);
|
|
2329
|
+
const commandBytes = header.getUint32(20, true);
|
|
2330
|
+
if (commandBytes > 16777216) throw new MachoFormatIssue("unsupported", `load commands occupy ${commandBytes} bytes, above the ${MAX_LOAD_COMMAND_BYTES}-byte limit`);
|
|
2331
|
+
if (headerSize + commandBytes > length) throw new MachoFormatIssue("malformed", "load commands extend beyond the Mach-O slice");
|
|
2332
|
+
const commands = await readExact(readAt, base + headerSize, commandBytes, "load commands");
|
|
2333
|
+
const slice = decodeCommands(commands, {
|
|
2334
|
+
wide,
|
|
2335
|
+
cpuType: header.getUint32(4, true),
|
|
2336
|
+
cpuSubtype: header.getUint32(8, true),
|
|
2337
|
+
fileType: header.getUint32(12, true),
|
|
2338
|
+
commandCount,
|
|
2339
|
+
sliceOffset: base,
|
|
2340
|
+
sliceSize: length,
|
|
2341
|
+
fatCpuType: fat?.fatCpuType ?? null,
|
|
2342
|
+
fatCpuSubtype: fat?.fatCpuSubtype ?? null,
|
|
2343
|
+
fatAlignmentExponent: fat?.alignmentExponent ?? null
|
|
2344
|
+
});
|
|
2345
|
+
const distinctPlatforms = [...new Set(slice.platforms)];
|
|
2346
|
+
slice.platform = distinctPlatforms.length === 1 ? distinctPlatforms[0] ?? null : null;
|
|
2347
|
+
return slice;
|
|
2348
|
+
}
|
|
2349
|
+
throw new MachoFormatIssue(magic === swap(MH_MAGIC) || magic === swap(MH_MAGIC_64) ? "unsupported" : "malformed", magic === swap(MH_MAGIC) || magic === swap(MH_MAGIC_64) ? "big-endian Mach-O slices are not supported" : `slice at offset ${base} has no Mach-O header`);
|
|
2350
|
+
};
|
|
2351
|
+
decodeCommands = (bytes, header) => {
|
|
2352
|
+
const alignment = header.wide ? 8 : 4;
|
|
2353
|
+
const view = viewOf(bytes);
|
|
2354
|
+
const slice = {
|
|
2355
|
+
architecture: architectureName(header.cpuType, header.cpuSubtype),
|
|
2356
|
+
slice_offset: header.sliceOffset,
|
|
2357
|
+
slice_size: header.sliceSize,
|
|
2358
|
+
cpu_type: header.cpuType,
|
|
2359
|
+
cpu_subtype: header.cpuSubtype,
|
|
2360
|
+
fat_cpu_type: header.fatCpuType,
|
|
2361
|
+
fat_cpu_subtype: header.fatCpuSubtype,
|
|
2362
|
+
fat_alignment_exponent: header.fatAlignmentExponent,
|
|
2363
|
+
file_type: fileTypeName(header.fileType),
|
|
2364
|
+
file_type_code: header.fileType,
|
|
2365
|
+
platform: null,
|
|
2366
|
+
platforms: [],
|
|
2367
|
+
install_name: null,
|
|
2368
|
+
dependencies: [],
|
|
2369
|
+
rpaths: [],
|
|
2370
|
+
dyld_environment: [],
|
|
2371
|
+
code_signature_present: false
|
|
2372
|
+
};
|
|
2373
|
+
let offset = 0;
|
|
2374
|
+
for (let index = 0; index < header.commandCount; index++) {
|
|
2375
|
+
if (offset + 8 > bytes.byteLength) throw new MachoFormatIssue("malformed", `load command ${index} starts beyond sizeofcmds`);
|
|
2376
|
+
const command = view.getUint32(offset, true);
|
|
2377
|
+
const size = view.getUint32(offset + 4, true);
|
|
2378
|
+
if (size < 8 || size % alignment !== 0 || offset + size > bytes.byteLength) throw new MachoFormatIssue("malformed", `load command ${index} at offset ${offset} has invalid cmdsize ${size}`);
|
|
2379
|
+
const body = bytes.subarray(offset, offset + size);
|
|
2380
|
+
decodeCommand(command, body, index, slice);
|
|
2381
|
+
offset += size;
|
|
2382
|
+
}
|
|
2383
|
+
if (offset !== bytes.byteLength) throw new MachoFormatIssue("malformed", `load commands declare ${header.commandCount} commands but sizeofcmds holds ${bytes.byteLength} bytes`);
|
|
2384
|
+
return slice;
|
|
2385
|
+
};
|
|
2386
|
+
decodeCommand = (command, body, index, slice) => {
|
|
2387
|
+
if (command === LC_ID_DYLIB) {
|
|
2388
|
+
slice.install_name = commandString(body, 24, index);
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
if (command === LC_RPATH) {
|
|
2392
|
+
slice.rpaths.push(commandString(body, 12, index));
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2395
|
+
if (command === LC_DYLD_ENVIRONMENT) {
|
|
2396
|
+
slice.dyld_environment.push(commandString(body, 12, index));
|
|
2397
|
+
return;
|
|
2398
|
+
}
|
|
2399
|
+
if (command === LC_CODE_SIGNATURE) {
|
|
2400
|
+
if (body.byteLength < 16) throw new MachoFormatIssue("malformed", `load command ${index} is too short for LC_CODE_SIGNATURE`);
|
|
2401
|
+
slice.code_signature_present = true;
|
|
2402
|
+
return;
|
|
2403
|
+
}
|
|
2404
|
+
if (command === LC_BUILD_VERSION) {
|
|
2405
|
+
if (body.byteLength < 24) throw new MachoFormatIssue("malformed", `load command ${index} is too short for LC_BUILD_VERSION`);
|
|
2406
|
+
const view = viewOf(body);
|
|
2407
|
+
const toolCount = view.getUint32(20, true);
|
|
2408
|
+
if (toolCount > Math.floor((body.byteLength - 24) / 8)) throw new MachoFormatIssue("malformed", `load command ${index} LC_BUILD_VERSION tool records exceed cmdsize`);
|
|
2409
|
+
const platform = view.getUint32(8, true);
|
|
2410
|
+
slice.platforms.push(platform);
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
const legacyPlatform = legacyVersionMinPlatform(command, slice.cpu_type);
|
|
2414
|
+
if (legacyPlatform !== undefined) {
|
|
2415
|
+
if (body.byteLength < 16) throw new MachoFormatIssue("malformed", `load command ${index} is too short for a version-min command`);
|
|
2416
|
+
slice.platforms.push(legacyPlatform);
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
2419
|
+
const name = DEPENDENCY_COMMANDS.get(command);
|
|
2420
|
+
if (name !== undefined) slice.dependencies.push(decodeDependency(name, body, index));
|
|
2421
|
+
};
|
|
2422
|
+
decodeDependency = (command, body, index) => {
|
|
2423
|
+
if (body.byteLength < 24) throw new MachoFormatIssue("malformed", `load command ${index} is too short for a dylib command`);
|
|
2424
|
+
const view = viewOf(body);
|
|
2425
|
+
const nameOffset = view.getUint32(8, true);
|
|
2426
|
+
const usesFlags = nameOffset === 28 && body.byteLength >= 28 && view.getUint32(12, true) === DYLIB_USE_MARKER;
|
|
2427
|
+
const flags = usesFlags ? view.getUint32(24, true) : 0;
|
|
2428
|
+
return {
|
|
2429
|
+
command,
|
|
2430
|
+
encoding: usesFlags ? "dylib_use_command" : "dylib_command",
|
|
2431
|
+
install_name: commandString(body, usesFlags ? 28 : 24, index),
|
|
2432
|
+
weak: command === "LC_LOAD_WEAK_DYLIB" || (flags & DYLIB_USE_WEAK_LINK) !== 0,
|
|
2433
|
+
upward: command === "LC_LOAD_UPWARD_DYLIB" || (flags & DYLIB_USE_UPWARD) !== 0,
|
|
2434
|
+
reexport: command === "LC_REEXPORT_DYLIB" || (flags & DYLIB_USE_REEXPORT) !== 0,
|
|
2435
|
+
delayed_init: (flags & DYLIB_USE_DELAYED_INIT) !== 0,
|
|
2436
|
+
current_version: version(view.getUint32(16, true)),
|
|
2437
|
+
compatibility_version: version(view.getUint32(20, true))
|
|
2438
|
+
};
|
|
2439
|
+
};
|
|
2440
|
+
commandString = (body, minimumOffset, index) => {
|
|
2441
|
+
if (body.byteLength < 12) throw new MachoFormatIssue("malformed", `load command ${index} is too short to hold a string offset`);
|
|
2442
|
+
const offset = viewOf(body).getUint32(8, true);
|
|
2443
|
+
if (offset < minimumOffset || offset >= body.byteLength) throw new MachoFormatIssue("malformed", `load command ${index} has string offset ${offset} outside the command`);
|
|
2444
|
+
const end = body.indexOf(0, offset);
|
|
2445
|
+
if (end < 0) throw new MachoFormatIssue("malformed", `load command ${index} has an unterminated string`);
|
|
2446
|
+
try {
|
|
2447
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(body.subarray(offset, end));
|
|
2448
|
+
} catch {
|
|
2449
|
+
throw new MachoFormatIssue("malformed", `load command ${index} has a string that is not UTF-8`);
|
|
2450
|
+
}
|
|
2451
|
+
};
|
|
2452
|
+
readExact = async (readAt, offset, length, label) => {
|
|
2453
|
+
const bytes = await readAt(offset, length);
|
|
2454
|
+
if (bytes.byteLength < length) throw new MachoFormatIssue("malformed", `${label} is truncated`);
|
|
2455
|
+
return bytes;
|
|
2456
|
+
};
|
|
2457
|
+
CPU_ARCH_ABI64 = 16777216;
|
|
2458
|
+
CPU_ARCH_ABI64_32 = 33554432;
|
|
2459
|
+
CPU_TYPE_X86 = 7;
|
|
2460
|
+
CPU_TYPE_ARM = 12;
|
|
2461
|
+
CPU_SUBTYPE_MASK = 4278190080;
|
|
2462
|
+
CPU_SUBTYPE_ARM64E = 2;
|
|
2463
|
+
CPU_SUBTYPE_ARM64E_X1 = 12;
|
|
2464
|
+
CPU_SUBTYPE_X86_64_H = 8;
|
|
2465
|
+
architectureName = (cpuType, cpuSubtype) => {
|
|
2466
|
+
const subtype = cpuSubtype & ~CPU_SUBTYPE_MASK;
|
|
2467
|
+
if (cpuType === (CPU_TYPE_ARM | CPU_ARCH_ABI64)) return subtype === CPU_SUBTYPE_ARM64E || subtype === CPU_SUBTYPE_ARM64E_X1 ? "arm64e" : "arm64";
|
|
2468
|
+
if (cpuType === (CPU_TYPE_ARM | CPU_ARCH_ABI64_32)) return "arm64_32";
|
|
2469
|
+
if (cpuType === (CPU_TYPE_X86 | CPU_ARCH_ABI64)) return subtype === CPU_SUBTYPE_X86_64_H ? "x86_64h" : "x86_64";
|
|
2470
|
+
if (cpuType === CPU_TYPE_X86) return "i386";
|
|
2471
|
+
if (cpuType === CPU_TYPE_ARM) return "arm";
|
|
2472
|
+
return `cpu-${cpuType.toString(16)}`;
|
|
2473
|
+
};
|
|
2474
|
+
fileTypeName = (fileType) => fileType === 2 ? "execute" : fileType === 6 ? "dylib" : fileType === 8 ? "bundle" : "other";
|
|
2475
|
+
version = (value) => `${value >>> 16}.${value >>> 8 & 255}.${value & 255}`;
|
|
2476
|
+
swap = (value) => ((value & 255) << 24 | (value & 65280) << 8 | value >>> 8 & 65280 | value >>> 24) >>> 0;
|
|
2477
|
+
viewOf = (bytes) => new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
2478
|
+
})))();
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
//#endregion
|
|
2482
|
+
//#region dist/artifacts/MachOSliceArtifactReader.js
|
|
2483
|
+
var MachOSliceArtifactReader, readStructuralSlices, lipoMatchesSlice, lipoSubtypeMatches, lipoNameMatches;
|
|
2484
|
+
function init_MachOSliceArtifactReader() {
|
|
2485
|
+
return (init_MachOSliceArtifactReader = __esmMin((() => {
|
|
2486
|
+
init_CommandRunner();
|
|
2487
|
+
init_lipo();
|
|
2488
|
+
init_OwnedFileHandle();
|
|
2489
|
+
init_MachoLoadCommandReader();
|
|
2490
|
+
init_ArtifactReader();
|
|
2491
|
+
init_StreamBytes();
|
|
2492
|
+
init_RegularFile();
|
|
2493
|
+
init_readFileHandleChunks();
|
|
2494
|
+
MachOSliceArtifactReader = class {
|
|
2495
|
+
path;
|
|
2496
|
+
runner;
|
|
2497
|
+
format = "file";
|
|
2498
|
+
#command;
|
|
2499
|
+
#source;
|
|
2500
|
+
#ownedSource;
|
|
2501
|
+
#pendingSource;
|
|
2502
|
+
#entries = new Map();
|
|
2503
|
+
#pendingCommands = new Set();
|
|
2504
|
+
#ownsSource;
|
|
2505
|
+
#closed = false;
|
|
2506
|
+
#closePromise;
|
|
2507
|
+
constructor(path, environment, runner = new XcrunCommandRunner(environment), source) {
|
|
2508
|
+
this.path = path;
|
|
2509
|
+
this.runner = runner;
|
|
2510
|
+
this.#source = source;
|
|
2511
|
+
this.#ownsSource = source === undefined;
|
|
2512
|
+
}
|
|
2513
|
+
async *entries(signal) {
|
|
2514
|
+
this.#entries.clear();
|
|
2515
|
+
const source = await this.#ensureSource();
|
|
2516
|
+
await this.#verifySource(source);
|
|
2517
|
+
if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader is closed");
|
|
2518
|
+
const command = this.runner.run("lipo", ["-detailed_info", this.path], signal === undefined ? {} : { signal });
|
|
2519
|
+
this.#pendingCommands.add(command);
|
|
2520
|
+
let captured;
|
|
2521
|
+
try {
|
|
2522
|
+
captured = await command;
|
|
2523
|
+
} finally {
|
|
2524
|
+
this.#pendingCommands.delete(command);
|
|
2525
|
+
}
|
|
2526
|
+
if (!captured.ok) throw new ArtifactReaderFailure(captured.error.reason === "cancelled" ? "cancelled" : "unavailable", "lipo could not enumerate universal Mach-O slices", {
|
|
2527
|
+
cause: captured.error,
|
|
2528
|
+
...captured.error.cleanupFailure === null && captured.error.cleanupResources.length === 0 ? {} : { cleanup: {
|
|
2529
|
+
reason: captured.error.cleanupFailure ?? "Native command cleanup remains unverified",
|
|
2530
|
+
resources: [...captured.error.cleanupResources]
|
|
2531
|
+
} }
|
|
2532
|
+
});
|
|
2533
|
+
if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader closed during slice discovery");
|
|
2534
|
+
this.#command = {
|
|
2535
|
+
tool: captured.value.tool,
|
|
2536
|
+
arguments: ["-detailed_info", "$ARTIFACT"],
|
|
2537
|
+
tool_version: captured.value.toolVersion,
|
|
2538
|
+
executable_sha256: captured.value.executableSha256,
|
|
2539
|
+
exit_code: captured.value.exitCode,
|
|
2540
|
+
effects: ["read"]
|
|
2541
|
+
};
|
|
2542
|
+
await this.#verifySource(source);
|
|
2543
|
+
const fileSize = source.initial.size;
|
|
2544
|
+
const architectures = parseLipoArchitectures(captured.value.stdout);
|
|
2545
|
+
const structural = await readStructuralSlices(source.handle, fileSize);
|
|
2546
|
+
await this.#verifySource(source);
|
|
2547
|
+
if (structural.status === "malformed") throw new ArtifactReaderFailure("integrity", `Mach-O structural slice index is malformed: ${structural.reason}`);
|
|
2548
|
+
if (structural.status === "unsupported") throw new ArtifactReaderFailure("format", `Mach-O structural slice index is unsupported: ${structural.reason}`);
|
|
2549
|
+
const slices = structural.status === "parsed" ? structural.slices : null;
|
|
2550
|
+
const matchingSlices = new Map();
|
|
2551
|
+
if (slices !== null) {
|
|
2552
|
+
if (slices.length !== architectures.length) throw new ArtifactReaderFailure("integrity", "lipo architecture count disagrees with the Mach-O FAT table");
|
|
2553
|
+
const unmatched = [...slices];
|
|
2554
|
+
for (const reported of architectures) {
|
|
2555
|
+
const match = unmatched.findIndex((observed) => lipoMatchesSlice(reported, observed, slices.length === 1));
|
|
2556
|
+
if (match < 0) throw new ArtifactReaderFailure("integrity", `lipo slice metadata disagrees with the Mach-O FAT table: ${reported.name} (cputype=${reported.cpu_type ?? "unknown"}, cpusubtype=${reported.cpu_subtype ?? "unknown"}, offset=${reported.file_offset ?? "unknown"}, size=${reported.size ?? "unknown"}, alignment=${reported.alignment ?? "unknown"})`);
|
|
2557
|
+
const [observed] = unmatched.splice(match, 1);
|
|
2558
|
+
if (observed !== undefined) matchingSlices.set(reported, observed);
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
for (const architecture of architectures) {
|
|
2562
|
+
const structuralSlice = matchingSlices.get(architecture);
|
|
2563
|
+
const offset = architecture.file_offset ?? structuralSlice?.slice_offset;
|
|
2564
|
+
const sliceSize = architecture.size ?? structuralSlice?.slice_size;
|
|
2565
|
+
if (offset === undefined || sliceSize === undefined) throw new ArtifactReaderFailure("integrity", "lipo omitted a universal slice byte range");
|
|
2566
|
+
if (!Number.isSafeInteger(offset) || !Number.isSafeInteger(sliceSize) || offset < 0 || sliceSize <= 0 || !Number.isSafeInteger(offset + sliceSize) || offset + sliceSize > fileSize) throw new ArtifactReaderFailure("integrity", `lipo reported an out-of-bounds Mach-O slice: ${architecture.name}`);
|
|
2567
|
+
const entry = {
|
|
2568
|
+
path: `slices/${architecture.name}`,
|
|
2569
|
+
kind: "slice",
|
|
2570
|
+
declaredSize: sliceSize,
|
|
2571
|
+
compressedSize: null,
|
|
2572
|
+
executable: true,
|
|
2573
|
+
encrypted: false,
|
|
2574
|
+
byteOffset: offset,
|
|
2575
|
+
declaredSha256: null,
|
|
2576
|
+
unpacked: false,
|
|
2577
|
+
limitations: [
|
|
2578
|
+
...structural.status === "not-mach-o" ? ["Structural Mach-O facts were unavailable; slice range is based on lipo output."] : [],
|
|
2579
|
+
...architecture.file_offset === null || architecture.size === null ? ["Slice range was derived from structural Mach-O facts because lipo omitted it."] : [],
|
|
2580
|
+
...architecture.cpu_type !== null && architecture.cpu_type_code === null ? [`lipo CPU type is retained as unnormalized source text: ${architecture.cpu_type}`] : [],
|
|
2581
|
+
...architecture.cpu_subtype !== null && architecture.cpu_subtype_code === null ? [`lipo CPU subtype is retained as unnormalized source text: ${architecture.cpu_subtype}${architecture.capabilities === null ? "" : `; capabilities ${architecture.capabilities}`}`] : []
|
|
2582
|
+
],
|
|
2583
|
+
adapterKey: `${String(offset)}:${String(sliceSize)}`
|
|
2584
|
+
};
|
|
2585
|
+
this.#entries.set(entry.adapterKey, copyArtifactEntry(entry));
|
|
2586
|
+
yield entry;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
async open(entry, signal) {
|
|
2590
|
+
if (signal?.aborted === true) return Promise.reject(new ArtifactReaderFailure("cancelled", "Mach-O slice read cancelled"));
|
|
2591
|
+
const produced = this.#entries.get(entry.adapterKey);
|
|
2592
|
+
if (produced === undefined || !sameArtifactEntry(entry, produced)) throw new ArtifactReaderFailure("integrity", "Mach-O slice entry metadata does not match this reader's inventory");
|
|
2593
|
+
const offset = produced.byteOffset;
|
|
2594
|
+
const size = produced.declaredSize;
|
|
2595
|
+
if (offset === null || size === null || !Number.isSafeInteger(offset) || !Number.isSafeInteger(size) || offset < 0 || size <= 0) throw new ArtifactReaderFailure("integrity", "Invalid Mach-O slice byte range");
|
|
2596
|
+
const source = await this.#ensureSource();
|
|
2597
|
+
await this.#verifySource(source);
|
|
2598
|
+
if (!Number.isSafeInteger(offset + size) || offset + size > source.initial.size) throw new ArtifactReaderFailure("integrity", `Mach-O slice range is outside the artifact: ${entry.path}`);
|
|
2599
|
+
const sourceStream = readFileHandleChunks(source.handle, {
|
|
2600
|
+
start: offset,
|
|
2601
|
+
end: offset + size - 1,
|
|
2602
|
+
...signal === undefined ? {} : { signal }
|
|
2603
|
+
});
|
|
2604
|
+
const verifySource = () => this.#verifySource(source);
|
|
2605
|
+
return Readable.from((async function* () {
|
|
2606
|
+
let observedBytes = 0;
|
|
2607
|
+
try {
|
|
2608
|
+
for await (const raw of sourceStream) {
|
|
2609
|
+
const chunk = streamChunkToBuffer(raw);
|
|
2610
|
+
observedBytes += chunk.byteLength;
|
|
2611
|
+
if (observedBytes > size) throw new ArtifactReaderFailure("integrity", `Mach-O slice exceeded its reported size: ${entry.path}`);
|
|
2612
|
+
yield chunk;
|
|
2613
|
+
}
|
|
2614
|
+
} catch (cause) {
|
|
2615
|
+
if (cause instanceof ArtifactReaderFailure) throw cause;
|
|
2616
|
+
if (signal?.aborted === true) throw new ArtifactReaderFailure("cancelled", "Mach-O slice read cancelled", { cause });
|
|
2617
|
+
throw new ArtifactReaderFailure("integrity", `Could not read Mach-O slice range: ${entry.path}`, { cause });
|
|
2618
|
+
}
|
|
2619
|
+
if (observedBytes !== size) throw new ArtifactReaderFailure("integrity", `Mach-O slice size disagrees with lipo metadata: ${entry.path}`);
|
|
2620
|
+
await verifySource();
|
|
2621
|
+
})());
|
|
2622
|
+
}
|
|
2623
|
+
provenance() {
|
|
2624
|
+
return this.#command === undefined ? [] : [structuredClone(this.#command)];
|
|
2625
|
+
}
|
|
2626
|
+
async close() {
|
|
2627
|
+
this.#closed = true;
|
|
2628
|
+
this.#closePromise ??= this.#releaseResources().catch((cause) => {
|
|
2629
|
+
this.#closePromise = undefined;
|
|
2630
|
+
throw cause;
|
|
2631
|
+
});
|
|
2632
|
+
return this.#closePromise;
|
|
2633
|
+
}
|
|
2634
|
+
async #releaseResources() {
|
|
2635
|
+
await Promise.allSettled(this.#pendingCommands);
|
|
2636
|
+
let cleanup;
|
|
2637
|
+
try {
|
|
2638
|
+
const failures = await this.runner.retryCleanup?.() ?? [];
|
|
2639
|
+
if (failures.length > 0) cleanup = {
|
|
2640
|
+
reason: failures.map(({ reason, resources }) => `${resources.join(", ")}: ${reason}`).join("; "),
|
|
2641
|
+
resources: [...new Set(failures.flatMap(({ resources }) => resources))]
|
|
2642
|
+
};
|
|
2643
|
+
} catch (cause) {
|
|
2644
|
+
cleanup = ArtifactReaderFailure.cleanupObservation(cause, "native-command-process-cleanup");
|
|
2645
|
+
}
|
|
2646
|
+
try {
|
|
2647
|
+
await this.#closeSource();
|
|
2648
|
+
} catch (cause) {
|
|
2649
|
+
if (cleanup === undefined) throw cause;
|
|
2650
|
+
throw ArtifactReaderFailure.withCleanup(cause, cleanup);
|
|
2651
|
+
}
|
|
2652
|
+
if (cleanup !== undefined) throw new ArtifactReaderFailure("unavailable", "Native command process cleanup remains incomplete", { cleanup });
|
|
2653
|
+
}
|
|
2654
|
+
async #ensureSource() {
|
|
2655
|
+
if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader is closed");
|
|
2656
|
+
if (this.#source !== undefined) return this.#source;
|
|
2657
|
+
this.#pendingSource ??= this.#acquireSource();
|
|
2658
|
+
const source = await this.#pendingSource;
|
|
2659
|
+
if (this.#closed) throw new ArtifactReaderFailure("unavailable", "Universal Mach-O reader closed during source acquisition");
|
|
2660
|
+
return source;
|
|
2661
|
+
}
|
|
2662
|
+
async #acquireSource() {
|
|
2663
|
+
let handle;
|
|
2664
|
+
try {
|
|
2665
|
+
handle = await openRegularFile(this.path, { symlinks: "reject" });
|
|
2666
|
+
} catch (cause) {
|
|
2667
|
+
if (!(cause instanceof RegularFileAdmissionFailure)) throw cause;
|
|
2668
|
+
this.#ownedSource = cause.owner;
|
|
2669
|
+
const primary = cause.cause instanceof NonRegularFileReadError ? new ArtifactReaderFailure("format", `Universal Mach-O source is not a regular file: ${this.path}`, { cause: cause.cause }) : cause.cause;
|
|
2670
|
+
throw ArtifactReaderFailure.withCleanup(primary, ArtifactReaderFailure.cleanupObservation(cause.cleanupCause, this.path));
|
|
2671
|
+
}
|
|
2672
|
+
const owner = new OwnedFileHandle(handle);
|
|
2673
|
+
this.#ownedSource = owner;
|
|
2674
|
+
try {
|
|
2675
|
+
const initial = await handle.stat();
|
|
2676
|
+
const source = {
|
|
2677
|
+
handle,
|
|
2678
|
+
initial
|
|
2679
|
+
};
|
|
2680
|
+
this.#source = source;
|
|
2681
|
+
return source;
|
|
2682
|
+
} catch (cause) {
|
|
2683
|
+
try {
|
|
2684
|
+
await owner.close();
|
|
2685
|
+
this.#ownedSource = undefined;
|
|
2686
|
+
} catch (cleanupCause) {
|
|
2687
|
+
throw ArtifactReaderFailure.withCleanup(cause, ArtifactReaderFailure.cleanupObservation(cleanupCause, this.path));
|
|
2688
|
+
}
|
|
2689
|
+
throw cause;
|
|
2690
|
+
}
|
|
2691
|
+
}
|
|
2692
|
+
async #closeSource() {
|
|
2693
|
+
await this.#pendingSource?.catch(() => undefined);
|
|
2694
|
+
if (!this.#ownsSource || this.#ownedSource === undefined) return;
|
|
2695
|
+
await this.#ownedSource.close();
|
|
2696
|
+
this.#ownedSource = undefined;
|
|
2697
|
+
this.#source = undefined;
|
|
2698
|
+
}
|
|
2699
|
+
async #verifySource(source) {
|
|
2700
|
+
const [opened, currentPath] = await Promise.all([source.handle.stat(), lstat(this.path)]);
|
|
2701
|
+
if (!sameRegularFileState(source.initial, opened) || !sameRegularFileState(source.initial, currentPath)) throw new ArtifactReaderFailure("integrity", `Universal Mach-O source changed during inventory: ${this.path}`);
|
|
2702
|
+
}
|
|
2703
|
+
};
|
|
2704
|
+
readStructuralSlices = async (file, size) => {
|
|
2705
|
+
const readAt = async (offset, length) => {
|
|
2706
|
+
const bytes = Buffer.alloc(length);
|
|
2707
|
+
const { bytesRead } = await file.read(bytes, 0, length, offset);
|
|
2708
|
+
return bytes.subarray(0, bytesRead);
|
|
2709
|
+
};
|
|
2710
|
+
return readMachoImage(readAt, size);
|
|
2711
|
+
};
|
|
2712
|
+
lipoMatchesSlice = (reported, observed, structurallyUnique) => {
|
|
2713
|
+
const observedCpuType = observed.fat_cpu_type ?? observed.cpu_type;
|
|
2714
|
+
const observedCpuSubtype = observed.fat_cpu_subtype ?? observed.cpu_subtype;
|
|
2715
|
+
const hasPhysicalIdentity = reported.file_offset !== null || reported.size !== null || reported.cpu_type_code !== null || reported.cpu_subtype_code !== null;
|
|
2716
|
+
return (hasPhysicalIdentity || structurallyUnique) && lipoNameMatches(reported.name, observed.architecture) && (reported.file_offset === null || reported.file_offset === observed.slice_offset) && (reported.size === null || reported.size === observed.slice_size) && (reported.cpu_type_code === null || reported.cpu_type_code === observedCpuType) && lipoSubtypeMatches(reported, observedCpuSubtype) && (reported.alignment === null || observed.fat_alignment_exponent === null || reported.alignment === 2 ** observed.fat_alignment_exponent);
|
|
2717
|
+
};
|
|
2718
|
+
lipoSubtypeMatches = (reported, observedCpuSubtype) => {
|
|
2719
|
+
if (reported.cpu_subtype_code !== null) return reported.cpu_subtype_code === observedCpuSubtype;
|
|
2720
|
+
const bits = lipoSubtypeBits(reported.cpu_subtype);
|
|
2721
|
+
return bits === null || bits === (observedCpuSubtype & 16777215);
|
|
2722
|
+
};
|
|
2723
|
+
lipoNameMatches = (reported, observed) => reported === observed || observed === "arm64e" && /^arm64e\.[A-Za-z0-9_]+$/u.test(reported);
|
|
2724
|
+
})))();
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
//#endregion
|
|
2728
|
+
//#region dist/artifacts/NativeDmgOwnership.js
|
|
2729
|
+
var systemEntitySchema, attachOutputSchema, infoOutputSchema, parseNativeDmgInfo, parseNativeDmgAttachOutput, resolveNativeDmgOwnership, ownershipFromAttachOutput, topLevelDevices, isBelowRoot;
|
|
2730
|
+
function init_NativeDmgOwnership() {
|
|
2731
|
+
return (init_NativeDmgOwnership = __esmMin((() => {
|
|
2732
|
+
systemEntitySchema = z.object({
|
|
2733
|
+
"dev-entry": z.string().startsWith("/dev/"),
|
|
2734
|
+
"mount-point": z.string().optional()
|
|
2735
|
+
});
|
|
2736
|
+
attachOutputSchema = z.object({ "system-entities": z.array(systemEntitySchema) });
|
|
2737
|
+
infoOutputSchema = z.object({ images: z.array(z.object({ "system-entities": z.array(systemEntitySchema) })) });
|
|
2738
|
+
parseNativeDmgInfo = (stdout) => infoOutputSchema.parse(parse(stdout));
|
|
2739
|
+
parseNativeDmgAttachOutput = (stdout) => attachOutputSchema.parse(parse(stdout));
|
|
2740
|
+
resolveNativeDmgOwnership = (input) => {
|
|
2741
|
+
const rootedImages = input.info.images.filter((image) => image["system-entities"].some(({ "mount-point": mountPoint }) => mountPoint !== undefined && isBelowRoot(input.mountRoot, mountPoint)));
|
|
2742
|
+
if (rootedImages.length > 1) return {
|
|
2743
|
+
status: "unknown",
|
|
2744
|
+
reason: "multiple hdiutil image groups report mounts beneath the owned root"
|
|
2745
|
+
};
|
|
2746
|
+
const rootedImage = rootedImages[0];
|
|
2747
|
+
if (rootedImage !== undefined) {
|
|
2748
|
+
const hasOutsideMount = rootedImage["system-entities"].some(({ "mount-point": mountPoint }) => mountPoint !== undefined && !isBelowRoot(input.mountRoot, mountPoint));
|
|
2749
|
+
const groupDevices = rootedImage["system-entities"].map(({ "dev-entry": device }) => device);
|
|
2750
|
+
const devices = topLevelDevices(groupDevices);
|
|
2751
|
+
const overlapsBaseline = groupDevices.some((device) => input.baselineDevices.has(device));
|
|
2752
|
+
if (hasOutsideMount || overlapsBaseline || devices.length === 0) return {
|
|
2753
|
+
status: "unknown",
|
|
2754
|
+
reason: hasOutsideMount ? "the image group contains a mount outside the owned root" : overlapsBaseline ? "the image group includes a device present before attachment" : "the owned mount group contains no detachable device"
|
|
2755
|
+
};
|
|
2756
|
+
return {
|
|
2757
|
+
status: "owned",
|
|
2758
|
+
devices,
|
|
2759
|
+
source: "info"
|
|
2760
|
+
};
|
|
2761
|
+
}
|
|
2762
|
+
if (input.attachOutputReturned) {
|
|
2763
|
+
const attachOwnership = ownershipFromAttachOutput(input.attachOutput, input.mountRoot, input.baselineDevices);
|
|
2764
|
+
if (attachOwnership.status === "owned") {
|
|
2765
|
+
return attachOwnership;
|
|
2766
|
+
}
|
|
2767
|
+
if (attachOwnership.status === "unknown") return attachOwnership;
|
|
2768
|
+
}
|
|
2769
|
+
const newlyListedDevice = input.info.images.some((image) => image["system-entities"].some(({ "dev-entry": device }) => !input.baselineDevices.has(device)));
|
|
2770
|
+
if (newlyListedDevice) return {
|
|
2771
|
+
status: "unknown",
|
|
2772
|
+
reason: "hdiutil lists devices absent from the pre-attach baseline, but none is tied uniquely to the owned root; ownership is unknown"
|
|
2773
|
+
};
|
|
2774
|
+
return { status: "none" };
|
|
2775
|
+
};
|
|
2776
|
+
ownershipFromAttachOutput = (output, mountRoot, baselineDevices) => {
|
|
2777
|
+
if (output === undefined) return {
|
|
2778
|
+
status: "unknown",
|
|
2779
|
+
reason: "hdiutil attach succeeded but its ownership facts were malformed"
|
|
2780
|
+
};
|
|
2781
|
+
const entities = output["system-entities"];
|
|
2782
|
+
const hasRootMount = entities.some(({ "mount-point": mountPoint }) => mountPoint !== undefined && isBelowRoot(mountRoot, mountPoint));
|
|
2783
|
+
const hasOutsideMount = entities.some(({ "mount-point": mountPoint }) => mountPoint !== undefined && !isBelowRoot(mountRoot, mountPoint));
|
|
2784
|
+
const devices = entities.map(({ "dev-entry": device }) => device);
|
|
2785
|
+
const uniqueDevices = topLevelDevices(devices);
|
|
2786
|
+
const overlapsBaseline = devices.some((device) => baselineDevices.has(device));
|
|
2787
|
+
if (hasRootMount) {
|
|
2788
|
+
if (hasOutsideMount || overlapsBaseline || uniqueDevices.length === 0) return {
|
|
2789
|
+
status: "unknown",
|
|
2790
|
+
reason: hasOutsideMount ? "the attach result includes a mount outside the owned root" : overlapsBaseline ? "the attach result includes a device present before attachment" : "the attach result's owned mount has no detachable device"
|
|
2791
|
+
};
|
|
2792
|
+
return {
|
|
2793
|
+
status: "owned",
|
|
2794
|
+
devices: uniqueDevices,
|
|
2795
|
+
source: "attach"
|
|
2796
|
+
};
|
|
2797
|
+
}
|
|
2798
|
+
if (devices.length === 0) return {
|
|
2799
|
+
status: "unknown",
|
|
2800
|
+
reason: "hdiutil attach succeeded without reporting device ownership facts"
|
|
2801
|
+
};
|
|
2802
|
+
if (devices.some((device) => !baselineDevices.has(device))) return {
|
|
2803
|
+
status: "unknown",
|
|
2804
|
+
reason: "the attach result reports new devices without a mount beneath the owned root"
|
|
2805
|
+
};
|
|
2806
|
+
return { status: "none" };
|
|
2807
|
+
};
|
|
2808
|
+
topLevelDevices = (devices) => {
|
|
2809
|
+
const unique = [...new Set(devices)];
|
|
2810
|
+
return unique.filter((device) => !unique.some((parent) => /^\/dev\/disk\d+$/u.test(parent) && device.startsWith(`${parent}s`) && /^\d+$/u.test(device.slice(parent.length + 1))));
|
|
2811
|
+
};
|
|
2812
|
+
isBelowRoot = (root, path) => {
|
|
2813
|
+
const child = relative(root, resolve(path));
|
|
2814
|
+
return child !== "" && child !== "." && child !== ".." && !child.startsWith(`..${sep}`);
|
|
2815
|
+
};
|
|
2816
|
+
})))();
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
//#endregion
|
|
2820
|
+
//#region dist/artifacts/NativeDmgArtifactReader.js
|
|
2821
|
+
var HDIUTIL_COMMAND_TIMEOUT_MS, DETACH_SETTLE_DELAYS_MS, delay, NativeDmgCommandFailure, createSystemHost, NativeDmgArtifactReader, failureMessage, processNotStarted, runChecked, describeCommandFailure, processExitCode, processOutput, commandFailureReason, verifyFailureReason, verifyFailureDiagnostic, command;
|
|
2822
|
+
function init_NativeDmgArtifactReader() {
|
|
2823
|
+
return (init_NativeDmgArtifactReader = __esmMin((() => {
|
|
2824
|
+
init_ArtifactReader();
|
|
2825
|
+
init_DirectoryArtifactReader();
|
|
2826
|
+
init_ExecFileOutput();
|
|
2827
|
+
init_NativeDmgOwnership();
|
|
2828
|
+
HDIUTIL_COMMAND_TIMEOUT_MS = 12e4;
|
|
2829
|
+
DETACH_SETTLE_DELAYS_MS = [
|
|
2830
|
+
250,
|
|
2831
|
+
500,
|
|
2832
|
+
1e3
|
|
2833
|
+
];
|
|
2834
|
+
delay = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
2835
|
+
NativeDmgCommandFailure = class extends ArtifactReaderFailure {
|
|
2836
|
+
stdout;
|
|
2837
|
+
processNotStarted;
|
|
2838
|
+
constructor(reason, message, stdout, options) {
|
|
2839
|
+
super(reason, message, options?.cause === undefined ? undefined : { cause: options.cause });
|
|
2840
|
+
this.stdout = stdout;
|
|
2841
|
+
this.processNotStarted = options?.processNotStarted ?? false;
|
|
2842
|
+
}
|
|
2843
|
+
};
|
|
2844
|
+
createSystemHost = (environment) => ({
|
|
2845
|
+
delay,
|
|
2846
|
+
async run(arguments_, signal, options) {
|
|
2847
|
+
try {
|
|
2848
|
+
const { stdout, stderr } = await execFileOutput("/usr/bin/hdiutil", [...arguments_], {
|
|
2849
|
+
env: environment,
|
|
2850
|
+
stopSignal: "SIGTERM",
|
|
2851
|
+
...options === undefined ? {} : { timeout: options.timeoutMs },
|
|
2852
|
+
...signal === undefined ? {} : { signal }
|
|
2853
|
+
});
|
|
2854
|
+
return {
|
|
2855
|
+
stdout,
|
|
2856
|
+
stderr,
|
|
2857
|
+
exitCode: 0
|
|
2858
|
+
};
|
|
2859
|
+
} catch (cause) {
|
|
2860
|
+
const output = execFileOutputFailure(cause);
|
|
2861
|
+
if (cause instanceof Error && cause.name === "AbortError") throw new NativeDmgCommandFailure("cancelled", "DMG operation cancelled", output?.stdout ?? "", { cause });
|
|
2862
|
+
const exitCode = typeof output?.code === "number" ? output.code : processExitCode(cause);
|
|
2863
|
+
if (exitCode !== undefined) return {
|
|
2864
|
+
stdout: output?.stdout ?? processOutput(cause, "stdout"),
|
|
2865
|
+
stderr: output?.stderr ?? processOutput(cause, "stderr"),
|
|
2866
|
+
exitCode,
|
|
2867
|
+
cause
|
|
2868
|
+
};
|
|
2869
|
+
throw new NativeDmgCommandFailure(commandFailureReason(cause, arguments_[0]), `hdiutil ${arguments_[0] ?? "operation"} failed: ${describeCommandFailure(cause, arguments_)}`, output?.stdout ?? "", {
|
|
2870
|
+
cause,
|
|
2871
|
+
processNotStarted: processNotStarted(cause)
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
});
|
|
2876
|
+
NativeDmgArtifactReader = class {
|
|
2877
|
+
path;
|
|
2878
|
+
format = "file";
|
|
2879
|
+
host;
|
|
2880
|
+
#provenance = [];
|
|
2881
|
+
#initialization;
|
|
2882
|
+
#directory;
|
|
2883
|
+
#devices = [];
|
|
2884
|
+
#inventoryConfirmedDevices = new Set();
|
|
2885
|
+
#mountRoot;
|
|
2886
|
+
#baselineDevices = new Set();
|
|
2887
|
+
#attachOutput;
|
|
2888
|
+
#attachOutputReturned = false;
|
|
2889
|
+
#attachMayHaveMounted = false;
|
|
2890
|
+
#ownershipUncertainty;
|
|
2891
|
+
#closed = false;
|
|
2892
|
+
#closePromise;
|
|
2893
|
+
#activeDirectoryOperations = new Set();
|
|
2894
|
+
constructor(path, environment, host) {
|
|
2895
|
+
this.path = path;
|
|
2896
|
+
if (process.platform !== "darwin" && host === undefined) throw new ArtifactReaderFailure("unavailable", "Native DMG traversal is available only on macOS");
|
|
2897
|
+
this.host = host ?? createSystemHost(environment);
|
|
2898
|
+
}
|
|
2899
|
+
async *entries(signal) {
|
|
2900
|
+
await this.#ensureAttached(signal);
|
|
2901
|
+
const directory = this.#directory;
|
|
2902
|
+
if (directory === undefined) throw new ArtifactReaderFailure("unavailable", "DMG is not attached");
|
|
2903
|
+
const prefix = basename(this.path);
|
|
2904
|
+
const entries = directory.entries(signal)[Symbol.asyncIterator]();
|
|
2905
|
+
try {
|
|
2906
|
+
for (;;) {
|
|
2907
|
+
if (this.#closed) return;
|
|
2908
|
+
const next = await this.#trackDirectoryOperation(() => entries.next());
|
|
2909
|
+
if (this.#closed) return;
|
|
2910
|
+
if (next.done) return;
|
|
2911
|
+
yield {
|
|
2912
|
+
...next.value,
|
|
2913
|
+
path: `${prefix}/${next.value.path}`
|
|
2914
|
+
};
|
|
2915
|
+
}
|
|
2916
|
+
} finally {
|
|
2917
|
+
await entries.return?.();
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
async open(entry, signal) {
|
|
2921
|
+
await this.#ensureAttached(signal);
|
|
2922
|
+
const directory = this.#directory;
|
|
2923
|
+
if (directory === undefined) throw new ArtifactReaderFailure("unavailable", "DMG is not attached");
|
|
2924
|
+
return this.#trackDirectoryOperation(() => directory.open(entry, signal));
|
|
2925
|
+
}
|
|
2926
|
+
provenance() {
|
|
2927
|
+
return structuredClone(this.#provenance);
|
|
2928
|
+
}
|
|
2929
|
+
close() {
|
|
2930
|
+
this.#closed = true;
|
|
2931
|
+
this.#closePromise ??= this.#closeOwnedResources().catch((cause) => {
|
|
2932
|
+
this.#closePromise = undefined;
|
|
2933
|
+
throw cause;
|
|
2934
|
+
});
|
|
2935
|
+
return this.#closePromise;
|
|
2936
|
+
}
|
|
2937
|
+
async #closeOwnedResources() {
|
|
2938
|
+
await this.#initialization?.catch(() => undefined);
|
|
2939
|
+
await Promise.allSettled(this.#activeDirectoryOperations);
|
|
2940
|
+
await this.#closeMountedDirectory();
|
|
2941
|
+
let detachFailure = await this.#detachOwnedDevices();
|
|
2942
|
+
if (this.#devices.length === 0 && this.#mountRoot !== undefined && !this.#attachMayHaveMounted) await rm(this.#mountRoot, {
|
|
2943
|
+
recursive: true,
|
|
2944
|
+
force: true
|
|
2945
|
+
}).then(() => {
|
|
2946
|
+
this.#mountRoot = undefined;
|
|
2947
|
+
this.#directory = undefined;
|
|
2948
|
+
}, (cause) => {
|
|
2949
|
+
detachFailure ??= cause;
|
|
2950
|
+
});
|
|
2951
|
+
if (this.#attachMayHaveMounted) {
|
|
2952
|
+
detachFailure ??= new Error(this.#ownershipUncertainty ?? "hdiutil attachment ownership remains unknown");
|
|
2953
|
+
}
|
|
2954
|
+
if (detachFailure !== undefined) throw new ArtifactReaderFailure("unavailable", `DMG detach or mount-root cleanup failed for ${JSON.stringify(this.path)}: ${failureMessage(detachFailure)}`, {
|
|
2955
|
+
cause: detachFailure,
|
|
2956
|
+
cleanup: {
|
|
2957
|
+
reason: failureMessage(detachFailure),
|
|
2958
|
+
resources: [
|
|
2959
|
+
...this.#devices.map((device) => `DMG device ${device}`),
|
|
2960
|
+
...this.#attachMayHaveMounted ? [`DMG attachment ownership unknown at mount root ${this.#mountRoot ?? this.path}`] : [],
|
|
2961
|
+
...this.#mountRoot === undefined ? [] : [`DMG mount root ${this.#mountRoot}`]
|
|
2962
|
+
]
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
async #detachOwnedDevices() {
|
|
2967
|
+
let detachFailure = await this.#reconcileAttachState();
|
|
2968
|
+
let remainingDevices = [];
|
|
2969
|
+
for (const device of [...this.#devices].reverse()) {
|
|
2970
|
+
const failure = await this.#detach(device);
|
|
2971
|
+
if (failure !== undefined) {
|
|
2972
|
+
remainingDevices.push(device);
|
|
2973
|
+
detachFailure ??= failure;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
for (const delayMs of DETACH_SETTLE_DELAYS_MS) {
|
|
2977
|
+
if (remainingDevices.length === 0) break;
|
|
2978
|
+
await (this.host.delay ?? delay)(delayMs);
|
|
2979
|
+
const stillAttached = [];
|
|
2980
|
+
for (const device of remainingDevices) {
|
|
2981
|
+
if (!await this.#isAttached(device)) continue;
|
|
2982
|
+
const failure = await this.#detach(device);
|
|
2983
|
+
if (failure !== undefined) {
|
|
2984
|
+
stillAttached.push(device);
|
|
2985
|
+
detachFailure = failure;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
remainingDevices = stillAttached;
|
|
2989
|
+
}
|
|
2990
|
+
if (remainingDevices.length === 0) detachFailure = undefined;
|
|
2991
|
+
this.#devices = remainingDevices.reverse();
|
|
2992
|
+
return detachFailure;
|
|
2993
|
+
}
|
|
2994
|
+
async #closeMountedDirectory() {
|
|
2995
|
+
if (this.#directory !== undefined) {
|
|
2996
|
+
try {
|
|
2997
|
+
await this.#directory.close();
|
|
2998
|
+
this.#directory = undefined;
|
|
2999
|
+
} catch (cause) {
|
|
3000
|
+
const mountRoot = this.#mountRoot ?? this.path;
|
|
3001
|
+
throw ArtifactReaderFailure.withCleanup(cause, {
|
|
3002
|
+
reason: `DMG mounted directory remains owned: ${failureMessage(cause)}`,
|
|
3003
|
+
resources: [
|
|
3004
|
+
`DMG mounted directory at ${mountRoot}`,
|
|
3005
|
+
`DMG mount root ${mountRoot}`,
|
|
3006
|
+
...this.#devices.map((device) => `DMG device ${device}`)
|
|
3007
|
+
]
|
|
3008
|
+
});
|
|
3009
|
+
}
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
/** Detach one device; return the failure only while it remains attached. */
|
|
3013
|
+
async #detach(device) {
|
|
3014
|
+
try {
|
|
3015
|
+
await runChecked(this.host, ["detach", device], undefined, { timeoutMs: HDIUTIL_COMMAND_TIMEOUT_MS });
|
|
3016
|
+
this.#provenance.push(command(["detach", device], ["mount"]));
|
|
3017
|
+
return undefined;
|
|
3018
|
+
} catch (cause) {
|
|
3019
|
+
return await this.#isAttached(device) ? cause : undefined;
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
async #reconcileAttachState() {
|
|
3023
|
+
if (!this.#attachMayHaveMounted) return undefined;
|
|
3024
|
+
try {
|
|
3025
|
+
await this.#resolveAttachOwnership();
|
|
3026
|
+
return undefined;
|
|
3027
|
+
} catch (cause) {
|
|
3028
|
+
this.#ownershipUncertainty = failureMessage(cause);
|
|
3029
|
+
return cause;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
/** Treat unknown hdiutil state as attached during cleanup. */
|
|
3033
|
+
async #isAttached(device) {
|
|
3034
|
+
try {
|
|
3035
|
+
const parsed = await this.#readInfo();
|
|
3036
|
+
const isListed = parsed.images.some((image) => image["system-entities"].some((entity) => entity["dev-entry"] === device));
|
|
3037
|
+
if (isListed) {
|
|
3038
|
+
this.#inventoryConfirmedDevices.add(device);
|
|
3039
|
+
return true;
|
|
3040
|
+
}
|
|
3041
|
+
return !this.#inventoryConfirmedDevices.has(device);
|
|
3042
|
+
} catch {
|
|
3043
|
+
return true;
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
async #ensureAttached(signal) {
|
|
3047
|
+
if (this.#closed) throw new ArtifactReaderFailure("unavailable", "DMG reader is closed");
|
|
3048
|
+
this.#initialization ??= this.#attach(signal);
|
|
3049
|
+
await this.#initialization;
|
|
3050
|
+
if (this.#closed) throw new ArtifactReaderFailure("unavailable", "DMG reader is closed");
|
|
3051
|
+
}
|
|
3052
|
+
async #trackDirectoryOperation(operation) {
|
|
3053
|
+
if (this.#closed) throw new ArtifactReaderFailure("unavailable", "DMG reader is closed");
|
|
3054
|
+
const running = Promise.resolve().then(operation);
|
|
3055
|
+
this.#activeDirectoryOperations.add(running);
|
|
3056
|
+
try {
|
|
3057
|
+
return await running;
|
|
3058
|
+
} finally {
|
|
3059
|
+
this.#activeDirectoryOperations.delete(running);
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
async #attach(signal) {
|
|
3063
|
+
await runChecked(this.host, ["verify", this.path], signal);
|
|
3064
|
+
this.#provenance.push(command(["verify", this.path], ["read"]));
|
|
3065
|
+
const baseline = await this.#readInfo();
|
|
3066
|
+
this.#baselineDevices = new Set(baseline.images.flatMap((image) => image["system-entities"].map(({ "dev-entry": device }) => device)));
|
|
3067
|
+
const mountRoot = await realpath(await mkdtemp(join(tmpdir(), "rea-dmg-")));
|
|
3068
|
+
this.#mountRoot = mountRoot;
|
|
3069
|
+
try {
|
|
3070
|
+
this.#attachMayHaveMounted = true;
|
|
3071
|
+
const attached = await runChecked(this.host, [
|
|
3072
|
+
"attach",
|
|
3073
|
+
"-readonly",
|
|
3074
|
+
"-nobrowse",
|
|
3075
|
+
"-plist",
|
|
3076
|
+
"-mountroot",
|
|
3077
|
+
mountRoot,
|
|
3078
|
+
this.path
|
|
3079
|
+
], signal, { timeoutMs: HDIUTIL_COMMAND_TIMEOUT_MS });
|
|
3080
|
+
this.#attachOutputReturned = true;
|
|
3081
|
+
let parsed;
|
|
3082
|
+
try {
|
|
3083
|
+
parsed = parseNativeDmgAttachOutput(attached.stdout);
|
|
3084
|
+
} catch (cause) {
|
|
3085
|
+
throw new ArtifactReaderFailure("format", "hdiutil returned a malformed attachment plist", { cause });
|
|
3086
|
+
}
|
|
3087
|
+
if (parsed["system-entities"].length === 0) throw new ArtifactReaderFailure("format", "hdiutil returned no attached devices");
|
|
3088
|
+
this.#attachOutput = parsed;
|
|
3089
|
+
const ownership = await this.#resolveAttachOwnership();
|
|
3090
|
+
if (ownership !== "owned") throw new ArtifactReaderFailure(ownership === "unknown" ? "unavailable" : "path", ownership === "unknown" ? `DMG attachment ownership is uncertain: ${this.#ownershipUncertainty ?? "no unique mount under the owned root"}` : "hdiutil did not mount a new image beneath the owned root");
|
|
3091
|
+
this.#provenance.push(command([
|
|
3092
|
+
"attach",
|
|
3093
|
+
"-readonly",
|
|
3094
|
+
"-nobrowse",
|
|
3095
|
+
"-plist",
|
|
3096
|
+
"-mountroot",
|
|
3097
|
+
mountRoot,
|
|
3098
|
+
this.path
|
|
3099
|
+
], ["read", "mount"]));
|
|
3100
|
+
this.#directory = new DirectoryArtifactReader(mountRoot);
|
|
3101
|
+
} catch (cause) {
|
|
3102
|
+
if (cause instanceof NativeDmgCommandFailure && cause.stdout !== "") {
|
|
3103
|
+
try {
|
|
3104
|
+
this.#attachOutput = parseNativeDmgAttachOutput(cause.stdout);
|
|
3105
|
+
this.#attachOutputReturned = true;
|
|
3106
|
+
} catch {}
|
|
3107
|
+
}
|
|
3108
|
+
if (cause instanceof NativeDmgCommandFailure && cause.processNotStarted) {
|
|
3109
|
+
this.#attachMayHaveMounted = false;
|
|
3110
|
+
this.#ownershipUncertainty = undefined;
|
|
3111
|
+
}
|
|
3112
|
+
throw cause;
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
async #readInfo() {
|
|
3116
|
+
const info = await runChecked(this.host, ["info", "-plist"], undefined, { timeoutMs: HDIUTIL_COMMAND_TIMEOUT_MS });
|
|
3117
|
+
return parseNativeDmgInfo(info.stdout);
|
|
3118
|
+
}
|
|
3119
|
+
async #resolveAttachOwnership() {
|
|
3120
|
+
const mountRoot = this.#mountRoot;
|
|
3121
|
+
if (mountRoot === undefined) throw new Error("DMG mount root is unavailable for ownership discovery");
|
|
3122
|
+
const ownership = resolveNativeDmgOwnership({
|
|
3123
|
+
info: await this.#readInfo(),
|
|
3124
|
+
...this.#attachOutput === undefined ? {} : { attachOutput: this.#attachOutput },
|
|
3125
|
+
attachOutputReturned: this.#attachOutputReturned,
|
|
3126
|
+
mountRoot,
|
|
3127
|
+
baselineDevices: this.#baselineDevices
|
|
3128
|
+
});
|
|
3129
|
+
if (ownership.status === "owned") {
|
|
3130
|
+
this.#devices = [...ownership.devices];
|
|
3131
|
+
if (ownership.source === "info") for (const device of ownership.devices) this.#inventoryConfirmedDevices.add(device);
|
|
3132
|
+
this.#attachMayHaveMounted = false;
|
|
3133
|
+
this.#ownershipUncertainty = undefined;
|
|
3134
|
+
return "owned";
|
|
3135
|
+
}
|
|
3136
|
+
if (ownership.status === "unknown") {
|
|
3137
|
+
this.#ownershipUncertainty = ownership.reason;
|
|
3138
|
+
return "unknown";
|
|
3139
|
+
}
|
|
3140
|
+
this.#attachMayHaveMounted = false;
|
|
3141
|
+
this.#ownershipUncertainty = undefined;
|
|
3142
|
+
this.#devices = [];
|
|
3143
|
+
return "none";
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
3146
|
+
failureMessage = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
3147
|
+
processNotStarted = (cause) => {
|
|
3148
|
+
if (!(cause instanceof Error)) return false;
|
|
3149
|
+
const syscall = Reflect.get(cause, "syscall");
|
|
3150
|
+
const code = Reflect.get(cause, "code");
|
|
3151
|
+
const errno = Reflect.get(cause, "errno");
|
|
3152
|
+
return typeof syscall === "string" && syscall.startsWith("spawn ") && (typeof code === "string" || typeof code === "number" || typeof errno === "number");
|
|
3153
|
+
};
|
|
3154
|
+
runChecked = async (host, arguments_, signal, options) => {
|
|
3155
|
+
let result;
|
|
3156
|
+
try {
|
|
3157
|
+
result = await host.run(arguments_, signal, options);
|
|
3158
|
+
} catch (cause) {
|
|
3159
|
+
if (cause instanceof ArtifactReaderFailure) throw cause;
|
|
3160
|
+
if (cause instanceof Error && cause.name === "AbortError") throw new NativeDmgCommandFailure("cancelled", "DMG operation cancelled", execFileOutputFailure(cause)?.stdout ?? "", { cause });
|
|
3161
|
+
const output = execFileOutputFailure(cause);
|
|
3162
|
+
throw new NativeDmgCommandFailure(commandFailureReason(cause, arguments_[0]), `hdiutil ${arguments_[0] ?? "operation"} failed: ${describeCommandFailure(cause, arguments_)}`, output?.stdout ?? "", {
|
|
3163
|
+
cause,
|
|
3164
|
+
processNotStarted: processNotStarted(cause)
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
if (result.exitCode !== 0) {
|
|
3168
|
+
const failure = {
|
|
3169
|
+
command: "/usr/bin/hdiutil",
|
|
3170
|
+
exitCode: result.exitCode,
|
|
3171
|
+
...result.cause === undefined ? {} : { code: processExitCode(result.cause) },
|
|
3172
|
+
stdout: result.stdout,
|
|
3173
|
+
...result.stderr === undefined ? {} : { stderr: result.stderr }
|
|
3174
|
+
};
|
|
3175
|
+
const reason = commandFailureReason(failure, arguments_[0]);
|
|
3176
|
+
const details = describeCommandFailure(failure, arguments_);
|
|
3177
|
+
const unknownVerifyFailure = arguments_[0] === "verify" && reason === "unavailable";
|
|
3178
|
+
throw new NativeDmgCommandFailure(reason, unknownVerifyFailure ? `hdiutil verify failed; captured diagnostics do not establish the failure cause: ${details}` : `hdiutil ${arguments_[0] ?? "operation"} failed: ${details}`, result.stdout, { cause: result.cause ?? failure });
|
|
3179
|
+
}
|
|
3180
|
+
return {
|
|
3181
|
+
stdout: result.stdout,
|
|
3182
|
+
exitCode: 0
|
|
3183
|
+
};
|
|
3184
|
+
};
|
|
3185
|
+
describeCommandFailure = (cause, arguments_) => {
|
|
3186
|
+
const fields = {
|
|
3187
|
+
command: "/usr/bin/hdiutil",
|
|
3188
|
+
arguments: [...arguments_]
|
|
3189
|
+
};
|
|
3190
|
+
if (typeof cause === "object" && cause !== null) {
|
|
3191
|
+
for (const key of [
|
|
3192
|
+
"code",
|
|
3193
|
+
"exitCode",
|
|
3194
|
+
"errno",
|
|
3195
|
+
"syscall",
|
|
3196
|
+
"signal",
|
|
3197
|
+
"stdout",
|
|
3198
|
+
"stderr"
|
|
3199
|
+
]) {
|
|
3200
|
+
const value = Reflect.get(cause, key);
|
|
3201
|
+
if (typeof value === "string" || typeof value === "number") fields[key] = value;
|
|
3202
|
+
}
|
|
3203
|
+
const code = Reflect.get(cause, "code");
|
|
3204
|
+
if (typeof code === "number") fields.exitCode = code;
|
|
3205
|
+
}
|
|
3206
|
+
if (cause instanceof ArtifactReaderFailure) fields.message = cause.message;
|
|
3207
|
+
else if (cause instanceof Error) fields.message = cause.message;
|
|
3208
|
+
return JSON.stringify(fields);
|
|
3209
|
+
};
|
|
3210
|
+
processExitCode = (cause) => {
|
|
3211
|
+
if (typeof cause !== "object" || cause === null) return undefined;
|
|
3212
|
+
const exitCode = Reflect.get(cause, "exitCode");
|
|
3213
|
+
if (typeof exitCode === "number") return exitCode;
|
|
3214
|
+
const code = Reflect.get(cause, "code");
|
|
3215
|
+
return typeof code === "number" ? code : undefined;
|
|
3216
|
+
};
|
|
3217
|
+
processOutput = (cause, field) => {
|
|
3218
|
+
if (typeof cause !== "object" || cause === null) return "";
|
|
3219
|
+
const value = Reflect.get(cause, field);
|
|
3220
|
+
return typeof value === "string" ? value : "";
|
|
3221
|
+
};
|
|
3222
|
+
commandFailureReason = (cause, operation) => {
|
|
3223
|
+
if (typeof cause !== "object" || cause === null) return "unavailable";
|
|
3224
|
+
const code = Reflect.get(cause, "code");
|
|
3225
|
+
const exitCode = Reflect.get(cause, "exitCode");
|
|
3226
|
+
if (typeof code === "number" || typeof exitCode === "number") return operation === "verify" ? verifyFailureReason(cause) : "unavailable";
|
|
3227
|
+
if (code === "ENOENT") {
|
|
3228
|
+
const syscall = Reflect.get(cause, "syscall");
|
|
3229
|
+
return typeof syscall === "string" && syscall.startsWith("spawn") ? "unavailable" : "io";
|
|
3230
|
+
}
|
|
3231
|
+
if (code === "EACCES" || code === "EPERM" || code === "EIO" || code === "ENOTDIR" || code === "EISDIR" || code === "ENODEV" || code === "EROFS" || code === "EMFILE" || code === "ENFILE") return "io";
|
|
3232
|
+
return "unavailable";
|
|
3233
|
+
};
|
|
3234
|
+
verifyFailureReason = (cause) => {
|
|
3235
|
+
const diagnostic = verifyFailureDiagnostic(processOutput(cause, "stdout"), processOutput(cause, "stderr"));
|
|
3236
|
+
switch (diagnostic) {
|
|
3237
|
+
case "image not recognized": return "format";
|
|
3238
|
+
case "invalid checksum":
|
|
3239
|
+
case "image data corrupted": return "integrity";
|
|
3240
|
+
case "No such file or directory":
|
|
3241
|
+
case "Permission denied":
|
|
3242
|
+
case "Input/output error": return "io";
|
|
3243
|
+
default: return "unavailable";
|
|
3244
|
+
}
|
|
3245
|
+
};
|
|
3246
|
+
verifyFailureDiagnostic = (stdout, stderr) => {
|
|
3247
|
+
const prefix = "hdiutil: verify failed - ";
|
|
3248
|
+
return `${stdout}\n${stderr}`.split(/\r?\n/u).map((line) => line.trim()).find((line) => line.startsWith(prefix))?.slice(prefix.length);
|
|
3249
|
+
};
|
|
3250
|
+
command = (arguments_, effects) => ({
|
|
3251
|
+
tool: "/usr/bin/hdiutil",
|
|
3252
|
+
arguments: [...arguments_],
|
|
3253
|
+
tool_version: null,
|
|
3254
|
+
executable_sha256: null,
|
|
3255
|
+
exit_code: 0,
|
|
3256
|
+
effects
|
|
3257
|
+
});
|
|
3258
|
+
})))();
|
|
3259
|
+
}
|
|
3260
|
+
|
|
3261
|
+
//#endregion
|
|
3262
|
+
//#region dist/artifacts/inventory/reader.js
|
|
3263
|
+
var createReader, inventoryLimitations;
|
|
3264
|
+
function init_reader() {
|
|
3265
|
+
return (init_reader = __esmMin((() => {
|
|
3266
|
+
init_AsarArtifactReader();
|
|
3267
|
+
init_DirectoryArtifactReader();
|
|
3268
|
+
init_MachOSliceArtifactReader();
|
|
3269
|
+
init_NativeDmgArtifactReader();
|
|
3270
|
+
init_ZipArtifactReader();
|
|
3271
|
+
init_zipPackageFormat();
|
|
3272
|
+
createReader = (path, format, environment, rootSource) => {
|
|
3273
|
+
if (isZipPackageFormat(format)) return new ZipArtifactReader(path, format, undefined, rootSource);
|
|
3274
|
+
switch (format) {
|
|
3275
|
+
case "directory": return new DirectoryArtifactReader(path);
|
|
3276
|
+
case "asar": return new AsarArtifactReader(path);
|
|
3277
|
+
case "mach-o-universal": return process.platform === "darwin" ? new MachOSliceArtifactReader(path, environment, undefined, rootSource) : undefined;
|
|
3278
|
+
case "dmg":
|
|
3279
|
+
if (process.platform !== "darwin") return undefined;
|
|
3280
|
+
return new NativeDmgArtifactReader(path, environment);
|
|
3281
|
+
default: return undefined;
|
|
3282
|
+
}
|
|
3283
|
+
};
|
|
3284
|
+
inventoryLimitations = (format, reader) => {
|
|
3285
|
+
if (reader !== undefined) return isZipPackageFormat(reader.format) ? [ZIP_NON_ENTRY_TAIL_LIMITATION] : [];
|
|
3286
|
+
if (format === "dmg" || format === "pkg") return [`${format.toUpperCase()} root hash is observed; child inventory requires a native macOS adapter.`];
|
|
3287
|
+
if (format === "mach-o-universal" && process.platform !== "darwin") return ["Universal Mach-O slices require the native macOS lipo adapter."];
|
|
3288
|
+
return ["Artifact has no child container entries."];
|
|
3289
|
+
};
|
|
3290
|
+
})))();
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3293
|
+
//#endregion
|
|
3294
|
+
//#region dist/artifacts/inventory/types.js
|
|
3295
|
+
var STRICT_INTEGRITY_POLICY;
|
|
3296
|
+
function init_types() {
|
|
3297
|
+
return (init_types = __esmMin((() => {
|
|
3298
|
+
STRICT_INTEGRITY_POLICY = { mode: "fail" };
|
|
3299
|
+
})))();
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
//#endregion
|
|
3303
|
+
//#region dist/artifacts/inventory/scanReader.js
|
|
3304
|
+
var UNAVAILABLE_UNPACKED_LIMITATION, emptyScan, scanReader, visitArtifactEntries, digestArtifactEntry, isExpandableAsar, isUnavailableUnpackedEntry;
|
|
3305
|
+
function init_scanReader() {
|
|
3306
|
+
return (init_scanReader = __esmMin((() => {
|
|
3307
|
+
init_ArtifactPaths();
|
|
3308
|
+
init_ArtifactReader();
|
|
3309
|
+
init_AsarArtifactReader();
|
|
3310
|
+
init_ArtifactGraphConstruction();
|
|
3311
|
+
init_types();
|
|
3312
|
+
init_ArtifactHash();
|
|
3313
|
+
UNAVAILABLE_UNPACKED_LIMITATION = "ASAR unpacked companion bytes were unavailable; no content hash or child artifact was produced.";
|
|
3314
|
+
emptyScan = () => ({
|
|
3315
|
+
nodes: new Map(),
|
|
3316
|
+
occurrences: [],
|
|
3317
|
+
pendingContradictions: []
|
|
3318
|
+
});
|
|
3319
|
+
scanReader = async (reader, ownedReaders, signal, integrity = STRICT_INTEGRITY_POLICY) => {
|
|
3320
|
+
const { nodes, occurrences, pendingContradictions } = emptyScan();
|
|
3321
|
+
if (reader === undefined) return {
|
|
3322
|
+
nodes,
|
|
3323
|
+
occurrences,
|
|
3324
|
+
pendingContradictions,
|
|
3325
|
+
caseCollisionLimitation: undefined
|
|
3326
|
+
};
|
|
3327
|
+
const context = {
|
|
3328
|
+
reader,
|
|
3329
|
+
signal,
|
|
3330
|
+
integrity,
|
|
3331
|
+
nodes,
|
|
3332
|
+
occurrences,
|
|
3333
|
+
pendingContradictions,
|
|
3334
|
+
occurrenceByPath: new Map(),
|
|
3335
|
+
registry: new ArtifactPathRegistry(),
|
|
3336
|
+
expandedContainerIds: new Set(),
|
|
3337
|
+
ownedReaders
|
|
3338
|
+
};
|
|
3339
|
+
await visitArtifactEntries(context, reader, "");
|
|
3340
|
+
resolveOccurrenceParents(occurrences, context.occurrenceByPath, context.expandedContainerIds);
|
|
3341
|
+
return {
|
|
3342
|
+
nodes,
|
|
3343
|
+
occurrences,
|
|
3344
|
+
pendingContradictions,
|
|
3345
|
+
caseCollisionLimitation: annotateEnglishUnicodeCaseCollisions(occurrences)
|
|
3346
|
+
};
|
|
3347
|
+
};
|
|
3348
|
+
visitArtifactEntries = async (context, currentReader, prefix) => {
|
|
3349
|
+
const stack = [{
|
|
3350
|
+
reader: currentReader,
|
|
3351
|
+
prefix,
|
|
3352
|
+
iterator: currentReader.entries(context.signal)[Symbol.asyncIterator]()
|
|
3353
|
+
}];
|
|
3354
|
+
let failure;
|
|
3355
|
+
try {
|
|
3356
|
+
while (stack.length > 0) {
|
|
3357
|
+
const frame = stack.at(-1);
|
|
3358
|
+
if (frame === undefined) break;
|
|
3359
|
+
const next = await frame.iterator.next();
|
|
3360
|
+
if (next.done) {
|
|
3361
|
+
stack.pop();
|
|
3362
|
+
continue;
|
|
3363
|
+
}
|
|
3364
|
+
const entry = next.value;
|
|
3365
|
+
const logicalPath = normalizeArtifactPath(frame.prefix.length === 0 ? entry.path : `${frame.prefix}/${entry.path}`);
|
|
3366
|
+
const expandableAsar = isExpandableAsar(entry, logicalPath);
|
|
3367
|
+
context.registry.add(logicalPath, expandableAsar ? "directory" : entry.kind);
|
|
3368
|
+
const occurrence = createOccurrence(entry, logicalPath, null);
|
|
3369
|
+
let digested;
|
|
3370
|
+
try {
|
|
3371
|
+
digested = await digestArtifactEntry(context, frame.reader, entry, logicalPath);
|
|
3372
|
+
} catch (cause) {
|
|
3373
|
+
if (!isUnavailableUnpackedEntry(cause, entry)) throw cause;
|
|
3374
|
+
occurrence.hash_status = "unavailable";
|
|
3375
|
+
occurrence.limitations.push(UNAVAILABLE_UNPACKED_LIMITATION);
|
|
3376
|
+
}
|
|
3377
|
+
if (digested === undefined) noteUnreadContainerSuffix(occurrence);
|
|
3378
|
+
else {
|
|
3379
|
+
context.nodes.set(digested.node.artifact_id, digested.node);
|
|
3380
|
+
occurrence.artifact_id = digested.node.artifact_id;
|
|
3381
|
+
occurrence.artifact_kind = digested.classification.kind;
|
|
3382
|
+
occurrence.artifact_format = digested.classification.format;
|
|
3383
|
+
occurrence.hash_status = digested.mismatched ? "mismatched" : "verified";
|
|
3384
|
+
if (digested.mismatched) occurrence.limitations.push("Declared integrity metadata contradicts observed bytes.");
|
|
3385
|
+
}
|
|
3386
|
+
context.occurrences.push(occurrence);
|
|
3387
|
+
context.occurrenceByPath.set(logicalPath, occurrence);
|
|
3388
|
+
if (expandableAsar && digested !== undefined && digested.classification.format === "asar" && !digested.mismatched) {
|
|
3389
|
+
const nested = new AsarArtifactReader(entry.adapterKey);
|
|
3390
|
+
context.ownedReaders.push(nested);
|
|
3391
|
+
await nested.prepareContainer(digested.node.sha256, context.signal);
|
|
3392
|
+
context.expandedContainerIds.add(occurrence.occurrence_id);
|
|
3393
|
+
stack.push({
|
|
3394
|
+
reader: nested,
|
|
3395
|
+
prefix: logicalPath,
|
|
3396
|
+
iterator: nested.entries(context.signal)[Symbol.asyncIterator]()
|
|
3397
|
+
});
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
} catch (cause) {
|
|
3401
|
+
failure = { cause };
|
|
3402
|
+
} finally {
|
|
3403
|
+
for (const { iterator, prefix, reader } of stack.reverse()) {
|
|
3404
|
+
try {
|
|
3405
|
+
await iterator.return?.();
|
|
3406
|
+
} catch (cause) {
|
|
3407
|
+
failure = { cause: ArtifactReaderFailure.withCleanup(failure === undefined ? cause : failure.cause, ArtifactReaderFailure.cleanupObservation(cause, `artifact traversal for ${prefix || reader.format}`)) };
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
if (failure !== undefined) throw failure.cause;
|
|
3412
|
+
};
|
|
3413
|
+
digestArtifactEntry = async (context, currentReader, entry, logicalPath) => {
|
|
3414
|
+
if (entry.kind !== "file" && entry.kind !== "slice" || entry.encrypted) return undefined;
|
|
3415
|
+
const digest = await hashReadable(await currentReader.open(entry, context.signal), context.signal);
|
|
3416
|
+
const mismatched = entry.declaredSha256 !== null && entry.declaredSha256 !== digest.sha256;
|
|
3417
|
+
if (mismatched && entry.declaredSha256 !== null) {
|
|
3418
|
+
if (context.integrity.mode === "fail") throw new ArtifactReaderFailure("integrity", `Artifact integrity metadata disagrees with content: ${logicalPath}`, undefined, {
|
|
3419
|
+
logicalPath,
|
|
3420
|
+
declaredSha256: entry.declaredSha256,
|
|
3421
|
+
calculatedSha256: digest.sha256,
|
|
3422
|
+
unpacked: entry.unpacked
|
|
3423
|
+
});
|
|
3424
|
+
context.pendingContradictions.push({
|
|
3425
|
+
logicalPath,
|
|
3426
|
+
declaredSha256: entry.declaredSha256,
|
|
3427
|
+
observedSha256: digest.sha256,
|
|
3428
|
+
entryKind: entry.kind,
|
|
3429
|
+
unpacked: entry.unpacked
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3432
|
+
const classified = entry.kind === "slice" ? {
|
|
3433
|
+
kind: "universal-slice",
|
|
3434
|
+
format: "mach-o"
|
|
3435
|
+
} : classifyArtifactContent(logicalPath, digest.prefix, digest.bytes);
|
|
3436
|
+
return {
|
|
3437
|
+
node: createArtifactNode({
|
|
3438
|
+
sha256: digest.sha256,
|
|
3439
|
+
size: digest.bytes,
|
|
3440
|
+
format: classifyArtifactBytes(digest.prefix, digest.bytes),
|
|
3441
|
+
contentState: "embedded"
|
|
3442
|
+
}),
|
|
3443
|
+
mismatched,
|
|
3444
|
+
classification: classified
|
|
3445
|
+
};
|
|
3446
|
+
};
|
|
3447
|
+
isExpandableAsar = (entry, logicalPath) => entry.kind === "file" && logicalPath.toLowerCase().endsWith(".asar") && isAbsolute(entry.adapterKey);
|
|
3448
|
+
isUnavailableUnpackedEntry = (cause, entry) => entry.unpacked && cause instanceof ArtifactReaderFailure && cause.reason === "unavailable";
|
|
3449
|
+
})))();
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3452
|
+
//#endregion
|
|
3453
|
+
//#region dist/artifacts/inventory/scanCanonical.js
|
|
3454
|
+
var scanCanonicalArtifactInventory, scanCanonicalArtifactInventoryInScope, cleanupInventoryOwners, buildInventorySnapshot, buildIntegrityContradictions, verifyRootDigest, sortNodes, sortOccurrences, sortEdges, buildManifest, buildLimitations;
|
|
3455
|
+
function init_scanCanonical() {
|
|
3456
|
+
return (init_scanCanonical = __esmMin((() => {
|
|
3457
|
+
init_unicodeCodePointOrder();
|
|
3458
|
+
init_AsarArtifactReader();
|
|
3459
|
+
init_ArtifactReader();
|
|
3460
|
+
init_artifactGraph();
|
|
3461
|
+
init_ArtifactGraphConstruction();
|
|
3462
|
+
init_artifactIdentity();
|
|
3463
|
+
init_classify();
|
|
3464
|
+
init_hostExecutableMarking();
|
|
3465
|
+
init_hashStableRootArtifact();
|
|
3466
|
+
init_reader();
|
|
3467
|
+
init_scanReader();
|
|
3468
|
+
init_types();
|
|
3469
|
+
scanCanonicalArtifactInventory = async (path, options, readerFactory = createReader) => options.resourceScope.run(() => scanCanonicalArtifactInventoryInScope(path, options, readerFactory));
|
|
3470
|
+
scanCanonicalArtifactInventoryInScope = async (path, options, readerFactory = createReader) => {
|
|
3471
|
+
const integrity = options.integrity ?? STRICT_INTEGRITY_POLICY;
|
|
3472
|
+
const metadata = await lstat(path);
|
|
3473
|
+
const { format: rootFormat, digest: rootDigest, rootSource } = await classifyAndHashRootForInventory(path, metadata.isDirectory(), metadata, options);
|
|
3474
|
+
let reader;
|
|
3475
|
+
let readerCreationFailure;
|
|
3476
|
+
try {
|
|
3477
|
+
reader = readerFactory(path, rootFormat, options.environment ?? {}, rootSource);
|
|
3478
|
+
} catch (cause) {
|
|
3479
|
+
readerCreationFailure = { cause };
|
|
3480
|
+
}
|
|
3481
|
+
const ownedReaders = reader === undefined ? [] : [reader];
|
|
3482
|
+
let outcome;
|
|
3483
|
+
try {
|
|
3484
|
+
if (readerCreationFailure !== undefined) throw readerCreationFailure.cause;
|
|
3485
|
+
if (reader instanceof AsarArtifactReader) await reader.prepareContainer(rootDigest?.sha256, options.signal);
|
|
3486
|
+
const { nodes, occurrences, pendingContradictions, caseCollisionLimitation } = await scanReader(reader, ownedReaders, options.signal, integrity);
|
|
3487
|
+
outcome = {
|
|
3488
|
+
kind: "completed",
|
|
3489
|
+
snapshot: await buildInventorySnapshot({
|
|
3490
|
+
path,
|
|
3491
|
+
metadata,
|
|
3492
|
+
rootFormat,
|
|
3493
|
+
rootDigest,
|
|
3494
|
+
rootSource,
|
|
3495
|
+
resourceScope: options.resourceScope,
|
|
3496
|
+
reader,
|
|
3497
|
+
signal: options.signal,
|
|
3498
|
+
nodes,
|
|
3499
|
+
occurrences,
|
|
3500
|
+
pendingContradictions,
|
|
3501
|
+
caseCollisionLimitation
|
|
3502
|
+
})
|
|
3503
|
+
};
|
|
3504
|
+
} catch (cause) {
|
|
3505
|
+
outcome = {
|
|
3506
|
+
kind: "failed",
|
|
3507
|
+
cause
|
|
3508
|
+
};
|
|
3509
|
+
}
|
|
3510
|
+
const cleanupFailure = await cleanupInventoryOwners({
|
|
3511
|
+
path,
|
|
3512
|
+
options,
|
|
3513
|
+
rootSource,
|
|
3514
|
+
ownedReaders,
|
|
3515
|
+
outcome
|
|
3516
|
+
});
|
|
3517
|
+
if (cleanupFailure !== undefined) throw cleanupFailure;
|
|
3518
|
+
if (outcome.kind === "failed") throw outcome.cause;
|
|
3519
|
+
return outcome.snapshot;
|
|
3520
|
+
};
|
|
3521
|
+
cleanupInventoryOwners = async ({ path, options, rootSource, ownedReaders, outcome }) => {
|
|
3522
|
+
let cleanupFailure;
|
|
3523
|
+
const owners = [...ownedReaders].reverse().map((reader) => ({
|
|
3524
|
+
kind: "reader",
|
|
3525
|
+
reader,
|
|
3526
|
+
resource: `artifact reader for ${path}`
|
|
3527
|
+
}));
|
|
3528
|
+
if (rootSource !== undefined) owners.push({
|
|
3529
|
+
kind: "file-handle",
|
|
3530
|
+
handle: rootSource.owner,
|
|
3531
|
+
resource: `root artifact descriptor for ${path}`
|
|
3532
|
+
});
|
|
3533
|
+
for (const owner of owners) {
|
|
3534
|
+
const attempt = await options.resourceScope.release(owner);
|
|
3535
|
+
if (attempt.kind === "released") continue;
|
|
3536
|
+
const primary = cleanupFailure ?? (outcome.kind === "failed" ? outcome.cause : attempt.cause);
|
|
3537
|
+
cleanupFailure = ArtifactReaderFailure.withCleanup(primary, ArtifactReaderFailure.cleanupObservation(attempt.cause, owner.resource), outcome.kind === "completed" ? {
|
|
3538
|
+
kind: "artifact-inventory",
|
|
3539
|
+
inventory: outcome.snapshot
|
|
3540
|
+
} : undefined);
|
|
3541
|
+
}
|
|
3542
|
+
return cleanupFailure;
|
|
3543
|
+
};
|
|
3544
|
+
buildInventorySnapshot = async (input) => {
|
|
3545
|
+
const { path, metadata, rootFormat, rootDigest, rootSource, reader, signal } = input;
|
|
3546
|
+
materializeDirectoryNodes(input.occurrences, input.nodes);
|
|
3547
|
+
const rootNode = createRootNode({
|
|
3548
|
+
digest: rootDigest,
|
|
3549
|
+
occurrences: input.occurrences
|
|
3550
|
+
});
|
|
3551
|
+
input.nodes.set(rootNode.artifact_id, rootNode);
|
|
3552
|
+
rekeyOccurrences(rootNode.artifact_id, input.occurrences);
|
|
3553
|
+
const rootOccurrence = rootOccurrenceFor(rootNode, {
|
|
3554
|
+
size: metadata.size,
|
|
3555
|
+
executable: hostExecutableMarking(path, metadata),
|
|
3556
|
+
format: rootFormat,
|
|
3557
|
+
path
|
|
3558
|
+
});
|
|
3559
|
+
for (const occurrence of input.occurrences) if (occurrence.parent_occurrence_id === null) occurrence.parent_occurrence_id = rootOccurrence.occurrence_id;
|
|
3560
|
+
input.occurrences.unshift(rootOccurrence);
|
|
3561
|
+
const occurrenceById = new Map(input.occurrences.map((occurrence) => [occurrence.occurrence_id, occurrence]));
|
|
3562
|
+
const occurrenceByPath = indexOccurrencesByPath(input.occurrences);
|
|
3563
|
+
const integrityContradictions = buildIntegrityContradictions(input.pendingContradictions, occurrenceByPath, occurrenceById, rootNode);
|
|
3564
|
+
const edges = createArtifactEdges(rootNode.artifact_id, input.occurrences, reader?.provenance()[0]);
|
|
3565
|
+
const orderedNodes = sortNodes([...input.nodes.values()]);
|
|
3566
|
+
const orderedOccurrences = sortOccurrences(input.occurrences);
|
|
3567
|
+
const orderedEdges = sortEdges(edges).map((edge, ordinal) => ({
|
|
3568
|
+
...edge,
|
|
3569
|
+
ordinal
|
|
3570
|
+
}));
|
|
3571
|
+
await verifyRootDigest(path, rootDigest, rootSource, input.resourceScope, signal);
|
|
3572
|
+
const graphSha256 = artifactGraphDigest({
|
|
3573
|
+
nodes: orderedNodes,
|
|
3574
|
+
occurrences: orderedOccurrences,
|
|
3575
|
+
edges: orderedEdges,
|
|
3576
|
+
contradictions: integrityContradictions
|
|
3577
|
+
});
|
|
3578
|
+
const manifest = buildManifest({
|
|
3579
|
+
rootNode,
|
|
3580
|
+
rootFormat,
|
|
3581
|
+
graphSha256,
|
|
3582
|
+
orderedNodes,
|
|
3583
|
+
orderedOccurrences,
|
|
3584
|
+
orderedEdges
|
|
3585
|
+
});
|
|
3586
|
+
return {
|
|
3587
|
+
manifest,
|
|
3588
|
+
nodes: orderedNodes,
|
|
3589
|
+
occurrences: orderedOccurrences,
|
|
3590
|
+
edges: orderedEdges,
|
|
3591
|
+
provenance: reader?.provenance() ?? [],
|
|
3592
|
+
integrity_contradictions: integrityContradictions,
|
|
3593
|
+
limitations: buildLimitations(rootFormat, reader, integrityContradictions, input.caseCollisionLimitation)
|
|
3594
|
+
};
|
|
3595
|
+
};
|
|
3596
|
+
buildIntegrityContradictions = (pending, occurrenceByPath, occurrenceById, rootNode) => pending.map((contradiction) => {
|
|
3597
|
+
const occurrence = occurrenceByPath.get(contradiction.logicalPath);
|
|
3598
|
+
if (occurrence === undefined) throw new ArtifactReaderFailure("integrity", "Integrity contradiction lost its graph occurrence");
|
|
3599
|
+
const parent = occurrence.parent_occurrence_id === null ? undefined : occurrenceById.get(occurrence.parent_occurrence_id);
|
|
3600
|
+
const parentArtifactId = parent?.artifact_id ?? rootNode.artifact_id;
|
|
3601
|
+
return {
|
|
3602
|
+
contradiction_id: artifactContradictionId({
|
|
3603
|
+
rootArtifactId: rootNode.artifact_id,
|
|
3604
|
+
logicalPath: contradiction.logicalPath,
|
|
3605
|
+
declaredSha256: contradiction.declaredSha256,
|
|
3606
|
+
observedSha256: contradiction.observedSha256
|
|
3607
|
+
}),
|
|
3608
|
+
occurrence_id: occurrence.occurrence_id,
|
|
3609
|
+
parent_artifact_id: parentArtifactId,
|
|
3610
|
+
logical_path: contradiction.logicalPath,
|
|
3611
|
+
declared_sha256: contradiction.declaredSha256,
|
|
3612
|
+
observed_sha256: contradiction.observedSha256,
|
|
3613
|
+
entry_kind: contradiction.entryKind,
|
|
3614
|
+
unpacked: contradiction.unpacked,
|
|
3615
|
+
trust: "observed-untrusted",
|
|
3616
|
+
provenance: "container-integrity-metadata-versus-observed-bytes",
|
|
3617
|
+
limitations: ["Observed bytes contradict declared integrity metadata and cannot support equivalence."]
|
|
3618
|
+
};
|
|
3619
|
+
});
|
|
3620
|
+
verifyRootDigest = async (path, rootDigest, rootSource, resourceScope, signal) => {
|
|
3621
|
+
if (rootDigest === null) return;
|
|
3622
|
+
const verified = rootSource === undefined ? await hashStableRootArtifact(path, resourceScope, signal) : await hashStableRootArtifactHandle(path, rootSource.handle, rootSource.initial, signal);
|
|
3623
|
+
if (verified.sha256 !== rootDigest.sha256 || verified.bytes !== rootDigest.bytes) throw new ArtifactReaderFailure("integrity", "Root artifact changed during inventory");
|
|
3624
|
+
};
|
|
3625
|
+
sortNodes = (nodes) => nodes.sort((left, right) => compareUnicodeCodePoints(left.artifact_id, right.artifact_id));
|
|
3626
|
+
sortOccurrences = (occurrences) => occurrences.sort((left, right) => compareUnicodeCodePoints(left.logical_path, right.logical_path));
|
|
3627
|
+
sortEdges = (edges) => edges.sort((left, right) => compareUnicodeCodePoints(left.edge_id, right.edge_id));
|
|
3628
|
+
buildManifest = ({ rootNode, rootFormat, graphSha256, orderedNodes, orderedOccurrences, orderedEdges }) => artifactInventoryResultSchema.shape.manifest.parse({
|
|
3629
|
+
manifest_id: artifactManifestId(rootNode.artifact_id, graphSha256),
|
|
3630
|
+
root_artifact_id: rootNode.artifact_id,
|
|
3631
|
+
root_sha256: rootNode.sha256,
|
|
3632
|
+
root_format: rootFormat,
|
|
3633
|
+
graph_sha256: graphSha256,
|
|
3634
|
+
node_count: orderedNodes.length,
|
|
3635
|
+
occurrence_count: orderedOccurrences.length,
|
|
3636
|
+
edge_count: orderedEdges.length
|
|
3637
|
+
});
|
|
3638
|
+
buildLimitations = (rootFormat, reader, integrityContradictions, caseCollisionLimitation) => [
|
|
3639
|
+
...inventoryLimitations(rootFormat, reader),
|
|
3640
|
+
...caseCollisionLimitation === undefined ? [] : [caseCollisionLimitation],
|
|
3641
|
+
...integrityContradictions.length === 0 ? [] : [`${String(integrityContradictions.length)} integrity contradiction(s) were recorded; mismatched content is observed-untrusted.`]
|
|
3642
|
+
];
|
|
3643
|
+
})))();
|
|
3644
|
+
}
|
|
3645
|
+
|
|
3646
|
+
//#endregion
|
|
3647
|
+
export { init_ArtifactPaths as C, init_ZipArtifactReader as E, DESTINATION_CASE_COLLISION_PREFIX as S, ZipArtifactReader as T, SafeOutputTreeCreationFailure as _, hasMachoMagic as a, streamChunkToBuffer as b, abortIfNeeded as c, DirectoryArtifactReader as d, init_DirectoryArtifactReader as f, init_SafeOutputTree as g, SafeOutputTree as h, init_MachOSliceArtifactReader as i, hashReadable as l, init_AsarArtifactReader as m, scanCanonicalArtifactInventoryInScope as n, init_MachoLoadCommandReader as o, AsarArtifactReader as p, MachOSliceArtifactReader as r, readMachoImage as s, init_scanCanonical as t, init_ArtifactHash as u, init_SafeOutputTreeCreationFailure as v, normalizeArtifactPath as w, ArtifactPathRegistry as x, init_StreamBytes as y };
|