rea-agents 6.2.0 → 6.3.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 +18 -20
- package/bridge/hopper_bridge.py +2 -0
- package/dist/android/JadxProvider.js +8 -2
- package/dist/android/JadxSession.js +51 -9
- package/dist/application/BinaryTargetResolver.js +63 -17
- package/dist/application/BrowserScenarioEvidence.js +2 -2
- package/dist/application/ClientConfigurationDocument.js +28 -0
- package/dist/application/ClientRegistrationStatus.js +19 -6
- package/dist/application/DirectAnalysis.js +12 -6
- package/dist/application/DirectAnalysisCleanup.js +0 -1
- package/dist/application/DirectAnalysisStatus.js +2 -5
- package/dist/application/Doctor.js +25 -34
- package/dist/application/DoctorDiagnostics.js +1 -1
- package/dist/application/EvidenceBundleFiles.js +1 -1
- package/dist/application/InvestigationProviders.js +4 -4
- package/dist/application/JsonFiles.js +15 -15
- package/dist/application/LinuxHopper.js +2 -1
- package/dist/application/ReconstructionObligationCandidates.js +9 -2
- package/dist/application/ReconstructionObligationLedgerProjection.js +3 -1
- package/dist/application/RegularFileRead.js +17 -0
- package/dist/application/Setup.js +18 -7
- package/dist/application/SetupClientConfiguration.js +18 -7
- package/dist/application/SetupHost.js +6 -4
- package/dist/application/SetupPlan.js +19 -15
- package/dist/application/SetupSkill.js +57 -8
- package/dist/application/SupportedClients.js +43 -0
- package/dist/application/Uninstall.js +18 -2
- package/dist/application/UpdateMaintenance.js +6 -2
- package/dist/application/Utf8JsonInput.js +64 -0
- package/dist/application/WebScriptExportService.js +13 -6
- package/dist/application/android/AndroidAnalysisService.js +1 -1
- package/dist/application/binary/AnalysisSnapshotCache.js +5 -4
- package/dist/application/binary/BinarySession.js +16 -0
- package/dist/application/binary/BinarySessionOpen.js +9 -1
- package/dist/application/javascript/ElectronActiveEvidence.js +2 -2
- package/dist/application/javascript/ElectronBoundaryAnalysis.js +2 -2
- package/dist/application/javascript/ElectronBoundaryGraphNative.js +5 -1
- package/dist/application/javascript/JavaScriptApplicationEvidence.js +1 -0
- package/dist/application/javascript/JavaScriptApplicationEvidenceGraph.js +107 -46
- package/dist/application/javascript/JavaScriptApplicationService.js +1 -0
- package/dist/application/javascript/JavaScriptApplicationWorkflowService.js +59 -45
- package/dist/application/javascript/JavaScriptArtifactAnalysis.js +0 -6
- package/dist/application/javascript/JavaScriptArtifactGraphBuilder.js +8 -18
- package/dist/application/javascript/JavaScriptArtifactGraphFindings.js +34 -26
- package/dist/application/javascript/JavaScriptArtifactPathResolution.js +44 -12
- package/dist/application/javascript/JavaScriptArtifactReconstruction.js +6 -3
- package/dist/application/javascript/JavaScriptArtifactReconstructionInput.js +1 -0
- package/dist/application/javascript/JavaScriptJsonModules.js +2 -2
- package/dist/application/javascript/JavaScriptModuleRelationships.js +5 -17
- package/dist/application/javascript/JavaScriptRuntimeReconciliationService.js +11 -27
- package/dist/application/javascript/JavaScriptSemanticGraphAsyncProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphBuilder.js +8 -6
- package/dist/application/javascript/JavaScriptSemanticGraphChildProcessProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphConstruction.js +7 -5
- package/dist/application/javascript/JavaScriptSemanticGraphDataProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphEvidence.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphFingerprintProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphFlowProjection.js +2 -2
- package/dist/application/javascript/JavaScriptSemanticGraphObjectProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphProjection.js +4 -4
- package/dist/application/javascript/JavaScriptSemanticGraphResourceProjection.js +1 -1
- package/dist/application/javascript/JavaScriptSemanticGraphValueProjection.js +10 -7
- package/dist/application/javascript/JavaScriptSemanticTraceService.js +15 -10
- package/dist/application/native/NativeCallRoutes.js +2 -4
- package/dist/artifacts/ArtifactProvider.js +14 -16
- package/dist/artifacts/ArtifactProviderMetadata.js +1 -4
- package/dist/artifacts/AsarArtifactReader.js +81 -17
- package/dist/artifacts/DirectoryArtifactReader.js +2 -2
- package/dist/artifacts/NativeDmgArtifactReader.js +152 -67
- package/dist/artifacts/NativeDmgOwnership.js +109 -0
- package/dist/artifacts/apple/KeyedArchiveReader.js +54 -46
- package/dist/artifacts/apple/MachoLoadCommandReader.js +36 -6
- package/dist/artifacts/extraction/ArtifactExtraction.js +29 -11
- package/dist/artifacts/inventory/ArtifactGraphConstruction.js +7 -8
- package/dist/artifacts/inventory/classify.js +33 -14
- package/dist/artifacts/inventory/hashStableRootArtifact.js +37 -0
- package/dist/artifacts/inventory/scanCanonical.js +28 -22
- package/dist/artifacts/inventory/scanReader.js +7 -11
- package/dist/artifacts/javascript/JavaScriptArtifactFiles.js +65 -27
- package/dist/browser/CdpBrowserProvider.js +4 -3
- package/dist/browser/CdpCaptureStorageFingerprints.js +3 -3
- package/dist/browser/CdpElectronInspection.js +2 -2
- package/dist/browser/CdpElectronProvider.js +4 -3
- package/dist/browser/CdpElectronScripts.js +2 -2
- package/dist/browser/CdpWebMcpDiscovery.js +16 -13
- package/dist/browser/PlaywrightBrowserScenarioProvider.js +6 -6
- package/dist/browser/PlaywrightScenarioBrowser.js +145 -42
- package/dist/browser/PlaywrightScenarioSession.js +3 -11
- package/dist/browser/WebSourceMapFetcher.js +32 -6
- package/dist/browser/assets/ScenarioScriptCapture.js +8 -12
- package/dist/cli/coreAnalysisCommands.js +2 -2
- package/dist/cli/coreBinaryCommands.js +13 -9
- package/dist/cli/electronCommands.js +9 -10
- package/dist/cli/javascriptApplicationAnalysis.js +2 -12
- package/dist/cli/jsonOutput.js +3 -2
- package/dist/cli/streamedJsonOutput.js +83 -4
- package/dist/cli/utilityCommands.js +2 -4
- package/dist/cli.js +5 -2
- package/dist/cliJsonFile.js +179 -0
- package/dist/cliJsonInput.js +47 -34
- package/dist/cliObservationOptions.js +4 -0
- package/dist/composition/auxiliaryAnalysisProviders.js +5 -4
- package/dist/composition/browserScenario.js +2 -2
- package/dist/composition/directAnalysis.js +2 -3
- package/dist/contracts/artifactComparisonExample.js +5 -5
- package/dist/contracts/errorSchemas.js +3 -1
- package/dist/contracts/functionComparisonExample.js +8 -0
- package/dist/contracts/inputSchemaPresentation.js +94 -3
- package/dist/contracts/javascript/electronToolContracts.js +2 -1
- package/dist/contracts/javascript/javascriptApplicationWorkflowExamples.js +3 -2
- package/dist/contracts/javascript/javascriptExportShapeComparisonExample.js +6 -3
- package/dist/contracts/javascript/javascriptRuntimeReconciliationExample.js +8 -7
- package/dist/contracts/managed/managedToolContracts.js +3 -2
- package/dist/contracts/mobileApplicationGraphExamples.js +5 -5
- package/dist/contracts/native/nativeToolContracts.js +1 -1
- package/dist/contracts/sessionLifecycleInputs.js +4 -3
- package/dist/contracts/sessionStatusContract.js +3 -2
- package/dist/contracts/sessionToolContracts.js +3 -2
- package/dist/contracts/sessionToolSchemas.js +3 -2
- package/dist/contracts/toolOutputSchemaGroups.js +2 -2
- package/dist/contracts/toolOutputSchemaPrimitives.js +2 -5
- package/dist/domain/analysisErrorBase.js +5 -0
- package/dist/domain/analysisErrorPresentation.js +4 -2
- package/dist/domain/analysisSnapshot.js +3 -1
- package/dist/domain/analysisView/analysisView.js +1 -3
- package/dist/domain/android/androidPartialObservation.js +36 -0
- package/dist/domain/apple/dylibResolution.js +1 -1
- package/dist/domain/artifactComparison.js +4 -4
- package/dist/domain/artifactGraph.js +1 -1
- package/dist/domain/artifactIdentity.js +8 -8
- package/dist/domain/artifactInspection.js +8 -8
- package/dist/domain/artifactInventoryEvidence.js +5 -5
- package/dist/domain/browserCompleteness.js +3 -2
- package/dist/domain/browserScenarioCaptureValues.js +2 -2
- package/dist/domain/browserScenarioNormalization.js +3 -3
- package/dist/domain/browserScenarioValues.js +3 -2
- package/dist/domain/callPath.js +8 -10
- package/dist/domain/canonicalDigest.js +7 -1
- package/dist/domain/canonicalOrdering.js +1 -13
- package/dist/domain/changedBehavior.js +2 -3
- package/dist/domain/comparisonSemantics.js +0 -5
- package/dist/domain/digests.js +0 -3
- package/dist/domain/evidence.js +10 -5
- package/dist/domain/evidenceBundle.js +51 -33
- package/dist/domain/firmware/firmwareAnalysis.js +4 -3
- package/dist/domain/functionComparison.js +2 -1
- package/dist/domain/functionComparisonNormalization.js +4 -3
- package/dist/domain/functionComparisonResults.js +2 -2
- package/dist/domain/functionDossierEvidence.js +2 -1
- package/dist/domain/hopperValues.js +11 -15
- package/dist/domain/javascript/electronActiveObservation.js +4 -3
- package/dist/domain/javascript/electronStaticAnalysisBrowser.js +2 -2
- package/dist/domain/javascript/electronStaticAnalysisIpc.js +9 -1
- package/dist/domain/javascript/electronStaticAnalysisNative.js +5 -3
- package/dist/domain/javascript/electronStaticAnalysisValues.js +8 -4
- package/dist/domain/javascript/javascriptApplicationAnalysis.js +3 -1
- package/dist/domain/javascript/javascriptApplicationChangeGraph.js +12 -8
- package/dist/domain/javascript/javascriptApplicationEvidenceSchemas.js +4 -0
- package/dist/domain/javascript/javascriptApplicationGraph.js +15 -13
- package/dist/domain/javascript/javascriptApplicationVersionComparison.js +4 -4
- package/dist/domain/javascript/javascriptApplicationVersionComparisonSchemas.js +37 -22
- package/dist/domain/javascript/javascriptApplicationVersionItems.js +45 -34
- package/dist/domain/javascript/javascriptApplicationVersionKeys.js +7 -7
- package/dist/domain/javascript/javascriptAstFingerprint.js +2 -2
- package/dist/domain/javascript/javascriptAstValues.js +22 -0
- package/dist/domain/javascript/javascriptExportShapeComparison.js +3 -2
- package/dist/domain/javascript/javascriptExportShapeComparisonSchemas.js +31 -23
- package/dist/domain/javascript/javascriptExportShapeSelection.js +2 -2
- package/dist/domain/javascript/javascriptExportShapeVariants.js +3 -2
- package/dist/domain/javascript/javascriptFeatureSeed.js +5 -3
- package/dist/domain/javascript/javascriptFeatureTrace.js +7 -6
- package/dist/domain/javascript/javascriptFeatureTraceSchemas.js +17 -9
- package/dist/domain/javascript/javascriptFeatureTraversal.js +4 -4
- package/dist/domain/javascript/javascriptNativeHandoff.js +6 -6
- package/dist/domain/javascript/javascriptRuntimeObservation.js +8 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliation.js +12 -6
- package/dist/domain/javascript/javascriptRuntimeReconciliationActive.js +9 -8
- package/dist/domain/javascript/javascriptRuntimeReconciliationCaptureParsing.js +212 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationGraph.js +5 -4
- package/dist/domain/javascript/javascriptRuntimeReconciliationInputValidation.js +28 -0
- package/dist/domain/javascript/javascriptRuntimeReconciliationMatching.js +5 -5
- package/dist/domain/javascript/javascriptRuntimeReconciliationParsing.js +12 -223
- package/dist/domain/javascript/javascriptRuntimeReconciliationResult.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeReconciliationRuntime.js +15 -4
- package/dist/domain/javascript/javascriptRuntimeReconciliationSchemas.js +2 -2
- package/dist/domain/javascript/javascriptRuntimeStaticCandidates.js +7 -6
- package/dist/domain/javascript/javascriptSemanticAnalysis.js +200 -8
- package/dist/domain/javascript/javascriptSemanticCallResolution.js +9 -7
- package/dist/domain/javascript/javascriptSemanticChildProcesses.js +2 -2
- package/dist/domain/javascript/javascriptSemanticCoverage.js +20 -0
- package/dist/domain/javascript/javascriptSemanticDataEffectHelpers.js +7 -9
- package/dist/domain/javascript/javascriptSemanticDataEffects.js +4 -11
- package/dist/domain/javascript/javascriptSemanticFingerprints.js +2 -2
- package/dist/domain/javascript/javascriptSemanticGraph.js +142 -35
- package/dist/domain/javascript/javascriptSemanticGraphSchemas.js +19 -1
- package/dist/domain/javascript/javascriptSemanticIr.js +0 -4
- package/dist/domain/javascript/javascriptSemanticIterationSources.js +106 -0
- package/dist/domain/javascript/javascriptSemanticMemberMutations.js +497 -113
- package/dist/domain/javascript/javascriptSemanticMutationInitializers.js +190 -0
- package/dist/domain/javascript/javascriptSemanticMutationValues.js +41 -27
- package/dist/domain/javascript/javascriptSemanticObjects.js +2 -6
- package/dist/domain/javascript/javascriptSemanticPrimitives.js +7 -2
- package/dist/domain/javascript/javascriptSemanticProjection.js +20 -14
- package/dist/domain/javascript/javascriptSemanticPromises.js +15 -21
- package/dist/domain/javascript/javascriptSemanticPropertyPaths.js +23 -0
- package/dist/domain/javascript/javascriptSemanticProvenance.js +3 -3
- package/dist/domain/javascript/javascriptSemanticQuery.js +8 -2
- package/dist/domain/javascript/javascriptSemanticQueryIdentity.js +3 -2
- package/dist/domain/javascript/javascriptSemanticQuerySchemas.js +8 -9
- package/dist/domain/javascript/javascriptSemanticRequireOrigin.js +16 -10
- package/dist/domain/javascript/javascriptSemanticReturns.js +23 -27
- package/dist/domain/javascript/javascriptSemanticTraversal.js +6 -1
- package/dist/domain/javascript/javascriptSemanticValues.js +135 -24
- package/dist/domain/javascript/javascriptSourceMapPaths.js +11 -1
- package/dist/domain/javascript/javascriptSourceParser.js +34 -9
- package/dist/domain/javascript/javascriptStaticAnalysisBundler.js +5 -6
- package/dist/domain/javascript/javascriptStaticAnalysisHelpers.js +26 -15
- package/dist/domain/javascript/sourceToBundleComparison.js +7 -5
- package/dist/domain/javascript/sourceToBundleSignals.js +7 -7
- package/dist/domain/jsonSerialization.js +109 -55
- package/dist/domain/jsonShape.js +46 -19
- package/dist/domain/localPath.js +10 -4
- package/dist/domain/managed/managedApplicationGraph.js +10 -6
- package/dist/domain/managed/managedApplicationGraphNodes.js +82 -57
- package/dist/domain/managed/managedMemberComparisonMatch.js +6 -7
- package/dist/domain/native/nativeCallObservation.js +2 -4
- package/dist/domain/native/nativeValueFlow.js +5 -11
- package/dist/domain/native/objcSwiftMetadata.js +15 -17
- package/dist/domain/process/processCapture.js +11 -10
- package/dist/domain/process/processCaptureCoverage.js +8 -5
- package/dist/domain/process/processCaptureExample.js +43 -0
- package/dist/domain/process/processCaptureValidation.js +4 -3
- package/dist/domain/process/processComparison.js +0 -23
- package/dist/domain/process/processScenario.js +3 -3
- package/dist/domain/process/processTraceEvaluation.js +4 -4
- package/dist/domain/process/processTraceSpecification.js +1 -3
- package/dist/domain/providerCleanupError.js +6 -2
- package/dist/domain/reconstructionCoverage.js +2 -1
- package/dist/domain/reconstructionUnknowns.js +4 -3
- package/dist/domain/reconstructionVerification.js +3 -2
- package/dist/domain/referenceSourceGraph.js +7 -7
- package/dist/domain/referenceSourceImportParsing.js +34 -45
- package/dist/domain/residualUnknown.js +3 -2
- package/dist/domain/staticRuntimeCorrelation.js +2 -1
- package/dist/domain/swiftSymbolClassification.js +6 -1
- package/dist/domain/symbolAnalysis.js +17 -2
- package/dist/domain/unicodeCodePointOrder.js +6 -0
- package/dist/domain/webBundleAnalyzerInspection.js +9 -1
- package/dist/domain/webCaptureDiff.js +71 -29
- package/dist/domain/webCaptureDiffSchemas.js +2 -8
- package/dist/domain/webInventory.js +3 -2
- package/dist/domain/webMcpDiscovery.js +4 -3
- package/dist/domain/webScriptExport.js +1 -1
- package/dist/dotnet/ManagedMemberInstructionDecoder.js +1 -2
- package/dist/dotnet/ManagedStaticProvider.js +10 -7
- package/dist/dotnet/ManagedStaticProviderMetadata.js +1 -4
- package/dist/filesystem/RegularFile.js +41 -0
- package/dist/generatedPackageMetadata.js +1 -1
- package/dist/ghidra/GhidraClient.js +14 -4
- package/dist/ghidra/GhidraInstallation.js +111 -10
- package/dist/ghidra/GhidraLauncher.js +43 -19
- package/dist/hopper/HopperCleanup.js +1 -1
- package/dist/ida/IdaOperationRunner.js +2 -0
- package/dist/ida/IdaSessionClient.js +4 -2
- package/dist/inspector/JavaScriptRuntimeScope.js +9 -5
- package/dist/inspector/V8InspectorCaptureProjection.js +46 -13
- package/dist/inspector/V8InspectorProvider.js +60 -8
- package/dist/main/shutdown.js +76 -32
- package/dist/main/transport.js +1 -1
- package/dist/native/AppleObjcDispatchFacets.js +3 -3
- package/dist/native/AppleObjcProperties.js +17 -7
- package/dist/native/LldbCallTracer.js +241 -75
- package/dist/native/NativeMacOSProvider.js +10 -5
- package/dist/native/NativeMacOSProviderMetadata.js +1 -2
- package/dist/process/ProcessOwnershipObservation.js +9 -13
- package/dist/process/capture/FilesystemSnapshot.js +88 -18
- package/dist/process/capture/ProcessCaptureLifecycle.js +13 -27
- package/dist/process/capture/ProcessFilesystemEffects.js +19 -4
- package/dist/process/capture/ProcessHarness.js +8 -21
- package/dist/server/analysisAdmission.js +8 -0
- package/dist/server/createServer.js +22 -23
- package/dist/server/registerApplicationTools/compareExportShapes.js +2 -1
- package/dist/server/registerApplicationTools/helpers.js +3 -2
- package/dist/server/registerArtifactTools.js +2 -2
- package/dist/server/registerCloseLifecycleTool.js +6 -4
- package/dist/server/registerEnhancedTools.js +78 -73
- package/dist/server/registerEvidenceTools.js +54 -46
- package/dist/server/registerManagedTools.js +7 -4
- package/dist/server/registerOfficialTools.js +31 -25
- package/dist/server/registerSessionTools.js +9 -3
- package/native/windows/build/manifest.json +1 -1
- package/package.json +6 -3
- package/skills/reverse-engineer-anything/SKILL.md +5 -5
- package/skills/reverse-engineer-anything/references/native-and-artifacts.md +9 -0
- package/dist/artifacts/inventory/policy.js +0 -2
- package/dist/domain/managed/managedApplicationGraphNodeCoverage.js +0 -6
- package/dist/server/registerNativeTools.js +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBuiltin } from "node:module";
|
|
2
2
|
import { posix } from "node:path";
|
|
3
3
|
import { admitsCanonicalPathSyntax, hasScheme, htmlUrlText, looksExternal, percentDecodeUrlPath, stripQueryAndFragment, } from "../../domain/artifactPathSyntax.js";
|
|
4
4
|
const EXTENSIONS = [
|
|
@@ -11,7 +11,6 @@ const EXTENSIONS = [
|
|
|
11
11
|
".html",
|
|
12
12
|
".node",
|
|
13
13
|
];
|
|
14
|
-
const NODE_BUILTINS = new Set(builtinModules.map((name) => name.replace(/^node:/u, "")));
|
|
15
14
|
/** Resolve one declaration under its exact syntax/metadata context. */
|
|
16
15
|
export const resolveArtifactPathByContext = (input) => resolvePackagePath(input, new Set());
|
|
17
16
|
const resolvePackagePath = (input, packageChain, mode = "full", exportsTargetUrl = false) => {
|
|
@@ -109,9 +108,7 @@ const contextualCandidate = (input, exportsTargetUrl) => {
|
|
|
109
108
|
};
|
|
110
109
|
const bareModuleCandidate = (input, declared) => {
|
|
111
110
|
const packageName = barePackageName(declared);
|
|
112
|
-
if (packageName === null ||
|
|
113
|
-
NODE_BUILTINS.has(packageName) ||
|
|
114
|
-
declared.startsWith("#"))
|
|
111
|
+
if (packageName === null || isBuiltin(declared) || declared.startsWith("#"))
|
|
115
112
|
return unresolvedOutcome(input, "external", [
|
|
116
113
|
"The bare specifier is a Node builtin, package import map, or invalid package name.",
|
|
117
114
|
]);
|
|
@@ -179,7 +176,9 @@ const htmlCandidate = (input) => {
|
|
|
179
176
|
if (declaredPath.startsWith("/"))
|
|
180
177
|
return declaredPath.slice(1);
|
|
181
178
|
if (base === undefined || base === null || base === "")
|
|
182
|
-
return
|
|
179
|
+
return declaredPath === ""
|
|
180
|
+
? input.sourcePath
|
|
181
|
+
: posix.join(posix.dirname(input.sourcePath), declaredPath);
|
|
183
182
|
// A local base href is a second untrusted path input; apply the same
|
|
184
183
|
// admission rules a declared path gets so it cannot smuggle traversal or
|
|
185
184
|
// separator syntax past canonicalization.
|
|
@@ -195,21 +194,32 @@ const htmlCandidate = (input) => {
|
|
|
195
194
|
const basePath = decodedBase.startsWith("/")
|
|
196
195
|
? decodedBase.slice(1)
|
|
197
196
|
: posix.join(posix.dirname(input.sourcePath), decodedBase);
|
|
197
|
+
if (declaredPath === "")
|
|
198
|
+
return emptyHtmlReference(input, decodedBase, basePath);
|
|
198
199
|
return posix.join(htmlBaseDirectory(decodedBase, basePath), declaredPath);
|
|
199
200
|
};
|
|
201
|
+
const emptyHtmlReference = (input, base, basePath) => {
|
|
202
|
+
if (!htmlBaseIsDirectory(base))
|
|
203
|
+
return basePath;
|
|
204
|
+
const confined = confineCandidate(input, basePath);
|
|
205
|
+
if (typeof confined !== "string")
|
|
206
|
+
return confined;
|
|
207
|
+
return unresolvedOutcome(input, "not-found", [
|
|
208
|
+
`The HTML reference resolves to directory ${confined || "."}, not an exact selected application file.`,
|
|
209
|
+
]);
|
|
210
|
+
};
|
|
200
211
|
/**
|
|
201
212
|
* The directory a relative HTML reference resolves against. A base path
|
|
202
213
|
* ending in "/" or in a "." or ".." segment is already a directory, because a
|
|
203
214
|
* relative reference resolves against the base URL's directory and those
|
|
204
215
|
* segments are dropped rather than stepped through.
|
|
205
216
|
*/
|
|
206
|
-
const
|
|
217
|
+
const htmlBaseIsDirectory = (base) => base.endsWith("/") ||
|
|
207
218
|
base.endsWith("/.") ||
|
|
208
219
|
base.endsWith("/..") ||
|
|
209
220
|
base === "." ||
|
|
210
|
-
base === ".."
|
|
211
|
-
|
|
212
|
-
: posix.dirname(basePath);
|
|
221
|
+
base === "..";
|
|
222
|
+
const htmlBaseDirectory = (base, basePath) => htmlBaseIsDirectory(base) ? basePath : posix.dirname(basePath);
|
|
213
223
|
const confineCandidate = (input, candidate) => {
|
|
214
224
|
const normalized = posix.normalize(candidate);
|
|
215
225
|
if (normalized === ".." ||
|
|
@@ -354,11 +364,20 @@ const packageEntry = (text, moduleKind, useExports) => {
|
|
|
354
364
|
}
|
|
355
365
|
};
|
|
356
366
|
const packageExport = (value, moduleKind) => {
|
|
367
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
368
|
+
const keys = Object.keys(value);
|
|
369
|
+
if (keys.some((key) => key.startsWith(".")) &&
|
|
370
|
+
keys.some((key) => !key.startsWith(".")))
|
|
371
|
+
return {
|
|
372
|
+
status: "rejected",
|
|
373
|
+
limitation: "The package exports configuration mixes subpath keys and condition keys.",
|
|
374
|
+
};
|
|
375
|
+
}
|
|
357
376
|
const root = typeof value === "object" && value !== null && Object.hasOwn(value, ".")
|
|
358
377
|
? Reflect.get(value, ".")
|
|
359
378
|
: value;
|
|
360
379
|
const flattened = exportTargets(root, packageExportConditions(moduleKind));
|
|
361
|
-
if (flattened.kind === "invalid")
|
|
380
|
+
if (flattened.kind === "invalid" || flattened.kind === "invalid-config")
|
|
362
381
|
return { status: "rejected", limitation: flattened.limitation };
|
|
363
382
|
const first = flattened.kind === "unmatched" ? undefined : flattened.values[0];
|
|
364
383
|
return first === undefined
|
|
@@ -404,6 +423,9 @@ const exportTargets = (value, conditions) => {
|
|
|
404
423
|
let invalid = null;
|
|
405
424
|
for (const entry of value) {
|
|
406
425
|
const nested = exportTargets(entry, conditions);
|
|
426
|
+
// Node's array fallback catches invalid targets, not invalid configuration.
|
|
427
|
+
if (nested.kind === "invalid-config")
|
|
428
|
+
return nested;
|
|
407
429
|
if (nested.kind === "invalid") {
|
|
408
430
|
invalid = nested.limitation;
|
|
409
431
|
continue;
|
|
@@ -420,6 +442,14 @@ const exportTargets = (value, conditions) => {
|
|
|
420
442
|
}
|
|
421
443
|
if (typeof value !== "object")
|
|
422
444
|
return invalidExportTarget(value, "must be a relative string, object, array, or null");
|
|
445
|
+
for (const key of Object.keys(value)) {
|
|
446
|
+
const numeric = Number(key);
|
|
447
|
+
if (String(numeric) === key && numeric >= 0 && numeric < 0xffff_ffff)
|
|
448
|
+
return {
|
|
449
|
+
kind: "invalid-config",
|
|
450
|
+
limitation: `The package exports configuration contains numeric condition key ${JSON.stringify(key)}.`,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
423
453
|
for (const [condition, target] of Object.entries(value)) {
|
|
424
454
|
if (!conditions.has(condition))
|
|
425
455
|
continue;
|
|
@@ -433,11 +463,13 @@ const exportTargets = (value, conditions) => {
|
|
|
433
463
|
* Node selects an exports target by walking the declared keys in order and
|
|
434
464
|
* taking the first whose condition is active for the calling resolver.
|
|
435
465
|
* "default" is always active, and "node" plus "node-addons" are active for the
|
|
436
|
-
* built-in resolver that owns installed-package imports and requires.
|
|
466
|
+
* built-in resolver that owns installed-package imports and requires. The
|
|
467
|
+
* supported Node runtimes also activate "module-sync" for both loaders.
|
|
437
468
|
*/
|
|
438
469
|
const packageExportConditions = (moduleKind) => new Set([
|
|
439
470
|
"node",
|
|
440
471
|
"node-addons",
|
|
472
|
+
"module-sync",
|
|
441
473
|
...(moduleKind === undefined ? [] : [moduleKind]),
|
|
442
474
|
"default",
|
|
443
475
|
]);
|
|
@@ -21,7 +21,10 @@ export const reconstructJavaScriptArtifact = async (rawInput, signal, progress)
|
|
|
21
21
|
abortIfNeeded(signal);
|
|
22
22
|
const path = await resolveSelectedInput(input.input_path);
|
|
23
23
|
const format = await resolveFormat(path, input);
|
|
24
|
-
const snapshot = await scanCanonicalArtifactInventory(path, {
|
|
24
|
+
const snapshot = await scanCanonicalArtifactInventory(path, {
|
|
25
|
+
signal,
|
|
26
|
+
integrity: { mode: input.integrity_policy },
|
|
27
|
+
});
|
|
25
28
|
if (snapshot.manifest.root_format !== format)
|
|
26
29
|
throw new ArtifactReaderFailure("format", `Artifact inventory classified ${path} as ${snapshot.manifest.root_format}, not ${format}`);
|
|
27
30
|
const reader = createReader(path, format);
|
|
@@ -47,7 +50,7 @@ export const reconstructJavaScriptArtifact = async (rawInput, signal, progress)
|
|
|
47
50
|
await reportPhase("seal_javascript_application_graph", "Sealing the validated application graph");
|
|
48
51
|
const graph = await completeJavaScriptAnalysisSteps(applicationGraphSteps, signal);
|
|
49
52
|
await reportPhase("build_javascript_semantic_graph", "Binding and validating static semantic relationships");
|
|
50
|
-
const semanticGraphSteps = semanticProjection.finishImmutableSteps(snapshot.manifest.root_sha256, graph
|
|
53
|
+
const semanticGraphSteps = semanticProjection.finishImmutableSteps(snapshot.manifest.root_sha256, graph);
|
|
51
54
|
await reportPhase("seal_javascript_semantic_graph", "Validating and sealing the semantic graph");
|
|
52
55
|
const semanticGraph = await completeJavaScriptAnalysisSteps(semanticGraphSteps, signal);
|
|
53
56
|
await checkpointJavaScriptAnalysis(signal);
|
|
@@ -57,6 +60,7 @@ export const reconstructJavaScriptArtifact = async (rawInput, signal, progress)
|
|
|
57
60
|
root_artifact_sha256: snapshot.manifest.root_sha256,
|
|
58
61
|
inventory_manifest_id: snapshot.manifest.manifest_id,
|
|
59
62
|
inventory_graph_sha256: snapshot.manifest.graph_sha256,
|
|
63
|
+
integrity_contradictions: snapshot.integrity_contradictions,
|
|
60
64
|
graph,
|
|
61
65
|
semantic_graph: semanticGraph,
|
|
62
66
|
electron_summary: summarizeElectronBoundaries(analysis),
|
|
@@ -70,7 +74,6 @@ export const reconstructJavaScriptArtifact = async (rawInput, signal, progress)
|
|
|
70
74
|
findings: analysis.findings,
|
|
71
75
|
modules: analysis.modules,
|
|
72
76
|
parse_failures: analysis.parse_failures,
|
|
73
|
-
truncated_scopes: analysis.truncated_scopes,
|
|
74
77
|
},
|
|
75
78
|
limitations: analysis.limitations,
|
|
76
79
|
};
|
|
@@ -3,4 +3,5 @@ import { z } from "zod";
|
|
|
3
3
|
export const javascriptArtifactReconstructionInputSchema = z.strictObject({
|
|
4
4
|
input_path: z.string().min(1),
|
|
5
5
|
format: z.enum(["auto", "asar", "directory"]).default("auto"),
|
|
6
|
+
integrity_policy: z.enum(["fail", "record-and-continue"]).default("fail"),
|
|
6
7
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { compareUnicodeCodePoints } from "../../domain/unicodeCodePointOrder.js";
|
|
2
2
|
/** Parse one approved JSON module without evaluating JavaScript or resolving imports. */
|
|
3
3
|
export const analyzeJavaScriptJsonModule = (file) => {
|
|
4
4
|
if (!file.text.included)
|
|
@@ -26,7 +26,7 @@ export const analyzeJavaScriptJsonModule = (file) => {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
const keys = typeof value === "object" && value !== null && !Array.isArray(value)
|
|
29
|
-
? Object.keys(value).sort(
|
|
29
|
+
? Object.keys(value).sort(compareUnicodeCodePoints)
|
|
30
30
|
: [];
|
|
31
31
|
const retained = keys;
|
|
32
32
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { posix } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { compareUnicodeCodePoints } from "../../domain/unicodeCodePointOrder.js";
|
|
3
3
|
import { completeApplicationCoverage, partialApplicationCoverage, } from "../../domain/javascript/javascriptApplicationEvidenceSchemas.js";
|
|
4
|
-
import { semanticCoverageResourceLimits } from "../../domain/javascript/javascriptSemanticCoverage.js";
|
|
5
|
-
import {
|
|
4
|
+
import { semanticCoverageResourceLimits, semanticResourceLimitCoverage, } from "../../domain/javascript/javascriptSemanticCoverage.js";
|
|
5
|
+
import { semanticResourceLimitReason } from "../../domain/javascript/javascriptSemanticResourceLimits.js";
|
|
6
6
|
import { addAstContainsEdge, artifactLocalIdentity, } from "./JavaScriptArtifactGraphContext.js";
|
|
7
7
|
import { astObservationEvidence, staticInferenceEvidence, } from "./JavaScriptArtifactGraphEvidence.js";
|
|
8
8
|
import { resolveArtifactPathByContext, } from "./JavaScriptArtifactPathResolution.js";
|
|
@@ -17,7 +17,7 @@ export const addJavaScriptSourceModules = (context) => {
|
|
|
17
17
|
continue;
|
|
18
18
|
const exports = semantic.ir.moduleLinks
|
|
19
19
|
.flatMap(({ exportedName }) => exportedName === null ? [] : [exportedName])
|
|
20
|
-
.sort(
|
|
20
|
+
.sort(compareUnicodeCodePoints);
|
|
21
21
|
const retainedExports = [...new Set(exports)];
|
|
22
22
|
const source = context.accumulator.addNode({
|
|
23
23
|
kind: "javascript-module",
|
|
@@ -264,19 +264,7 @@ const semanticCoverage = (semantic) => {
|
|
|
264
264
|
const resourceLimits = semanticCoverageResourceLimits(semantic.ir.coverage);
|
|
265
265
|
if (semantic.ir.coverage.status === "complete" && resourceLimits.length === 0)
|
|
266
266
|
return completeApplicationCoverage();
|
|
267
|
-
return partialApplicationCoverage(resourceLimits.
|
|
268
|
-
name: `javascript_semantic_${resourceLimit.replaceAll("-", "_")}`,
|
|
269
|
-
value: resourceLimit === "primitive-candidates"
|
|
270
|
-
? SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT
|
|
271
|
-
: resourceLimit === "primitive-bytes"
|
|
272
|
-
? SEMANTIC_PRIMITIVE_JSON_BYTES_LIMIT
|
|
273
|
-
: SEMANTIC_EXPRESSION_DEPTH_LIMIT,
|
|
274
|
-
unit: resourceLimit === "expression-depth"
|
|
275
|
-
? "depth"
|
|
276
|
-
: resourceLimit === "primitive-bytes"
|
|
277
|
-
? "bytes"
|
|
278
|
-
: "items",
|
|
279
|
-
})), semantic.ir.coverage.omittedCount);
|
|
267
|
+
return partialApplicationCoverage(semanticResourceLimitCoverage(resourceLimits), semantic.ir.coverage.omittedCount);
|
|
280
268
|
};
|
|
281
269
|
const moduleFormat = (path, ir) => {
|
|
282
270
|
const extension = posix.extname(path).toLowerCase();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { AnalysisProtocolError } from "../../domain/analysisErrorCore.js";
|
|
4
4
|
import {} from "../../domain/analysisErrorBase.js";
|
|
5
5
|
import { analysisInputErrorFromIssues } from "../../domain/inputIssueProjection.js";
|
|
6
|
-
import { reconcileJavaScriptRuntime } from "../../domain/javascript/javascriptRuntimeReconciliation.js";
|
|
6
|
+
import { parseRuntimeReconciliationInput, reconcileJavaScriptRuntime, } from "../../domain/javascript/javascriptRuntimeReconciliation.js";
|
|
7
7
|
import { reconcileJavaScriptRuntimeInputSchema } from "../../domain/javascript/javascriptRuntimeReconciliationSchemas.js";
|
|
8
8
|
import { err, ok } from "../../domain/result.js";
|
|
9
9
|
import { createJavaScriptRuntimeReconciliationEvidence } from "./JavaScriptRuntimeReconciliationEvidence.js";
|
|
@@ -17,19 +17,20 @@ export const reconcileJavaScriptRuntimeEvidence = (rawInput) => {
|
|
|
17
17
|
};
|
|
18
18
|
/** Reconcile input already parsed by a trusted adapter boundary. */
|
|
19
19
|
export const reconcileJavaScriptRuntimeEvidenceValidated = (parsedInput) => {
|
|
20
|
+
let parsed;
|
|
20
21
|
try {
|
|
21
|
-
|
|
22
|
-
const result = reconcileJavaScriptRuntime(input);
|
|
23
|
-
return ok(createJavaScriptRuntimeReconciliationEvidence(input, result));
|
|
22
|
+
parsed = parseRuntimeReconciliationInput(normalizeRuntimeMappingRoots(parsedInput));
|
|
24
23
|
}
|
|
25
24
|
catch (cause) {
|
|
26
25
|
if (cause instanceof z.ZodError)
|
|
27
26
|
return err(analysisInputErrorFromIssues(OPERATION, cause.issues, parsedInput));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
return err(new AnalysisProtocolError("JavaScript runtime reconciliation input parsing failed", { cause }));
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const result = reconcileJavaScriptRuntime(parsed);
|
|
31
|
+
return ok(createJavaScriptRuntimeReconciliationEvidence(parsed.input, result));
|
|
32
|
+
}
|
|
33
|
+
catch (cause) {
|
|
33
34
|
return err(new AnalysisProtocolError("JavaScript runtime reconciliation produced an invalid result", { cause }));
|
|
34
35
|
}
|
|
35
36
|
};
|
|
@@ -50,20 +51,3 @@ const normalizeRuntimeMappingRoots = (input) => ({
|
|
|
50
51
|
const isPortableAbsolutePath = (path) => path.startsWith("/") ||
|
|
51
52
|
/^[a-z]:[\\/]/iu.test(path) ||
|
|
52
53
|
/^(?:\\\\|\/\/)[^\\/]+[\\/][^\\/]+(?:[\\/]|$)/u.test(path);
|
|
53
|
-
const SAFE_RECONCILIATION_INPUT_CONSTRAINTS = new Set([
|
|
54
|
-
"Evidence semantic identifier does not match its record",
|
|
55
|
-
"JavaScript application Evidence subject disagrees with its result",
|
|
56
|
-
"Runtime reconciliation requires inspect_web_page, inspect_electron_page, observe_javascript_runtime, or capture_electron_scenario Evidence",
|
|
57
|
-
"Runtime Evidence target or declared role disagrees with its result",
|
|
58
|
-
"Runtime Evidence contains an invalid builtin location",
|
|
59
|
-
"Runtime Evidence target disagrees with its captured result",
|
|
60
|
-
"Browser Evidence target is outside its recorded origin scope",
|
|
61
|
-
"Runtime Evidence contains source without source-capture selection",
|
|
62
|
-
"Active Electron Evidence application path disagrees with its configured root",
|
|
63
|
-
...[
|
|
64
|
-
"inspect_web_page",
|
|
65
|
-
"inspect_electron_page",
|
|
66
|
-
"observe_javascript_runtime",
|
|
67
|
-
"capture_electron_scenario",
|
|
68
|
-
].map((operation) => `Evidence does not match the supported ${operation} contract`),
|
|
69
|
-
]);
|
|
@@ -84,7 +84,7 @@ const addEventUnknown = (context, operation, event, relation) => {
|
|
|
84
84
|
: `Static ${operation.method} emitter identity is partial.`,
|
|
85
85
|
candidate_node_ids: [],
|
|
86
86
|
evidence: unknownSemanticEvidence(context.file, operation.location),
|
|
87
|
-
}));
|
|
87
|
+
}, context.state.evidenceContexts));
|
|
88
88
|
};
|
|
89
89
|
/** Project Node timer scheduling and exact local handle cancellation. */
|
|
90
90
|
export const projectSemanticTimers = (context) => {
|
|
@@ -153,5 +153,5 @@ const projectTimerCancellation = (context, operation, timerNodes) => {
|
|
|
153
153
|
detail: `Static ${operation.method} handle resolution was ${operation.resolution}.`,
|
|
154
154
|
candidate_node_ids: [],
|
|
155
155
|
evidence: unknownSemanticEvidence(context.file, operation.location),
|
|
156
|
-
}));
|
|
156
|
+
}, context.state.evidenceContexts));
|
|
157
157
|
};
|
|
@@ -45,7 +45,7 @@ export const buildJavaScriptSemanticGraph = ({ rootArtifactSha256, applicationGr
|
|
|
45
45
|
if (analyzed.semantic !== null)
|
|
46
46
|
projection.projectFile(analyzed.file, analyzed.semantic.ir);
|
|
47
47
|
}
|
|
48
|
-
return projection.finish(rootArtifactSha256, applicationGraph
|
|
48
|
+
return projection.finish(rootArtifactSha256, applicationGraph);
|
|
49
49
|
};
|
|
50
50
|
/** Accumulate semantic nodes while each source IR is still file-local. */
|
|
51
51
|
export const createJavaScriptSemanticGraphProjection = () => {
|
|
@@ -68,7 +68,7 @@ export const createJavaScriptSemanticGraphProjection = () => {
|
|
|
68
68
|
truncatedFiles += 1;
|
|
69
69
|
state.fileNodeBudget = null;
|
|
70
70
|
};
|
|
71
|
-
const finishWith = (factory, rootArtifactSha256, applicationGraph
|
|
71
|
+
const finishWith = (factory, rootArtifactSha256, applicationGraph) => {
|
|
72
72
|
bindSemanticGraphApplicationNodes(state, applicationGraph);
|
|
73
73
|
if (state.roots.size === 0)
|
|
74
74
|
addFallbackRoot(rootArtifactSha256, state);
|
|
@@ -78,6 +78,7 @@ export const createJavaScriptSemanticGraphProjection = () => {
|
|
|
78
78
|
root_artifact_sha256: rootArtifactSha256,
|
|
79
79
|
application_graph_id: applicationGraph.graph_id,
|
|
80
80
|
root_node_ids: [...state.roots],
|
|
81
|
+
evidence_contexts: state.evidenceContexts.contexts,
|
|
81
82
|
nodes: [...state.nodes.values()],
|
|
82
83
|
relations: [...state.relations.values()],
|
|
83
84
|
fingerprints,
|
|
@@ -98,7 +99,7 @@ export const createJavaScriptSemanticGraphProjection = () => {
|
|
|
98
99
|
: [],
|
|
99
100
|
families: JAVASCRIPT_SEMANTIC_RELATION_FAMILIES.map((family) => ({
|
|
100
101
|
family,
|
|
101
|
-
status: semanticFamilyStatus(family
|
|
102
|
+
status: semanticFamilyStatus(family),
|
|
102
103
|
retained_relations: [...state.relations.values()].filter((relation) => JAVASCRIPT_SEMANTIC_RELATION_FAMILY[relation.relation] ===
|
|
103
104
|
family).length,
|
|
104
105
|
omitted_relations: truncatedFiles > 0 ? null : 0,
|
|
@@ -125,13 +126,14 @@ export const createJavaScriptSemanticGraphProjection = () => {
|
|
|
125
126
|
state.relations.clear();
|
|
126
127
|
state.unknowns.clear();
|
|
127
128
|
state.roots.clear();
|
|
129
|
+
state.evidenceContexts.clear();
|
|
128
130
|
fingerprints.length = 0;
|
|
129
131
|
return graph;
|
|
130
132
|
};
|
|
131
133
|
return {
|
|
132
134
|
projectFile: projectSource,
|
|
133
|
-
finish: (rootArtifactSha256, applicationGraph
|
|
134
|
-
finishImmutableSteps: (rootArtifactSha256, applicationGraph
|
|
135
|
+
finish: (rootArtifactSha256, applicationGraph) => finishWith(createJavaScriptSemanticGraph, rootArtifactSha256, applicationGraph),
|
|
136
|
+
finishImmutableSteps: (rootArtifactSha256, applicationGraph) => finishWith(createImmutableJavaScriptSemanticGraphSteps, rootArtifactSha256, applicationGraph),
|
|
135
137
|
};
|
|
136
138
|
};
|
|
137
139
|
const projectFile = (file, ir, state) => {
|
|
@@ -209,7 +211,7 @@ const projectFile = (file, ir, state) => {
|
|
|
209
211
|
projectSemanticResources(context);
|
|
210
212
|
projectSemanticClosureCaptures(context);
|
|
211
213
|
projectSemanticFrontiers(context);
|
|
212
|
-
return projectSemanticFunctionFingerprints(file, ir, callableNodes);
|
|
214
|
+
return projectSemanticFunctionFingerprints(file, ir, callableNodes, state.evidenceContexts);
|
|
213
215
|
};
|
|
214
216
|
const createReturnSiteNodes = (file, ir, callables, state) => {
|
|
215
217
|
const result = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { javascriptDisplayText } from "../../domain/javascript/javascriptAstValues.js";
|
|
2
|
-
import { createJavaScriptSemanticGraphNode, createJavaScriptSemanticGraphRelation, javaScriptSemanticNodeId, } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
|
+
import { createJavaScriptSemanticGraphNode, createJavaScriptSemanticGraphRelation, JavaScriptSemanticEvidenceContextRegistry, javaScriptSemanticNodeId, } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
3
3
|
import { inferredSemanticEvidence, observedSemanticEvidence, unavailableSemanticRootEvidence, } from "./JavaScriptSemanticGraphEvidence.js";
|
|
4
4
|
/** Create empty projection state with structural application-node mappings. */
|
|
5
5
|
export const createSemanticGraphProjectionState = (applicationGraph) => {
|
|
@@ -8,6 +8,7 @@ export const createSemanticGraphProjectionState = (applicationGraph) => {
|
|
|
8
8
|
nodes: new Map(),
|
|
9
9
|
relations: new Map(),
|
|
10
10
|
unknowns: new Map(),
|
|
11
|
+
evidenceContexts: new JavaScriptSemanticEvidenceContextRegistry(),
|
|
11
12
|
roots: new Set(),
|
|
12
13
|
applicationNodeIdsByLocation: index.identifiers,
|
|
13
14
|
};
|
|
@@ -38,7 +39,7 @@ export const constructSemanticGraphNode = (file, input, state) => createJavaScri
|
|
|
38
39
|
label: input.label === null ? null : javascriptDisplayText(input.label),
|
|
39
40
|
properties: input.properties ?? {},
|
|
40
41
|
evidence: observedSemanticEvidence(file, input.location),
|
|
41
|
-
});
|
|
42
|
+
}, state.evidenceContexts);
|
|
42
43
|
/** Reuse retained identities and reject exhausted budgets before allocation. */
|
|
43
44
|
export const retainSemanticGraphNode = (state, file, input) => {
|
|
44
45
|
const identifier = javaScriptSemanticNodeId({
|
|
@@ -89,8 +90,9 @@ export const addSemanticGraphRelation = (state, input) => {
|
|
|
89
90
|
relation: input.relation,
|
|
90
91
|
resolution: input.resolution ?? "candidate",
|
|
91
92
|
properties: input.properties ?? {},
|
|
92
|
-
evidence: input.evidence ??
|
|
93
|
-
|
|
93
|
+
evidence: input.evidence ??
|
|
94
|
+
inferredSemanticEvidence(state.evidenceContexts.resolve(input.source.evidence)),
|
|
95
|
+
}, state.evidenceContexts);
|
|
94
96
|
if (state.relations.has(value.relation_id))
|
|
95
97
|
return;
|
|
96
98
|
state.relations.set(value.relation_id, value);
|
|
@@ -116,7 +118,7 @@ export const addSemanticFallbackRoot = (rootArtifactSha256, state) => {
|
|
|
116
118
|
label: "unavailable semantic root",
|
|
117
119
|
properties: {},
|
|
118
120
|
evidence: unavailableSemanticRootEvidence(rootArtifactSha256),
|
|
119
|
-
}));
|
|
121
|
+
}, state.evidenceContexts));
|
|
120
122
|
if (node !== null)
|
|
121
123
|
state.roots.add(node.node_id);
|
|
122
124
|
};
|
|
@@ -32,7 +32,7 @@ export const observedSemanticEvidence = (file, location) => ({
|
|
|
32
32
|
});
|
|
33
33
|
/** Conservative static relationship evidence derived from one syntax node. */
|
|
34
34
|
export const inferredSemanticEvidence = (source) => ({
|
|
35
|
-
...source
|
|
35
|
+
...source,
|
|
36
36
|
authority: "static-relationship-inference",
|
|
37
37
|
state: "inferred",
|
|
38
38
|
confidence: "high",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createJavaScriptSemanticFingerprint, } from "../../domain/javascript/javascriptSemanticGraph.js";
|
|
2
2
|
import { observedSemanticEvidence } from "./JavaScriptSemanticGraphEvidence.js";
|
|
3
3
|
/** Bind domain fingerprint components to exact semantic function nodes. */
|
|
4
|
-
export const projectSemanticFunctionFingerprints = (file, ir, callableNodes) => ir.functionFingerprints.flatMap((fingerprint) => {
|
|
4
|
+
export const projectSemanticFunctionFingerprints = (file, ir, callableNodes, evidenceContexts) => ir.functionFingerprints.flatMap((fingerprint) => {
|
|
5
5
|
const callable = callableNodes.get(fingerprint.callableId);
|
|
6
6
|
if (callable === undefined)
|
|
7
7
|
return [];
|
|
@@ -20,6 +20,6 @@ export const projectSemanticFunctionFingerprints = (file, ir, callableNodes) =>
|
|
|
20
20
|
},
|
|
21
21
|
limitations: fingerprint.limitations,
|
|
22
22
|
evidence: observedSemanticEvidence(file, callable.identity.source_range),
|
|
23
|
-
}),
|
|
23
|
+
}, evidenceContexts),
|
|
24
24
|
];
|
|
25
25
|
});
|
|
@@ -119,7 +119,7 @@ const addPromiseUnknown = (context, operation, promise, promiseNodes) => {
|
|
|
119
119
|
return candidate === undefined ? [] : [candidate.node_id];
|
|
120
120
|
}),
|
|
121
121
|
evidence: unknownSemanticEvidence(context.file, operation.location),
|
|
122
|
-
}));
|
|
122
|
+
}, context.state.evidenceContexts));
|
|
123
123
|
};
|
|
124
124
|
/** Link direct return expressions to their retained semantic references. */
|
|
125
125
|
export const projectSemanticReturnValues = (context) => {
|
|
@@ -175,7 +175,7 @@ export const projectSemanticFrontiers = (context) => {
|
|
|
175
175
|
detail: frontier.reason,
|
|
176
176
|
candidate_node_ids: [],
|
|
177
177
|
evidence: unknownSemanticEvidence(context.file, frontier.location),
|
|
178
|
-
});
|
|
178
|
+
}, context.state.evidenceContexts);
|
|
179
179
|
addSemanticGraphUnknown(context.state, unknown);
|
|
180
180
|
}
|
|
181
181
|
};
|
|
@@ -106,5 +106,5 @@ const addObjectUnknown = (context, operation, node, target) => {
|
|
|
106
106
|
detail: `Static ${operation.kind} property ${operation.propertyPath === null ? "path is unresolved" : semanticPropertyPointer(operation.propertyPath)} has ${target.presence} presence; its receiver is ${target.receiverResolved ? "a retained container" : "unresolved or not a retained container"}; object identity is ${operation.resolution}.`,
|
|
107
107
|
candidate_node_ids: [],
|
|
108
108
|
evidence: unknownSemanticEvidence(context.file, operation.location),
|
|
109
|
-
}));
|
|
109
|
+
}, context.state.evidenceContexts));
|
|
110
110
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { compareUnicodeCodePoints } from "../../domain/unicodeCodePointOrder.js";
|
|
2
2
|
import { JAVASCRIPT_SEMANTIC_RELATION_FAMILIES } from "../../domain/javascript/javascriptSemanticGraphSchemas.js";
|
|
3
3
|
/** Index one immutable file IR; read retained callable membership at query time. */
|
|
4
4
|
export const createSemanticCallableOwnerLookup = (ir, nodes) => {
|
|
@@ -29,7 +29,7 @@ export const createSemanticCallableOwnerLookup = (ir, nodes) => {
|
|
|
29
29
|
const node = nodes.get(candidate.callableId);
|
|
30
30
|
const rank = best === undefined
|
|
31
31
|
? 1
|
|
32
|
-
:
|
|
32
|
+
: compareUnicodeCodePoints(candidate.priority, best.priority) ||
|
|
33
33
|
best.order - candidate.order;
|
|
34
34
|
if (node !== undefined && rank > 0) {
|
|
35
35
|
best = candidate;
|
|
@@ -120,7 +120,7 @@ export const createSemanticCallSiteLookup = (ir, nodes) => {
|
|
|
120
120
|
};
|
|
121
121
|
const rangeKey = (range) => `${range.start.line}:${range.start.column}-${range.end.line}:${range.end.column}`;
|
|
122
122
|
/** Report extractor support without treating missing families as absence. */
|
|
123
|
-
export const semanticFamilyStatus = (family
|
|
123
|
+
export const semanticFamilyStatus = (family) => {
|
|
124
124
|
if (![
|
|
125
125
|
"call-flow",
|
|
126
126
|
"boundary",
|
|
@@ -136,7 +136,7 @@ export const semanticFamilyStatus = (family, analysis) => {
|
|
|
136
136
|
"timer",
|
|
137
137
|
].includes(family))
|
|
138
138
|
return "unsupported";
|
|
139
|
-
return
|
|
139
|
+
return "partial";
|
|
140
140
|
};
|
|
141
141
|
const contains = (outer, inner) => pointCompare(outer.start, inner.start) <= 0 &&
|
|
142
142
|
pointCompare(outer.end, inner.end) >= 0;
|
|
@@ -54,5 +54,5 @@ const projectRelease = (context, operation, resourceNodes) => {
|
|
|
54
54
|
detail: `Static ${operation.method} resource ownership is ambiguous.`,
|
|
55
55
|
candidate_node_ids: resources.map(({ node_id: identifier }) => identifier),
|
|
56
56
|
evidence: unknownSemanticEvidence(context.file, operation.location),
|
|
57
|
-
}));
|
|
57
|
+
}, context.state.evidenceContexts));
|
|
58
58
|
};
|
|
@@ -72,17 +72,20 @@ const projectValue = (input) => {
|
|
|
72
72
|
detail: `Initializer container has unknown ${value.status === "object" ? "properties" : "items"}${container.coverage.omitted === null ? " with an unknown omitted count" : `; ${container.coverage.omitted} omitted`}.`,
|
|
73
73
|
candidate_node_ids: [target.node_id],
|
|
74
74
|
evidence: unknownSemanticEvidence(context.file, binding.definitions[0]?.location ?? null),
|
|
75
|
-
}));
|
|
75
|
+
}, context.state.evidenceContexts));
|
|
76
76
|
}
|
|
77
|
-
else if (value.status === "unknown"
|
|
77
|
+
else if (value.status === "unknown" ||
|
|
78
|
+
value.status === "ambiguous" ||
|
|
79
|
+
value.status === "cycle") {
|
|
78
80
|
const location = binding.definitions[0]?.location ?? null;
|
|
79
81
|
const evidence = observedSemanticEvidence(context.file, location);
|
|
80
|
-
const isPropertyValue = role.startsWith("property:");
|
|
81
82
|
addSemanticGraphUnknown(context.state, createJavaScriptSemanticGraphUnknown({
|
|
82
83
|
node_id: target.node_id,
|
|
83
|
-
family:
|
|
84
|
-
relation_kinds: [
|
|
85
|
-
reason:
|
|
84
|
+
family: "data-flow",
|
|
85
|
+
relation_kinds: ["defines"],
|
|
86
|
+
reason: value.resourceLimit === undefined
|
|
87
|
+
? "unknown-value"
|
|
88
|
+
: "resource-limit",
|
|
86
89
|
detail: `${value.reason} Unknown value at ${role}.`,
|
|
87
90
|
candidate_node_ids: [target.node_id],
|
|
88
91
|
evidence: {
|
|
@@ -92,7 +95,7 @@ const projectValue = (input) => {
|
|
|
92
95
|
confidence: "unknown",
|
|
93
96
|
limitations: [value.reason],
|
|
94
97
|
},
|
|
95
|
-
}));
|
|
98
|
+
}, context.state.evidenceContexts));
|
|
96
99
|
}
|
|
97
100
|
};
|
|
98
101
|
const addLiteralNode = (context, binding, value, role) => retainSemanticGraphNode(context.state, context.file, {
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AnalysisInputError, AnalysisProtocolError, } from "../../domain/analysisErrorCore.js";
|
|
3
3
|
import {} from "../../domain/analysisErrorBase.js";
|
|
4
|
+
import { applicationGraphEvidenceInputError, parseApplicationGraphEvidence, } from "./JavaScriptApplicationEvidenceGraph.js";
|
|
4
5
|
import { jsonValueSchema } from "../../domain/jsonValue.js";
|
|
5
6
|
import { queryJavaScriptSemanticGraph } from "../../domain/javascript/javascriptSemanticQuery.js";
|
|
6
7
|
import { javaScriptSemanticTraceResultSchema, traceJavaScriptSemanticsInputSchema, } from "../../domain/javascript/javascriptSemanticTraceSchemas.js";
|
|
7
8
|
import { err, ok } from "../../domain/result.js";
|
|
8
|
-
import { parseApplicationGraphEvidence } from "./JavaScriptApplicationEvidenceGraph.js";
|
|
9
9
|
import { createJavaScriptSemanticTraceEvidence } from "./JavaScriptApplicationWorkflowEvidence.js";
|
|
10
10
|
const OPERATION = "trace_javascript_semantics";
|
|
11
11
|
/** Trace semantic relations from input already parsed by a trusted adapter. */
|
|
12
12
|
export const traceJavaScriptSemanticsEvidenceValidated = (input) => {
|
|
13
|
+
const sourceResult = parseApplicationGraphEvidence(input.application, [
|
|
14
|
+
"application",
|
|
15
|
+
]);
|
|
16
|
+
if (!sourceResult.ok)
|
|
17
|
+
return err(applicationGraphEvidenceInputError(OPERATION, sourceResult.error));
|
|
18
|
+
const source = sourceResult.value;
|
|
19
|
+
if (source.semanticGraph === null)
|
|
20
|
+
return err(new AnalysisInputError(OPERATION, undefined, [
|
|
21
|
+
{
|
|
22
|
+
path: ["application"],
|
|
23
|
+
reason: "invalid_value",
|
|
24
|
+
expected: "inline Evidence from analyze_javascript_application with a semantic graph",
|
|
25
|
+
},
|
|
26
|
+
]));
|
|
13
27
|
try {
|
|
14
|
-
const source = parseApplicationGraphEvidence(input.application);
|
|
15
|
-
if (source.semanticGraph === null)
|
|
16
|
-
return err(new AnalysisInputError(OPERATION, undefined, [
|
|
17
|
-
{
|
|
18
|
-
path: ["application"],
|
|
19
|
-
reason: "invalid_value",
|
|
20
|
-
expected: "inline Evidence from analyze_javascript_application with a semantic graph",
|
|
21
|
-
},
|
|
22
|
-
]));
|
|
23
28
|
const query = queryJavaScriptSemanticGraph(source.semanticGraph, input.query);
|
|
24
29
|
const result = javaScriptSemanticTraceResultSchema.parse({
|
|
25
30
|
...query,
|
|
@@ -3,16 +3,14 @@ import { parseRelatedAddresses, referenceKindSchema, } from "../../domain/hopper
|
|
|
3
3
|
import { err, ok } from "../../domain/result.js";
|
|
4
4
|
import { AnalysisOutputError } from "../../domain/analysisErrorCore.js";
|
|
5
5
|
const referencesSchema = z.object({
|
|
6
|
-
reference_kinds_available: z.boolean()
|
|
6
|
+
reference_kinds_available: z.boolean(),
|
|
7
7
|
references: z.array(z.object({
|
|
8
8
|
source_address: z.string(),
|
|
9
9
|
target_address: z.string(),
|
|
10
10
|
target_procedure: z.object({ address: z.string() }).nullable(),
|
|
11
11
|
kind: referenceKindSchema,
|
|
12
12
|
})),
|
|
13
|
-
unresolved_calls: z
|
|
14
|
-
.array(z.object({ address: z.string(), reason: z.string() }))
|
|
15
|
-
.default([]),
|
|
13
|
+
unresolved_calls: z.array(z.object({ address: z.string(), reason: z.string() })),
|
|
16
14
|
});
|
|
17
15
|
/** Prefer typed static call references, preserving computed targets and targetless sites. */
|
|
18
16
|
export const readNativeCallRoutes = async (analysis, procedure, signal) => {
|