rea-agents 1.7.0 → 2.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 +112 -59
- package/bridge/ghidra/ReaGhidraBridge.java +96 -11
- package/dist/application/ArtifactExtraction.js +1 -1
- package/dist/application/ArtifactInventory/classify.js +42 -0
- package/dist/application/ArtifactInventory/hash.js +43 -0
- package/dist/application/ArtifactInventory/reader.js +41 -0
- package/dist/application/ArtifactInventory/scanCanonical.js +155 -0
- package/dist/application/ArtifactInventory/scanReader.js +124 -0
- package/dist/application/ArtifactInventory/types.js +10 -0
- package/dist/application/ArtifactInventory.js +9 -351
- package/dist/application/AuthorizedArtifactInventory.js +2 -2
- package/dist/application/BinarySession.js +47 -270
- package/dist/application/BinarySessionExecution.js +28 -0
- package/dist/application/BinarySessionOpen.js +39 -0
- package/dist/application/BinarySessionRecords.js +149 -0
- package/dist/application/BinarySessionStatus.js +75 -0
- package/dist/application/CapabilityInventory.js +42 -2
- package/dist/application/ClientRegistrationStatus.js +1 -1
- package/dist/application/CrossVersionInventory.js +8 -2
- package/dist/application/CrossVersionInvestigation.js +11 -29
- package/dist/application/CrossVersionInvestigationCollections.js +23 -0
- package/dist/application/DirectAnalysis.js +47 -44
- package/dist/application/Doctor.js +165 -197
- package/dist/application/DoctorDiagnostics.js +180 -0
- package/dist/application/ElectronBoundaryAnalysis.js +112 -0
- package/dist/application/ElectronBoundaryGraph.js +9 -0
- package/dist/application/ElectronBoundaryGraphContext.js +62 -0
- package/dist/application/ElectronBoundaryGraphIpc.js +242 -0
- package/dist/application/ElectronBoundaryGraphNative.js +86 -0
- package/dist/application/ElectronBoundaryGraphWindows.js +223 -0
- package/dist/application/EnhancedToolPagination.js +22 -0
- package/dist/application/EnhancedToolTypes.js +4 -0
- package/dist/application/EnhancedTools.js +58 -50
- package/dist/application/InstrumentedJavaScriptReplayHost.js +36 -0
- package/dist/application/InvestigationProviders.js +30 -0
- package/dist/application/InvestigationWorkspaceStore.js +24 -10
- package/dist/application/JavaScriptApplicationEvidence.js +26 -0
- package/dist/application/JavaScriptApplicationEvidenceGraph.js +89 -0
- package/dist/application/JavaScriptApplicationService.js +74 -0
- package/dist/application/JavaScriptApplicationWorkflowEvidence.js +29 -0
- package/dist/application/JavaScriptApplicationWorkflowService.js +90 -0
- package/dist/application/JavaScriptArtifactAnalysis.js +52 -7
- package/dist/application/JavaScriptArtifactFiles.js +6 -2
- package/dist/application/JavaScriptArtifactGraphBuilder.js +82 -17
- package/dist/application/JavaScriptArtifactGraphBundlers.js +225 -0
- package/dist/application/JavaScriptArtifactGraphContext.js +37 -36
- package/dist/application/JavaScriptArtifactGraphDocuments.js +27 -4
- package/dist/application/JavaScriptArtifactGraphEvidence.js +24 -14
- package/dist/application/JavaScriptArtifactGraphFindings.js +54 -8
- package/dist/application/JavaScriptArtifactGraphStructure.js +29 -101
- package/dist/application/JavaScriptArtifactPathResolution.js +269 -0
- package/dist/application/JavaScriptArtifactReconstruction.js +4 -1
- package/dist/application/JavaScriptArtifactReconstructionInput.js +2 -83
- package/dist/application/JavaScriptJsonModules.js +39 -0
- package/dist/application/JavaScriptModuleRelationships.js +262 -0
- package/dist/application/JavaScriptReplayPermission.js +16 -0
- package/dist/application/JavaScriptReplayPlanning.js +201 -0
- package/dist/application/JavaScriptReplayService.js +292 -0
- package/dist/application/JavaScriptRuntimeReconciliationEvidence.js +25 -0
- package/dist/application/JavaScriptRuntimeReconciliationService.js +27 -0
- package/dist/application/LinuxHopper.js +10 -0
- package/dist/application/MacHopper.js +22 -11
- package/dist/application/ManagedApplicationGraphService.js +55 -0
- package/dist/application/ManagedMemberComparisonService.js +122 -0
- package/dist/application/ManagedNativeVerificationService.js +39 -0
- package/dist/application/ManagedReconstructionService.js +58 -0
- package/dist/application/ManagedRuntimeCorrelationService.js +103 -0
- package/dist/application/NodeRuntimeCharacterizationService.js +196 -0
- package/dist/application/PermissionAuthority.js +106 -63
- package/dist/application/ProcessCaptureCapability.js +1 -1
- package/dist/application/ProcessCapturePermission.js +13 -0
- package/dist/application/ProcessCli.js +2 -12
- package/dist/application/ProcessHarness.js +1 -1
- package/dist/application/ProcessSampling.js +15 -11
- package/dist/application/ProjectPermissionStore.js +49 -9
- package/dist/application/RealHopperAssertions.js +76 -0
- package/dist/application/ReconstructionCoverageService.js +69 -0
- package/dist/application/ReconstructionCoverageWorkspaceStore.js +31 -0
- package/dist/application/RuntimeExecutableDiagnostics.js +172 -0
- package/dist/application/Setup.js +147 -259
- package/dist/application/SetupClientConfiguration.js +220 -0
- package/dist/application/SetupClients.js +24 -2
- package/dist/application/SetupPlan.js +123 -12
- package/dist/application/SetupSkill.js +26 -12
- package/dist/application/SupportedClients.js +1 -0
- package/dist/application/Uninstall.js +6 -3
- package/dist/application/WindowsCapabilities.js +86 -0
- package/dist/application/runtime.js +2 -0
- package/dist/artifacts/AsarArtifactReader.js +11 -0
- package/dist/browser/BrowserProcessStartup.js +88 -0
- package/dist/browser/CdpCaptureDocuments.js +12 -8
- package/dist/browser/CdpCaptureEventBodyShapes.js +75 -0
- package/dist/browser/CdpCaptureEventHandlers.js +336 -0
- package/dist/browser/CdpCaptureEventHelpers.js +71 -0
- package/dist/browser/CdpCaptureEventState.js +1 -0
- package/dist/browser/CdpCaptureEventTypes.js +1 -0
- package/dist/browser/CdpCaptureEvents.js +46 -464
- package/dist/browser/CdpElectronInspection.js +106 -162
- package/dist/browser/CdpElectronProvider.js +5 -1
- package/dist/browser/CdpElectronScriptEvents.js +69 -0
- package/dist/browser/CdpElectronScripts.js +94 -0
- package/dist/browser/CdpElectronWorkers.js +56 -0
- package/dist/browser/CdpObservationSession.js +51 -8
- package/dist/browser/CdpPageCapture.js +12 -129
- package/dist/browser/CdpPageCaptureScripts.js +97 -0
- package/dist/browser/CdpPageCaptureWorkers.js +46 -0
- package/dist/browser/CdpWebMcpDiscovery.js +38 -14
- package/dist/browser/PngVisualDiff.js +9 -2
- package/dist/catalogIdentity.js +8 -1
- package/dist/cli/artifactCommands.js +82 -0
- package/dist/cli/coreAnalysisCommands.js +232 -0
- package/dist/cli/managedCommands.js +397 -0
- package/dist/cli/managedProjectGraphCommand.js +24 -0
- package/dist/cli/options.js +9 -0
- package/dist/cli/setupCommands.js +108 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utilityCommands.js +122 -0
- package/dist/cli.js +13 -383
- package/dist/cliApplicationCommands.js +176 -0
- package/dist/cliBrowserAdvancedCommands.js +73 -16
- package/dist/cliBrowserCommands.js +39 -115
- package/dist/cliCommandNames.js +17 -0
- package/dist/cliElectronCommands.js +100 -27
- package/dist/cliEvidenceCommands.js +13 -2
- package/dist/cliInvestigationCommands.js +53 -10
- package/dist/cliJsonInput.js +54 -0
- package/dist/cliObservationOptions.js +137 -0
- package/dist/cliPolicyCommands.js +80 -46
- package/dist/cliSetup.js +289 -0
- package/dist/config/environment.js +107 -0
- package/dist/config/parseConfig.js +228 -0
- package/dist/config/parsers.js +68 -0
- package/dist/config/permissions.js +30 -0
- package/dist/config/types.js +1 -0
- package/dist/config.js +1 -292
- package/dist/contracts/applicationToolContracts.js +225 -0
- package/dist/contracts/artifactToolContracts.js +5 -9
- package/dist/contracts/browserToolContracts.js +14 -62
- package/dist/contracts/electronToolContracts.js +45 -19
- package/dist/contracts/errorSchemas.js +1 -0
- package/dist/contracts/investigationExamples.js +0 -6
- package/dist/contracts/javascriptApplicationWorkflowExamples.js +46 -0
- package/dist/contracts/javascriptRuntimeReconciliationExample.js +208 -0
- package/dist/contracts/managedToolContracts.js +153 -0
- package/dist/contracts/managedWorkflowExamples.js +346 -0
- package/dist/contracts/managedWorkflowToolContracts.js +203 -0
- package/dist/contracts/nativeToolContracts.js +2 -6
- package/dist/contracts/promptContracts.js +18 -2
- package/dist/contracts/providerSelection.js +2 -0
- package/dist/contracts/toolContractExamples.js +10 -25
- package/dist/contracts/toolContracts.js +49 -47
- package/dist/contracts/toolEffects.js +174 -0
- package/dist/contracts/toolOutputSchemaGroups.js +232 -0
- package/dist/contracts/toolOutputSchemaPrimitives.js +327 -0
- package/dist/contracts/toolOutputSchemas.js +2 -535
- package/dist/doctorRuntime.js +42 -1
- package/dist/domain/analysisErrorPresentation.js +234 -0
- package/dist/domain/analysisErrorProjection.js +284 -0
- package/dist/domain/artifactComparison.js +37 -19
- package/dist/domain/binaryTarget.js +87 -37
- package/dist/domain/browserObservation.js +1 -282
- package/dist/domain/browserObservationSchemas.js +286 -0
- package/dist/domain/bundleComparison.js +4 -4
- package/dist/domain/electronObservation.js +13 -0
- package/dist/domain/electronStaticAnalysis.js +9 -0
- package/dist/domain/electronStaticAnalysisBrowser.js +206 -0
- package/dist/domain/electronStaticAnalysisIpc.js +171 -0
- package/dist/domain/electronStaticAnalysisNative.js +164 -0
- package/dist/domain/electronStaticAnalysisTypes.js +1 -0
- package/dist/domain/electronStaticAnalysisValues.js +103 -0
- package/dist/domain/errors.js +32 -448
- package/dist/domain/functionComparison.js +4 -165
- package/dist/domain/functionComparisonDimensions.js +164 -0
- package/dist/domain/functionComparisonSchemas.js +3 -8
- package/dist/domain/inputIssueProjection.js +52 -0
- package/dist/domain/javascriptApplicationAnalysis.js +155 -0
- package/dist/domain/javascriptApplicationChangeGraph.js +231 -0
- package/dist/domain/javascriptApplicationEvidenceSchemas.js +18 -0
- package/dist/domain/javascriptApplicationGraph.js +2 -1
- package/dist/domain/javascriptApplicationGraphSchemas.js +7 -0
- package/dist/domain/javascriptApplicationVersionComparison.js +116 -0
- package/dist/domain/javascriptApplicationVersionComparisonSchemas.js +139 -0
- package/dist/domain/javascriptApplicationVersionItems.js +233 -0
- package/dist/domain/javascriptApplicationVersionKeys.js +170 -0
- package/dist/domain/javascriptExportInstrumentation.js +97 -0
- package/dist/domain/javascriptFeatureSeed.js +140 -0
- package/dist/domain/javascriptFeatureTrace.js +232 -0
- package/dist/domain/javascriptFeatureTraceSchemas.js +136 -0
- package/dist/domain/javascriptFeatureTraversal.js +100 -0
- package/dist/domain/javascriptNativeHandoff.js +85 -0
- package/dist/domain/javascriptReplay.js +361 -0
- package/dist/domain/javascriptRuntimeLoadState.js +106 -0
- package/dist/domain/javascriptRuntimeReconciliation.js +42 -0
- package/dist/domain/javascriptRuntimeReconciliationGraph.js +169 -0
- package/dist/domain/javascriptRuntimeReconciliationMatching.js +247 -0
- package/dist/domain/javascriptRuntimeReconciliationParsing.js +160 -0
- package/dist/domain/javascriptRuntimeReconciliationResult.js +119 -0
- package/dist/domain/javascriptRuntimeReconciliationRuntime.js +316 -0
- package/dist/domain/javascriptRuntimeReconciliationSchemas.js +245 -0
- package/dist/domain/javascriptRuntimeStaticCandidates.js +193 -0
- package/dist/domain/javascriptSemanticAnalysis.js +386 -0
- package/dist/domain/javascriptSemanticIr.js +30 -0
- package/dist/domain/javascriptSemanticProjection.js +366 -0
- package/dist/domain/javascriptSemanticState.js +40 -0
- package/dist/domain/javascriptSemanticTraversal.js +22 -0
- package/dist/domain/javascriptSemanticValues.js +352 -0
- package/dist/domain/javascriptStaticAnalysis.js +26 -254
- package/dist/domain/javascriptStaticAnalysisBundler.js +209 -0
- package/dist/domain/javascriptStaticAnalysisCalls.js +180 -0
- package/dist/domain/javascriptStaticAnalysisFindings.js +39 -0
- package/dist/domain/javascriptStaticAnalysisHelpers.js +81 -2
- package/dist/domain/javascriptStaticAnalysisState.js +6 -0
- package/dist/domain/knownPageCoverage.js +21 -0
- package/dist/domain/managedApplicationGraph.js +206 -0
- package/dist/domain/managedApplicationGraphCoverage.js +170 -0
- package/dist/domain/managedApplicationGraphNodeCoverage.js +6 -0
- package/dist/domain/managedApplicationGraphNodes.js +336 -0
- package/dist/domain/managedArtifact.js +452 -0
- package/dist/domain/managedMemberComparison.js +211 -0
- package/dist/domain/managedMemberComparisonCoverage.js +72 -0
- package/dist/domain/managedMemberComparisonMatch.js +356 -0
- package/dist/domain/managedNativeVerification.js +46 -0
- package/dist/domain/managedNativeVerificationMatch.js +272 -0
- package/dist/domain/managedNativeVerificationSchemas.js +141 -0
- package/dist/domain/managedReconstruction.js +196 -0
- package/dist/domain/managedRuntimeCorrelation.js +184 -0
- package/dist/domain/nodeRuntimeCharacterization.js +66 -0
- package/dist/domain/permissionPolicy.js +2 -0
- package/dist/domain/reconstructionCoverage.js +387 -0
- package/dist/domain/reconstructionCoverageEvaluation.js +212 -0
- package/dist/domain/reconstructionVerificationSchemas.js +9 -3
- package/dist/domain/runtimeCharacterization.js +85 -0
- package/dist/domain/webBundleAnalyzer.js +3 -409
- package/dist/domain/webBundleAnalyzerAst.js +77 -0
- package/dist/domain/webBundleAnalyzerInspection.js +307 -0
- package/dist/domain/webBundleAnalyzerResult.js +120 -0
- package/dist/dotnet/ManagedArtifactInspector.js +339 -0
- package/dist/dotnet/ManagedMemberInspector.js +153 -0
- package/dist/dotnet/ManagedMemberInspectorCore.js +297 -0
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +427 -0
- package/dist/dotnet/ManagedMemberRows.js +120 -0
- package/dist/dotnet/ManagedMetadataHeaps.js +131 -0
- package/dist/dotnet/ManagedMetadataInventory.js +104 -0
- package/dist/dotnet/ManagedMetadataInventoryRows.js +292 -0
- package/dist/dotnet/ManagedMetadataLayout.js +259 -0
- package/dist/dotnet/ManagedMetadataRowSizes.js +54 -0
- package/dist/dotnet/ManagedMethodBodyReader.js +143 -0
- package/dist/dotnet/ManagedNativeBoundaryHelpers.js +311 -0
- package/dist/dotnet/ManagedNativeBoundaryInspector.js +143 -0
- package/dist/dotnet/ManagedPeReader.js +188 -0
- package/dist/dotnet/ManagedReaderFailure.js +10 -0
- package/dist/dotnet/ManagedStaticProvider.js +203 -0
- package/dist/generatedPackageMetadata.js +2 -2
- package/dist/ghidra/GhidraClient.js +76 -91
- package/dist/ghidra/GhidraClientStartup.js +29 -0
- package/dist/ghidra/GhidraClientWire.js +34 -0
- package/dist/ghidra/GhidraDefaults.js +1 -1
- package/dist/ghidra/GhidraDiagnostics.js +6 -1
- package/dist/ghidra/GhidraInstallation.js +20 -15
- package/dist/ghidra/GhidraLauncher.js +93 -29
- package/dist/ghidra/GhidraProvider.js +67 -161
- package/dist/ghidra/GhidraProviderCapabilities.js +173 -0
- package/dist/ghidra/GhidraSessionValues.js +2 -0
- package/dist/ghidra/GhidraSocketConnection.js +44 -7
- package/dist/ghidra/GhidraTargetSnapshot.js +30 -0
- package/dist/ghidra/GhidraTransport.js +71 -0
- package/dist/identity.js +3 -2
- package/dist/main/messages.js +5 -0
- package/dist/main/reload.js +49 -0
- package/dist/main/shutdown.js +25 -0
- package/dist/main/startup.js +14 -0
- package/dist/main/state.js +26 -0
- package/dist/main/transport.js +61 -0
- package/dist/main/types.js +1 -0
- package/dist/main.js +35 -132
- package/dist/process/PrivateRuntimeRoot.js +3 -2
- package/dist/process/ProcessOwnership.js +35 -0
- package/dist/process/ProviderProcess.js +2 -0
- package/dist/replay/JavaScriptReplayWorker.js +300 -0
- package/dist/replay/LinuxJavaScriptReplayRunner.js +217 -0
- package/dist/replay/LinuxJavaScriptReplaySandbox.js +140 -0
- package/dist/replay/LinuxRuntimeClosure.js +46 -0
- package/dist/replay/LinuxSeccompPolicy.js +40 -0
- package/dist/replay/ReplayOutcome.js +95 -0
- package/dist/replay/ReplayProcessLifecycle.js +71 -0
- package/dist/replay/ReplayWorkerProtocol.js +55 -0
- package/dist/replay/SystemJavaScriptReplayHost.js +182 -0
- package/dist/server/ProcessCaptureElicitation.js +157 -0
- package/dist/server/createServer.js +158 -41
- package/dist/server/registerApplicationTools/characterization.js +57 -0
- package/dist/server/registerApplicationTools/compareVersions.js +34 -0
- package/dist/server/registerApplicationTools/controlledReplay.js +38 -0
- package/dist/server/registerApplicationTools/coverage.js +84 -0
- package/dist/server/registerApplicationTools/helpers.js +42 -0
- package/dist/server/registerApplicationTools/traceFeature.js +26 -0
- package/dist/server/registerApplicationTools/types.js +1 -0
- package/dist/server/registerApplicationTools.js +13 -0
- package/dist/server/registerArtifactComparisonTool.js +16 -9
- package/dist/server/registerBrowserTools.js +61 -60
- package/dist/server/registerBundleComparisonTool.js +17 -20
- package/dist/server/registerElectronTools.js +39 -12
- package/dist/server/registerEnhancedTools.js +52 -15
- package/dist/server/registerEvidenceResources.js +54 -0
- package/dist/server/registerEvidenceTools.js +5 -1
- package/dist/server/registerFunctionComparisonTool.js +14 -7
- package/dist/server/registerInvestigationTools/helpers.js +74 -0
- package/dist/server/registerInvestigationTools/types.js +1 -0
- package/dist/server/registerInvestigationTools.js +103 -132
- package/dist/server/registerManagedTools.js +6 -0
- package/dist/server/registerManagedWorkflowTools/compareManagedMembers.js +65 -0
- package/dist/server/registerManagedWorkflowTools/contract.js +8 -0
- package/dist/server/registerManagedWorkflowTools/evidence.js +43 -0
- package/dist/server/registerManagedWorkflowTools/importManagedReconstruction.js +39 -0
- package/dist/server/registerManagedWorkflowTools/planManagedRuntimeCorrelation.js +39 -0
- package/dist/server/registerManagedWorkflowTools/projectManagedApplicationGraph.js +52 -0
- package/dist/server/registerManagedWorkflowTools/types.js +1 -0
- package/dist/server/registerManagedWorkflowTools/verifyManagedNativeBoundaries.js +75 -0
- package/dist/server/registerManagedWorkflowTools.js +13 -0
- package/dist/server/registerOfficialTools.js +81 -67
- package/dist/server/registerProcessComparisonTool.js +25 -47
- package/dist/server/registerSessionRecordTools.js +137 -0
- package/dist/server/registerSessionStatusTool.js +9 -8
- package/dist/server/registerSessionTools.js +77 -216
- package/dist/server/sessionAvailabilityPolicy.js +10 -0
- package/dist/server/sessionEvidence.js +14 -19
- package/dist/server/toolInputValidation.js +77 -0
- package/dist/server/toolRegistrationOptions.js +177 -2
- package/dist/server/toolResult.js +30 -17
- package/package.json +21 -14
- package/scripts/rea.mjs +1 -1
- package/skills/{rea-analysis → reverse-engineer-anything}/SKILL.md +75 -6
- package/scripts/prepare-node-pty.mjs +0 -35
- package/scripts/rebuild-native.mjs +0 -22
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { createJavaScriptApplicationEdge, createJavaScriptApplicationNode, } from "./javascriptApplicationGraph.js";
|
|
2
|
+
/** Project authorized passive capture metadata into capture-scoped JAG nodes. */
|
|
3
|
+
export const projectRuntimeCaptures = (captures, maximumEntities) => {
|
|
4
|
+
if (maximumEntities < captures.length)
|
|
5
|
+
throw new TypeError("Runtime entity limit must admit one target for every capture");
|
|
6
|
+
const all = captures.flatMap(projectCapture);
|
|
7
|
+
const targets = all.filter(({ kind }) => kind === "target");
|
|
8
|
+
const nonTargets = all.filter(({ kind }) => kind !== "target");
|
|
9
|
+
const retained = [...targets, ...nonTargets].slice(0, maximumEntities);
|
|
10
|
+
const retainedIds = new Set(retained.map(({ node }) => node.node_id));
|
|
11
|
+
const nodes = retained.map(({ node }) => node);
|
|
12
|
+
const edges = captures
|
|
13
|
+
.flatMap((capture) => runtimeEdges(capture, all))
|
|
14
|
+
.filter(({ source_node_id: source, target_node_id: target }) => retainedIds.has(source) && retainedIds.has(target));
|
|
15
|
+
const targetNodeByEvidenceId = new Map(retained
|
|
16
|
+
.filter(({ kind }) => kind === "target")
|
|
17
|
+
.map(({ capture, node }) => [capture.evidence.evidence_id, node]));
|
|
18
|
+
return {
|
|
19
|
+
entities: retained,
|
|
20
|
+
nodes,
|
|
21
|
+
edges,
|
|
22
|
+
targetNodeByEvidenceId,
|
|
23
|
+
omittedEntities: all.length - retained.length,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const projectCapture = (capture) => {
|
|
27
|
+
const target = targetEntity(capture);
|
|
28
|
+
return [
|
|
29
|
+
target,
|
|
30
|
+
...frameEntities(capture),
|
|
31
|
+
...scriptEntities(capture),
|
|
32
|
+
...workerEntities(capture),
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
const targetEntity = (capture) => {
|
|
36
|
+
const target = capture.inspection.target;
|
|
37
|
+
const location = "url" in target
|
|
38
|
+
? { kind: "url", value: target.url }
|
|
39
|
+
: { kind: "file", value: target.file_path };
|
|
40
|
+
return runtimeEntity(capture, {
|
|
41
|
+
kind: "target",
|
|
42
|
+
nodeKind: "target",
|
|
43
|
+
runtimeKey: target.target_id,
|
|
44
|
+
targetKey: target.target_id,
|
|
45
|
+
frameKey: null,
|
|
46
|
+
scriptKey: null,
|
|
47
|
+
location,
|
|
48
|
+
staticKind: "renderer",
|
|
49
|
+
sourceSha256: null,
|
|
50
|
+
label: target.title,
|
|
51
|
+
properties: {
|
|
52
|
+
runtime_type: target.type,
|
|
53
|
+
location: location.value.slice(0, 4_096),
|
|
54
|
+
attached: target.attached,
|
|
55
|
+
},
|
|
56
|
+
section: "target",
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const frameEntities = (capture) => capture.inspection.frames.map((frame) => {
|
|
60
|
+
const location = "url" in frame
|
|
61
|
+
? { kind: "url", value: frame.url }
|
|
62
|
+
: { kind: "file", value: frame.file_path };
|
|
63
|
+
return runtimeEntity(capture, {
|
|
64
|
+
kind: "frame",
|
|
65
|
+
nodeKind: "frame",
|
|
66
|
+
runtimeKey: frame.frame_id,
|
|
67
|
+
targetKey: capture.inspection.target.target_id,
|
|
68
|
+
frameKey: frame.frame_id,
|
|
69
|
+
scriptKey: null,
|
|
70
|
+
location,
|
|
71
|
+
staticKind: "renderer",
|
|
72
|
+
sourceSha256: null,
|
|
73
|
+
label: location.value,
|
|
74
|
+
properties: {
|
|
75
|
+
parent_frame_id: frame.parent_frame_id,
|
|
76
|
+
location: location.value.slice(0, 4_096),
|
|
77
|
+
},
|
|
78
|
+
section: "frames",
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
const scriptEntities = (capture) => capture.inspection.scripts.items.map((script) => {
|
|
82
|
+
const location = "url" in script
|
|
83
|
+
? { kind: "url", value: script.url }
|
|
84
|
+
: { kind: "file", value: script.file_path };
|
|
85
|
+
return runtimeEntity(capture, {
|
|
86
|
+
kind: "script",
|
|
87
|
+
nodeKind: "runtime-script-instance",
|
|
88
|
+
runtimeKey: script.script_key,
|
|
89
|
+
targetKey: capture.inspection.target.target_id,
|
|
90
|
+
frameKey: script.frame_id,
|
|
91
|
+
scriptKey: script.script_key,
|
|
92
|
+
location,
|
|
93
|
+
staticKind: "javascript",
|
|
94
|
+
sourceSha256: script.source.included
|
|
95
|
+
? script.source.artifact.sha256
|
|
96
|
+
: null,
|
|
97
|
+
label: location.value,
|
|
98
|
+
properties: {
|
|
99
|
+
location: location.value.slice(0, 4_096),
|
|
100
|
+
cdp_hash: script.cdp_hash,
|
|
101
|
+
length: script.length,
|
|
102
|
+
is_module: script.is_module,
|
|
103
|
+
language: script.language,
|
|
104
|
+
source_sha256: script.source.included
|
|
105
|
+
? script.source.artifact.sha256
|
|
106
|
+
: null,
|
|
107
|
+
...("source_map_url" in script
|
|
108
|
+
? { source_map_url: script.source_map_url }
|
|
109
|
+
: {}),
|
|
110
|
+
},
|
|
111
|
+
section: "scripts",
|
|
112
|
+
...(script.source.included
|
|
113
|
+
? { artifactSha256: script.source.artifact.sha256 }
|
|
114
|
+
: {}),
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const workerEntities = (capture) => capture.inspection.workers.map((worker) => {
|
|
118
|
+
const location = "url" in worker
|
|
119
|
+
? { kind: "url", value: worker.url }
|
|
120
|
+
: { kind: "file", value: worker.file_path };
|
|
121
|
+
const serviceWorker = worker.type.includes("service");
|
|
122
|
+
return runtimeEntity(capture, {
|
|
123
|
+
kind: "worker",
|
|
124
|
+
nodeKind: serviceWorker ? "service-worker" : "worker",
|
|
125
|
+
runtimeKey: worker.target_id,
|
|
126
|
+
targetKey: worker.target_id,
|
|
127
|
+
frameKey: worker.parent_frame_id,
|
|
128
|
+
scriptKey: null,
|
|
129
|
+
location,
|
|
130
|
+
staticKind: serviceWorker ? "service-worker" : "worker",
|
|
131
|
+
sourceSha256: null,
|
|
132
|
+
label: location.value,
|
|
133
|
+
properties: {
|
|
134
|
+
runtime_type: worker.type,
|
|
135
|
+
location: location.value.slice(0, 4_096),
|
|
136
|
+
attached: worker.attached,
|
|
137
|
+
opener_target_id: worker.opener_target_id,
|
|
138
|
+
parent_frame_id: worker.parent_frame_id,
|
|
139
|
+
},
|
|
140
|
+
section: "workers",
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
const runtimeEntity = (capture, input) => ({
|
|
144
|
+
kind: input.kind,
|
|
145
|
+
section: input.section,
|
|
146
|
+
capture,
|
|
147
|
+
runtimeKey: input.runtimeKey,
|
|
148
|
+
location: input.location,
|
|
149
|
+
frameKey: input.frameKey,
|
|
150
|
+
sourceSha256: input.sourceSha256,
|
|
151
|
+
staticKind: input.staticKind,
|
|
152
|
+
node: createJavaScriptApplicationNode({
|
|
153
|
+
kind: input.nodeKind,
|
|
154
|
+
identity: {
|
|
155
|
+
strategy: "runtime-instance",
|
|
156
|
+
stability: "capture-only",
|
|
157
|
+
capture_sha256: capture.captureSha256,
|
|
158
|
+
runtime_key: input.runtimeKey,
|
|
159
|
+
},
|
|
160
|
+
observations: [
|
|
161
|
+
{
|
|
162
|
+
label: input.label.slice(0, 1_024) || null,
|
|
163
|
+
properties: input.properties,
|
|
164
|
+
evidence: runtimeEvidence(capture, input),
|
|
165
|
+
},
|
|
166
|
+
],
|
|
167
|
+
}),
|
|
168
|
+
});
|
|
169
|
+
const runtimeEvidence = (capture, input) => ({
|
|
170
|
+
authority: "passive-cdp-runtime",
|
|
171
|
+
state: "observed",
|
|
172
|
+
confidence: "exact",
|
|
173
|
+
artifact: input.artifactSha256 === undefined
|
|
174
|
+
? {
|
|
175
|
+
available: false,
|
|
176
|
+
reason: input.section === "scripts" ? "not-observed" : "not-applicable",
|
|
177
|
+
detail: input.section === "scripts"
|
|
178
|
+
? "Script source bytes were not included in this passive capture."
|
|
179
|
+
: "This runtime entity has no standalone artifact bytes.",
|
|
180
|
+
}
|
|
181
|
+
: {
|
|
182
|
+
available: true,
|
|
183
|
+
artifact_id: `art_${input.artifactSha256}`,
|
|
184
|
+
sha256: input.artifactSha256,
|
|
185
|
+
},
|
|
186
|
+
location: {
|
|
187
|
+
available: true,
|
|
188
|
+
value: {
|
|
189
|
+
kind: "runtime",
|
|
190
|
+
capture_sha256: capture.captureSha256,
|
|
191
|
+
target_key: input.targetKey,
|
|
192
|
+
frame_key: input.frameKey,
|
|
193
|
+
script_key: input.scriptKey,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
extractor: {
|
|
197
|
+
name: capture.evidence.provider.id,
|
|
198
|
+
version: capture.evidence.provider.version ??
|
|
199
|
+
(capture.kind === "browser" ? "2" : "1"),
|
|
200
|
+
operation: capture.kind === "browser" ? "inspect_web_page" : "inspect_electron_page",
|
|
201
|
+
executable_sha256: null,
|
|
202
|
+
},
|
|
203
|
+
coverage: runtimeSectionCoverage(capture, input.section),
|
|
204
|
+
limitations: [
|
|
205
|
+
"The entity was observed only within one bounded passive CDP capture.",
|
|
206
|
+
...(runtimeSectionComplete(capture, input.section)
|
|
207
|
+
? []
|
|
208
|
+
: [
|
|
209
|
+
`The runtime ${input.section} inventory was incomplete within this capture.`,
|
|
210
|
+
]),
|
|
211
|
+
],
|
|
212
|
+
evidence_ids: [capture.evidence.evidence_id],
|
|
213
|
+
});
|
|
214
|
+
const runtimeEdges = (capture, entities) => {
|
|
215
|
+
const local = entities.filter(({ capture: candidate }) => candidate.evidence.evidence_id === capture.evidence.evidence_id);
|
|
216
|
+
const target = local.find(({ kind }) => kind === "target");
|
|
217
|
+
if (target === undefined)
|
|
218
|
+
return [];
|
|
219
|
+
const frames = new Map(local
|
|
220
|
+
.filter(({ kind }) => kind === "frame")
|
|
221
|
+
.map((entity) => [entity.runtimeKey, entity]));
|
|
222
|
+
return local.flatMap((entity) => {
|
|
223
|
+
if (entity === target)
|
|
224
|
+
return [];
|
|
225
|
+
const parent = (entity.kind === "script" || entity.kind === "worker") &&
|
|
226
|
+
entity.frameKey !== null
|
|
227
|
+
? (frames.get(entity.frameKey) ?? target)
|
|
228
|
+
: target;
|
|
229
|
+
return [
|
|
230
|
+
createJavaScriptApplicationEdge({
|
|
231
|
+
source_node_id: parent.node.node_id,
|
|
232
|
+
target_node_id: entity.node.node_id,
|
|
233
|
+
relation: entity.kind === "script" ? "loads" : "contains",
|
|
234
|
+
properties: { basis: "passive-cdp-observation" },
|
|
235
|
+
evidence: runtimeRelationshipEvidence(capture, entity),
|
|
236
|
+
}),
|
|
237
|
+
];
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
const runtimeRelationshipEvidence = (capture, entity) => ({
|
|
241
|
+
authority: "passive-cdp-runtime",
|
|
242
|
+
state: "observed",
|
|
243
|
+
confidence: "exact",
|
|
244
|
+
artifact: {
|
|
245
|
+
available: false,
|
|
246
|
+
reason: "not-applicable",
|
|
247
|
+
detail: "The relationship is runtime metadata, not standalone bytes.",
|
|
248
|
+
},
|
|
249
|
+
location: {
|
|
250
|
+
available: true,
|
|
251
|
+
value: {
|
|
252
|
+
kind: "runtime",
|
|
253
|
+
capture_sha256: capture.captureSha256,
|
|
254
|
+
target_key: capture.inspection.target.target_id,
|
|
255
|
+
frame_key: entity.frameKey,
|
|
256
|
+
script_key: entity.kind === "script" ? entity.runtimeKey : null,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
extractor: {
|
|
260
|
+
name: capture.evidence.provider.id,
|
|
261
|
+
version: capture.evidence.provider.version ??
|
|
262
|
+
(capture.kind === "browser" ? "2" : "1"),
|
|
263
|
+
operation: capture.kind === "browser" ? "inspect_web_page" : "inspect_electron_page",
|
|
264
|
+
executable_sha256: null,
|
|
265
|
+
},
|
|
266
|
+
coverage: runtimeSectionCoverage(capture, entity.section),
|
|
267
|
+
limitations: [
|
|
268
|
+
"The relationship was observed only within one bounded passive CDP capture.",
|
|
269
|
+
],
|
|
270
|
+
evidence_ids: [capture.evidence.evidence_id],
|
|
271
|
+
});
|
|
272
|
+
const runtimeSectionComplete = (capture, section) => {
|
|
273
|
+
if (section === "target")
|
|
274
|
+
return true;
|
|
275
|
+
if (section === "scripts")
|
|
276
|
+
return capture.scriptsCompleteWithinScope;
|
|
277
|
+
return (!capture.inspection.completeness.truncated_sections.includes(section) &&
|
|
278
|
+
!capture.inspection.completeness.unavailable_sections.includes(section));
|
|
279
|
+
};
|
|
280
|
+
const runtimeSectionCoverage = (capture, section) => {
|
|
281
|
+
if (runtimeSectionComplete(capture, section))
|
|
282
|
+
return {
|
|
283
|
+
status: "complete",
|
|
284
|
+
truncated: false,
|
|
285
|
+
omitted_count: 0,
|
|
286
|
+
limits: [],
|
|
287
|
+
};
|
|
288
|
+
const truncated = section !== "target" &&
|
|
289
|
+
capture.inspection.completeness.truncated_sections.includes(section);
|
|
290
|
+
return {
|
|
291
|
+
status: "partial",
|
|
292
|
+
truncated,
|
|
293
|
+
omitted_count: null,
|
|
294
|
+
limits: truncated
|
|
295
|
+
? [
|
|
296
|
+
{
|
|
297
|
+
name: `passive-cdp-${section}-limit`,
|
|
298
|
+
value: runtimeSectionCount(capture, section),
|
|
299
|
+
unit: "items",
|
|
300
|
+
},
|
|
301
|
+
]
|
|
302
|
+
: [],
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
const runtimeSectionCount = (capture, section) => {
|
|
306
|
+
switch (section) {
|
|
307
|
+
case "target":
|
|
308
|
+
return 1;
|
|
309
|
+
case "frames":
|
|
310
|
+
return capture.inspection.frames.length;
|
|
311
|
+
case "scripts":
|
|
312
|
+
return capture.inspection.scripts.items.length;
|
|
313
|
+
case "workers":
|
|
314
|
+
return capture.inspection.workers.length;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { isAbsolute, resolve } from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { evidenceSchema } from "./evidence.js";
|
|
4
|
+
import { compareCodePoints, javascriptApplicationGraphSchema, } from "./javascriptApplicationGraph.js";
|
|
5
|
+
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
|
6
|
+
const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
|
7
|
+
const nodeIdSchema = z.string().regex(/^jag_node_[a-f0-9]{64}$/u);
|
|
8
|
+
const boundedTextSchema = z.string().min(1).max(4_096);
|
|
9
|
+
const safePrefixSchema = z
|
|
10
|
+
.string()
|
|
11
|
+
.max(4_096)
|
|
12
|
+
.refine((value) => value === "" ||
|
|
13
|
+
(!value.startsWith("/") &&
|
|
14
|
+
!value.includes("\\") &&
|
|
15
|
+
value.split("/").every((part) => !["", ".", ".."].includes(part))), "Artifact prefix must be empty or a safe relative POSIX path");
|
|
16
|
+
const runtimeFileMappingSchema = z.strictObject({
|
|
17
|
+
kind: z.literal("file-root"),
|
|
18
|
+
root: z
|
|
19
|
+
.string()
|
|
20
|
+
.min(1)
|
|
21
|
+
.max(16_384)
|
|
22
|
+
.refine(isAbsolute, "Runtime file mapping root must be absolute")
|
|
23
|
+
.overwrite((value) => resolve(value)),
|
|
24
|
+
artifact_prefix: safePrefixSchema.default(""),
|
|
25
|
+
});
|
|
26
|
+
const runtimeUrlMappingSchema = z.strictObject({
|
|
27
|
+
kind: z.literal("url-prefix"),
|
|
28
|
+
prefix: z
|
|
29
|
+
.string()
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(16_384)
|
|
32
|
+
.refine((value) => normalizeRuntimeUrlPrefix(value) !== null, "Runtime URL prefix must be HTTP(S) without credentials, query, or fragment")
|
|
33
|
+
.overwrite((value) => normalizeRuntimeUrlPrefix(value) ?? value),
|
|
34
|
+
artifact_prefix: safePrefixSchema.default(""),
|
|
35
|
+
});
|
|
36
|
+
const normalizeRuntimeUrlPrefix = (value) => {
|
|
37
|
+
let url;
|
|
38
|
+
try {
|
|
39
|
+
url = new URL(value);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (!["http:", "https:"].includes(url.protocol) ||
|
|
45
|
+
url.username !== "" ||
|
|
46
|
+
url.password !== "" ||
|
|
47
|
+
url.search !== "" ||
|
|
48
|
+
url.hash !== "")
|
|
49
|
+
return null;
|
|
50
|
+
if (!url.pathname.endsWith("/"))
|
|
51
|
+
url.pathname += "/";
|
|
52
|
+
return url.href;
|
|
53
|
+
};
|
|
54
|
+
/** Caller-declared translation from an authorized runtime location to a layer. */
|
|
55
|
+
const runtimeLocationMappingSchema = z.discriminatedUnion("kind", [
|
|
56
|
+
runtimeFileMappingSchema,
|
|
57
|
+
runtimeUrlMappingSchema,
|
|
58
|
+
]);
|
|
59
|
+
const staticLayerSchema = z.strictObject({
|
|
60
|
+
role: z.enum(["application", "cache", "assets"]),
|
|
61
|
+
analysis: evidenceSchema,
|
|
62
|
+
runtime_mappings: z
|
|
63
|
+
.array(runtimeLocationMappingSchema)
|
|
64
|
+
.max(32)
|
|
65
|
+
.overwrite(normalizeRuntimeMappings)
|
|
66
|
+
.default([]),
|
|
67
|
+
});
|
|
68
|
+
function normalizeRuntimeMappings(mappings) {
|
|
69
|
+
return [
|
|
70
|
+
...new Map(mappings.map((mapping) => [runtimeMappingKey(mapping), mapping])).values(),
|
|
71
|
+
].sort((left, right) => compareCodePoints(runtimeMappingKey(left), runtimeMappingKey(right)));
|
|
72
|
+
}
|
|
73
|
+
function runtimeMappingKey(mapping) {
|
|
74
|
+
return mapping.kind === "file-root"
|
|
75
|
+
? `file-root\0${mapping.root}\0${mapping.artifact_prefix}`
|
|
76
|
+
: `url-prefix\0${mapping.prefix}\0${mapping.artifact_prefix}`;
|
|
77
|
+
}
|
|
78
|
+
const reconciliationLimitsSchema = z.strictObject({
|
|
79
|
+
max_runtime_entities: z.number().int().min(1).max(50_000).default(10_000),
|
|
80
|
+
max_reconciliation_items: z.number().int().min(1).max(50_000).default(20_000),
|
|
81
|
+
max_static_load_states: z.number().int().min(1).max(50_000).default(20_000),
|
|
82
|
+
});
|
|
83
|
+
/** Evidence-backed static layers and passive captures to reconcile. */
|
|
84
|
+
export const reconcileJavaScriptRuntimeInputSchema = z
|
|
85
|
+
.strictObject({
|
|
86
|
+
static_layers: z.array(staticLayerSchema).min(1).max(8),
|
|
87
|
+
runtime_observations: z.array(evidenceSchema).min(1).max(32),
|
|
88
|
+
limits: reconciliationLimitsSchema.default({
|
|
89
|
+
max_runtime_entities: 10_000,
|
|
90
|
+
max_reconciliation_items: 20_000,
|
|
91
|
+
max_static_load_states: 20_000,
|
|
92
|
+
}),
|
|
93
|
+
})
|
|
94
|
+
.superRefine((input, context) => {
|
|
95
|
+
if (input.static_layers.filter(({ role }) => role === "application")
|
|
96
|
+
.length !== 1)
|
|
97
|
+
context.addIssue({
|
|
98
|
+
code: "custom",
|
|
99
|
+
path: ["static_layers"],
|
|
100
|
+
message: "Exactly one application static layer is required",
|
|
101
|
+
});
|
|
102
|
+
const staticIds = input.static_layers.map(({ analysis }) => analysis.evidence_id);
|
|
103
|
+
if (new Set(staticIds).size !== staticIds.length)
|
|
104
|
+
context.addIssue({
|
|
105
|
+
code: "custom",
|
|
106
|
+
path: ["static_layers"],
|
|
107
|
+
message: "Static layer Evidence must be unique",
|
|
108
|
+
});
|
|
109
|
+
const runtimeIds = input.runtime_observations.map(({ evidence_id: id }) => id);
|
|
110
|
+
if (new Set(runtimeIds).size !== runtimeIds.length)
|
|
111
|
+
context.addIssue({
|
|
112
|
+
code: "custom",
|
|
113
|
+
path: ["runtime_observations"],
|
|
114
|
+
message: "Runtime observation Evidence must be unique",
|
|
115
|
+
});
|
|
116
|
+
if (input.limits.max_runtime_entities < input.runtime_observations.length)
|
|
117
|
+
context.addIssue({
|
|
118
|
+
code: "custom",
|
|
119
|
+
path: ["limits", "max_runtime_entities"],
|
|
120
|
+
message: "Runtime entity limit must retain one target per observation",
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
const layerSummarySchema = z.strictObject({
|
|
124
|
+
layer_id: z.string().regex(/^jrl_[a-f0-9]{64}$/u),
|
|
125
|
+
role: z.enum(["application", "cache", "assets"]),
|
|
126
|
+
evidence_id: evidenceIdSchema,
|
|
127
|
+
graph_id: z.string().regex(/^jag_[a-f0-9]{64}$/u),
|
|
128
|
+
root_artifact_sha256: digestSchema,
|
|
129
|
+
input_path: z.string().min(1).max(16_384),
|
|
130
|
+
format: z.enum(["asar", "directory"]),
|
|
131
|
+
runtime_mappings: z.array(runtimeLocationMappingSchema).max(32),
|
|
132
|
+
});
|
|
133
|
+
const captureSummarySchema = z.strictObject({
|
|
134
|
+
evidence_id: evidenceIdSchema,
|
|
135
|
+
capture_sha256: digestSchema,
|
|
136
|
+
kind: z.enum(["browser", "electron"]),
|
|
137
|
+
target_node_id: nodeIdSchema,
|
|
138
|
+
target_key: boundedTextSchema,
|
|
139
|
+
target_location: boundedTextSchema,
|
|
140
|
+
frames: z.number().int().min(0),
|
|
141
|
+
scripts: z.number().int().min(0),
|
|
142
|
+
workers: z.number().int().min(0),
|
|
143
|
+
scripts_complete_within_scope: z.boolean(),
|
|
144
|
+
});
|
|
145
|
+
const reconciliationReasonSchema = z.enum([
|
|
146
|
+
"content-and-location-match",
|
|
147
|
+
"unique-content-match",
|
|
148
|
+
"unique-location-match",
|
|
149
|
+
"ambiguous-static-candidates",
|
|
150
|
+
"captured-content-disagrees-with-static-location",
|
|
151
|
+
"no-static-content-match",
|
|
152
|
+
"no-authorized-location-mapping",
|
|
153
|
+
"runtime-frame-unattributed",
|
|
154
|
+
"static-or-runtime-coverage-incomplete",
|
|
155
|
+
"reconciliation-limit-reached",
|
|
156
|
+
]);
|
|
157
|
+
const reconciliationItemSchema = z.strictObject({
|
|
158
|
+
reconciliation_id: z.string().regex(/^jrr_item_[a-f0-9]{64}$/u),
|
|
159
|
+
entity_kind: z.enum(["target", "frame", "script", "worker"]),
|
|
160
|
+
runtime_evidence_id: evidenceIdSchema,
|
|
161
|
+
runtime_node_id: nodeIdSchema,
|
|
162
|
+
static_layer_id: z
|
|
163
|
+
.string()
|
|
164
|
+
.regex(/^jrl_[a-f0-9]{64}$/u)
|
|
165
|
+
.nullable(),
|
|
166
|
+
static_node_id: nodeIdSchema.nullable(),
|
|
167
|
+
status: z.enum(["matched", "ambiguous", "unmatched", "unknown"]),
|
|
168
|
+
basis: z.enum([
|
|
169
|
+
"content-and-location",
|
|
170
|
+
"content-sha256",
|
|
171
|
+
"module-source-sha256",
|
|
172
|
+
"artifact-path",
|
|
173
|
+
"operator-file-mapping",
|
|
174
|
+
"operator-url-mapping",
|
|
175
|
+
"none",
|
|
176
|
+
]),
|
|
177
|
+
confidence: z.enum(["exact", "high", "medium", "low", "unknown"]),
|
|
178
|
+
reason: reconciliationReasonSchema,
|
|
179
|
+
candidate_static_count: z.number().int().min(0).max(800_000),
|
|
180
|
+
candidate_static_nodes: z
|
|
181
|
+
.array(z.strictObject({
|
|
182
|
+
static_layer_id: z.string().regex(/^jrl_[a-f0-9]{64}$/u),
|
|
183
|
+
static_node_id: nodeIdSchema,
|
|
184
|
+
}))
|
|
185
|
+
.max(1_000),
|
|
186
|
+
});
|
|
187
|
+
const staticLoadStateSchema = z.strictObject({
|
|
188
|
+
static_layer_id: z.string().regex(/^jrl_[a-f0-9]{64}$/u),
|
|
189
|
+
static_node_id: nodeIdSchema,
|
|
190
|
+
kind: z.enum(["javascript-asset", "javascript-chunk", "javascript-module"]),
|
|
191
|
+
status: z.enum([
|
|
192
|
+
"loaded",
|
|
193
|
+
"resident-in-loaded-asset",
|
|
194
|
+
"not-observed-in-capture",
|
|
195
|
+
"unknown",
|
|
196
|
+
]),
|
|
197
|
+
runtime_node_ids: z.array(nodeIdSchema).max(10_000),
|
|
198
|
+
reason: z.enum([
|
|
199
|
+
"runtime-script-correspondence",
|
|
200
|
+
"containing-asset-was-loaded",
|
|
201
|
+
"not-observed-in-bounded-capture",
|
|
202
|
+
"layer-outside-runtime-scope",
|
|
203
|
+
"static-or-runtime-coverage-incomplete",
|
|
204
|
+
]),
|
|
205
|
+
});
|
|
206
|
+
/** Deterministic static/passive-runtime reconciliation with a combined JAG. */
|
|
207
|
+
export const javascriptRuntimeReconciliationResultSchema = z.strictObject({
|
|
208
|
+
schema_version: z.literal(1),
|
|
209
|
+
reconciliation_id: z.string().regex(/^jrr_[a-f0-9]{64}$/u),
|
|
210
|
+
static_layers: z.array(layerSummarySchema).min(1).max(8),
|
|
211
|
+
runtime_captures: z.array(captureSummarySchema).min(1).max(32),
|
|
212
|
+
graph: javascriptApplicationGraphSchema,
|
|
213
|
+
summary: z.strictObject({
|
|
214
|
+
runtime_targets: z.number().int().min(0),
|
|
215
|
+
runtime_frames: z.number().int().min(0),
|
|
216
|
+
runtime_scripts: z.number().int().min(0),
|
|
217
|
+
runtime_workers: z.number().int().min(0),
|
|
218
|
+
matched: z.number().int().min(0),
|
|
219
|
+
ambiguous: z.number().int().min(0),
|
|
220
|
+
unmatched: z.number().int().min(0),
|
|
221
|
+
unknown: z.number().int().min(0),
|
|
222
|
+
static_loaded: z.number().int().min(0),
|
|
223
|
+
static_resident: z.number().int().min(0),
|
|
224
|
+
static_not_observed: z.number().int().min(0),
|
|
225
|
+
static_unknown: z.number().int().min(0),
|
|
226
|
+
}),
|
|
227
|
+
reconciliations: z.array(reconciliationItemSchema).max(50_000),
|
|
228
|
+
static_load_states: z.array(staticLoadStateSchema).max(50_000),
|
|
229
|
+
source_map_authority: z.strictObject({
|
|
230
|
+
used_for_primary_matching: z.literal(false),
|
|
231
|
+
static_layers_with_read_approval: z.number().int().min(0),
|
|
232
|
+
runtime_script_declarations: z.number().int().min(0),
|
|
233
|
+
limitation: boundedTextSchema,
|
|
234
|
+
}),
|
|
235
|
+
coverage: z.strictObject({
|
|
236
|
+
status: z.enum(["complete-within-inputs", "partial", "truncated"]),
|
|
237
|
+
truncated: z.boolean(),
|
|
238
|
+
omitted_runtime_entities: z.number().int().min(0),
|
|
239
|
+
omitted_reconciliation_items: z.number().int().min(0),
|
|
240
|
+
omitted_static_load_states: z.number().int().min(0),
|
|
241
|
+
omitted_graph_items: z.number().int().min(0),
|
|
242
|
+
}),
|
|
243
|
+
evidence_links: z.array(evidenceIdSchema).min(2).max(40),
|
|
244
|
+
limitations: z.array(boundedTextSchema).max(1_000),
|
|
245
|
+
});
|