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
|
@@ -166,6 +166,7 @@ const createState = (program) => {
|
|
|
166
166
|
bindings: new Map(),
|
|
167
167
|
};
|
|
168
168
|
return {
|
|
169
|
+
parentsByNode: new WeakMap(),
|
|
169
170
|
scopes: [root],
|
|
170
171
|
scopesById: new Map([[root.scopeId, root]]),
|
|
171
172
|
scopeByNode: new WeakMap([[program, root]]),
|
|
@@ -173,6 +174,8 @@ const createState = (program) => {
|
|
|
173
174
|
callables: [],
|
|
174
175
|
callableNodesById: new Map(),
|
|
175
176
|
moduleLinks: [],
|
|
177
|
+
moduleLinkBindings: new WeakMap(),
|
|
178
|
+
conditionalInitializers: new WeakSet(),
|
|
176
179
|
};
|
|
177
180
|
};
|
|
178
181
|
const collectDefinitions = (program, state) => {
|
|
@@ -180,9 +183,25 @@ const collectDefinitions = (program, state) => {
|
|
|
180
183
|
currentSemanticScope(state.scopes),
|
|
181
184
|
];
|
|
182
185
|
const openedScopes = new WeakMap();
|
|
186
|
+
const assignments = [];
|
|
187
|
+
const functionBodies = [];
|
|
183
188
|
traverseJavaScriptAst(program, {
|
|
184
|
-
enter: (node, parent) => {
|
|
189
|
+
enter: (node, parent, readAncestors) => {
|
|
185
190
|
let parentScope = currentSemanticScope(stack);
|
|
191
|
+
if (parent !== null &&
|
|
192
|
+
(t.isObjectMethod(parent) || t.isClassMethod(parent)) &&
|
|
193
|
+
parent.computed &&
|
|
194
|
+
parent.key === node &&
|
|
195
|
+
parentScope.parentScopeId !== null) {
|
|
196
|
+
// A computed method key is evaluated before entering the method's
|
|
197
|
+
// parameter and body environments.
|
|
198
|
+
const keyScope = state.scopesById.get(parentScope.parentScopeId);
|
|
199
|
+
if (keyScope !== undefined) {
|
|
200
|
+
stack.push(keyScope);
|
|
201
|
+
openedScopes.set(node, 1);
|
|
202
|
+
parentScope = keyScope;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
186
205
|
if (parent !== null &&
|
|
187
206
|
t.isWithStatement(parent) &&
|
|
188
207
|
parent.body === node) {
|
|
@@ -205,6 +224,12 @@ const collectDefinitions = (program, state) => {
|
|
|
205
224
|
if (nested !== undefined) {
|
|
206
225
|
stack.push(nested);
|
|
207
226
|
openedScopes.set(node, (openedScopes.get(node) ?? 0) + 1);
|
|
227
|
+
if (t.isBlockStatement(node) && t.isFunction(parent))
|
|
228
|
+
functionBodies.push({
|
|
229
|
+
body: node,
|
|
230
|
+
scope: nested,
|
|
231
|
+
parameters: parent.params,
|
|
232
|
+
});
|
|
208
233
|
}
|
|
209
234
|
const scope = currentSemanticScope(stack);
|
|
210
235
|
state.scopeByNode.set(node, scope);
|
|
@@ -216,12 +241,73 @@ const collectDefinitions = (program, state) => {
|
|
|
216
241
|
state,
|
|
217
242
|
});
|
|
218
243
|
bindInnerDeclaration(node, parent, scope, state);
|
|
244
|
+
if (t.isVariableDeclarator(node) &&
|
|
245
|
+
node.init != null &&
|
|
246
|
+
parent !== null &&
|
|
247
|
+
t.isVariableDeclaration(parent, { kind: "var" }) &&
|
|
248
|
+
hasConditionalInitializer(readAncestors()))
|
|
249
|
+
state.conditionalInitializers.add(node.init);
|
|
250
|
+
if (t.isAssignmentExpression(node) ||
|
|
251
|
+
t.isUpdateExpression(node) ||
|
|
252
|
+
t.isForOfStatement(node) ||
|
|
253
|
+
t.isForInStatement(node))
|
|
254
|
+
assignments.push({ node, scope });
|
|
219
255
|
},
|
|
220
256
|
exit: (node) => {
|
|
221
257
|
for (let count = openedScopes.get(node) ?? 0; count > 0; count--)
|
|
222
258
|
stack.pop();
|
|
223
259
|
},
|
|
224
260
|
});
|
|
261
|
+
// All declarations must exist before resolving writes, including hoisted
|
|
262
|
+
// functions and local declarations that shadow an outer binding.
|
|
263
|
+
for (const { node, scope } of assignments)
|
|
264
|
+
bindAssignment(node, scope, state);
|
|
265
|
+
for (const { body, scope, parameters } of functionBodies)
|
|
266
|
+
for (const parameter of parameters)
|
|
267
|
+
for (const identifier of assignedPatternIdentifiers(t.isTSParameterProperty(parameter) ? parameter.parameter : parameter))
|
|
268
|
+
copyParameterToBody({ identifier, body, scope, state });
|
|
269
|
+
};
|
|
270
|
+
const copyParameterToBody = (input) => {
|
|
271
|
+
const { identifier, body, scope, state } = input;
|
|
272
|
+
const binding = scope.bindings.get(identifier.name);
|
|
273
|
+
if (binding === undefined ||
|
|
274
|
+
binding.kind !== "variable" ||
|
|
275
|
+
binding.definitions.some(({ kind }) => kind === "function"))
|
|
276
|
+
return;
|
|
277
|
+
// A separate body var environment starts with the parameter's value. The
|
|
278
|
+
// real parameter identifier retains its scope and source location; entryBody
|
|
279
|
+
// records when the copy occurs without inventing an expression in the AST.
|
|
280
|
+
binding.initializers.unshift({
|
|
281
|
+
node: identifier,
|
|
282
|
+
projection: [],
|
|
283
|
+
entryBody: body,
|
|
284
|
+
});
|
|
285
|
+
for (let index = binding.initializers.length - 1; index >= 0; index -= 1) {
|
|
286
|
+
const initializer = binding.initializers[index];
|
|
287
|
+
if (initializer !== undefined &&
|
|
288
|
+
initializer.entryBody === undefined &&
|
|
289
|
+
initializer.projection.length === 0 &&
|
|
290
|
+
t.isIdentifier(initializer.node) &&
|
|
291
|
+
resolveSemanticBindingState(state, initializer.node, initializer.node.name) === binding)
|
|
292
|
+
// Direct self-initialization preserves the prior value, including any
|
|
293
|
+
// actual overwrite before it. Keep the source definition/reference facts.
|
|
294
|
+
binding.initializers.splice(index, 1);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
const hasConditionalInitializer = (ancestors) => {
|
|
298
|
+
// A hoisted var can remain undefined when control flow skips its initializer.
|
|
299
|
+
// Conditions outside the owning callable/static block do not govern its body.
|
|
300
|
+
for (let index = ancestors.length - 1; index >= 0; index -= 1) {
|
|
301
|
+
const node = ancestors[index];
|
|
302
|
+
if (t.isFunction(node) || t.isProgram(node) || t.isStaticBlock(node))
|
|
303
|
+
return false;
|
|
304
|
+
if (t.isIfStatement(node) ||
|
|
305
|
+
t.isLoop(node) ||
|
|
306
|
+
t.isSwitchCase(node) ||
|
|
307
|
+
t.isTryStatement(node))
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
return false;
|
|
225
311
|
};
|
|
226
312
|
const bindOuterDeclaration = (node, scope, state) => {
|
|
227
313
|
if (t.isFunctionDeclaration(node) && t.isIdentifier(node.id))
|
|
@@ -279,7 +365,9 @@ const bindInnerDeclaration = (node, parent, scope, state) => {
|
|
|
279
365
|
mutable: true,
|
|
280
366
|
kind: "catch",
|
|
281
367
|
});
|
|
282
|
-
|
|
368
|
+
};
|
|
369
|
+
const bindAssignment = (node, scope, state) => {
|
|
370
|
+
if (t.isAssignmentExpression(node)) {
|
|
283
371
|
if (t.isIdentifier(node.left))
|
|
284
372
|
addAssignment(node.left, node.operator === "=" ||
|
|
285
373
|
node.operator === "||=" ||
|
|
@@ -293,8 +381,11 @@ const bindInnerDeclaration = (node, parent, scope, state) => {
|
|
|
293
381
|
else if (t.isUpdateExpression(node) && t.isIdentifier(node.argument))
|
|
294
382
|
addAssignment(node.argument, node, scope, state);
|
|
295
383
|
else if (t.isForOfStatement(node) || t.isForInStatement(node))
|
|
296
|
-
for (const
|
|
297
|
-
|
|
384
|
+
for (const pattern of t.isVariableDeclaration(node.left)
|
|
385
|
+
? node.left.declarations.map(({ id }) => id)
|
|
386
|
+
: [node.left])
|
|
387
|
+
for (const identifier of assignedPatternIdentifiers(pattern))
|
|
388
|
+
addAssignment(identifier, node, scope, state);
|
|
298
389
|
};
|
|
299
390
|
const assignedPatternIdentifiers = (pattern) => {
|
|
300
391
|
const identifiers = [];
|
|
@@ -392,10 +483,47 @@ const scopeKind = (node, parent) => {
|
|
|
392
483
|
if (t.isStaticBlock(node))
|
|
393
484
|
return "static-block";
|
|
394
485
|
if (t.isBlockStatement(node) &&
|
|
395
|
-
|
|
486
|
+
parent !== null &&
|
|
487
|
+
t.isFunction(parent) &&
|
|
488
|
+
parent.body === node) {
|
|
489
|
+
// Parameter expressions cannot see declarations in the function body.
|
|
490
|
+
// Retain the outer function scope for parameters and callable ownership;
|
|
491
|
+
// body declarations belong to a separate variable environment.
|
|
492
|
+
return functionParametersHaveExpressions(parent) ? "function" : undefined;
|
|
493
|
+
}
|
|
494
|
+
if (t.isBlockStatement(node))
|
|
396
495
|
return "block";
|
|
397
496
|
return undefined;
|
|
398
497
|
};
|
|
498
|
+
const functionParametersHaveExpressions = (node) => {
|
|
499
|
+
const pending = [...node.params];
|
|
500
|
+
while (pending.length > 0) {
|
|
501
|
+
const parameter = pending.pop();
|
|
502
|
+
if (t.isAssignmentPattern(parameter))
|
|
503
|
+
return true;
|
|
504
|
+
if (t.isTSParameterProperty(parameter))
|
|
505
|
+
pending.push(parameter.parameter);
|
|
506
|
+
else if (t.isRestElement(parameter))
|
|
507
|
+
pending.push(parameter.argument);
|
|
508
|
+
else if (t.isArrayPattern(parameter)) {
|
|
509
|
+
for (const element of parameter.elements)
|
|
510
|
+
if (element !== null)
|
|
511
|
+
pending.push(element);
|
|
512
|
+
}
|
|
513
|
+
else if (t.isObjectPattern(parameter)) {
|
|
514
|
+
for (const property of parameter.properties) {
|
|
515
|
+
if (t.isRestElement(property))
|
|
516
|
+
pending.push(property.argument);
|
|
517
|
+
else {
|
|
518
|
+
if (property.computed)
|
|
519
|
+
return true;
|
|
520
|
+
pending.push(property.value);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return false;
|
|
526
|
+
};
|
|
399
527
|
const bindImports = (node, scope, state) => {
|
|
400
528
|
for (const specifier of node.specifiers) {
|
|
401
529
|
const importedPath = t.isImportDefaultSpecifier(specifier)
|
|
@@ -429,12 +557,29 @@ const bindFunctionLocals = (node, scope, state) => {
|
|
|
429
557
|
});
|
|
430
558
|
};
|
|
431
559
|
const bindPattern = (input) => {
|
|
432
|
-
const { pattern, initializer, scope, state, mutable, kind = "variable", projection = [], } = input;
|
|
560
|
+
const { pattern, initializer, scope, state, mutable, kind = "variable", projection = [], referenceOnly = false, copyKind, copyProjectionOffset, copyExcludedKeys, copyStartIndex, fallbackSources, requiredSources, } = input;
|
|
433
561
|
if (t.isTSParameterProperty(pattern)) {
|
|
434
562
|
bindPattern({ ...input, pattern: pattern.parameter });
|
|
435
563
|
return;
|
|
436
564
|
}
|
|
437
565
|
if (t.isIdentifier(pattern)) {
|
|
566
|
+
if (referenceOnly) {
|
|
567
|
+
const binding = scope.bindings.get(pattern.name);
|
|
568
|
+
if (binding !== undefined && initializer !== null)
|
|
569
|
+
binding.referenceInitializers.push({
|
|
570
|
+
node: initializer,
|
|
571
|
+
projection,
|
|
572
|
+
...(copyKind === undefined ? {} : { copyKind }),
|
|
573
|
+
...(copyProjectionOffset === undefined
|
|
574
|
+
? {}
|
|
575
|
+
: { copyProjectionOffset }),
|
|
576
|
+
...(copyExcludedKeys === undefined ? {} : { copyExcludedKeys }),
|
|
577
|
+
...(copyStartIndex === undefined ? {} : { copyStartIndex }),
|
|
578
|
+
...(fallbackSources === undefined ? {} : { fallbackSources }),
|
|
579
|
+
...(requiredSources === undefined ? {} : { requiredSources }),
|
|
580
|
+
});
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
438
583
|
addBinding({
|
|
439
584
|
state,
|
|
440
585
|
scope,
|
|
@@ -454,6 +599,25 @@ const bindPattern = (input) => {
|
|
|
454
599
|
initializer: kind === "parameter" || kind === "catch"
|
|
455
600
|
? initializer
|
|
456
601
|
: (initializer ?? pattern.right),
|
|
602
|
+
requiredSources: [
|
|
603
|
+
...(requiredSources ?? []),
|
|
604
|
+
...(initializer === null ? [] : [{ node: initializer, projection }]),
|
|
605
|
+
],
|
|
606
|
+
});
|
|
607
|
+
bindPattern({
|
|
608
|
+
state,
|
|
609
|
+
scope,
|
|
610
|
+
mutable,
|
|
611
|
+
kind,
|
|
612
|
+
pattern: pattern.left,
|
|
613
|
+
initializer: pattern.right,
|
|
614
|
+
projection: [],
|
|
615
|
+
referenceOnly: true,
|
|
616
|
+
fallbackSources: [
|
|
617
|
+
...(fallbackSources ?? []),
|
|
618
|
+
...(initializer === null ? [] : [{ node: initializer, projection }]),
|
|
619
|
+
],
|
|
620
|
+
...(requiredSources === undefined ? {} : { requiredSources }),
|
|
457
621
|
});
|
|
458
622
|
return;
|
|
459
623
|
}
|
|
@@ -468,7 +632,7 @@ const bindPattern = (input) => {
|
|
|
468
632
|
}
|
|
469
633
|
if (t.isObjectPattern(pattern))
|
|
470
634
|
for (const property of pattern.properties) {
|
|
471
|
-
if (t.isRestElement(property))
|
|
635
|
+
if (t.isRestElement(property)) {
|
|
472
636
|
bindPattern({
|
|
473
637
|
...input,
|
|
474
638
|
pattern: property.argument,
|
|
@@ -476,6 +640,21 @@ const bindPattern = (input) => {
|
|
|
476
640
|
mutable: true,
|
|
477
641
|
projection: [],
|
|
478
642
|
});
|
|
643
|
+
bindPattern({
|
|
644
|
+
...input,
|
|
645
|
+
pattern: property.argument,
|
|
646
|
+
projection: [...projection, null],
|
|
647
|
+
referenceOnly: true,
|
|
648
|
+
copyKind: "object-rest",
|
|
649
|
+
copyProjectionOffset: projection.length,
|
|
650
|
+
copyExcludedKeys: pattern.properties.flatMap((property) => {
|
|
651
|
+
if (t.isRestElement(property))
|
|
652
|
+
return [];
|
|
653
|
+
const key = semanticStaticPropertyKey(property.key, property.computed);
|
|
654
|
+
return key === null ? [] : [key];
|
|
655
|
+
}),
|
|
656
|
+
});
|
|
657
|
+
}
|
|
479
658
|
else {
|
|
480
659
|
const name = semanticStaticPropertyKey(property.key, property.computed);
|
|
481
660
|
bindPattern({
|
|
@@ -487,12 +666,23 @@ const bindPattern = (input) => {
|
|
|
487
666
|
}
|
|
488
667
|
else if (t.isArrayPattern(pattern))
|
|
489
668
|
pattern.elements.forEach((element, index) => {
|
|
490
|
-
if (element !== null)
|
|
669
|
+
if (element !== null) {
|
|
491
670
|
bindPattern({
|
|
492
671
|
...input,
|
|
493
672
|
pattern: element,
|
|
494
673
|
projection: [...projection, index],
|
|
495
674
|
});
|
|
675
|
+
if (t.isRestElement(element))
|
|
676
|
+
bindPattern({
|
|
677
|
+
...input,
|
|
678
|
+
pattern: element.argument,
|
|
679
|
+
projection: [...projection, null],
|
|
680
|
+
referenceOnly: true,
|
|
681
|
+
copyKind: "array-rest",
|
|
682
|
+
copyProjectionOffset: projection.length,
|
|
683
|
+
copyStartIndex: index,
|
|
684
|
+
});
|
|
685
|
+
}
|
|
496
686
|
});
|
|
497
687
|
};
|
|
498
688
|
const addBinding = (input) => {
|
|
@@ -519,8 +709,10 @@ const createBinding = (scope, name, kind, mutable) => ({
|
|
|
519
709
|
kind,
|
|
520
710
|
mutable,
|
|
521
711
|
mutatedPaths: [],
|
|
712
|
+
escapedPaths: [],
|
|
522
713
|
definitions: [],
|
|
523
714
|
initializers: [],
|
|
715
|
+
referenceInitializers: [],
|
|
524
716
|
directOrigins: [],
|
|
525
717
|
});
|
|
526
718
|
const addAssignment = (identifier, initializer, scope, state) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
|
-
import {
|
|
2
|
+
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
3
3
|
import { semanticCallableIdForNode } from "./javascriptSemanticProjection.js";
|
|
4
|
+
import { unwrapJavaScriptExpression } from "./javascriptAstValues.js";
|
|
4
5
|
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
5
6
|
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
|
6
7
|
/** Resolve local callable candidates without following dynamic properties. */
|
|
@@ -11,6 +12,11 @@ export const resolveLocalCallables = (input) => resolveCallables(input.node, {
|
|
|
11
12
|
bindingCache: input.bindingCache,
|
|
12
13
|
});
|
|
13
14
|
const resolveCallables = (node, context) => {
|
|
15
|
+
// `unwrapJavaScriptExpression` strips all transparent layers iteratively,
|
|
16
|
+
// so a single recursion step suffices (no per-layer stack growth).
|
|
17
|
+
const unwrapped = unwrapJavaScriptExpression(node).node;
|
|
18
|
+
if (unwrapped !== node)
|
|
19
|
+
return resolveCallables(unwrapped, context);
|
|
14
20
|
const direct = semanticCallableIdForNode(node);
|
|
15
21
|
if (direct !== null && context.callableById.has(direct))
|
|
16
22
|
return {
|
|
@@ -20,10 +26,6 @@ const resolveCallables = (node, context) => {
|
|
|
20
26
|
};
|
|
21
27
|
if (t.isIdentifier(node))
|
|
22
28
|
return resolveIdentifier(node, context);
|
|
23
|
-
if (t.isTSAsExpression(node) ||
|
|
24
|
-
t.isTSTypeAssertion(node) ||
|
|
25
|
-
t.isTSNonNullExpression(node))
|
|
26
|
-
return resolveCallables(node.expression, context);
|
|
27
29
|
if (t.isConditionalExpression(node) || t.isLogicalExpression(node))
|
|
28
30
|
return resolveAlternatives(t.isConditionalExpression(node) ? node.consequent : node.left, t.isConditionalExpression(node) ? node.alternate : node.right, context);
|
|
29
31
|
return {
|
|
@@ -103,7 +105,7 @@ export const parameterBindings = (callable, index, state) => {
|
|
|
103
105
|
.filter((binding) => binding.kind === "parameter" &&
|
|
104
106
|
binding.definitions.some(({ kind, location }) => kind === "parameter" &&
|
|
105
107
|
parameterAcceptsArgument(callable, location, index, state)))
|
|
106
|
-
.sort((left, right) =>
|
|
108
|
+
.sort((left, right) => compareUnicodeCodePoints(left.bindingId, right.bindingId));
|
|
107
109
|
};
|
|
108
110
|
const parameterAcceptsArgument = (callable, location, argumentIndex, state) => {
|
|
109
111
|
const node = state.callableNodesById.get(callable.callableId);
|
|
@@ -122,4 +124,4 @@ const rangeContains = (outer, inner) => (outer.start.line < inner.start.line ||
|
|
|
122
124
|
(outer.end.line > inner.end.line ||
|
|
123
125
|
(outer.end.line === inner.end.line &&
|
|
124
126
|
outer.end.column >= inner.end.column));
|
|
125
|
-
const uniqueCallableIds = (values) => [...new Set(values)].sort(
|
|
127
|
+
const uniqueCallableIds = (values) => [...new Set(values)].sort(compareUnicodeCodePoints);
|
|
@@ -3,7 +3,7 @@ import { semanticBuiltinNamespacePath } from "./javascriptSemanticProvenance.js"
|
|
|
3
3
|
import { semanticCallableIdForNode } from "./javascriptSemanticProjection.js";
|
|
4
4
|
import { semanticStaticPropertyName } from "./javascriptAstValues.js";
|
|
5
5
|
import { resolveSemanticBindingState, } from "./javascriptSemanticState.js";
|
|
6
|
-
import {
|
|
6
|
+
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
7
7
|
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
|
8
8
|
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
|
9
9
|
import { dataEffectLiteralString, dataEffectMemberCallee, assignedSemanticResultBindings, scalarAssignedResultBinding, semanticProjectedBindingFacts, } from "./javascriptSemanticDataEffectHelpers.js";
|
|
@@ -130,7 +130,7 @@ const childInteraction = (node, ownerCallableId, context) => {
|
|
|
130
130
|
processBindingId: binding?.bindingId ?? null,
|
|
131
131
|
linkedProcessIds: linked
|
|
132
132
|
.map((candidate) => spawnId(candidate))
|
|
133
|
-
.sort(
|
|
133
|
+
.sort(compareUnicodeCodePoints),
|
|
134
134
|
eventName: kind === "listener" ? eventName : null,
|
|
135
135
|
signalName: kind === "signal"
|
|
136
136
|
? (dataEffectLiteralString(node.arguments[0]) ?? "SIGTERM")
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
import { SEMANTIC_EXPRESSION_DEPTH_LIMIT, SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT, SEMANTIC_PRIMITIVE_JSON_BYTES_LIMIT, } from "./javascriptSemanticResourceLimits.js";
|
|
1
2
|
/** Classify whole-file semantic coverage from parsing and value bounds. */
|
|
2
3
|
export const semanticCoverage = (parserPartial, resourceLimits = []) => resourceLimits.length > 0
|
|
3
4
|
? { status: "partial", omittedCount: null, resourceLimits }
|
|
4
5
|
: { status: parserPartial ? "partial" : "complete", omittedCount: 0 };
|
|
5
6
|
/** Read typed resource-limit classifications from any coverage state. */
|
|
6
7
|
export const semanticCoverageResourceLimits = (coverage) => coverage.resourceLimits ?? [];
|
|
8
|
+
const semanticResourceBounds = {
|
|
9
|
+
"primitive-candidates": {
|
|
10
|
+
value: SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT,
|
|
11
|
+
unit: "items",
|
|
12
|
+
},
|
|
13
|
+
"primitive-bytes": {
|
|
14
|
+
value: SEMANTIC_PRIMITIVE_JSON_BYTES_LIMIT,
|
|
15
|
+
unit: "bytes",
|
|
16
|
+
},
|
|
17
|
+
"expression-depth": {
|
|
18
|
+
value: SEMANTIC_EXPRESSION_DEPTH_LIMIT,
|
|
19
|
+
unit: "depth",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
/** Map semantic evaluator bounds to their caller-visible application coverage. */
|
|
23
|
+
export const semanticResourceLimitCoverage = (resourceLimits) => resourceLimits.map((resourceLimit) => ({
|
|
24
|
+
name: `javascript_semantic_${resourceLimit.replaceAll("-", "_")}`,
|
|
25
|
+
...semanticResourceBounds[resourceLimit],
|
|
26
|
+
}));
|
|
7
27
|
/** Classify one callable's direct-return coverage. */
|
|
8
28
|
export const semanticReturnCoverage = (retainedCount, parserPartial) => ({
|
|
9
29
|
status: parserPartial ? "partial" : "complete",
|
|
@@ -3,7 +3,7 @@ import { semanticBuiltinNamespacePath } from "./javascriptSemanticProvenance.js"
|
|
|
3
3
|
import { semanticCallableIdForNode } from "./javascriptSemanticProjection.js";
|
|
4
4
|
import { resolveSemanticBindingState, semanticResolutionBlocked, } from "./javascriptSemanticState.js";
|
|
5
5
|
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
|
6
|
-
import { readExactJavaScriptLiteral, semanticStaticPropertyKey, semanticStaticPropertyName, } from "./javascriptAstValues.js";
|
|
6
|
+
import { readExactJavaScriptLiteral, semanticStaticPropertyKey, semanticStaticPropertyName, unwrapJavaScriptExpression, } from "./javascriptAstValues.js";
|
|
7
7
|
/** Resolve bindings written by the nearest variable or assignment owner. */
|
|
8
8
|
export const assignedSemanticResultBindings = (node, ancestors, state) => {
|
|
9
9
|
for (let index = ancestors.length - 1; index >= 0; index -= 1) {
|
|
@@ -34,14 +34,12 @@ const assignedSourceIs = (node, source) => {
|
|
|
34
34
|
while (true) {
|
|
35
35
|
if (t.isAwaitExpression(value))
|
|
36
36
|
value = value.argument;
|
|
37
|
-
else
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else
|
|
44
|
-
break;
|
|
37
|
+
else {
|
|
38
|
+
const unwrapped = unwrapJavaScriptExpression(value).node;
|
|
39
|
+
if (unwrapped === value)
|
|
40
|
+
break;
|
|
41
|
+
value = unwrapped;
|
|
42
|
+
}
|
|
45
43
|
}
|
|
46
44
|
return value === node;
|
|
47
45
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import { semanticBuiltinNamespacePath } from "./javascriptSemanticProvenance.js";
|
|
3
|
-
import {
|
|
4
|
-
import { semanticStaticPropertyKey, semanticStaticPropertyName, } from "./javascriptAstValues.js";
|
|
3
|
+
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
4
|
+
import { semanticStaticPropertyKey, semanticStaticPropertyName, unwrapJavaScriptExpression, } from "./javascriptAstValues.js";
|
|
5
5
|
import { resolveSemanticBindingState, semanticResolutionBlocked, } from "./javascriptSemanticState.js";
|
|
6
6
|
import { builtinDataEffectMethod as builtinMethod, dataEffectArgumentBindingId as argumentBindingId, dataEffectLiteralString as literalString, dataEffectMemberCallee as memberCallee, dataEffectMemberObject as memberObject, dataEffectPrimitive as primitiveValue, isSemanticProcessObject as isProcessObject, outerDataEffectBinding as outerAssignedBinding, assignedSemanticResultBindings, semanticProjectedBindingFacts, traverseDataEffects as traverseWithContext, } from "./javascriptSemanticDataEffectHelpers.js";
|
|
7
7
|
import { range } from "./javascriptStaticAnalysisHelpers.js";
|
|
@@ -101,14 +101,7 @@ const collectDefaults = (program, context, configurations) => {
|
|
|
101
101
|
if (!t.isLogicalExpression(node) ||
|
|
102
102
|
(node.operator !== "??" && node.operator !== "||"))
|
|
103
103
|
return;
|
|
104
|
-
|
|
105
|
-
while (t.isParenthesizedExpression(source) ||
|
|
106
|
-
t.isTSAsExpression(source) ||
|
|
107
|
-
t.isTSTypeAssertion(source) ||
|
|
108
|
-
t.isTypeCastExpression(source) ||
|
|
109
|
-
t.isTSSatisfiesExpression(source) ||
|
|
110
|
-
t.isTSNonNullExpression(source))
|
|
111
|
-
source = source.expression;
|
|
104
|
+
const source = unwrapJavaScriptExpression(node.left).node;
|
|
112
105
|
const candidate = configurationsByNode.get(source);
|
|
113
106
|
if (candidate === undefined)
|
|
114
107
|
return;
|
|
@@ -197,7 +190,7 @@ const collectResponseConsumers = (program, context, requests) => {
|
|
|
197
190
|
projectedResultBindings: semanticProjectedBindingFacts(assignedSemanticResultBindings(node, context.ancestors, context.state).filter(({ projectionPath }) => projectionPath.length > 0)),
|
|
198
191
|
linkedRequestIds: linked
|
|
199
192
|
.map(({ operation }) => operation.requestId)
|
|
200
|
-
.sort(
|
|
193
|
+
.sort(compareUnicodeCodePoints),
|
|
201
194
|
endpoint: null,
|
|
202
195
|
fields: [],
|
|
203
196
|
resolution: linked.length === 1 &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import * as t from "@babel/types";
|
|
3
|
-
import {
|
|
3
|
+
import { compareUnicodeCodePoints } from "../unicodeCodePointOrder.js";
|
|
4
4
|
import { semanticCallableIdForNode } from "./javascriptSemanticProjection.js";
|
|
5
5
|
import { traverseJavaScriptAst } from "./javascriptSemanticTraversal.js";
|
|
6
6
|
/** Build bounded rename- and formatting-resistant components per callable. */
|
|
@@ -38,7 +38,7 @@ export const collectJavaScriptSemanticFingerprints = (input) => {
|
|
|
38
38
|
normalizedAstSha256: digest(syntax.normalizedTokens),
|
|
39
39
|
controlFlowSha256: digest(syntax.controlFlowTokens),
|
|
40
40
|
relationShapeSha256: digest(relationShape(callable, callSitesByCaller.get(callable.callableId) ?? [], captureCountByCallable.get(callable.callableId) ?? 0, promiseEffects)),
|
|
41
|
-
literalSetSha256: digest([...new Set(syntax.literals)].sort(
|
|
41
|
+
literalSetSha256: digest([...new Set(syntax.literals)].sort(compareUnicodeCodePoints)),
|
|
42
42
|
effects: [
|
|
43
43
|
...(isAsyncCallable(node) ? ["async"] : []),
|
|
44
44
|
...(childProcessEffects.length > 0
|