rea-agents 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -17
- package/bridge/android/ReaJadxBridge.java +14 -5
- package/bridge/ghidra/ReaGhidraBridge.java +173 -47
- package/bridge/hopper_bridge.py +310 -128
- package/bridge/mitmproxy/capture.py +0 -2
- package/bridge/native/rea_lldb_tracer.py +630 -94
- package/bridge/process/ProcessRunTokenReader.swift +39 -5
- package/bridge/pwntools/recorded_crash_impl.py +4 -0
- package/dist/android/JadxConfiguration.js +196 -33
- package/dist/android/JadxMcpTransport.js +4 -0
- package/dist/android/JadxProtocol.js +6 -0
- package/dist/android/JadxProvider.js +19 -2
- package/dist/android/JadxSession.js +23 -4
- package/dist/application/AnalysisContextQueries.js +8 -35
- package/dist/application/AnalysisDocument.js +32 -0
- package/dist/application/AppBundleExecutable.js +67 -21
- package/dist/application/CallPathTracing.js +19 -3
- package/dist/application/CapabilityInventory.js +6 -3
- package/dist/application/ClientConfigurationDocument.js +871 -6
- package/dist/application/ClientRegistrationIdentity.js +26 -5
- package/dist/application/ClientRegistrationStatus.js +29 -14
- package/dist/application/DirectAnalysis.js +27 -37
- package/dist/application/Doctor.js +4 -2
- package/dist/application/DoctorScope.js +25 -13
- package/dist/application/EnhancedLiteralTracing.js +22 -25
- package/dist/application/EnhancedTools.js +13 -11
- package/dist/application/EvidenceBundleFiles.js +23 -11
- package/dist/application/FunctionAnalysisEvidence.js +2 -3
- package/dist/application/InventoryProjectionEvidence.js +4 -3
- package/dist/application/InvestigationProviders.js +3 -2
- package/dist/application/JsonFiles.js +50 -28
- package/dist/application/ProcedureAddressResolution.js +11 -0
- package/dist/application/ReconstructionCoverageService.js +7 -4
- package/dist/application/ReconstructionObligationLedgerService.js +4 -3
- package/dist/application/Setup.js +13 -1
- package/dist/application/SetupClientConfiguration.js +10 -15
- package/dist/application/SetupHost.js +5 -2
- package/dist/application/SetupPlan.js +5 -3
- package/dist/application/SupportedClients.js +34 -1
- package/dist/application/Uninstall.js +4 -3
- package/dist/application/Update.js +18 -3
- package/dist/application/UpdateRuntime.js +46 -25
- package/dist/application/WebModuleTraceService.js +4 -2
- package/dist/application/WebNetworkCaptureService.js +4 -2
- package/dist/application/WebRuntimeService.js +5 -3
- package/dist/application/WebScriptExportService.js +2 -2
- package/dist/application/WebSourceLocationService.js +4 -2
- package/dist/application/WorkflowEvidence.js +82 -0
- package/dist/application/binary/AnalysisProviderEvaluation.js +21 -5
- package/dist/application/binary/AnalysisProviderRegistry.js +2 -0
- package/dist/application/binary/AnalysisSnapshotCache.js +3 -6
- package/dist/application/binary/BinarySession.js +95 -68
- package/dist/application/binary/BinarySessionOpen.js +3 -3
- package/dist/application/binary/BinarySessionRecords.js +25 -3
- package/dist/application/binary/BinarySessionStatus.js +17 -1
- package/dist/application/binary/CompositeProvider.js +13 -0
- package/dist/application/binary/LazyAnalysisProvider.js +3 -0
- package/dist/application/binaryDiagnostics/BinaryLayoutService.js +4 -2
- package/dist/application/binaryDiagnostics/RecordedCrashService.js +4 -2
- package/dist/application/evm/EvmInterfaceService.js +4 -2
- package/dist/application/investigation/EvidenceLedger.js +21 -7
- package/dist/application/investigation/InvestigationRecords.js +8 -0
- package/dist/application/javascript/JavaScriptAnalysisControl.js +34 -0
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +24 -3
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +19 -2
- package/dist/application/javascript/JavaScriptApplicationService.js +22 -15
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +5 -5
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +5 -4
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +39 -7
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +6 -3
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +11 -3
- package/dist/application/javascript/JavaScriptModuleRelationships.js +37 -8
- package/dist/application/javascript/JavaScriptRecoveryService.js +4 -2
- package/dist/application/javascript/JavaScriptRuntimeObservationService.js +3 -1
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +3 -3
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +63 -61
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +23 -1
- package/dist/application/managed/ManagedApplicationGraphService.js +4 -3
- package/dist/application/managed/ManagedMemberComparisonService.js +7 -4
- package/dist/application/managed/ManagedNativeVerificationService.js +4 -3
- package/dist/application/managed/ManagedReconstructionService.js +4 -3
- package/dist/application/process/ProcessCli.js +14 -6
- package/dist/application/process/ProcessEvidence.js +4 -3
- package/dist/application/workflowInputError.js +18 -0
- package/dist/artifacts/ArtifactProvider.js +12 -2
- package/dist/artifacts/MachOSliceArtifactReader.js +98 -14
- package/dist/artifacts/NativeDmgArtifactReader.js +13 -6
- package/dist/artifacts/apple/AppleAssetCatalogAnalysis.js +22 -3
- package/dist/artifacts/apple/InterfaceBuilderAnalysis.js +176 -56
- package/dist/artifacts/apple/InterfaceBuilderDecodeBudget.js +195 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +36 -22
- package/dist/artifacts/apple/MachoLoadCommandReader.js +92 -31
- package/dist/artifacts/apple/NibArchive.js +81 -14
- package/dist/artifacts/apple/NibViewHierarchy.js +10 -3
- package/dist/artifacts/apple/PlistNumberLiterals.js +164 -0
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +13 -8
- package/dist/artifacts/inventory/scanCanonical.js +11 -14
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +6 -2
- package/dist/browser/CdpCaptureCompleteness.js +2 -0
- package/dist/browser/CdpCaptureEventHandlers.js +76 -11
- package/dist/browser/CdpCaptureEventTypes.js +5 -1
- package/dist/browser/CdpCaptureEvents.js +25 -0
- package/dist/browser/CdpConnection.js +30 -11
- package/dist/browser/CdpOptionalCommand.js +2 -3
- package/dist/browser/CdpPageCapture.js +23 -1
- package/dist/browser/PlaywrightElectronActiveActions.js +32 -23
- package/dist/browser/PlaywrightElectronActiveProjection.js +141 -0
- package/dist/browser/PlaywrightElectronActiveProvider.js +123 -124
- package/dist/browser/WebSourceMapFetcher.js +426 -72
- package/dist/browser/assets/LocalWebScriptArtifacts.js +2 -2
- package/dist/browser/history/CaptureFailures.js +37 -1
- package/dist/browser/history/CaptureRelease.js +5 -0
- package/dist/browser/history/HarCaptureAdapter.js +3 -3
- package/dist/browser/history/HarJson.js +3 -2
- package/dist/browser/history/HistoricalCaptureDecoder.js +4 -2
- package/dist/cli/analysisSelector.js +23 -0
- package/dist/cli/applicationCommands.js +2 -3
- package/dist/cli/coreBinaryCommands.js +70 -12
- package/dist/cli/electronCommands.js +7 -6
- package/dist/cli/javascriptApplicationAnalysis.js +7 -3
- package/dist/cli/jsonOutput.js +4 -99
- package/dist/cli/nativeCallCommands.js +2 -3
- package/dist/cli/webRuntimeCommands.js +8 -8
- package/dist/cli.js +2 -1
- package/dist/cliCommandNames.js +0 -1
- package/dist/cliJsonInput.js +9 -4
- package/dist/config/environment.js +4 -0
- package/dist/config/ghidraStartupTimeout.js +17 -0
- package/dist/config/mcpResponseBudget.js +22 -0
- package/dist/config/parseConfig.js +2 -1
- package/dist/contracts/enhancedInputs.js +5 -3
- package/dist/contracts/enhancedToolContracts.js +3 -3
- package/dist/contracts/hopperMemoryContracts.js +2 -5
- package/dist/contracts/javascript/electronToolContracts.js +1 -1
- package/dist/contracts/managed/managedToolContracts.js +2 -4
- package/dist/contracts/native/nativeToolContracts.js +4 -2
- package/dist/contracts/officialToolContracts.js +14 -15
- package/dist/contracts/promptContracts.js +3 -3
- package/dist/contracts/sessionLifecycleInputs.js +3 -7
- package/dist/contracts/sessionStatusContract.js +2 -4
- package/dist/contracts/sessionToolContracts.js +4 -6
- package/dist/contracts/sessionToolSchemas.js +2 -5
- package/dist/contracts/toolContractExamples.js +0 -1
- package/dist/contracts/toolContractHelpers.js +4 -1
- package/dist/contracts/toolEffects.js +0 -1
- package/dist/contracts/toolOutputSchemaGroups.js +28 -27
- package/dist/contracts/toolOutputSchemaPrimitives.js +18 -0
- package/dist/contracts/toolSchemaMetadata.js +69 -10
- package/dist/contracts/webNetworkCaptureToolContracts.js +1 -1
- package/dist/domain/analysisErrorBase.js +8 -3
- package/dist/domain/analysisErrorCore.js +3 -1
- package/dist/domain/analysisErrorPresentation.js +72 -17
- package/dist/domain/analysisErrorProjection.js +106 -27
- package/dist/domain/android/androidAnalysis.js +2 -4
- package/dist/domain/android/androidApplication.js +17 -9
- package/dist/domain/apple/appleApplication.js +41 -14
- package/dist/domain/apple/dyldEnvironment.js +73 -0
- package/dist/domain/apple/dylibResolution.js +120 -9
- package/dist/domain/apple/dylibResolutionFindings.js +9 -7
- package/dist/domain/apple/interfaceBuilderGraph.js +25 -13
- package/dist/domain/apple/interfaceBuilderKeyedArchive.js +13 -3
- package/dist/domain/apple/keyedArchive.js +9 -1
- package/dist/domain/apple/machoContainer.js +54 -0
- package/dist/domain/apple/plistNumbers.js +76 -0
- package/dist/domain/artifactIdentity.js +29 -0
- package/dist/domain/artifactInventoryEvidence.js +19 -24
- package/dist/domain/bridgeCandidateProjection.js +71 -0
- package/dist/domain/browserCompleteness.js +1 -0
- package/dist/domain/browserObservationError.js +24 -5
- package/dist/domain/browserScenarioValues.js +2 -6
- package/dist/domain/bundleComparison.js +3 -2
- package/dist/domain/canonicalJsonDigestSteps.js +133 -0
- package/dist/domain/canonicalOrdering.js +9 -5
- package/dist/domain/changedBehavior.js +6 -6
- package/dist/domain/comparisonSourceEvidence.js +40 -0
- package/dist/domain/configurationErrors.js +1 -1
- package/dist/domain/evidence.js +64 -9
- package/dist/domain/evidenceBundle.js +42 -1
- package/dist/domain/evidenceErrors.js +12 -1
- package/dist/domain/explicitSensitiveFailure.js +17 -1
- package/dist/domain/firmware/firmwareAnalysis.js +6 -7
- package/dist/domain/hopperErrors.js +23 -2
- package/dist/domain/hopperValues.js +51 -8
- package/dist/domain/immutableJson.js +114 -0
- package/dist/domain/inputIssueProjection.js +3 -0
- package/dist/domain/javascript/electronActiveObservation.js +30 -4
- package/dist/domain/javascript/electronStaticAnalysisValues.js +6 -12
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +71 -23
- package/dist/domain/javascript/javascriptApplicationGraph.js +13 -0
- package/dist/domain/javascript/javascriptAstValues.js +20 -0
- package/dist/domain/javascript/javascriptRecovery.js +3 -8
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +97 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +6 -5
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +9 -17
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +22 -5
- package/dist/domain/javascript/javascriptSemanticGraph.js +13 -0
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +1 -0
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +25 -17
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -4
- package/dist/domain/javascript/javascriptSemanticResourceLimits.js +77 -0
- package/dist/domain/javascript/javascriptSemanticValues.js +83 -11
- package/dist/domain/javascript/javascriptSourceParser.js +6 -2
- package/dist/domain/javascript/javascriptStaticAnalysis.js +22 -17
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -3
- package/dist/domain/javascript/javascriptStaticAnalysisCalls.js +14 -4
- package/dist/domain/javascript/javascriptStaticAnalysisFindings.js +66 -7
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +28 -16
- package/dist/domain/javascript/javascriptStaticAnalysisState.js +3 -2
- package/dist/domain/jsonSerialization.js +109 -0
- package/dist/domain/jsonValue.js +90 -6
- package/dist/domain/localPath.js +6 -0
- package/dist/domain/managed/managedApplicationGraph.js +10 -10
- package/dist/domain/managed/managedInspectionEvidence.js +16 -0
- package/dist/domain/managed/managedMemberComparisonMatch.js +5 -9
- package/dist/domain/managed/managedNativeVerification.js +3 -9
- package/dist/domain/native/fileOffsetPartialObservation.js +1 -0
- package/dist/domain/native/nativeCallObservation.js +33 -11
- package/dist/domain/native/nativeCallPartialObservation.js +33 -0
- package/dist/domain/process/processCapture.js +8 -4
- package/dist/domain/process/processComparison.js +38 -4
- package/dist/domain/process/processScenario.js +11 -10
- package/dist/domain/propertyListKeys.js +1 -1
- package/dist/domain/propertyListXmlText.js +19 -0
- package/dist/domain/providerAdapterError.js +1 -1
- package/dist/domain/providerOperationHealth.js +54 -0
- package/dist/domain/reconstructionVerification.js +6 -43
- package/dist/domain/reconstructionVerificationSchemas.js +2 -2
- package/dist/domain/staticRuntimeCorrelation.js +6 -43
- package/dist/domain/webBundleAnalysis.js +20 -8
- package/dist/domain/webBundleAnalyzerInspection.js +13 -8
- package/dist/domain/webBundleAnalyzerResult.js +41 -2
- package/dist/domain/webRuntime.js +19 -5
- package/dist/domain/webSourceLocation.js +1 -0
- package/dist/firmware/FirmwareFiles.js +1 -1
- package/dist/generatedPackageMetadata.js +1 -1
- package/dist/ghidra/GhidraAnalysisProfile.js +5 -0
- package/dist/ghidra/GhidraClient.js +47 -14
- package/dist/ghidra/GhidraDiagnostics.js +7 -7
- package/dist/ghidra/GhidraFunctionValues.js +10 -7
- package/dist/ghidra/GhidraInstallation.js +18 -21
- package/dist/ghidra/GhidraInventoryValues.js +14 -4
- package/dist/ghidra/GhidraJavaLaunch.js +62 -0
- package/dist/ghidra/GhidraLauncher.js +33 -16
- package/dist/ghidra/GhidraProviderCapabilities.js +14 -2
- package/dist/ghidra/GhidraProviderClient.js +23 -12
- package/dist/ghidra/GhidraSessionError.js +11 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +47 -12
- package/dist/ghidra/GhidraTransport.js +20 -0
- package/dist/hopper/BridgeLauncher.js +31 -11
- package/dist/hopper/HopperAnalysisProfile.js +62 -4
- package/dist/hopper/HopperCleanup.js +15 -3
- package/dist/hopper/HopperClient.js +222 -14
- package/dist/hopper/HopperFileOffset.js +237 -0
- package/dist/hopper/HopperMachOImage.js +196 -0
- package/dist/hopper/HopperOperationStage.js +6 -0
- package/dist/hopper/HopperProvider.js +63 -9
- package/dist/hopper/HopperProviderCapabilities.js +19 -1
- package/dist/hopper/HopperRegexSearch.js +137 -0
- package/dist/hopper/HopperRegexWorker.js +27 -0
- package/dist/hopper/HopperRequestQueue.js +68 -19
- package/dist/hopper/HopperTargetLease.js +3 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -1
- package/dist/inspector/V8InspectorCaptureProjection.js +8 -3
- package/dist/inspector/V8InspectorProvider.js +47 -11
- package/dist/javascript/sourceMaps/DecodedSourceMap.js +47 -0
- package/dist/javascript/sourceMaps/SourceMapCommand.js +16 -0
- package/dist/javascript/sourceMaps/SourceMapFormat.js +79 -31
- package/dist/javascript/sourceMaps/TraceSourceMap.js +14 -28
- package/dist/mcpDoctor.js +62 -2
- package/dist/native/AppleDispatchCoverage.js +47 -6
- package/dist/native/AppleDispatchDecodeFacts.js +6 -0
- package/dist/native/AppleDispatchMetadata.js +6 -3
- package/dist/native/AppleMachoFixups.js +48 -24
- package/dist/native/AppleMachoSelection.js +32 -16
- package/dist/native/AppleObjcCategories.js +6 -2
- package/dist/native/AppleObjcDispatchFacets.js +5 -2
- package/dist/native/AppleObjcProperties.js +2 -1
- package/dist/native/AppleSwiftDispatchFacets.js +27 -21
- package/dist/native/AppleSwiftVtables.js +21 -15
- package/dist/native/CommandRunner.js +81 -84
- package/dist/native/LldbCallTracer.js +365 -102
- package/dist/native/LldbRetainedObservations.js +178 -0
- package/dist/native/NativeCallObservation.js +62 -3
- package/dist/native/NativeMacOSProvider.js +98 -17
- package/dist/native/SignatureTargetBinding.js +155 -0
- package/dist/native/parsers/lipo.js +71 -1
- package/dist/native/pwndbg/PwndbgCoreContext.js +25 -5
- package/dist/native/pwntools/RecordedCrashStructureBindings.js +2 -0
- package/dist/process/DarwinProcessRunTokenReader.js +8 -9
- package/dist/process/ExecFileOutput.js +20 -0
- package/dist/process/OwnedCommand.js +7 -2
- package/dist/process/ProcessOwnership.js +203 -53
- package/dist/process/ProcessOwnershipObservation.js +49 -4
- package/dist/process/ProviderProcess.js +38 -7
- package/dist/process/capture/ProcessCaptureError.js +2 -2
- package/dist/process/capture/ProcessCaptureLifecycle.js +100 -34
- package/dist/server/EvidenceMcpServer.js +146 -0
- package/dist/server/createServer.js +15 -8
- package/dist/server/registerAndroidTools.js +2 -4
- package/dist/server/registerApplicationTools/helpers.js +2 -4
- package/dist/server/registerArtifactComparisonTool.js +11 -7
- package/dist/server/registerBinaryDiagnosticsTools.js +2 -4
- package/dist/server/registerBrowserScenarioTool.js +2 -4
- package/dist/server/registerBrowserTools.js +2 -4
- package/dist/server/registerBundleComparisonTool.js +2 -3
- package/dist/server/registerCloseLifecycleTool.js +8 -18
- package/dist/server/registerElectronTools.js +2 -4
- package/dist/server/registerEnhancedTools.js +18 -59
- package/dist/server/registerEvidenceTools.js +2 -4
- package/dist/server/registerEvmTools.js +2 -4
- package/dist/server/registerFirmwareTools.js +2 -4
- package/dist/server/registerFunctionComparisonTool.js +10 -6
- package/dist/server/registerInvestigationTools.js +7 -7
- package/dist/server/registerJavaScriptRecoveryTool.js +2 -4
- package/dist/server/registerJavaScriptRuntimeObservationTools.js +2 -4
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +2 -4
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +2 -4
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +2 -4
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +2 -4
- package/dist/server/registerOfficialTools.js +2 -4
- package/dist/server/registerProcessComparisonTool.js +71 -45
- package/dist/server/registerRecordedCrashTools.js +2 -4
- package/dist/server/registerSessionRecordTools.js +5 -6
- package/dist/server/registerSessionStatusTool.js +17 -3
- package/dist/server/registerSessionTools.js +11 -3
- package/dist/server/registerWebModuleTool.js +2 -4
- package/dist/server/registerWebNetworkCaptureTool.js +2 -4
- package/dist/server/registerWebRuntimeTools.js +3 -7
- package/dist/server/registerWebScriptTool.js +2 -4
- package/dist/server/registerWebSourceLocationTool.js +2 -4
- package/dist/server/runDerivedOperation.js +15 -3
- package/dist/server/sessionAvailabilityPolicy.js +0 -1
- package/dist/server/toolRegistrationOptions.js +2 -2
- package/dist/server/toolResult.js +62 -10
- package/dist/server/toolResultEncoding.js +33 -0
- package/install.sh +1 -1
- package/native/windows/build/manifest.json +1 -1
- package/package.json +8 -3
- package/scripts/electron-active-hook-boundaries.cjs +18 -20
- package/scripts/electron-active-hook.cjs +241 -37
- package/skills/reverse-engineer-anything/SKILL.md +11 -3
- package/skills/reverse-engineer-anything/references/javascript-applications.md +8 -1
- package/dist/ghidra/GhidraDefaults.js +0 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Preserve unambiguous exact integers; disclose rounded or unclassified numbers. */
|
|
2
|
+
export const createPlistNumberProjection = (literals) => {
|
|
3
|
+
let exactIntegerCount = 0;
|
|
4
|
+
let ambiguousNumberCount = 0;
|
|
5
|
+
const mapNumber = (item) => {
|
|
6
|
+
if (Number.isSafeInteger(item) || !Number.isInteger(item))
|
|
7
|
+
return item;
|
|
8
|
+
if (literals.incomplete) {
|
|
9
|
+
ambiguousNumberCount += 1;
|
|
10
|
+
return item;
|
|
11
|
+
}
|
|
12
|
+
const decimals = literals.integers.get(item);
|
|
13
|
+
if (decimals === undefined) {
|
|
14
|
+
if (!literals.reals.has(item))
|
|
15
|
+
ambiguousNumberCount += 1;
|
|
16
|
+
return item;
|
|
17
|
+
}
|
|
18
|
+
const [decimal] = decimals;
|
|
19
|
+
if (decimals.size !== 1 ||
|
|
20
|
+
decimal === undefined ||
|
|
21
|
+
literals.reals.has(item)) {
|
|
22
|
+
ambiguousNumberCount += 1;
|
|
23
|
+
return item;
|
|
24
|
+
}
|
|
25
|
+
exactIntegerCount += 1;
|
|
26
|
+
return { $plist_type: "integer", decimal };
|
|
27
|
+
};
|
|
28
|
+
const map = (item) => {
|
|
29
|
+
if (typeof item === "number")
|
|
30
|
+
return mapNumber(item);
|
|
31
|
+
if (Array.isArray(item))
|
|
32
|
+
return item.map(map);
|
|
33
|
+
if (item !== null && typeof item === "object") {
|
|
34
|
+
const keys = Object.keys(item);
|
|
35
|
+
const marker = item[keys[0] ?? ""];
|
|
36
|
+
const reference = keys.length === 1 &&
|
|
37
|
+
(keys[0] === "UID" || keys[0] === "CF$UID") &&
|
|
38
|
+
typeof marker === "number";
|
|
39
|
+
if (reference) {
|
|
40
|
+
// Keep malformed numeric reference markers recognizable by the graph reader.
|
|
41
|
+
if (typeof marker === "number" &&
|
|
42
|
+
!Number.isSafeInteger(marker) &&
|
|
43
|
+
(literals.integers.has(marker) || !literals.reals.has(marker)))
|
|
44
|
+
ambiguousNumberCount += 1;
|
|
45
|
+
return item;
|
|
46
|
+
}
|
|
47
|
+
return Object.fromEntries(Object.entries(item).map(([key, child]) => [key, map(child)]));
|
|
48
|
+
}
|
|
49
|
+
return item;
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
project: map,
|
|
53
|
+
limitations: () => [
|
|
54
|
+
...(literals.incomplete
|
|
55
|
+
? [
|
|
56
|
+
"Original archive number metadata could not be completely observed; decoded numbers may lose integer precision and exact integer/real association is unavailable.",
|
|
57
|
+
]
|
|
58
|
+
: []),
|
|
59
|
+
...(literals.unsafeIntegerLiterals === 0
|
|
60
|
+
? []
|
|
61
|
+
: [
|
|
62
|
+
`${String(literals.unsafeIntegerLiterals)} observed integer literal(s) in the original archive exceed the exact range of a JSON number. Decoded numbers may lose integer precision unless represented as { "$plist_type": "integer", "decimal": "<exact digits>" }; the original archive bytes retain those literals.`,
|
|
63
|
+
]),
|
|
64
|
+
...(exactIntegerCount === 0
|
|
65
|
+
? []
|
|
66
|
+
: [
|
|
67
|
+
`${String(exactIntegerCount)} unambiguous integer value(s) are reported with exact decimal text as { "$plist_type": "integer", "decimal": "<exact digits>" }.`,
|
|
68
|
+
]),
|
|
69
|
+
...(ambiguousNumberCount === 0
|
|
70
|
+
? []
|
|
71
|
+
: [
|
|
72
|
+
`${String(ambiguousNumberCount)} number(s) beyond the exact integer range remain as decoded because their source integer/real type or reference marker cannot be associated unambiguously; integer precision loss remains possible.`,
|
|
73
|
+
]),
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { canonicalDigest } from "./comparisonSemantics.js";
|
|
2
|
+
/** Content-address an artifact independently of where it was observed. */
|
|
3
|
+
export const artifactIdForContent = (sha256) => `art_${canonicalDigest({ sha256 }, "Artifact")}`;
|
|
4
|
+
/** Identify an occurrence by its root and exact logical location. */
|
|
5
|
+
export const occurrenceIdForLocation = (input) => input.logicalPath === "."
|
|
6
|
+
? `occ_${canonicalDigest({ root: input.rootArtifactId }, "Artifact")}`
|
|
7
|
+
: `occ_${canonicalDigest({
|
|
8
|
+
root_artifact_id: input.rootArtifactId,
|
|
9
|
+
logical_path: input.logicalPath,
|
|
10
|
+
entry_kind: input.entryKind,
|
|
11
|
+
}, "Artifact")}`;
|
|
12
|
+
/** Commit to graph members in the ordering established by the inventory owner. */
|
|
13
|
+
export const artifactGraphDigest = (input) => canonicalDigest({
|
|
14
|
+
nodes: input.nodes,
|
|
15
|
+
occurrences: input.occurrences,
|
|
16
|
+
edges: input.edges,
|
|
17
|
+
integrity_contradictions: input.contradictions,
|
|
18
|
+
}, "Artifact");
|
|
19
|
+
/** Bind a root artifact to its graph commitment. */
|
|
20
|
+
export const artifactManifestId = (rootArtifactId, graphSha256) => `agm_${canonicalDigest({ root_artifact_id: rootArtifactId, graph_sha256: graphSha256 }, "Artifact")}`;
|
|
21
|
+
/** Identify one integrity disagreement at its observed logical path. */
|
|
22
|
+
export const artifactContradictionId = (input) => `ic_${canonicalDigest({
|
|
23
|
+
root_artifact_id: input.rootArtifactId,
|
|
24
|
+
logical_path: input.logicalPath,
|
|
25
|
+
declared_sha256: input.declaredSha256,
|
|
26
|
+
observed_sha256: input.observedSha256,
|
|
27
|
+
}, "Artifact")}`;
|
|
28
|
+
/** Identify an edge by its semantic relationship and exact occurrence. */
|
|
29
|
+
export const artifactEdgeId = (semantic) => `edge_${canonicalDigest(semantic, "Artifact")}`;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { artifactInventoryResultSchema, } from "./artifactGraph.js";
|
|
2
|
-
import {
|
|
2
|
+
import { canonicalJson } from "./comparisonSemantics.js";
|
|
3
|
+
import { artifactContradictionId, artifactEdgeId, artifactGraphDigest, artifactIdForContent, artifactManifestId, occurrenceIdForLocation, } from "./artifactIdentity.js";
|
|
3
4
|
import { parseEvidence } from "./evidence.js";
|
|
4
5
|
import { artifactInspectionResultSchema } from "./artifactInspection.js";
|
|
5
6
|
import { err, ok } from "./result.js";
|
|
@@ -29,8 +30,7 @@ const validateInventoryPage = (inventory) => {
|
|
|
29
30
|
assertUnique(inventory.occurrences.map(({ logical_path: path }) => path), "logical path");
|
|
30
31
|
assertUnique(inventory.edges.map(({ edge_id: id }) => id), "edge ID");
|
|
31
32
|
for (const node of inventory.nodes)
|
|
32
|
-
if (node.artifact_id !==
|
|
33
|
-
`art_${canonicalDigest({ sha256: node.sha256 }, "Artifact inventory")}`)
|
|
33
|
+
if (node.artifact_id !== artifactIdForContent(node.sha256))
|
|
34
34
|
throw new TypeError("Artifact node ID is not content-addressed");
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
@@ -110,27 +110,24 @@ const validateCompleteInventory = (inventory) => {
|
|
|
110
110
|
if (!nodeIds.has(contradiction.parent_artifact_id) ||
|
|
111
111
|
!occurrenceIds.has(contradiction.occurrence_id))
|
|
112
112
|
throw new TypeError("Integrity contradiction references a missing graph member");
|
|
113
|
-
const expectedId =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
113
|
+
const expectedId = artifactContradictionId({
|
|
114
|
+
rootArtifactId: inventory.manifest.root_artifact_id,
|
|
115
|
+
logicalPath: contradiction.logical_path,
|
|
116
|
+
declaredSha256: contradiction.declared_sha256,
|
|
117
|
+
observedSha256: contradiction.observed_sha256,
|
|
118
|
+
});
|
|
119
119
|
if (contradiction.contradiction_id !== expectedId)
|
|
120
120
|
throw new TypeError("Integrity contradiction ID does not match its identity");
|
|
121
121
|
}
|
|
122
|
-
const graphSha256 =
|
|
122
|
+
const graphSha256 = artifactGraphDigest({
|
|
123
123
|
nodes: inventory.nodes,
|
|
124
124
|
occurrences: inventory.occurrences,
|
|
125
125
|
edges: inventory.edges,
|
|
126
|
-
|
|
127
|
-
}
|
|
126
|
+
contradictions: inventory.integrityContradictions,
|
|
127
|
+
});
|
|
128
128
|
if (graphSha256 !== inventory.manifest.graph_sha256)
|
|
129
129
|
throw new TypeError("Artifact graph commitment does not match its members");
|
|
130
|
-
const manifestId =
|
|
131
|
-
root_artifact_id: inventory.manifest.root_artifact_id,
|
|
132
|
-
graph_sha256: graphSha256,
|
|
133
|
-
}, "Artifact inventory")}`;
|
|
130
|
+
const manifestId = artifactManifestId(inventory.manifest.root_artifact_id, graphSha256);
|
|
134
131
|
if (manifestId !== inventory.manifest.manifest_id)
|
|
135
132
|
throw new TypeError("Artifact manifest ID does not match its commitment");
|
|
136
133
|
};
|
|
@@ -140,13 +137,11 @@ const validateOccurrence = (occurrence, inventory, nodeIds, occurrenceIds) => {
|
|
|
140
137
|
if (occurrence.parent_occurrence_id !== null &&
|
|
141
138
|
!occurrenceIds.has(occurrence.parent_occurrence_id))
|
|
142
139
|
throw new TypeError("Artifact occurrence references a missing parent");
|
|
143
|
-
const expectedId =
|
|
144
|
-
|
|
145
|
-
:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
entry_kind: occurrence.entry_kind,
|
|
149
|
-
}, "Artifact inventory")}`;
|
|
140
|
+
const expectedId = occurrenceIdForLocation({
|
|
141
|
+
rootArtifactId: inventory.manifest.root_artifact_id,
|
|
142
|
+
logicalPath: occurrence.logical_path,
|
|
143
|
+
entryKind: occurrence.entry_kind,
|
|
144
|
+
});
|
|
150
145
|
if (occurrence.occurrence_id !== expectedId)
|
|
151
146
|
throw new TypeError("Artifact occurrence ID does not match its identity");
|
|
152
147
|
};
|
|
@@ -162,7 +157,7 @@ const validateEdge = (edge, nodeIds, occurrenceIds) => {
|
|
|
162
157
|
occurrence_id: edge.occurrence_id,
|
|
163
158
|
logical_path: edge.logical_path,
|
|
164
159
|
};
|
|
165
|
-
if (edge.edge_id !==
|
|
160
|
+
if (edge.edge_id !== artifactEdgeId(semantic))
|
|
166
161
|
throw new TypeError("Artifact edge ID does not match its identity");
|
|
167
162
|
};
|
|
168
163
|
const mergeExact = (output, key, value, label) => {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Coverage metadata for the bounded projection of candidate relationships. */
|
|
3
|
+
export const bridgeCandidateCoverageSchema = z.strictObject({
|
|
4
|
+
status: z.enum(["complete", "partial"]),
|
|
5
|
+
total_candidates: z.number().int().nonnegative(),
|
|
6
|
+
emitted_candidates: z.number().int().nonnegative(),
|
|
7
|
+
omitted_candidates: z.number().int().nonnegative(),
|
|
8
|
+
});
|
|
9
|
+
// The serialized candidate array is the retained representation; accounting
|
|
10
|
+
// its exact UTF-8 JSON size bounds both array objects and repeated path strings.
|
|
11
|
+
/** Maximum UTF-8 JSON size of a retained candidate array. */
|
|
12
|
+
export const MAX_BRIDGE_CANDIDATE_JSON_BYTES = 2 * 1024 * 1024;
|
|
13
|
+
const jsonText = (value) => {
|
|
14
|
+
const serialized = JSON.stringify(value);
|
|
15
|
+
if (serialized === undefined)
|
|
16
|
+
throw new TypeError("Bridge candidate is not JSON serializable");
|
|
17
|
+
return serialized;
|
|
18
|
+
};
|
|
19
|
+
/** Retain a deterministic prefix of grouped Cartesian candidates within a byte budget. */
|
|
20
|
+
export const projectCartesianCandidates = (input) => {
|
|
21
|
+
const total = input.groups.reduce((sum, group) => sum + group.left.length * group.right.length, 0);
|
|
22
|
+
const preparedGroups = input.groups.map((group) => ({
|
|
23
|
+
left: group.left.map((value) => ({
|
|
24
|
+
value,
|
|
25
|
+
pathBytes: Buffer.byteLength(jsonText(value.path)),
|
|
26
|
+
})),
|
|
27
|
+
right: group.right.map((value) => {
|
|
28
|
+
const emptyLeftCandidate = jsonText(input.createCandidate("", value));
|
|
29
|
+
return {
|
|
30
|
+
value,
|
|
31
|
+
rowOverhead: Buffer.byteLength(emptyLeftCandidate) - 2,
|
|
32
|
+
};
|
|
33
|
+
}),
|
|
34
|
+
}));
|
|
35
|
+
let estimatedFullBytes = 2 + Math.max(0, total - 1); // JSON array brackets and commas.
|
|
36
|
+
for (const group of preparedGroups) {
|
|
37
|
+
estimatedFullBytes +=
|
|
38
|
+
group.left.length *
|
|
39
|
+
group.right.reduce((sum, { rowOverhead }) => sum + rowOverhead, 0) +
|
|
40
|
+
group.right.length *
|
|
41
|
+
group.left.reduce((sum, { pathBytes }) => sum + pathBytes, 0);
|
|
42
|
+
}
|
|
43
|
+
const shouldEmitAll = estimatedFullBytes <= MAX_BRIDGE_CANDIDATE_JSON_BYTES;
|
|
44
|
+
const candidates = [];
|
|
45
|
+
let estimatedRetainedBytes = 2;
|
|
46
|
+
candidateLoop: for (const group of preparedGroups) {
|
|
47
|
+
for (const left of group.left) {
|
|
48
|
+
for (const right of group.right) {
|
|
49
|
+
const candidateBytes = right.rowOverhead + left.pathBytes;
|
|
50
|
+
const additionalBytes = candidateBytes + (candidates.length > 0 ? 1 : 0);
|
|
51
|
+
if (!shouldEmitAll &&
|
|
52
|
+
estimatedRetainedBytes + additionalBytes >
|
|
53
|
+
MAX_BRIDGE_CANDIDATE_JSON_BYTES)
|
|
54
|
+
break candidateLoop;
|
|
55
|
+
candidates.push(input.createCandidate(left.value.path, right.value));
|
|
56
|
+
estimatedRetainedBytes += additionalBytes;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
candidates,
|
|
62
|
+
coverage: {
|
|
63
|
+
status: candidates.length === total
|
|
64
|
+
? "complete"
|
|
65
|
+
: "partial",
|
|
66
|
+
total_candidates: total,
|
|
67
|
+
emitted_candidates: candidates.length,
|
|
68
|
+
omitted_candidates: total - candidates.length,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalysisError } from "./analysisErrorBase.js";
|
|
1
|
+
import { AnalysisError, } from "./analysisErrorBase.js";
|
|
2
2
|
import { AnalysisCancelledError } from "./analysisErrorCore.js";
|
|
3
3
|
/** A bounded passive browser observation failed at its CDP boundary. */
|
|
4
4
|
export class BrowserObservationError extends AnalysisError {
|
|
@@ -13,13 +13,32 @@ export class BrowserObservationError extends AnalysisError {
|
|
|
13
13
|
super(`Browser observation ${operation} failed: ${reason}`, options);
|
|
14
14
|
this.operation = operation;
|
|
15
15
|
this.reason = reason;
|
|
16
|
-
this.userMessage =
|
|
17
|
-
|
|
16
|
+
this.userMessage =
|
|
17
|
+
options?.detail ?? observationFailureMessage(operation, reason);
|
|
18
|
+
this.cleanupIncomplete =
|
|
19
|
+
this.cleanup !== undefined || reason === "cleanup_failed";
|
|
18
20
|
this.cleanupResources =
|
|
19
|
-
|
|
21
|
+
this.cleanup?.resources ??
|
|
22
|
+
(reason === "cleanup_failed" ? ["browser_transport"] : []);
|
|
20
23
|
this.userCategory =
|
|
21
|
-
reason === "cancelled" ||
|
|
24
|
+
reason === "cancelled" ||
|
|
25
|
+
options?.cause instanceof AnalysisCancelledError ||
|
|
26
|
+
(options?.cause instanceof AnalysisError &&
|
|
27
|
+
options.cause.userCategory === "cancelled")
|
|
22
28
|
? "cancelled"
|
|
23
29
|
: undefined;
|
|
24
30
|
}
|
|
25
31
|
}
|
|
32
|
+
const observationFailureMessage = (operation, reason) => {
|
|
33
|
+
if (reason === "cancelled")
|
|
34
|
+
return `${operation} was cancelled. Collected observations and cleanup status are reported when available.`;
|
|
35
|
+
if (reason === "timeout")
|
|
36
|
+
return `${operation} exceeded its execution deadline. Review the target's responsiveness and retained observations before retrying.`;
|
|
37
|
+
if (reason === "endpoint_unreachable")
|
|
38
|
+
return `${operation} could not reach the selected loopback debugging endpoint. Verify that the target process is running with debugging enabled and that the endpoint's port matches it, then retry.`;
|
|
39
|
+
if (reason === "target_not_found")
|
|
40
|
+
return `${operation} could not find the selected target at the debugging endpoint. Refresh target discovery for that endpoint and retry with a returned target ID.`;
|
|
41
|
+
if (reason === "disconnected")
|
|
42
|
+
return `${operation} lost its debugging connection. Verify that the target process is still running, refresh target discovery, and retry the observation.`;
|
|
43
|
+
return undefined;
|
|
44
|
+
};
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { isAbsoluteLocalPath } from "./localPath.js";
|
|
2
|
+
import { isAbsoluteLocalPath, localPathStringSchema } from "./localPath.js";
|
|
3
3
|
import { browserNetworkContentSelectionSchema } from "./browserNetworkEvidence.js";
|
|
4
4
|
import { browserEndpointSchema, browserOriginSchema, } from "./browserObservation.js";
|
|
5
5
|
export const scenarioIdentifierSchema = z
|
|
6
6
|
.string()
|
|
7
7
|
.regex(/^[A-Za-z][A-Za-z0-9._-]*$/u);
|
|
8
|
-
const browserExecutablePathSchema =
|
|
9
|
-
.string()
|
|
10
|
-
.trim()
|
|
11
|
-
.min(1)
|
|
12
|
-
.refine(isAbsoluteLocalPath, {
|
|
8
|
+
const browserExecutablePathSchema = localPathStringSchema.refine(isAbsoluteLocalPath, {
|
|
13
9
|
message: "executable_path must be an absolute local filesystem path (for example /opt/chromium/chrome or C:\\chromium\\chrome.exe)",
|
|
14
10
|
});
|
|
15
11
|
const browserScenarioBaseUrlSchema = z
|
|
@@ -4,6 +4,7 @@ import { parseEvidenceBundle, serializeEvidenceBundle, } from "./evidenceBundle.
|
|
|
4
4
|
import { digestSchema } from "./../domain/digests.js";
|
|
5
5
|
import { prefixedDigestSchema } from "./../domain/digests.js";
|
|
6
6
|
import { comparisonStatusSchema } from "./comparisonStatus.js";
|
|
7
|
+
import { localPathStringSchema } from "./localPath.js";
|
|
7
8
|
const evidenceIdSchema = prefixedDigestSchema("ev");
|
|
8
9
|
const classificationSchema = z.enum([
|
|
9
10
|
"added",
|
|
@@ -15,8 +16,8 @@ const classificationSchema = z.enum([
|
|
|
15
16
|
]);
|
|
16
17
|
/** Strict input for canonical Evidence bundle comparison. */
|
|
17
18
|
export const bundleComparisonInputSchema = z.strictObject({
|
|
18
|
-
left_bundle_path:
|
|
19
|
-
right_bundle_path:
|
|
19
|
+
left_bundle_path: localPathStringSchema,
|
|
20
|
+
right_bundle_path: localPathStringSchema,
|
|
20
21
|
record_pairs: z
|
|
21
22
|
.array(z.object({
|
|
22
23
|
left_evidence_id: evidenceIdSchema,
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/** Hash owned, validated JSON in bounded steps without a document-sized string. */
|
|
3
|
+
export function* canonicalJsonDigestSteps(value) {
|
|
4
|
+
const hash = createHash("sha256");
|
|
5
|
+
const ancestors = new Set();
|
|
6
|
+
const stack = [{ kind: "value", value }];
|
|
7
|
+
let buffered = "";
|
|
8
|
+
let flushed = false;
|
|
9
|
+
const emit = (part) => {
|
|
10
|
+
buffered += part;
|
|
11
|
+
if (buffered.length >= 8192) {
|
|
12
|
+
hash.update(buffered);
|
|
13
|
+
buffered = "";
|
|
14
|
+
flushed = true;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
while (stack.length > 0) {
|
|
19
|
+
if (flushed) {
|
|
20
|
+
flushed = false;
|
|
21
|
+
yield;
|
|
22
|
+
}
|
|
23
|
+
const frame = stack.pop();
|
|
24
|
+
if (frame === undefined)
|
|
25
|
+
break;
|
|
26
|
+
if (frame.kind === "separator") {
|
|
27
|
+
emit(":");
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (frame.kind === "string") {
|
|
31
|
+
if (frame.index === frame.value.length) {
|
|
32
|
+
emit('"');
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
let end = Math.min(frame.index + 8192, frame.value.length);
|
|
36
|
+
const last = frame.value.charCodeAt(end - 1);
|
|
37
|
+
const next = frame.value.charCodeAt(end);
|
|
38
|
+
if (end < frame.value.length &&
|
|
39
|
+
last >= 0xd800 &&
|
|
40
|
+
last <= 0xdbff &&
|
|
41
|
+
next >= 0xdc00 &&
|
|
42
|
+
next <= 0xdfff)
|
|
43
|
+
end -= 1;
|
|
44
|
+
emit(JSON.stringify(frame.value.slice(frame.index, end)).slice(1, -1));
|
|
45
|
+
frame.index = end;
|
|
46
|
+
stack.push(frame);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (frame.kind === "array") {
|
|
50
|
+
if (frame.index === frame.length) {
|
|
51
|
+
emit("]");
|
|
52
|
+
ancestors.delete(frame.value);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const item = frame.value[frame.index];
|
|
56
|
+
if (item === undefined)
|
|
57
|
+
throw new TypeError("Canonical JSON digest requires dense JSON arrays");
|
|
58
|
+
if (frame.index++ > 0)
|
|
59
|
+
emit(",");
|
|
60
|
+
stack.push(frame, { kind: "value", value: item });
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (frame.kind === "object") {
|
|
64
|
+
if (frame.index === frame.keys.length) {
|
|
65
|
+
emit("}");
|
|
66
|
+
ancestors.delete(frame.value);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const key = frame.keys[frame.index++];
|
|
70
|
+
if (key === undefined)
|
|
71
|
+
throw new TypeError("Canonical JSON object changed during hashing");
|
|
72
|
+
const item = frame.value[key];
|
|
73
|
+
if (item === undefined)
|
|
74
|
+
continue;
|
|
75
|
+
if (frame.written++ > 0)
|
|
76
|
+
emit(",");
|
|
77
|
+
if (key.length > 8192) {
|
|
78
|
+
emit('"');
|
|
79
|
+
stack.push(frame, { kind: "value", value: item }, { kind: "separator" }, { kind: "string", value: key, index: 0 });
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
emit(JSON.stringify(key));
|
|
83
|
+
emit(":");
|
|
84
|
+
stack.push(frame, { kind: "value", value: item });
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const item = frame.value;
|
|
88
|
+
if (typeof item === "string" && item.length > 8192) {
|
|
89
|
+
emit('"');
|
|
90
|
+
stack.push({ kind: "string", value: item, index: 0 });
|
|
91
|
+
}
|
|
92
|
+
else if (item === null || typeof item !== "object") {
|
|
93
|
+
if (typeof item === "number" && !Number.isFinite(item))
|
|
94
|
+
throw new Error(Number.isNaN(item)
|
|
95
|
+
? "NaN is not allowed"
|
|
96
|
+
: "Infinity is not allowed");
|
|
97
|
+
emit(JSON.stringify(item));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (ancestors.has(item))
|
|
101
|
+
throw new Error("Circular reference detected");
|
|
102
|
+
ancestors.add(item);
|
|
103
|
+
if (Array.isArray(item)) {
|
|
104
|
+
emit("[");
|
|
105
|
+
stack.push({
|
|
106
|
+
kind: "array",
|
|
107
|
+
value: item,
|
|
108
|
+
length: item.length,
|
|
109
|
+
index: 0,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
emit("{");
|
|
114
|
+
stack.push({
|
|
115
|
+
kind: "object",
|
|
116
|
+
value: item,
|
|
117
|
+
keys: Object.keys(item).sort(),
|
|
118
|
+
index: 0,
|
|
119
|
+
written: 0,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (buffered !== "")
|
|
125
|
+
hash.update(buffered);
|
|
126
|
+
return hash.digest("hex");
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
stack.length = 0;
|
|
130
|
+
ancestors.clear();
|
|
131
|
+
buffered = "";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { compareUnicodeCodePoints } from "./unicodeCodePointOrder.js";
|
|
1
2
|
/**
|
|
2
3
|
* Canonical code-point ordering shared across domain and application layers.
|
|
3
4
|
*
|
|
4
|
-
* Compares strings by Unicode code point
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Compares strings by Unicode code point so graph ordering, fingerprints, and
|
|
6
|
+
* deterministic tie-breaks stay stable regardless of locale. Prefer this over
|
|
7
|
+
* `String.prototype.localeCompare`, which is locale-dependent.
|
|
8
|
+
*
|
|
9
|
+
* Ordering by code point differs from ordering by UTF-16 code unit for astral
|
|
10
|
+
* code points (above U+FFFF), whose lead surrogate is numerically below the
|
|
11
|
+
* BMP tail U+E000-U+FFFF.
|
|
8
12
|
*/
|
|
9
|
-
export const compareCodePoints = (left, right) => left
|
|
13
|
+
export const compareCodePoints = (left, right) => compareUnicodeCodePoints(left, right);
|
|
10
14
|
/** Deduplicate and sort strings with canonical code-point ordering. */
|
|
11
15
|
export const uniqueSorted = (values) => [...new Set(values)].sort(compareCodePoints);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { artifactComparisonResultSchema } from "./artifactComparison.js";
|
|
3
3
|
import { uniqueSorted } from "./canonicalOrdering.js";
|
|
4
|
+
import { comparisonSourceEvidenceIds } from "./comparisonSourceEvidence.js";
|
|
4
5
|
import { evidenceSchema, parseEvidence } from "./evidence.js";
|
|
5
6
|
import { functionComparisonResultSchema } from "./functionComparison.js";
|
|
6
7
|
import { PROCESS_PROVIDER, isProcessEvidenceProvider, } from "./process/processEvidenceProvider.js";
|
|
@@ -9,7 +10,7 @@ import { prefixedDigestSchema } from "./../domain/digests.js";
|
|
|
9
10
|
const evidenceIdSchema = prefixedDigestSchema("ev");
|
|
10
11
|
/** Input for aggregating existing comparison Evidence. */
|
|
11
12
|
export const changedBehaviorInputSchema = z.strictObject({
|
|
12
|
-
comparisons: z.array(evidenceSchema).
|
|
13
|
+
comparisons: z.array(evidenceSchema).min(1),
|
|
13
14
|
});
|
|
14
15
|
const findingSchema = z.object({
|
|
15
16
|
scope: z.enum(["runtime", "protocol", "resource", "static_candidate"]),
|
|
@@ -22,7 +23,7 @@ const findingSchema = z.object({
|
|
|
22
23
|
]),
|
|
23
24
|
status: comparisonStatusSchema,
|
|
24
25
|
source_comparison_id: evidenceIdSchema,
|
|
25
|
-
evidence_links: z.array(evidenceIdSchema).min(
|
|
26
|
+
evidence_links: z.array(evidenceIdSchema).min(2),
|
|
26
27
|
limitations: z.array(z.string()),
|
|
27
28
|
});
|
|
28
29
|
/** Truthful aggregate: runtime observations remain separate from static candidates. */
|
|
@@ -43,7 +44,7 @@ export const changedBehaviorResultSchema = z
|
|
|
43
44
|
findings: z.object({
|
|
44
45
|
items: z.array(findingSchema),
|
|
45
46
|
}),
|
|
46
|
-
evidence_links: z.array(evidenceIdSchema).min(
|
|
47
|
+
evidence_links: z.array(evidenceIdSchema).min(2),
|
|
47
48
|
limitations: z.array(z.string()),
|
|
48
49
|
})
|
|
49
50
|
.superRefine((result, context) => {
|
|
@@ -141,9 +142,8 @@ const parseComparisonEvidence = (input) => {
|
|
|
141
142
|
evidence.authority !== "analyst-inference" ||
|
|
142
143
|
evidence.subject !== null)
|
|
143
144
|
throw new TypeError("Comparison Evidence operation, predicate, and provider disagree");
|
|
144
|
-
if (evidence.evidence_links.
|
|
145
|
-
throw new TypeError("Comparison Evidence must cite both source observations");
|
|
146
|
-
assertUnique(evidence.evidence_links, "source Evidence links");
|
|
145
|
+
if (!comparisonSourceEvidenceIds(evidence).every((id) => evidence.evidence_links.includes(id)))
|
|
146
|
+
throw new TypeError("Comparison Evidence must cite both selected source observations");
|
|
147
147
|
parseResult(evidence);
|
|
148
148
|
return evidence;
|
|
149
149
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { uniqueSorted } from "./canonicalOrdering.js";
|
|
3
|
+
import { prefixedDigestSchema } from "./digests.js";
|
|
4
|
+
const evidenceIdSchema = prefixedDigestSchema("ev");
|
|
5
|
+
const sideParametersSchema = z.object({
|
|
6
|
+
left_evidence_id: evidenceIdSchema.optional(),
|
|
7
|
+
right_evidence_id: evidenceIdSchema.optional(),
|
|
8
|
+
left_evidence_ids: z.array(evidenceIdSchema).min(1).optional(),
|
|
9
|
+
right_evidence_ids: z.array(evidenceIdSchema).min(1).optional(),
|
|
10
|
+
});
|
|
11
|
+
/** Resolve each selected side and validate aliases and duplicates within that role. */
|
|
12
|
+
export const comparisonSourceEvidenceSides = (evidence) => {
|
|
13
|
+
const parameters = sideParametersSchema.parse(evidence.parameters);
|
|
14
|
+
if ((parameters.left_evidence_id === undefined) !==
|
|
15
|
+
(parameters.right_evidence_id === undefined) ||
|
|
16
|
+
(parameters.left_evidence_ids === undefined) !==
|
|
17
|
+
(parameters.right_evidence_ids === undefined))
|
|
18
|
+
throw new TypeError("Comparison Evidence source representation omitted one side");
|
|
19
|
+
const side = (single, multiple) => {
|
|
20
|
+
if (single !== undefined &&
|
|
21
|
+
multiple !== undefined &&
|
|
22
|
+
(multiple.length !== 1 || multiple[0] !== single))
|
|
23
|
+
throw new TypeError("Comparison Evidence source representations disagree");
|
|
24
|
+
const selected = single === undefined ? (multiple ?? []) : [single];
|
|
25
|
+
if (selected.length === 0)
|
|
26
|
+
throw new TypeError("Comparison Evidence omitted its source parameters");
|
|
27
|
+
if (new Set(selected).size !== selected.length)
|
|
28
|
+
throw new TypeError("Comparison Evidence repeats a source within one side");
|
|
29
|
+
return selected;
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
left: side(parameters.left_evidence_id, parameters.left_evidence_ids),
|
|
33
|
+
right: side(parameters.right_evidence_id, parameters.right_evidence_ids),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/** Resolve the source closure without counting observations shared by both roles twice. */
|
|
37
|
+
export const comparisonSourceEvidenceIds = (evidence) => {
|
|
38
|
+
const sides = comparisonSourceEvidenceSides(evidence);
|
|
39
|
+
return uniqueSorted([...sides.left, ...sides.right]);
|
|
40
|
+
};
|