@grafema/core 0.1.0-alpha.1
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/LICENSE +190 -0
- package/README.md +76 -0
- package/dist/Orchestrator.d.ts +142 -0
- package/dist/Orchestrator.d.ts.map +1 -0
- package/dist/Orchestrator.js +481 -0
- package/dist/api/GraphAPI.d.ts +87 -0
- package/dist/api/GraphAPI.d.ts.map +1 -0
- package/dist/api/GraphAPI.js +210 -0
- package/dist/api/GuaranteeAPI.d.ts +147 -0
- package/dist/api/GuaranteeAPI.d.ts.map +1 -0
- package/dist/api/GuaranteeAPI.js +288 -0
- package/dist/core/ASTWorker.d.ts +133 -0
- package/dist/core/ASTWorker.d.ts.map +1 -0
- package/dist/core/ASTWorker.js +352 -0
- package/dist/core/ASTWorkerPool.d.ts +85 -0
- package/dist/core/ASTWorkerPool.d.ts.map +1 -0
- package/dist/core/ASTWorkerPool.js +207 -0
- package/dist/core/AnalysisQueue.d.ts +104 -0
- package/dist/core/AnalysisQueue.d.ts.map +1 -0
- package/dist/core/AnalysisQueue.js +299 -0
- package/dist/core/AnalysisWorker.d.ts +14 -0
- package/dist/core/AnalysisWorker.d.ts.map +1 -0
- package/dist/core/AnalysisWorker.js +307 -0
- package/dist/core/GraphBackend.d.ts +156 -0
- package/dist/core/GraphBackend.d.ts.map +1 -0
- package/dist/core/GraphBackend.js +85 -0
- package/dist/core/GuaranteeManager.d.ts +230 -0
- package/dist/core/GuaranteeManager.d.ts.map +1 -0
- package/dist/core/GuaranteeManager.js +352 -0
- package/dist/core/ManifestStore.d.ts +71 -0
- package/dist/core/ManifestStore.d.ts.map +1 -0
- package/dist/core/ManifestStore.js +146 -0
- package/dist/core/NodeFactory.d.ts +160 -0
- package/dist/core/NodeFactory.d.ts.map +1 -0
- package/dist/core/NodeFactory.js +137 -0
- package/dist/core/NodeId.d.ts +88 -0
- package/dist/core/NodeId.d.ts.map +1 -0
- package/dist/core/NodeId.js +170 -0
- package/dist/core/ParallelAnalyzer.d.ts +120 -0
- package/dist/core/ParallelAnalyzer.d.ts.map +1 -0
- package/dist/core/ParallelAnalyzer.js +331 -0
- package/dist/core/PriorityQueue.d.ts +106 -0
- package/dist/core/PriorityQueue.d.ts.map +1 -0
- package/dist/core/PriorityQueue.js +168 -0
- package/dist/core/Profiler.d.ts +75 -0
- package/dist/core/Profiler.d.ts.map +1 -0
- package/dist/core/Profiler.js +149 -0
- package/dist/core/QueueWorker.d.ts +12 -0
- package/dist/core/QueueWorker.d.ts.map +1 -0
- package/dist/core/QueueWorker.js +567 -0
- package/dist/core/RFDBClient.d.ts +179 -0
- package/dist/core/RFDBClient.d.ts.map +1 -0
- package/dist/core/RFDBClient.js +429 -0
- package/dist/core/Task.d.ts +56 -0
- package/dist/core/Task.d.ts.map +1 -0
- package/dist/core/Task.js +85 -0
- package/dist/core/TaskTypes.d.ts +20 -0
- package/dist/core/TaskTypes.d.ts.map +1 -0
- package/dist/core/TaskTypes.js +10 -0
- package/dist/core/VersionManager.d.ts +166 -0
- package/dist/core/VersionManager.d.ts.map +1 -0
- package/dist/core/VersionManager.js +237 -0
- package/dist/core/WorkerPool.d.ts +82 -0
- package/dist/core/WorkerPool.d.ts.map +1 -0
- package/dist/core/WorkerPool.js +109 -0
- package/dist/core/nodes/CallSiteNode.d.ts +26 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -0
- package/dist/core/nodes/CallSiteNode.js +44 -0
- package/dist/core/nodes/ClassNode.d.ts +25 -0
- package/dist/core/nodes/ClassNode.d.ts.map +1 -0
- package/dist/core/nodes/ClassNode.js +40 -0
- package/dist/core/nodes/ConstantNode.d.ts +24 -0
- package/dist/core/nodes/ConstantNode.d.ts.map +1 -0
- package/dist/core/nodes/ConstantNode.js +39 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts +22 -0
- package/dist/core/nodes/DatabaseQueryNode.d.ts.map +1 -0
- package/dist/core/nodes/DatabaseQueryNode.js +37 -0
- package/dist/core/nodes/EntrypointNode.d.ts +102 -0
- package/dist/core/nodes/EntrypointNode.d.ts.map +1 -0
- package/dist/core/nodes/EntrypointNode.js +119 -0
- package/dist/core/nodes/EventListenerNode.d.ts +25 -0
- package/dist/core/nodes/EventListenerNode.d.ts.map +1 -0
- package/dist/core/nodes/EventListenerNode.js +39 -0
- package/dist/core/nodes/ExportNode.d.ts +26 -0
- package/dist/core/nodes/ExportNode.d.ts.map +1 -0
- package/dist/core/nodes/ExportNode.js +40 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +17 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalStdioNode.js +26 -0
- package/dist/core/nodes/FunctionNode.d.ts +27 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -0
- package/dist/core/nodes/FunctionNode.js +53 -0
- package/dist/core/nodes/GuaranteeNode.d.ts +76 -0
- package/dist/core/nodes/GuaranteeNode.d.ts.map +1 -0
- package/dist/core/nodes/GuaranteeNode.js +117 -0
- package/dist/core/nodes/HttpRequestNode.d.ts +24 -0
- package/dist/core/nodes/HttpRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/HttpRequestNode.js +38 -0
- package/dist/core/nodes/ImportNode.d.ts +27 -0
- package/dist/core/nodes/ImportNode.d.ts.map +1 -0
- package/dist/core/nodes/ImportNode.js +43 -0
- package/dist/core/nodes/LiteralNode.d.ts +26 -0
- package/dist/core/nodes/LiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/LiteralNode.js +40 -0
- package/dist/core/nodes/MethodCallNode.d.ts +29 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodCallNode.js +47 -0
- package/dist/core/nodes/MethodNode.d.ts +29 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -0
- package/dist/core/nodes/MethodNode.js +44 -0
- package/dist/core/nodes/ModuleNode.d.ts +29 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ModuleNode.js +49 -0
- package/dist/core/nodes/NodeKind.d.ts +91 -0
- package/dist/core/nodes/NodeKind.d.ts.map +1 -0
- package/dist/core/nodes/NodeKind.js +146 -0
- package/dist/core/nodes/ParameterNode.d.ts +26 -0
- package/dist/core/nodes/ParameterNode.d.ts.map +1 -0
- package/dist/core/nodes/ParameterNode.js +43 -0
- package/dist/core/nodes/ScopeNode.d.ts +32 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -0
- package/dist/core/nodes/ScopeNode.js +47 -0
- package/dist/core/nodes/ServiceNode.d.ts +44 -0
- package/dist/core/nodes/ServiceNode.d.ts.map +1 -0
- package/dist/core/nodes/ServiceNode.js +49 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +22 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -0
- package/dist/core/nodes/VariableDeclarationNode.js +38 -0
- package/dist/core/nodes/index.d.ts +25 -0
- package/dist/core/nodes/index.d.ts.map +1 -0
- package/dist/core/nodes/index.js +30 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/plugins/Plugin.d.ts +44 -0
- package/dist/plugins/Plugin.d.ts.map +1 -0
- package/dist/plugins/Plugin.js +46 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts +23 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.js +260 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts +19 -0
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressAnalyzer.js +306 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts +17 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +308 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +38 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.js +344 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +65 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -0
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +472 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +84 -0
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/JSASTAnalyzer.js +1378 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts +90 -0
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ReactAnalyzer.js +1153 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts +13 -0
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/RustAnalyzer.js +259 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts +21 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SQLiteAnalyzer.js +317 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts +35 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +303 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts +33 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SocketIOAnalyzer.js +283 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts +27 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -0
- package/dist/plugins/analysis/SystemDbAnalyzer.js +211 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts +85 -0
- package/dist/plugins/analysis/ast/ConditionParser.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ConditionParser.js +277 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts +15 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/ExpressionEvaluator.js +91 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +77 -0
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/GraphBuilder.js +1077 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts +41 -0
- package/dist/plugins/analysis/ast/OxcAdapter.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/OxcAdapter.js +40 -0
- package/dist/plugins/analysis/ast/types.d.ts +346 -0
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/types.js +4 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +93 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +24 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +77 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +377 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +27 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +232 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +25 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +172 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts +29 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +180 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +14 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +200 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +45 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +150 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts +17 -0
- package/dist/plugins/analysis/ast/visitors/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/visitors/index.js +13 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts +34 -0
- package/dist/plugins/discovery/DiscoveryPlugin.d.ts.map +1 -0
- package/dist/plugins/discovery/DiscoveryPlugin.js +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts +26 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +79 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts +14 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +65 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +19 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/ZonServiceDiscovery.js +204 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts +40 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -0
- package/dist/plugins/enrichment/AliasTracker.js +290 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts +30 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +135 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts +30 -0
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -0
- package/dist/plugins/enrichment/ImportExportLinker.js +176 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts +21 -0
- package/dist/plugins/enrichment/InstanceOfResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/InstanceOfResolver.js +117 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts +41 -0
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MethodCallResolver.js +252 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts +26 -0
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -0
- package/dist/plugins/enrichment/MountPointResolver.js +189 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts +89 -0
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -0
- package/dist/plugins/enrichment/PrefixEvaluator.js +415 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts +25 -0
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -0
- package/dist/plugins/enrichment/RustFFIEnricher.js +170 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +114 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +464 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts +27 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +238 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts +33 -0
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/JSModuleIndexer.js +299 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts +28 -0
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -0
- package/dist/plugins/indexing/RustModuleIndexer.js +140 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts +46 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -0
- package/dist/plugins/indexing/ServiceDetector.js +164 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts +23 -0
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -0
- package/dist/plugins/validation/CallResolverValidator.js +108 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts +24 -0
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -0
- package/dist/plugins/validation/DataFlowValidator.js +148 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts +25 -0
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -0
- package/dist/plugins/validation/EvalBanValidator.js +123 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts +11 -0
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -0
- package/dist/plugins/validation/GraphConnectivityValidator.js +135 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts +43 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -0
- package/dist/plugins/validation/SQLInjectionValidator.js +251 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts +26 -0
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -0
- package/dist/plugins/validation/ShadowingDetector.js +119 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts +21 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -0
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +151 -0
- package/dist/plugins/vcs/GitPlugin.d.ts +84 -0
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/GitPlugin.js +295 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts +133 -0
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -0
- package/dist/plugins/vcs/VCSPlugin.js +82 -0
- package/dist/plugins/vcs/index.d.ts +10 -0
- package/dist/plugins/vcs/index.d.ts.map +1 -0
- package/dist/plugins/vcs/index.js +18 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts +258 -0
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -0
- package/dist/storage/backends/RFDBServerBackend.js +565 -0
- package/dist/storage/backends/typeValidation.d.ts +47 -0
- package/dist/storage/backends/typeValidation.d.ts.map +1 -0
- package/dist/storage/backends/typeValidation.js +137 -0
- package/dist/validation/PathValidator.d.ts +81 -0
- package/dist/validation/PathValidator.d.ts.map +1 -0
- package/dist/validation/PathValidator.js +251 -0
- package/package.json +57 -0
- package/src/.rfguard/current-session.txt +1 -0
- package/src/Orchestrator.ts +673 -0
- package/src/api/GraphAPI.ts +305 -0
- package/src/api/GuaranteeAPI.ts +401 -0
- package/src/core/ASTWorker.ts +567 -0
- package/src/core/ASTWorkerPool.ts +299 -0
- package/src/core/AnalysisQueue.ts +447 -0
- package/src/core/AnalysisWorker.ts +410 -0
- package/src/core/GraphBackend.ts +265 -0
- package/src/core/GuaranteeManager.ts +581 -0
- package/src/core/ManifestStore.ts +196 -0
- package/src/core/NodeFactory.ts +274 -0
- package/src/core/NodeId.ts +257 -0
- package/src/core/ParallelAnalyzer.ts +476 -0
- package/src/core/PriorityQueue.ts +227 -0
- package/src/core/Profiler.ts +188 -0
- package/src/core/QueueWorker.ts +780 -0
- package/src/core/Task.ts +107 -0
- package/src/core/TaskTypes.ts +40 -0
- package/src/core/VersionManager.ts +404 -0
- package/src/core/WorkerPool.ts +180 -0
- package/src/core/nodes/CallSiteNode.ts +72 -0
- package/src/core/nodes/ClassNode.ts +69 -0
- package/src/core/nodes/ConstantNode.ts +63 -0
- package/src/core/nodes/DatabaseQueryNode.ts +60 -0
- package/src/core/nodes/EntrypointNode.ts +164 -0
- package/src/core/nodes/EventListenerNode.ts +64 -0
- package/src/core/nodes/ExportNode.ts +71 -0
- package/src/core/nodes/ExternalStdioNode.ts +36 -0
- package/src/core/nodes/FunctionNode.ts +78 -0
- package/src/core/nodes/GuaranteeNode.ts +162 -0
- package/src/core/nodes/HttpRequestNode.ts +63 -0
- package/src/core/nodes/ImportNode.ts +75 -0
- package/src/core/nodes/LiteralNode.ts +67 -0
- package/src/core/nodes/MethodCallNode.ts +79 -0
- package/src/core/nodes/MethodNode.ts +78 -0
- package/src/core/nodes/ModuleNode.ts +74 -0
- package/src/core/nodes/NodeKind.ts +171 -0
- package/src/core/nodes/ParameterNode.ts +73 -0
- package/src/core/nodes/ScopeNode.ts +80 -0
- package/src/core/nodes/ServiceNode.ts +86 -0
- package/src/core/nodes/VariableDeclarationNode.ts +60 -0
- package/src/core/nodes/index.ts +49 -0
- package/src/index.ts +93 -0
- package/src/plugins/Plugin.ts +74 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +322 -0
- package/src/plugins/analysis/ExpressAnalyzer.ts +401 -0
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +414 -0
- package/src/plugins/analysis/FetchAnalyzer.ts +441 -0
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +686 -0
- package/src/plugins/analysis/JSASTAnalyzer.ts +1680 -0
- package/src/plugins/analysis/ReactAnalyzer.ts +1368 -0
- package/src/plugins/analysis/RustAnalyzer.ts +438 -0
- package/src/plugins/analysis/SQLiteAnalyzer.ts +388 -0
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +429 -0
- package/src/plugins/analysis/SocketIOAnalyzer.ts +395 -0
- package/src/plugins/analysis/SystemDbAnalyzer.ts +284 -0
- package/src/plugins/analysis/ast/ConditionParser.ts +333 -0
- package/src/plugins/analysis/ast/ExpressionEvaluator.ts +117 -0
- package/src/plugins/analysis/ast/GraphBuilder.ts +1371 -0
- package/src/plugins/analysis/ast/OxcAdapter.ts +63 -0
- package/src/plugins/analysis/ast/types.ts +400 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +137 -0
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +528 -0
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +339 -0
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +273 -0
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +259 -0
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +235 -0
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +268 -0
- package/src/plugins/analysis/ast/visitors/index.ts +36 -0
- package/src/plugins/discovery/DiscoveryPlugin.ts +50 -0
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +117 -0
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +102 -0
- package/src/plugins/enrichment/AliasTracker.ts +399 -0
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +192 -0
- package/src/plugins/enrichment/ImportExportLinker.ts +221 -0
- package/src/plugins/enrichment/InstanceOfResolver.ts +165 -0
- package/src/plugins/enrichment/MethodCallResolver.ts +333 -0
- package/src/plugins/enrichment/MountPointResolver.ts +264 -0
- package/src/plugins/enrichment/PrefixEvaluator.ts +527 -0
- package/src/plugins/enrichment/RustFFIEnricher.ts +218 -0
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +682 -0
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +287 -0
- package/src/plugins/indexing/JSModuleIndexer.ts +374 -0
- package/src/plugins/indexing/RustModuleIndexer.ts +160 -0
- package/src/plugins/indexing/ServiceDetector.ts +230 -0
- package/src/plugins/validation/CallResolverValidator.ts +170 -0
- package/src/plugins/validation/DataFlowValidator.ts +233 -0
- package/src/plugins/validation/EvalBanValidator.ts +175 -0
- package/src/plugins/validation/GraphConnectivityValidator.ts +201 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +363 -0
- package/src/plugins/validation/ShadowingDetector.ts +173 -0
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +203 -0
- package/src/plugins/vcs/GitPlugin.ts +344 -0
- package/src/plugins/vcs/VCSPlugin.ts +190 -0
- package/src/plugins/vcs/index.ts +32 -0
- package/src/storage/backends/RFDBServerBackend.ts +687 -0
- package/src/storage/backends/typeValidation.ts +151 -0
- package/src/validation/PathValidator.ts +342 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CallExpressionVisitor - handles function calls and constructor invocations at module level
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - Direct function calls: foo()
|
|
6
|
+
* - Method calls: obj.method()
|
|
7
|
+
* - Event handlers: obj.on('event', handler)
|
|
8
|
+
* - Constructor calls: new Foo(), new Function()
|
|
9
|
+
*/
|
|
10
|
+
import { ASTVisitor } from './ASTVisitor.js';
|
|
11
|
+
import { ExpressionEvaluator } from '../ExpressionEvaluator.js';
|
|
12
|
+
export class CallExpressionVisitor extends ASTVisitor {
|
|
13
|
+
constructor(module, collections) {
|
|
14
|
+
super(module, collections);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Extract argument information for PASSES_ARGUMENT edges
|
|
18
|
+
*/
|
|
19
|
+
extractArguments(args, callId, module, callArguments, literals, literalCounterRef) {
|
|
20
|
+
args.forEach((arg, index) => {
|
|
21
|
+
const argInfo = {
|
|
22
|
+
callId,
|
|
23
|
+
argIndex: index,
|
|
24
|
+
file: module.file,
|
|
25
|
+
line: arg.loc?.start.line || 0,
|
|
26
|
+
column: arg.loc?.start.column || 0
|
|
27
|
+
};
|
|
28
|
+
// Check for spread: ...arg
|
|
29
|
+
let actualArg = arg;
|
|
30
|
+
if (arg.type === 'SpreadElement') {
|
|
31
|
+
argInfo.isSpread = true;
|
|
32
|
+
actualArg = arg.argument; // Get the actual argument
|
|
33
|
+
}
|
|
34
|
+
// Literal value
|
|
35
|
+
const literalValue = ExpressionEvaluator.extractLiteralValue(actualArg);
|
|
36
|
+
if (literalValue !== null) {
|
|
37
|
+
const literalId = `LITERAL#arg${index}#${module.file}#${argInfo.line}:${argInfo.column}:${literalCounterRef.value++}`;
|
|
38
|
+
literals.push({
|
|
39
|
+
id: literalId,
|
|
40
|
+
type: 'LITERAL',
|
|
41
|
+
value: literalValue,
|
|
42
|
+
valueType: typeof literalValue,
|
|
43
|
+
file: module.file,
|
|
44
|
+
line: argInfo.line,
|
|
45
|
+
column: argInfo.column,
|
|
46
|
+
parentCallId: callId,
|
|
47
|
+
argIndex: index
|
|
48
|
+
});
|
|
49
|
+
argInfo.targetType = 'LITERAL';
|
|
50
|
+
argInfo.targetId = literalId;
|
|
51
|
+
argInfo.literalValue = literalValue;
|
|
52
|
+
}
|
|
53
|
+
// Variable reference
|
|
54
|
+
else if (actualArg.type === 'Identifier') {
|
|
55
|
+
argInfo.targetType = 'VARIABLE';
|
|
56
|
+
argInfo.targetName = actualArg.name; // Will be resolved in GraphBuilder
|
|
57
|
+
}
|
|
58
|
+
// Function expression (callback)
|
|
59
|
+
else if (actualArg.type === 'ArrowFunctionExpression' || actualArg.type === 'FunctionExpression') {
|
|
60
|
+
argInfo.targetType = 'FUNCTION';
|
|
61
|
+
argInfo.functionLine = actualArg.loc?.start.line;
|
|
62
|
+
argInfo.functionColumn = actualArg.loc?.start.column;
|
|
63
|
+
}
|
|
64
|
+
// Call expression (nested call)
|
|
65
|
+
else if (actualArg.type === 'CallExpression') {
|
|
66
|
+
argInfo.targetType = 'CALL';
|
|
67
|
+
// Nested calls will be processed separately, link by position
|
|
68
|
+
argInfo.nestedCallLine = actualArg.loc?.start.line;
|
|
69
|
+
argInfo.nestedCallColumn = actualArg.loc?.start.column;
|
|
70
|
+
}
|
|
71
|
+
// Member expression: obj.prop or obj[x]
|
|
72
|
+
else if (actualArg.type === 'MemberExpression') {
|
|
73
|
+
const memberExpr = actualArg;
|
|
74
|
+
argInfo.targetType = 'EXPRESSION';
|
|
75
|
+
argInfo.expressionType = 'MemberExpression';
|
|
76
|
+
if (memberExpr.object.type === 'Identifier') {
|
|
77
|
+
argInfo.objectName = memberExpr.object.name;
|
|
78
|
+
}
|
|
79
|
+
if (!memberExpr.computed && memberExpr.property.type === 'Identifier') {
|
|
80
|
+
argInfo.propertyName = memberExpr.property.name;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Binary/Logical expression: a + b, a && b
|
|
84
|
+
else if (actualArg.type === 'BinaryExpression' || actualArg.type === 'LogicalExpression') {
|
|
85
|
+
const expr = actualArg;
|
|
86
|
+
const operator = expr.operator || '?';
|
|
87
|
+
const exprName = `<${actualArg.type}:${operator}>`;
|
|
88
|
+
const expressionId = `EXPRESSION#${exprName}#${module.file}#${argInfo.line}:${argInfo.column}:${literalCounterRef.value++}`;
|
|
89
|
+
// Create EXPRESSION node
|
|
90
|
+
literals.push({
|
|
91
|
+
id: expressionId,
|
|
92
|
+
type: 'EXPRESSION',
|
|
93
|
+
expressionType: actualArg.type,
|
|
94
|
+
operator: operator,
|
|
95
|
+
name: exprName,
|
|
96
|
+
file: module.file,
|
|
97
|
+
line: argInfo.line,
|
|
98
|
+
column: argInfo.column,
|
|
99
|
+
parentCallId: callId,
|
|
100
|
+
argIndex: index
|
|
101
|
+
});
|
|
102
|
+
argInfo.targetType = 'EXPRESSION';
|
|
103
|
+
argInfo.targetId = expressionId;
|
|
104
|
+
argInfo.expressionType = actualArg.type;
|
|
105
|
+
// Track DERIVES_FROM edges for identifiers in expression
|
|
106
|
+
const identifiers = this.extractIdentifiers(actualArg);
|
|
107
|
+
const { variableAssignments } = this.collections;
|
|
108
|
+
if (variableAssignments) {
|
|
109
|
+
for (const identName of identifiers) {
|
|
110
|
+
variableAssignments.push({
|
|
111
|
+
variableId: expressionId,
|
|
112
|
+
sourceId: null,
|
|
113
|
+
sourceName: identName,
|
|
114
|
+
sourceType: 'DERIVES_FROM_VARIABLE',
|
|
115
|
+
file: module.file
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Object literal
|
|
121
|
+
else if (actualArg.type === 'ObjectExpression') {
|
|
122
|
+
argInfo.targetType = 'OBJECT_LITERAL';
|
|
123
|
+
}
|
|
124
|
+
// Array literal
|
|
125
|
+
else if (actualArg.type === 'ArrayExpression') {
|
|
126
|
+
argInfo.targetType = 'ARRAY_LITERAL';
|
|
127
|
+
}
|
|
128
|
+
// Other expression types
|
|
129
|
+
else {
|
|
130
|
+
argInfo.targetType = 'EXPRESSION';
|
|
131
|
+
argInfo.expressionType = actualArg.type;
|
|
132
|
+
}
|
|
133
|
+
callArguments.push(argInfo);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Extract all Identifier names from an expression (recursively)
|
|
138
|
+
* Used for BinaryExpression/LogicalExpression to track DERIVES_FROM edges
|
|
139
|
+
*/
|
|
140
|
+
extractIdentifiers(node, identifiers = new Set()) {
|
|
141
|
+
if (!node)
|
|
142
|
+
return Array.from(identifiers);
|
|
143
|
+
if (node.type === 'Identifier') {
|
|
144
|
+
identifiers.add(node.name);
|
|
145
|
+
}
|
|
146
|
+
else if (node.type === 'BinaryExpression' || node.type === 'LogicalExpression') {
|
|
147
|
+
const expr = node;
|
|
148
|
+
this.extractIdentifiers(expr.left, identifiers);
|
|
149
|
+
this.extractIdentifiers(expr.right, identifiers);
|
|
150
|
+
}
|
|
151
|
+
else if (node.type === 'UnaryExpression') {
|
|
152
|
+
const expr = node;
|
|
153
|
+
this.extractIdentifiers(expr.argument, identifiers);
|
|
154
|
+
}
|
|
155
|
+
else if (node.type === 'ConditionalExpression') {
|
|
156
|
+
const expr = node;
|
|
157
|
+
this.extractIdentifiers(expr.test, identifiers);
|
|
158
|
+
this.extractIdentifiers(expr.consequent, identifiers);
|
|
159
|
+
this.extractIdentifiers(expr.alternate, identifiers);
|
|
160
|
+
}
|
|
161
|
+
else if (node.type === 'MemberExpression') {
|
|
162
|
+
const memberExpr = node;
|
|
163
|
+
// For obj.prop - track obj (but not prop as it's a property name)
|
|
164
|
+
if (memberExpr.object.type === 'Identifier') {
|
|
165
|
+
identifiers.add(memberExpr.object.name);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
this.extractIdentifiers(memberExpr.object, identifiers);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else if (node.type === 'CallExpression') {
|
|
172
|
+
const callExpr = node;
|
|
173
|
+
// For func() - track func if identifier, and all arguments
|
|
174
|
+
if (callExpr.callee.type === 'Identifier') {
|
|
175
|
+
identifiers.add(callExpr.callee.name);
|
|
176
|
+
}
|
|
177
|
+
for (const arg of callExpr.arguments) {
|
|
178
|
+
if (arg.type !== 'SpreadElement') {
|
|
179
|
+
this.extractIdentifiers(arg, identifiers);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
this.extractIdentifiers(arg.argument, identifiers);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return Array.from(identifiers);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get a stable scope ID for a function parent
|
|
190
|
+
* Format must match what FunctionVisitor creates:
|
|
191
|
+
* - FunctionDeclaration: FUNCTION#name#file#line
|
|
192
|
+
* - ArrowFunctionExpression: FUNCTION#name#file#line:col:counter
|
|
193
|
+
*
|
|
194
|
+
* NOTE: We don't have access to the counter here, so for arrow functions
|
|
195
|
+
* we try to match by name+file+line:col. This may not always work for
|
|
196
|
+
* multiple arrow functions on the same line.
|
|
197
|
+
*/
|
|
198
|
+
getFunctionScopeId(functionParent, module) {
|
|
199
|
+
const funcNode = functionParent.node;
|
|
200
|
+
const line = funcNode.loc?.start.line || 0;
|
|
201
|
+
const col = funcNode.loc?.start.column || 0;
|
|
202
|
+
// FunctionDeclaration with name
|
|
203
|
+
if (funcNode.type === 'FunctionDeclaration' && funcNode.id?.name) {
|
|
204
|
+
return `FUNCTION#${funcNode.id.name}#${module.file}#${line}`;
|
|
205
|
+
}
|
|
206
|
+
// For arrow functions and other cases, we can't perfectly match the ID
|
|
207
|
+
// because FunctionVisitor uses a counter. For now, use module.id as fallback
|
|
208
|
+
// to avoid creating invalid edges. The CALL node will be connected to MODULE
|
|
209
|
+
// instead of the specific function.
|
|
210
|
+
return module.id;
|
|
211
|
+
}
|
|
212
|
+
getHandlers() {
|
|
213
|
+
const { module } = this;
|
|
214
|
+
const callSites = this.collections.callSites ?? [];
|
|
215
|
+
const methodCalls = this.collections.methodCalls ?? [];
|
|
216
|
+
const eventListeners = this.collections.eventListeners ?? [];
|
|
217
|
+
const methodCallbacks = this.collections.methodCallbacks ?? [];
|
|
218
|
+
const literals = this.collections.literals ?? [];
|
|
219
|
+
const callArguments = this.collections.callArguments ?? [];
|
|
220
|
+
const callSiteCounterRef = (this.collections.callSiteCounterRef ?? { value: 0 });
|
|
221
|
+
const literalCounterRef = (this.collections.literalCounterRef ?? { value: 0 });
|
|
222
|
+
const processedNodes = this.collections.processedNodes ?? { callSites: new Set(), methodCalls: new Set(), eventListeners: new Set() };
|
|
223
|
+
return {
|
|
224
|
+
CallExpression: (path) => {
|
|
225
|
+
const callNode = path.node;
|
|
226
|
+
const functionParent = path.getFunctionParent();
|
|
227
|
+
// Determine parent scope - if inside a function, use function's scope, otherwise module
|
|
228
|
+
const parentScopeId = functionParent ? this.getFunctionScopeId(functionParent, module) : module.id;
|
|
229
|
+
// Identifier calls (direct function calls)
|
|
230
|
+
if (callNode.callee.type === 'Identifier') {
|
|
231
|
+
const callee = callNode.callee;
|
|
232
|
+
const callId = `CALL#${callee.name}#${module.file}#${callNode.loc.start.line}:${callNode.loc.start.column}:${callSiteCounterRef.value++}`;
|
|
233
|
+
callSites.push({
|
|
234
|
+
id: callId,
|
|
235
|
+
type: 'CALL',
|
|
236
|
+
name: callee.name,
|
|
237
|
+
file: module.file,
|
|
238
|
+
line: callNode.loc.start.line,
|
|
239
|
+
column: callNode.loc.start.column,
|
|
240
|
+
parentScopeId,
|
|
241
|
+
targetFunctionName: callee.name
|
|
242
|
+
});
|
|
243
|
+
// Extract arguments for PASSES_ARGUMENT edges
|
|
244
|
+
if (callNode.arguments.length > 0) {
|
|
245
|
+
this.extractArguments(callNode.arguments, callId, module, callArguments, literals, literalCounterRef);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// MemberExpression calls (method calls at module level)
|
|
249
|
+
else if (callNode.callee.type === 'MemberExpression') {
|
|
250
|
+
const memberCallee = callNode.callee;
|
|
251
|
+
const object = memberCallee.object;
|
|
252
|
+
const property = memberCallee.property;
|
|
253
|
+
const isComputed = memberCallee.computed;
|
|
254
|
+
if ((object.type === 'Identifier' || object.type === 'ThisExpression') && property.type === 'Identifier') {
|
|
255
|
+
const objectName = object.type === 'Identifier' ? object.name : 'this';
|
|
256
|
+
// For computed access obj[x](), methodName is '<computed>' but we save the variable name
|
|
257
|
+
const methodName = isComputed ? '<computed>' : property.name;
|
|
258
|
+
const computedPropertyVar = isComputed ? property.name : null;
|
|
259
|
+
// Special handling for .on() event handlers
|
|
260
|
+
if (methodName === 'on' && callNode.arguments.length >= 2) {
|
|
261
|
+
const firstArg = callNode.arguments[0];
|
|
262
|
+
const secondArg = callNode.arguments[1];
|
|
263
|
+
if (firstArg.type === 'StringLiteral') {
|
|
264
|
+
const eventName = firstArg.value;
|
|
265
|
+
// Dedup check
|
|
266
|
+
const nodeKey = `${callNode.start}:${callNode.end}`;
|
|
267
|
+
if (processedNodes.eventListeners.has(nodeKey)) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
processedNodes.eventListeners.add(nodeKey);
|
|
271
|
+
eventListeners.push({
|
|
272
|
+
id: `event:listener#${eventName}#${module.file}#${callNode.loc.start.line}:${callNode.loc.start.column}:${callSiteCounterRef.value++}`,
|
|
273
|
+
type: 'event:listener',
|
|
274
|
+
name: eventName,
|
|
275
|
+
object: objectName,
|
|
276
|
+
file: module.file,
|
|
277
|
+
line: callNode.loc.start.line,
|
|
278
|
+
parentScopeId,
|
|
279
|
+
callbackArg: secondArg
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
// Regular method call
|
|
285
|
+
const nodeKey = `${callNode.start}:${callNode.end}`;
|
|
286
|
+
if (processedNodes.methodCalls.has(nodeKey)) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
processedNodes.methodCalls.add(nodeKey);
|
|
290
|
+
const fullName = `${objectName}.${methodName}`;
|
|
291
|
+
const methodCallId = `CALL#${fullName}#${module.file}#${callNode.loc.start.line}:${callNode.loc.start.column}:${callSiteCounterRef.value++}`;
|
|
292
|
+
methodCalls.push({
|
|
293
|
+
id: methodCallId,
|
|
294
|
+
type: 'CALL',
|
|
295
|
+
name: fullName,
|
|
296
|
+
object: objectName,
|
|
297
|
+
method: methodName,
|
|
298
|
+
computed: isComputed,
|
|
299
|
+
computedPropertyVar, // Variable name used in obj[x]() calls
|
|
300
|
+
file: module.file,
|
|
301
|
+
line: callNode.loc.start.line,
|
|
302
|
+
column: callNode.loc.start.column,
|
|
303
|
+
parentScopeId
|
|
304
|
+
});
|
|
305
|
+
// Extract arguments for PASSES_ARGUMENT edges
|
|
306
|
+
if (callNode.arguments.length > 0) {
|
|
307
|
+
this.extractArguments(callNode.arguments, methodCallId, module, callArguments, literals, literalCounterRef);
|
|
308
|
+
// Also track callbacks for HAS_CALLBACK edges
|
|
309
|
+
callNode.arguments.forEach((arg) => {
|
|
310
|
+
if (arg.type === 'ArrowFunctionExpression' || arg.type === 'FunctionExpression') {
|
|
311
|
+
methodCallbacks.push({
|
|
312
|
+
methodCallId,
|
|
313
|
+
callbackLine: arg.loc.start.line,
|
|
314
|
+
callbackColumn: arg.loc.start.column,
|
|
315
|
+
callbackType: arg.type
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
// NewExpression: new Foo(), new Function(), new Map(), etc.
|
|
325
|
+
NewExpression: (path) => {
|
|
326
|
+
const newNode = path.node;
|
|
327
|
+
const functionParent = path.getFunctionParent();
|
|
328
|
+
const parentScopeId = functionParent ? this.getFunctionScopeId(functionParent, module) : module.id;
|
|
329
|
+
// Dedup check
|
|
330
|
+
const nodeKey = `new:${newNode.start}:${newNode.end}`;
|
|
331
|
+
if (processedNodes.methodCalls.has(nodeKey)) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
processedNodes.methodCalls.add(nodeKey);
|
|
335
|
+
// new Foo() - Identifier callee
|
|
336
|
+
if (newNode.callee.type === 'Identifier') {
|
|
337
|
+
const callee = newNode.callee;
|
|
338
|
+
const constructorName = callee.name;
|
|
339
|
+
callSites.push({
|
|
340
|
+
id: `CALL#new:${constructorName}#${module.file}#${newNode.loc.start.line}:${newNode.loc.start.column}:${callSiteCounterRef.value++}`,
|
|
341
|
+
type: 'CALL',
|
|
342
|
+
name: constructorName,
|
|
343
|
+
file: module.file,
|
|
344
|
+
line: newNode.loc.start.line,
|
|
345
|
+
column: newNode.loc.start.column,
|
|
346
|
+
parentScopeId,
|
|
347
|
+
targetFunctionName: constructorName,
|
|
348
|
+
isNew: true // Mark as constructor call
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
// new obj.Constructor() - MemberExpression callee
|
|
352
|
+
else if (newNode.callee.type === 'MemberExpression') {
|
|
353
|
+
const memberCallee = newNode.callee;
|
|
354
|
+
const object = memberCallee.object;
|
|
355
|
+
const property = memberCallee.property;
|
|
356
|
+
if (object.type === 'Identifier' && property.type === 'Identifier') {
|
|
357
|
+
const objectName = object.name;
|
|
358
|
+
const constructorName = property.name;
|
|
359
|
+
const fullName = `${objectName}.${constructorName}`;
|
|
360
|
+
methodCalls.push({
|
|
361
|
+
id: `CALL#new:${fullName}#${module.file}#${newNode.loc.start.line}:${newNode.loc.start.column}:${callSiteCounterRef.value++}`,
|
|
362
|
+
type: 'CALL',
|
|
363
|
+
name: fullName,
|
|
364
|
+
object: objectName,
|
|
365
|
+
method: constructorName,
|
|
366
|
+
file: module.file,
|
|
367
|
+
line: newNode.loc.start.line,
|
|
368
|
+
column: newNode.loc.start.column,
|
|
369
|
+
parentScopeId,
|
|
370
|
+
isNew: true // Mark as constructor call
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClassVisitor - handles class declarations and their methods
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - ClassDeclaration
|
|
6
|
+
* - ClassMethod (nested)
|
|
7
|
+
* - ClassProperty with function values (nested)
|
|
8
|
+
* - Implements (TypeScript)
|
|
9
|
+
* - Decorators
|
|
10
|
+
*/
|
|
11
|
+
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
|
|
12
|
+
import type { AnalyzeFunctionBodyCallback } from './FunctionVisitor.js';
|
|
13
|
+
export declare class ClassVisitor extends ASTVisitor {
|
|
14
|
+
private analyzeFunctionBody;
|
|
15
|
+
/**
|
|
16
|
+
* @param module - Current module being analyzed
|
|
17
|
+
* @param collections - Must contain arrays and counter refs
|
|
18
|
+
* @param analyzeFunctionBody - Callback to analyze method internals
|
|
19
|
+
*/
|
|
20
|
+
constructor(module: VisitorModule, collections: VisitorCollections, analyzeFunctionBody: AnalyzeFunctionBodyCallback);
|
|
21
|
+
/**
|
|
22
|
+
* Extract decorator information from a Decorator node
|
|
23
|
+
*/
|
|
24
|
+
private extractDecoratorInfo;
|
|
25
|
+
getHandlers(): VisitorHandlers;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=ClassVisitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/ClassVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAaH,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAqDxE,qBAAa,YAAa,SAAQ,UAAU;IAC1C,OAAO,CAAC,mBAAmB,CAA8B;IAEzD;;;;OAIG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,EAAE,2BAA2B;IAMlD;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA6C5B,WAAW,IAAI,eAAe;CAqM/B"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClassVisitor - handles class declarations and their methods
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - ClassDeclaration
|
|
6
|
+
* - ClassMethod (nested)
|
|
7
|
+
* - ClassProperty with function values (nested)
|
|
8
|
+
* - Implements (TypeScript)
|
|
9
|
+
* - Decorators
|
|
10
|
+
*/
|
|
11
|
+
import { ASTVisitor } from './ASTVisitor.js';
|
|
12
|
+
import { ExpressionEvaluator } from '../ExpressionEvaluator.js';
|
|
13
|
+
export class ClassVisitor extends ASTVisitor {
|
|
14
|
+
analyzeFunctionBody;
|
|
15
|
+
/**
|
|
16
|
+
* @param module - Current module being analyzed
|
|
17
|
+
* @param collections - Must contain arrays and counter refs
|
|
18
|
+
* @param analyzeFunctionBody - Callback to analyze method internals
|
|
19
|
+
*/
|
|
20
|
+
constructor(module, collections, analyzeFunctionBody) {
|
|
21
|
+
super(module, collections);
|
|
22
|
+
this.analyzeFunctionBody = analyzeFunctionBody;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Extract decorator information from a Decorator node
|
|
26
|
+
*/
|
|
27
|
+
extractDecoratorInfo(decorator, targetId, targetType, module) {
|
|
28
|
+
let decoratorName;
|
|
29
|
+
let decoratorArgs;
|
|
30
|
+
// @Decorator or @Decorator()
|
|
31
|
+
if (decorator.expression.type === 'Identifier') {
|
|
32
|
+
decoratorName = decorator.expression.name;
|
|
33
|
+
}
|
|
34
|
+
else if (decorator.expression.type === 'CallExpression') {
|
|
35
|
+
const callExpr = decorator.expression;
|
|
36
|
+
if (callExpr.callee.type === 'Identifier') {
|
|
37
|
+
decoratorName = callExpr.callee.name;
|
|
38
|
+
// Extract arguments (cast to Node since Babel types guarantee these are AST nodes)
|
|
39
|
+
decoratorArgs = callExpr.arguments.map(arg => {
|
|
40
|
+
return ExpressionEvaluator.extractLiteralValue(arg);
|
|
41
|
+
}).filter(v => v !== null);
|
|
42
|
+
if (decoratorArgs.length === 0) {
|
|
43
|
+
decoratorArgs = undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return null; // Complex decorator expression
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return null; // Unsupported decorator type
|
|
52
|
+
}
|
|
53
|
+
const decoratorId = `DECORATOR#${decoratorName}#${module.file}#${decorator.loc.start.line}:${decorator.loc.start.column}`;
|
|
54
|
+
return {
|
|
55
|
+
id: decoratorId,
|
|
56
|
+
type: 'DECORATOR',
|
|
57
|
+
name: decoratorName,
|
|
58
|
+
file: module.file,
|
|
59
|
+
line: decorator.loc.start.line,
|
|
60
|
+
column: decorator.loc.start.column,
|
|
61
|
+
arguments: decoratorArgs,
|
|
62
|
+
targetId,
|
|
63
|
+
targetType
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
getHandlers() {
|
|
67
|
+
const { module } = this;
|
|
68
|
+
const { functions, scopes, classDeclarations, decorators } = this.collections;
|
|
69
|
+
const analyzeFunctionBody = this.analyzeFunctionBody;
|
|
70
|
+
const collections = this.collections;
|
|
71
|
+
return {
|
|
72
|
+
ClassDeclaration: (classPath) => {
|
|
73
|
+
const classNode = classPath.node;
|
|
74
|
+
if (!classNode.id)
|
|
75
|
+
return; // Skip anonymous classes
|
|
76
|
+
const className = classNode.id.name;
|
|
77
|
+
// Create CLASS node for declaration
|
|
78
|
+
const classId = `CLASS#${className}#${module.file}#${classNode.loc.start.line}`;
|
|
79
|
+
const superClassName = classNode.superClass?.type === 'Identifier'
|
|
80
|
+
? classNode.superClass.name
|
|
81
|
+
: null;
|
|
82
|
+
// Extract implements (TypeScript)
|
|
83
|
+
const implementsNames = [];
|
|
84
|
+
const classNodeWithImplements = classNode;
|
|
85
|
+
if (classNodeWithImplements.implements && classNodeWithImplements.implements.length > 0) {
|
|
86
|
+
for (const impl of classNodeWithImplements.implements) {
|
|
87
|
+
if (impl.expression.type === 'Identifier') {
|
|
88
|
+
implementsNames.push(impl.expression.name);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
classDeclarations.push({
|
|
93
|
+
id: classId,
|
|
94
|
+
type: 'CLASS',
|
|
95
|
+
name: className,
|
|
96
|
+
file: module.file,
|
|
97
|
+
line: classNode.loc.start.line,
|
|
98
|
+
column: classNode.loc.start.column,
|
|
99
|
+
superClass: superClassName,
|
|
100
|
+
implements: implementsNames.length > 0 ? implementsNames : undefined,
|
|
101
|
+
methods: []
|
|
102
|
+
});
|
|
103
|
+
// Extract class decorators
|
|
104
|
+
const classNodeWithDecorators = classNode;
|
|
105
|
+
if (classNodeWithDecorators.decorators && classNodeWithDecorators.decorators.length > 0 && decorators) {
|
|
106
|
+
for (const decorator of classNodeWithDecorators.decorators) {
|
|
107
|
+
const decoratorInfo = this.extractDecoratorInfo(decorator, classId, 'CLASS', module);
|
|
108
|
+
if (decoratorInfo) {
|
|
109
|
+
decorators.push(decoratorInfo);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Get reference to current class for adding methods
|
|
114
|
+
const classDeclarationsTyped = classDeclarations;
|
|
115
|
+
const currentClass = classDeclarationsTyped[classDeclarationsTyped.length - 1];
|
|
116
|
+
// Process class methods and properties
|
|
117
|
+
classPath.traverse({
|
|
118
|
+
ClassProperty: (propPath) => {
|
|
119
|
+
const propNode = propPath.node;
|
|
120
|
+
// Skip if not property of current class
|
|
121
|
+
if (propPath.parent !== classNode.body) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const propName = propNode.key.type === 'Identifier'
|
|
125
|
+
? propNode.key.name
|
|
126
|
+
: propNode.key.value || 'anonymous';
|
|
127
|
+
// Extract property decorators (even for non-function properties)
|
|
128
|
+
const propNodeWithDecorators = propNode;
|
|
129
|
+
if (propNodeWithDecorators.decorators && propNodeWithDecorators.decorators.length > 0 && decorators) {
|
|
130
|
+
// For function properties, target will be set later; for regular properties, create a target ID
|
|
131
|
+
const propertyTargetId = `PROPERTY#${className}.${propName}#${module.file}#${propNode.loc.start.line}`;
|
|
132
|
+
for (const decorator of propNodeWithDecorators.decorators) {
|
|
133
|
+
const decoratorInfo = this.extractDecoratorInfo(decorator, propertyTargetId, 'PROPERTY', module);
|
|
134
|
+
if (decoratorInfo) {
|
|
135
|
+
decorators.push(decoratorInfo);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Only process if value is a function
|
|
140
|
+
if (propNode.value &&
|
|
141
|
+
(propNode.value.type === 'ArrowFunctionExpression' ||
|
|
142
|
+
propNode.value.type === 'FunctionExpression')) {
|
|
143
|
+
const funcNode = propNode.value;
|
|
144
|
+
const functionId = `FUNCTION#${className}.${propName}#${module.file}#${propNode.loc.start.line}:${propNode.loc.start.column}`;
|
|
145
|
+
// Add method to class methods list for CONTAINS edges
|
|
146
|
+
currentClass.methods.push(functionId);
|
|
147
|
+
functions.push({
|
|
148
|
+
id: functionId,
|
|
149
|
+
stableId: functionId,
|
|
150
|
+
type: 'FUNCTION',
|
|
151
|
+
name: propName,
|
|
152
|
+
file: module.file,
|
|
153
|
+
line: propNode.loc.start.line,
|
|
154
|
+
column: propNode.loc.start.column,
|
|
155
|
+
async: funcNode.async || false,
|
|
156
|
+
generator: funcNode.type === 'FunctionExpression' ? funcNode.generator || false : false,
|
|
157
|
+
arrowFunction: funcNode.type === 'ArrowFunctionExpression',
|
|
158
|
+
isClassProperty: true,
|
|
159
|
+
className: className
|
|
160
|
+
});
|
|
161
|
+
// Create SCOPE for property function body
|
|
162
|
+
const propBodyScopeId = `SCOPE#${className}.${propName}:body#${module.file}#${propNode.loc.start.line}`;
|
|
163
|
+
scopes.push({
|
|
164
|
+
id: propBodyScopeId,
|
|
165
|
+
type: 'SCOPE',
|
|
166
|
+
scopeType: 'property_body',
|
|
167
|
+
name: `${className}.${propName}:body`,
|
|
168
|
+
conditional: false,
|
|
169
|
+
file: module.file,
|
|
170
|
+
line: propNode.loc.start.line,
|
|
171
|
+
parentFunctionId: functionId
|
|
172
|
+
});
|
|
173
|
+
const funcPath = propPath.get('value');
|
|
174
|
+
analyzeFunctionBody(funcPath, propBodyScopeId, module, collections);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
ClassMethod: (methodPath) => {
|
|
178
|
+
const methodNode = methodPath.node;
|
|
179
|
+
const methodName = methodNode.key.type === 'Identifier'
|
|
180
|
+
? methodNode.key.name
|
|
181
|
+
: methodNode.key.value || 'anonymous';
|
|
182
|
+
// Skip if not method of current class (nested classes)
|
|
183
|
+
if (methodPath.parent !== classNode.body) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const functionId = `FUNCTION#${className}.${methodName}#${module.file}#${methodNode.loc.start.line}:${methodNode.loc.start.column}`;
|
|
187
|
+
// Add method to class methods list for CONTAINS edges
|
|
188
|
+
currentClass.methods.push(functionId);
|
|
189
|
+
const funcData = {
|
|
190
|
+
id: functionId,
|
|
191
|
+
stableId: functionId,
|
|
192
|
+
type: 'FUNCTION',
|
|
193
|
+
name: methodName,
|
|
194
|
+
file: module.file,
|
|
195
|
+
line: methodNode.loc.start.line,
|
|
196
|
+
column: methodNode.loc.start.column,
|
|
197
|
+
async: methodNode.async || false,
|
|
198
|
+
generator: methodNode.generator || false,
|
|
199
|
+
isClassMethod: true,
|
|
200
|
+
className: className,
|
|
201
|
+
methodKind: methodNode.kind
|
|
202
|
+
};
|
|
203
|
+
functions.push(funcData);
|
|
204
|
+
// Extract method decorators
|
|
205
|
+
const methodNodeWithDecorators = methodNode;
|
|
206
|
+
if (methodNodeWithDecorators.decorators && methodNodeWithDecorators.decorators.length > 0 && decorators) {
|
|
207
|
+
for (const decorator of methodNodeWithDecorators.decorators) {
|
|
208
|
+
const decoratorInfo = this.extractDecoratorInfo(decorator, functionId, 'METHOD', module);
|
|
209
|
+
if (decoratorInfo) {
|
|
210
|
+
decorators.push(decoratorInfo);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Create SCOPE for method body
|
|
215
|
+
const methodBodyScopeId = `SCOPE#${className}.${methodName}:body#${module.file}#${methodNode.loc.start.line}`;
|
|
216
|
+
scopes.push({
|
|
217
|
+
id: methodBodyScopeId,
|
|
218
|
+
type: 'SCOPE',
|
|
219
|
+
scopeType: 'method_body',
|
|
220
|
+
name: `${className}.${methodName}:body`,
|
|
221
|
+
conditional: false,
|
|
222
|
+
file: module.file,
|
|
223
|
+
line: methodNode.loc.start.line,
|
|
224
|
+
parentFunctionId: functionId
|
|
225
|
+
});
|
|
226
|
+
analyzeFunctionBody(methodPath, methodBodyScopeId, module, collections);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FunctionVisitor - handles function declarations and arrow functions
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - FunctionDeclaration
|
|
6
|
+
* - ArrowFunctionExpression (module-level)
|
|
7
|
+
*/
|
|
8
|
+
import type { Function } from '@babel/types';
|
|
9
|
+
import type { NodePath } from '@babel/traverse';
|
|
10
|
+
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
|
|
11
|
+
/**
|
|
12
|
+
* Callback type for analyzing function bodies
|
|
13
|
+
*/
|
|
14
|
+
export type AnalyzeFunctionBodyCallback = (path: NodePath<Function>, scopeId: string, module: VisitorModule, collections: VisitorCollections) => void;
|
|
15
|
+
export declare class FunctionVisitor extends ASTVisitor {
|
|
16
|
+
private analyzeFunctionBody;
|
|
17
|
+
/**
|
|
18
|
+
* @param module - Current module being analyzed
|
|
19
|
+
* @param collections - Must contain arrays and counter refs
|
|
20
|
+
* @param analyzeFunctionBody - Callback to analyze function internals
|
|
21
|
+
*/
|
|
22
|
+
constructor(module: VisitorModule, collections: VisitorCollections, analyzeFunctionBody: AnalyzeFunctionBodyCallback);
|
|
23
|
+
getHandlers(): VisitorHandlers;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=FunctionVisitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FunctionVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/FunctionVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAEV,QAAQ,EAOT,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AAuDjI;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACxC,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,KAC5B,IAAI,CAAC;AAEV,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAO,CAAC,mBAAmB,CAA8B;IAEzD;;;;OAIG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,mBAAmB,EAAE,2BAA2B;IAMlD,WAAW,IAAI,eAAe;CA2K/B"}
|