@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,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MethodCallResolver - обогащает METHOD_CALL ноды связями CALLS к определениям методов
|
|
3
|
+
*
|
|
4
|
+
* Находит вызовы методов (CALL с "object" атрибутом) и пытается связать их с:
|
|
5
|
+
* 1. Методами классов в том же файле
|
|
6
|
+
* 2. Методами классов в импортированных модулях
|
|
7
|
+
* 3. Методами объектов переменных
|
|
8
|
+
*
|
|
9
|
+
* СОЗДАЁТ РЁБРА:
|
|
10
|
+
* - METHOD_CALL -> CALLS -> METHOD (для методов классов)
|
|
11
|
+
* - METHOD_CALL -> CALLS -> FUNCTION (для методов объектов)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
15
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
16
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Extended call node with method properties
|
|
20
|
+
*/
|
|
21
|
+
interface MethodCallNode extends BaseNodeRecord {
|
|
22
|
+
object?: string;
|
|
23
|
+
method?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Class entry in method index
|
|
28
|
+
*/
|
|
29
|
+
interface ClassEntry {
|
|
30
|
+
classNode: BaseNodeRecord;
|
|
31
|
+
methods: Map<string, BaseNodeRecord>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class MethodCallResolver extends Plugin {
|
|
35
|
+
private _containingClassCache?: Map<string, BaseNodeRecord | null>;
|
|
36
|
+
|
|
37
|
+
get metadata(): PluginMetadata {
|
|
38
|
+
return {
|
|
39
|
+
name: 'MethodCallResolver',
|
|
40
|
+
phase: 'ENRICHMENT',
|
|
41
|
+
priority: 50,
|
|
42
|
+
creates: {
|
|
43
|
+
nodes: [],
|
|
44
|
+
edges: ['CALLS']
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async execute(context: PluginContext): Promise<PluginResult> {
|
|
50
|
+
const { graph, onProgress } = context;
|
|
51
|
+
|
|
52
|
+
console.log('[MethodCallResolver] Starting method call resolution...');
|
|
53
|
+
|
|
54
|
+
let methodCallsProcessed = 0;
|
|
55
|
+
let edgesCreated = 0;
|
|
56
|
+
let unresolved = 0;
|
|
57
|
+
|
|
58
|
+
// Собираем все METHOD_CALL ноды (CALL с object атрибутом)
|
|
59
|
+
const methodCalls: MethodCallNode[] = [];
|
|
60
|
+
for await (const node of graph.queryNodes({ nodeType: 'CALL' })) {
|
|
61
|
+
const callNode = node as MethodCallNode;
|
|
62
|
+
if (callNode.object) {
|
|
63
|
+
methodCalls.push(callNode);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(`[MethodCallResolver] Found ${methodCalls.length} method calls to resolve`);
|
|
68
|
+
|
|
69
|
+
// Собираем все классы и их методы для быстрого поиска
|
|
70
|
+
const classMethodIndex = await this.buildClassMethodIndex(graph);
|
|
71
|
+
console.log(`[MethodCallResolver] Indexed ${classMethodIndex.size} classes`);
|
|
72
|
+
|
|
73
|
+
// Собираем переменные и их типы (если известны)
|
|
74
|
+
const variableTypes = await this.buildVariableTypeIndex(graph);
|
|
75
|
+
|
|
76
|
+
const startTime = Date.now();
|
|
77
|
+
|
|
78
|
+
for (const methodCall of methodCalls) {
|
|
79
|
+
methodCallsProcessed++;
|
|
80
|
+
|
|
81
|
+
// Report progress every 50 calls
|
|
82
|
+
if (onProgress && methodCallsProcessed % 50 === 0) {
|
|
83
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
84
|
+
onProgress({
|
|
85
|
+
phase: 'enrichment',
|
|
86
|
+
currentPlugin: 'MethodCallResolver',
|
|
87
|
+
message: `Resolving method calls ${methodCallsProcessed}/${methodCalls.length} (${elapsed}s)`,
|
|
88
|
+
totalFiles: methodCalls.length,
|
|
89
|
+
processedFiles: methodCallsProcessed
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Log every 10 calls with timing
|
|
94
|
+
if (methodCallsProcessed % 10 === 0) {
|
|
95
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
96
|
+
const avgTime = ((Date.now() - startTime) / methodCallsProcessed).toFixed(0);
|
|
97
|
+
console.log(`[MethodCallResolver] Progress: ${methodCallsProcessed}/${methodCalls.length} (${elapsed}s, avg ${avgTime}ms/call)`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Пропускаем внешние методы (console, Array.prototype, etc.)
|
|
101
|
+
if (this.isExternalMethod(methodCall.object!, methodCall.method!)) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Проверяем есть ли уже CALLS ребро
|
|
106
|
+
const existingEdges = await graph.getOutgoingEdges(methodCall.id, ['CALLS']);
|
|
107
|
+
if (existingEdges.length > 0) {
|
|
108
|
+
continue; // Уже есть связь
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Пытаемся найти определение метода
|
|
112
|
+
const targetMethod = await this.resolveMethodCall(
|
|
113
|
+
methodCall,
|
|
114
|
+
classMethodIndex,
|
|
115
|
+
variableTypes,
|
|
116
|
+
graph
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
if (targetMethod) {
|
|
120
|
+
await graph.addEdge({
|
|
121
|
+
src: methodCall.id,
|
|
122
|
+
dst: targetMethod.id,
|
|
123
|
+
type: 'CALLS'
|
|
124
|
+
});
|
|
125
|
+
edgesCreated++;
|
|
126
|
+
} else {
|
|
127
|
+
unresolved++;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const summary = {
|
|
132
|
+
methodCallsProcessed,
|
|
133
|
+
edgesCreated,
|
|
134
|
+
unresolved,
|
|
135
|
+
classesIndexed: classMethodIndex.size
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
console.log('[MethodCallResolver] Summary:', summary);
|
|
139
|
+
|
|
140
|
+
return createSuccessResult({ nodes: 0, edges: edgesCreated }, summary);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Строит индекс классов и их методов
|
|
145
|
+
*/
|
|
146
|
+
private async buildClassMethodIndex(graph: PluginContext['graph']): Promise<Map<string, ClassEntry>> {
|
|
147
|
+
const index = new Map<string, ClassEntry>();
|
|
148
|
+
const startTime = Date.now();
|
|
149
|
+
let classCount = 0;
|
|
150
|
+
|
|
151
|
+
for await (const classNode of graph.queryNodes({ nodeType: 'CLASS' })) {
|
|
152
|
+
classCount++;
|
|
153
|
+
if (classCount % 50 === 0) {
|
|
154
|
+
console.log(`[MethodCallResolver] Indexing classes: ${classCount}...`);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const className = classNode.name as string;
|
|
158
|
+
if (!className) continue;
|
|
159
|
+
|
|
160
|
+
const classEntry: ClassEntry = {
|
|
161
|
+
classNode,
|
|
162
|
+
methods: new Map()
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const containsEdges = await graph.getOutgoingEdges(classNode.id, ['CONTAINS']);
|
|
166
|
+
for (const edge of containsEdges) {
|
|
167
|
+
const childNode = await graph.getNode(edge.dst);
|
|
168
|
+
if (childNode && (childNode.type === 'METHOD' || childNode.type === 'FUNCTION')) {
|
|
169
|
+
if (childNode.name) {
|
|
170
|
+
classEntry.methods.set(childNode.name as string, childNode);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
index.set(className, classEntry);
|
|
176
|
+
|
|
177
|
+
// Также индексируем по файлу для локального резолвинга
|
|
178
|
+
const fileKey = `${classNode.file}:${className}`;
|
|
179
|
+
index.set(fileKey, classEntry);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
183
|
+
console.log(`[MethodCallResolver] Indexed ${index.size} class entries in ${totalTime}s`);
|
|
184
|
+
|
|
185
|
+
return index;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Строит индекс переменных и их типов (из INSTANCE_OF рёбер)
|
|
190
|
+
*/
|
|
191
|
+
private async buildVariableTypeIndex(graph: PluginContext['graph']): Promise<Map<string, string>> {
|
|
192
|
+
const startTime = Date.now();
|
|
193
|
+
const index = new Map<string, string>();
|
|
194
|
+
|
|
195
|
+
for await (const classNode of graph.queryNodes({ nodeType: 'CLASS' })) {
|
|
196
|
+
if (!classNode.name) continue;
|
|
197
|
+
|
|
198
|
+
const incomingEdges = await graph.getIncomingEdges(classNode.id, ['INSTANCE_OF']);
|
|
199
|
+
for (const edge of incomingEdges) {
|
|
200
|
+
index.set(edge.src.toString(), classNode.name as string);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
205
|
+
console.log(`[MethodCallResolver] Built variable type index: ${index.size} entries in ${elapsed}s`);
|
|
206
|
+
return index;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Пытается найти определение метода
|
|
211
|
+
*/
|
|
212
|
+
private async resolveMethodCall(
|
|
213
|
+
methodCall: MethodCallNode,
|
|
214
|
+
classMethodIndex: Map<string, ClassEntry>,
|
|
215
|
+
variableTypes: Map<string, string>,
|
|
216
|
+
graph: PluginContext['graph']
|
|
217
|
+
): Promise<BaseNodeRecord | null> {
|
|
218
|
+
const { object, method, file } = methodCall;
|
|
219
|
+
|
|
220
|
+
if (!object || !method) return null;
|
|
221
|
+
|
|
222
|
+
// 1. Проверяем если object - это имя класса напрямую (статический вызов)
|
|
223
|
+
if (classMethodIndex.has(object)) {
|
|
224
|
+
const classEntry = classMethodIndex.get(object)!;
|
|
225
|
+
if (classEntry.methods.has(method)) {
|
|
226
|
+
return classEntry.methods.get(method)!;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 2. Проверяем локальный класс в том же файле
|
|
231
|
+
const localKey = `${file}:${object}`;
|
|
232
|
+
if (classMethodIndex.has(localKey)) {
|
|
233
|
+
const classEntry = classMethodIndex.get(localKey)!;
|
|
234
|
+
if (classEntry.methods.has(method)) {
|
|
235
|
+
return classEntry.methods.get(method)!;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// 3. Проверяем если object - это "this" (ссылка на текущий класс)
|
|
240
|
+
if (object === 'this') {
|
|
241
|
+
if (!this._containingClassCache) this._containingClassCache = new Map();
|
|
242
|
+
|
|
243
|
+
let containingClass = this._containingClassCache.get(methodCall.id);
|
|
244
|
+
if (containingClass === undefined) {
|
|
245
|
+
containingClass = await this.findContainingClass(methodCall, graph);
|
|
246
|
+
this._containingClassCache.set(methodCall.id, containingClass);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (containingClass && classMethodIndex.has(containingClass.name as string)) {
|
|
250
|
+
const classEntry = classMethodIndex.get(containingClass.name as string)!;
|
|
251
|
+
if (classEntry.methods.has(method)) {
|
|
252
|
+
return classEntry.methods.get(method)!;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 4. Используем variableTypes индекс
|
|
258
|
+
for (const [, className] of variableTypes.entries()) {
|
|
259
|
+
if (className && classMethodIndex.has(className)) {
|
|
260
|
+
const classEntry = classMethodIndex.get(className)!;
|
|
261
|
+
if (classEntry.methods.has(method)) {
|
|
262
|
+
return classEntry.methods.get(method)!;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Находит класс, содержащий данный method call
|
|
272
|
+
*/
|
|
273
|
+
private async findContainingClass(
|
|
274
|
+
methodCall: MethodCallNode,
|
|
275
|
+
graph: PluginContext['graph']
|
|
276
|
+
): Promise<BaseNodeRecord | null> {
|
|
277
|
+
const incomingEdges = await graph.getIncomingEdges(methodCall.id, ['CONTAINS']);
|
|
278
|
+
|
|
279
|
+
for (const edge of incomingEdges) {
|
|
280
|
+
const parentNode = await graph.getNode(edge.src);
|
|
281
|
+
if (!parentNode) continue;
|
|
282
|
+
|
|
283
|
+
if (parentNode.type === 'CLASS') {
|
|
284
|
+
return parentNode;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const found = await this.findContainingClassRecursive(parentNode, graph, new Set());
|
|
288
|
+
if (found) return found;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private async findContainingClassRecursive(
|
|
295
|
+
node: BaseNodeRecord,
|
|
296
|
+
graph: PluginContext['graph'],
|
|
297
|
+
visited: Set<string>
|
|
298
|
+
): Promise<BaseNodeRecord | null> {
|
|
299
|
+
if (visited.has(node.id.toString())) return null;
|
|
300
|
+
visited.add(node.id.toString());
|
|
301
|
+
|
|
302
|
+
const incomingEdges = await graph.getIncomingEdges(node.id, ['CONTAINS']);
|
|
303
|
+
|
|
304
|
+
for (const edge of incomingEdges) {
|
|
305
|
+
const parentNode = await graph.getNode(edge.src);
|
|
306
|
+
if (!parentNode) continue;
|
|
307
|
+
|
|
308
|
+
if (parentNode.type === 'CLASS') {
|
|
309
|
+
return parentNode;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const found = await this.findContainingClassRecursive(parentNode, graph, visited);
|
|
313
|
+
if (found) return found;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Проверяет является ли метод внешним (console, Array, Promise, etc.)
|
|
321
|
+
*/
|
|
322
|
+
private isExternalMethod(object: string, method: string): boolean {
|
|
323
|
+
const externalObjects = new Set([
|
|
324
|
+
'console', 'Math', 'JSON', 'Object', 'Array', 'String', 'Number',
|
|
325
|
+
'Boolean', 'Date', 'RegExp', 'Error', 'Promise', 'Set', 'Map',
|
|
326
|
+
'WeakSet', 'WeakMap', 'Symbol', 'Proxy', 'Reflect', 'Intl',
|
|
327
|
+
'process', 'global', 'window', 'document', 'Buffer',
|
|
328
|
+
'fs', 'path', 'http', 'https', 'crypto', 'os', 'url', 'util'
|
|
329
|
+
]);
|
|
330
|
+
|
|
331
|
+
return externalObjects.has(object);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MountPointResolver - ENRICHMENT plugin for resolving mount points
|
|
3
|
+
*
|
|
4
|
+
* Updates ENDPOINT nodes by adding fullPath based on MOUNT_POINT prefixes.
|
|
5
|
+
*
|
|
6
|
+
* Graph traversal:
|
|
7
|
+
* MOUNT_POINT --MOUNTS--> MODULE --EXPOSES--> ENDPOINT
|
|
8
|
+
*
|
|
9
|
+
* Updates:
|
|
10
|
+
* endpoint.fullPath = mountPoint.prefix + endpoint.localPath
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Plugin } from '../Plugin.js';
|
|
14
|
+
import { createSuccessResult, createErrorResult } from '@grafema/types';
|
|
15
|
+
import type { PluginMetadata, PluginContext, PluginResult, GraphBackend } from '@grafema/types';
|
|
16
|
+
import type { BaseNodeRecord } from '@grafema/types';
|
|
17
|
+
import type { EdgeRecord } from '@grafema/types';
|
|
18
|
+
|
|
19
|
+
interface EdgeCriteria {
|
|
20
|
+
type?: string;
|
|
21
|
+
src?: string;
|
|
22
|
+
dst?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface MountPointNode extends BaseNodeRecord {
|
|
26
|
+
prefix: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface EndpointNode extends BaseNodeRecord {
|
|
30
|
+
localPath?: string;
|
|
31
|
+
path?: string;
|
|
32
|
+
mountPrefixes?: string[];
|
|
33
|
+
fullPaths?: string[];
|
|
34
|
+
mountPrefix?: string;
|
|
35
|
+
fullPath?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class MountPointResolver extends Plugin {
|
|
39
|
+
get metadata(): PluginMetadata {
|
|
40
|
+
return {
|
|
41
|
+
name: 'MountPointResolver',
|
|
42
|
+
phase: 'ENRICHMENT',
|
|
43
|
+
priority: 90, // High priority - one of first enrichment plugins
|
|
44
|
+
creates: {
|
|
45
|
+
nodes: [], // Doesn't create new nodes
|
|
46
|
+
edges: [] // Doesn't create new edges
|
|
47
|
+
},
|
|
48
|
+
dependencies: ['JSModuleIndexer', 'JSASTAnalyzer']
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async execute(context: PluginContext): Promise<PluginResult> {
|
|
53
|
+
try {
|
|
54
|
+
const { graph } = context;
|
|
55
|
+
|
|
56
|
+
let endpointsUpdated = 0;
|
|
57
|
+
let mountPointsProcessed = 0;
|
|
58
|
+
|
|
59
|
+
// Find all MOUNT_POINT nodes
|
|
60
|
+
const allNodes = await graph.getAllNodes();
|
|
61
|
+
const mountPoints = allNodes.filter(node => node.type === 'MOUNT_POINT') as MountPointNode[];
|
|
62
|
+
|
|
63
|
+
console.log(`[MountPointResolver] Found ${mountPoints.length} mount points`);
|
|
64
|
+
|
|
65
|
+
// For each top-level mount point (from app.use in index.js)
|
|
66
|
+
// apply recursive resolver
|
|
67
|
+
const processedMountPoints = new Set<string>();
|
|
68
|
+
|
|
69
|
+
for (const mountPoint of mountPoints) {
|
|
70
|
+
if (!processedMountPoints.has(mountPoint.id)) {
|
|
71
|
+
const updated = await this.resolveMountPoint(graph, mountPoint, '', processedMountPoints);
|
|
72
|
+
endpointsUpdated += updated;
|
|
73
|
+
mountPointsProcessed++;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Fallback: process mount points without recursion (old logic for compatibility)
|
|
78
|
+
for (const mountPoint of mountPoints) {
|
|
79
|
+
if (processedMountPoints.has(mountPoint.id)) continue;
|
|
80
|
+
// Find MOUNT_POINT --MOUNTS--> MODULE edge
|
|
81
|
+
const mountsEdges = await this.findEdges(graph, {
|
|
82
|
+
type: 'MOUNTS',
|
|
83
|
+
src: mountPoint.id
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
for (const mountsEdge of mountsEdges) {
|
|
87
|
+
const targetModuleId = mountsEdge.dst;
|
|
88
|
+
|
|
89
|
+
// Find MODULE --EXPOSES--> ENDPOINT edges
|
|
90
|
+
const exposesEdges = await this.findEdges(graph, {
|
|
91
|
+
type: 'EXPOSES',
|
|
92
|
+
src: targetModuleId
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
for (const exposesEdge of exposesEdges) {
|
|
96
|
+
const endpointId = exposesEdge.dst;
|
|
97
|
+
const endpoint = await graph.getNode(endpointId) as EndpointNode | null;
|
|
98
|
+
|
|
99
|
+
if (endpoint && endpoint.type === 'ENDPOINT') {
|
|
100
|
+
// Support multiple mount points for one endpoint
|
|
101
|
+
// Store all prefixes and fullPaths in arrays
|
|
102
|
+
const mountPrefixes = endpoint.mountPrefixes || [];
|
|
103
|
+
const fullPaths = endpoint.fullPaths || [];
|
|
104
|
+
|
|
105
|
+
const prefix = mountPoint.prefix;
|
|
106
|
+
const fullPath = prefix + (endpoint.localPath || endpoint.path || '');
|
|
107
|
+
|
|
108
|
+
// Only add if not already added (avoid duplicates)
|
|
109
|
+
if (!mountPrefixes.includes(prefix)) {
|
|
110
|
+
mountPrefixes.push(prefix);
|
|
111
|
+
fullPaths.push(fullPath);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Update endpoint node
|
|
115
|
+
const updatedEndpoint: EndpointNode = {
|
|
116
|
+
...endpoint,
|
|
117
|
+
mountPrefixes,
|
|
118
|
+
fullPaths,
|
|
119
|
+
mountPrefix: endpoint.mountPrefix || prefix,
|
|
120
|
+
fullPath: endpoint.fullPath || fullPath
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
await graph.addNode(updatedEndpoint);
|
|
124
|
+
endpointsUpdated++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
mountPointsProcessed++;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(`[MountPointResolver] Updated ${endpointsUpdated} endpoints from ${mountPointsProcessed} mount points`);
|
|
133
|
+
|
|
134
|
+
return createSuccessResult(
|
|
135
|
+
{ nodes: 0, edges: 0 },
|
|
136
|
+
{ endpointsUpdated, mountPointsProcessed }
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error(`[MountPointResolver] Error:`, error);
|
|
141
|
+
return createErrorResult(error as Error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Recursively resolve mount point and all nested mount points
|
|
147
|
+
*/
|
|
148
|
+
private async resolveMountPoint(
|
|
149
|
+
graph: GraphBackend,
|
|
150
|
+
mountPoint: MountPointNode,
|
|
151
|
+
parentPrefix: string,
|
|
152
|
+
processedMountPoints: Set<string>
|
|
153
|
+
): Promise<number> {
|
|
154
|
+
let endpointsUpdated = 0;
|
|
155
|
+
|
|
156
|
+
// Mark as processed
|
|
157
|
+
processedMountPoints.add(mountPoint.id);
|
|
158
|
+
|
|
159
|
+
// Calculate full prefix (parent + current)
|
|
160
|
+
const fullPrefix = parentPrefix + mountPoint.prefix;
|
|
161
|
+
|
|
162
|
+
// Find MOUNT_POINT --MOUNTS--> MODULE edge
|
|
163
|
+
const mountsEdges = await this.findEdges(graph, {
|
|
164
|
+
type: 'MOUNTS',
|
|
165
|
+
src: mountPoint.id
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
for (const mountsEdge of mountsEdges) {
|
|
169
|
+
const targetModuleId = mountsEdge.dst;
|
|
170
|
+
|
|
171
|
+
// 1. Process ENDPOINT in this module
|
|
172
|
+
const exposesEdges = await this.findEdges(graph, {
|
|
173
|
+
type: 'EXPOSES',
|
|
174
|
+
src: targetModuleId
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
for (const exposesEdge of exposesEdges) {
|
|
178
|
+
const endpointId = exposesEdge.dst;
|
|
179
|
+
const endpoint = await graph.getNode(endpointId) as EndpointNode | null;
|
|
180
|
+
|
|
181
|
+
if (endpoint && endpoint.type === 'ENDPOINT') {
|
|
182
|
+
// Support multiple mount points
|
|
183
|
+
const mountPrefixes = endpoint.mountPrefixes || [];
|
|
184
|
+
const fullPaths = endpoint.fullPaths || [];
|
|
185
|
+
|
|
186
|
+
const fullPath = fullPrefix + (endpoint.localPath || endpoint.path || '');
|
|
187
|
+
|
|
188
|
+
// Only add if not already added
|
|
189
|
+
if (!mountPrefixes.includes(fullPrefix)) {
|
|
190
|
+
mountPrefixes.push(fullPrefix);
|
|
191
|
+
fullPaths.push(fullPath);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Update endpoint node with new data
|
|
195
|
+
const updatedEndpoint: EndpointNode = {
|
|
196
|
+
...endpoint,
|
|
197
|
+
mountPrefixes,
|
|
198
|
+
fullPaths,
|
|
199
|
+
mountPrefix: endpoint.mountPrefix || fullPrefix,
|
|
200
|
+
fullPath: endpoint.fullPath || fullPath
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
await graph.addNode(updatedEndpoint);
|
|
204
|
+
endpointsUpdated++;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 2. Recursively process nested MOUNT_POINT in this module
|
|
209
|
+
const definesEdges = await this.findEdges(graph, {
|
|
210
|
+
type: 'DEFINES',
|
|
211
|
+
src: targetModuleId
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
for (const definesEdge of definesEdges) {
|
|
215
|
+
const nestedMountPointId = definesEdge.dst;
|
|
216
|
+
const nestedMountPoint = await graph.getNode(nestedMountPointId) as MountPointNode | null;
|
|
217
|
+
|
|
218
|
+
if (nestedMountPoint && nestedMountPoint.type === 'MOUNT_POINT' &&
|
|
219
|
+
!processedMountPoints.has(nestedMountPointId)) {
|
|
220
|
+
// Recursively process nested mount point
|
|
221
|
+
endpointsUpdated += await this.resolveMountPoint(
|
|
222
|
+
graph,
|
|
223
|
+
nestedMountPoint,
|
|
224
|
+
fullPrefix, // Pass accumulated prefix
|
|
225
|
+
processedMountPoints
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return endpointsUpdated;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Helper method for finding edges by criteria
|
|
236
|
+
*/
|
|
237
|
+
private async findEdges(graph: GraphBackend, criteria: EdgeCriteria): Promise<EdgeRecord[]> {
|
|
238
|
+
const result: EdgeRecord[] = [];
|
|
239
|
+
|
|
240
|
+
// Get all edges using RFDBServerBackend API
|
|
241
|
+
if (!graph.getAllEdges) {
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
const allEdges = await graph.getAllEdges();
|
|
245
|
+
|
|
246
|
+
for (const edge of allEdges) {
|
|
247
|
+
let matches = true;
|
|
248
|
+
|
|
249
|
+
for (const [key, value] of Object.entries(criteria)) {
|
|
250
|
+
const edgeRecord = edge as unknown as Record<string, unknown>;
|
|
251
|
+
if (edgeRecord[key] !== value) {
|
|
252
|
+
matches = false;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (matches) {
|
|
258
|
+
result.push(edge);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
}
|