@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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTPConnectionEnricher - связывает http:request (frontend) с http:route (backend)
|
|
3
|
+
*
|
|
4
|
+
* Создаёт INTERACTS_WITH edges между:
|
|
5
|
+
* - Frontend fetch('/api/users') → Backend GET /api/users
|
|
6
|
+
* - Frontend fetch('/api/users', {method: 'POST'}) → Backend POST /api/users
|
|
7
|
+
*
|
|
8
|
+
* Поддержка параметризованных путей:
|
|
9
|
+
* - /api/graph/:serviceId матчится с /api/graph/my-service
|
|
10
|
+
*/
|
|
11
|
+
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
12
|
+
export class HTTPConnectionEnricher extends Plugin {
|
|
13
|
+
get metadata() {
|
|
14
|
+
return {
|
|
15
|
+
name: 'HTTPConnectionEnricher',
|
|
16
|
+
phase: 'ENRICHMENT',
|
|
17
|
+
priority: 50, // После основных enrichers
|
|
18
|
+
creates: {
|
|
19
|
+
nodes: [],
|
|
20
|
+
edges: ['INTERACTS_WITH']
|
|
21
|
+
},
|
|
22
|
+
dependencies: ['ExpressRouteAnalyzer', 'FetchAnalyzer']
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async execute(context) {
|
|
26
|
+
const { graph } = context;
|
|
27
|
+
try {
|
|
28
|
+
// Собираем все http:route (backend endpoints)
|
|
29
|
+
const routes = [];
|
|
30
|
+
for await (const node of graph.queryNodes({ type: 'http:route' })) {
|
|
31
|
+
routes.push(node);
|
|
32
|
+
}
|
|
33
|
+
// Собираем все http:request (frontend requests)
|
|
34
|
+
const requests = [];
|
|
35
|
+
for await (const node of graph.queryNodes({ type: 'http:request' })) {
|
|
36
|
+
requests.push(node);
|
|
37
|
+
}
|
|
38
|
+
console.log(`[HTTPConnectionEnricher] Found ${routes.length} routes, ${requests.length} requests`);
|
|
39
|
+
// Дедуплицируем по ID (из-за multi-service анализа)
|
|
40
|
+
const uniqueRoutes = this.deduplicateById(routes);
|
|
41
|
+
const uniqueRequests = this.deduplicateById(requests);
|
|
42
|
+
console.log(`[HTTPConnectionEnricher] Unique: ${uniqueRoutes.length} routes, ${uniqueRequests.length} requests`);
|
|
43
|
+
let edgesCreated = 0;
|
|
44
|
+
const connections = [];
|
|
45
|
+
// Для каждого request ищем matching route
|
|
46
|
+
for (const request of uniqueRequests) {
|
|
47
|
+
// Пропускаем dynamic URLs
|
|
48
|
+
if (request.url === 'dynamic' || !request.url) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const method = (request.method || 'GET').toUpperCase();
|
|
52
|
+
const url = request.url;
|
|
53
|
+
// Ищем matching route
|
|
54
|
+
for (const route of uniqueRoutes) {
|
|
55
|
+
const routeMethod = (route.method || 'GET').toUpperCase();
|
|
56
|
+
const routePath = route.path;
|
|
57
|
+
if (routePath && method === routeMethod && this.pathsMatch(url, routePath)) {
|
|
58
|
+
// Создаём edge
|
|
59
|
+
await graph.addEdge({
|
|
60
|
+
type: 'INTERACTS_WITH',
|
|
61
|
+
src: request.id,
|
|
62
|
+
dst: route.id,
|
|
63
|
+
matchType: this.hasParams(routePath) ? 'parametric' : 'exact'
|
|
64
|
+
});
|
|
65
|
+
connections.push({
|
|
66
|
+
request: `${method} ${url}`,
|
|
67
|
+
route: `${routeMethod} ${routePath}`,
|
|
68
|
+
requestFile: request.file,
|
|
69
|
+
routeFile: route.file
|
|
70
|
+
});
|
|
71
|
+
edgesCreated++;
|
|
72
|
+
break; // Один request → один route
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Логируем найденные связи
|
|
77
|
+
if (connections.length > 0) {
|
|
78
|
+
console.log(`[HTTPConnectionEnricher] Connections found:`);
|
|
79
|
+
for (const conn of connections) {
|
|
80
|
+
console.log(` ${conn.request} → ${conn.route}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return createSuccessResult({ nodes: 0, edges: edgesCreated }, {
|
|
84
|
+
connections: connections.length,
|
|
85
|
+
routesAnalyzed: uniqueRoutes.length,
|
|
86
|
+
requestsAnalyzed: uniqueRequests.length
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.error(`[HTTPConnectionEnricher] Error:`, error);
|
|
91
|
+
return createErrorResult(error instanceof Error ? error : new Error(String(error)));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Проверяет совпадают ли пути
|
|
96
|
+
* Поддерживает параметризованные пути: /api/users/:id матчится с /api/users/123
|
|
97
|
+
*/
|
|
98
|
+
pathsMatch(requestUrl, routePath) {
|
|
99
|
+
// Точное совпадение
|
|
100
|
+
if (requestUrl === routePath) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
// Если route не имеет параметров, требуем точное совпадение
|
|
104
|
+
if (!this.hasParams(routePath)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
// Преобразуем route path в regex
|
|
108
|
+
// /api/users/:id → /api/users/[^/]+
|
|
109
|
+
const regexPattern = routePath
|
|
110
|
+
.replace(/:[^/]+/g, '[^/]+') // :param → [^/]+
|
|
111
|
+
.replace(/\//g, '\\/'); // / → \/
|
|
112
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
113
|
+
return regex.test(requestUrl);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Проверяет есть ли параметры в пути
|
|
117
|
+
*/
|
|
118
|
+
hasParams(path) {
|
|
119
|
+
return Boolean(path && path.includes(':'));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Убирает дубликаты по ID
|
|
123
|
+
*/
|
|
124
|
+
deduplicateById(nodes) {
|
|
125
|
+
const seen = new Set();
|
|
126
|
+
const unique = [];
|
|
127
|
+
for (const node of nodes) {
|
|
128
|
+
if (!seen.has(node.id)) {
|
|
129
|
+
seen.add(node.id);
|
|
130
|
+
unique.push(node);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return unique;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImportExportLinker - создаёт IMPORTS_FROM edges между IMPORT и EXPORT нодами
|
|
3
|
+
*
|
|
4
|
+
* Этот enrichment plugin работает ПОСЛЕ JSASTAnalyzer и связывает:
|
|
5
|
+
* - IMPORT (default) -> IMPORTS_FROM -> EXPORT (default)
|
|
6
|
+
* - IMPORT (named) -> IMPORTS_FROM -> EXPORT (named, matching name)
|
|
7
|
+
*
|
|
8
|
+
* ОПТИМИЗАЦИЯ:
|
|
9
|
+
* Вместо O(n) итерации по всем EXPORT нодам для каждого импорта,
|
|
10
|
+
* строим индекс один раз и используем O(1) lookup.
|
|
11
|
+
*
|
|
12
|
+
* Индекс: Map<file, Map<exportKey, exportNode>>
|
|
13
|
+
* где exportKey = "default" | "named:functionName" | "all"
|
|
14
|
+
*/
|
|
15
|
+
import { Plugin } from '../Plugin.js';
|
|
16
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
17
|
+
export declare class ImportExportLinker extends Plugin {
|
|
18
|
+
get metadata(): PluginMetadata;
|
|
19
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Build index of all EXPORT nodes: Map<file, Map<exportKey, exportNode>>
|
|
22
|
+
* exportKey = "default" | "named:functionName" | "all"
|
|
23
|
+
*/
|
|
24
|
+
private buildExportIndex;
|
|
25
|
+
/**
|
|
26
|
+
* Build MODULE lookup: Map<file, moduleNode>
|
|
27
|
+
*/
|
|
28
|
+
private buildModuleLookup;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ImportExportLinker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportExportLinker.d.ts","sourceRoot":"","sources":["../../../src/plugins/enrichment/ImportExportLinker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAmBhF,qBAAa,kBAAmB,SAAQ,MAAM;IAC5C,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAyH5D;;;OAGG;YACW,gBAAgB;IA+B9B;;OAEG;YACW,iBAAiB;CAWhC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImportExportLinker - создаёт IMPORTS_FROM edges между IMPORT и EXPORT нодами
|
|
3
|
+
*
|
|
4
|
+
* Этот enrichment plugin работает ПОСЛЕ JSASTAnalyzer и связывает:
|
|
5
|
+
* - IMPORT (default) -> IMPORTS_FROM -> EXPORT (default)
|
|
6
|
+
* - IMPORT (named) -> IMPORTS_FROM -> EXPORT (named, matching name)
|
|
7
|
+
*
|
|
8
|
+
* ОПТИМИЗАЦИЯ:
|
|
9
|
+
* Вместо O(n) итерации по всем EXPORT нодам для каждого импорта,
|
|
10
|
+
* строим индекс один раз и используем O(1) lookup.
|
|
11
|
+
*
|
|
12
|
+
* Индекс: Map<file, Map<exportKey, exportNode>>
|
|
13
|
+
* где exportKey = "default" | "named:functionName" | "all"
|
|
14
|
+
*/
|
|
15
|
+
import { dirname, resolve } from 'path';
|
|
16
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
17
|
+
export class ImportExportLinker extends Plugin {
|
|
18
|
+
get metadata() {
|
|
19
|
+
return {
|
|
20
|
+
name: 'ImportExportLinker',
|
|
21
|
+
phase: 'ENRICHMENT',
|
|
22
|
+
priority: 90, // Run early in enrichment, after analysis
|
|
23
|
+
creates: {
|
|
24
|
+
nodes: [],
|
|
25
|
+
edges: ['IMPORTS_FROM']
|
|
26
|
+
},
|
|
27
|
+
dependencies: ['JSASTAnalyzer'] // Requires IMPORT and EXPORT nodes
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async execute(context) {
|
|
31
|
+
const { graph, onProgress } = context;
|
|
32
|
+
console.log('[ImportExportLinker] Starting import-export linking...');
|
|
33
|
+
const startTime = Date.now();
|
|
34
|
+
// Step 1: Build EXPORT index - Map<file, Map<exportKey, exportNode>>
|
|
35
|
+
const exportIndex = await this.buildExportIndex(graph);
|
|
36
|
+
const indexTime = Date.now() - startTime;
|
|
37
|
+
console.log(`[ImportExportLinker] Indexed exports from ${exportIndex.size} files in ${indexTime}ms`);
|
|
38
|
+
// Step 2: Build MODULE lookup - Map<file, moduleNode>
|
|
39
|
+
const modulesByFile = await this.buildModuleLookup(graph);
|
|
40
|
+
console.log(`[ImportExportLinker] Indexed ${modulesByFile.size} modules`);
|
|
41
|
+
// Step 3: Process all IMPORT nodes
|
|
42
|
+
const imports = [];
|
|
43
|
+
for await (const node of graph.queryNodes({ nodeType: 'IMPORT' })) {
|
|
44
|
+
imports.push(node);
|
|
45
|
+
}
|
|
46
|
+
console.log(`[ImportExportLinker] Found ${imports.length} imports to link`);
|
|
47
|
+
let edgesCreated = 0;
|
|
48
|
+
let skipped = 0;
|
|
49
|
+
let notFound = 0;
|
|
50
|
+
for (let i = 0; i < imports.length; i++) {
|
|
51
|
+
const imp = imports[i];
|
|
52
|
+
// Progress reporting
|
|
53
|
+
if (onProgress && i % 100 === 0) {
|
|
54
|
+
onProgress({
|
|
55
|
+
phase: 'enrichment',
|
|
56
|
+
currentPlugin: 'ImportExportLinker',
|
|
57
|
+
message: `Linking imports ${i}/${imports.length}`,
|
|
58
|
+
totalFiles: imports.length,
|
|
59
|
+
processedFiles: i
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// Skip external modules (non-relative imports)
|
|
63
|
+
const isRelative = imp.source && (imp.source.startsWith('./') || imp.source.startsWith('../'));
|
|
64
|
+
if (!isRelative) {
|
|
65
|
+
skipped++;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
// Resolve target file path
|
|
69
|
+
const currentDir = dirname(imp.file);
|
|
70
|
+
const basePath = resolve(currentDir, imp.source);
|
|
71
|
+
// Try different extensions
|
|
72
|
+
const extensions = ['', '.js', '.ts', '.jsx', '.tsx', '/index.js', '/index.ts'];
|
|
73
|
+
let targetFile = null;
|
|
74
|
+
let targetExports = null;
|
|
75
|
+
for (const ext of extensions) {
|
|
76
|
+
const testPath = basePath + ext;
|
|
77
|
+
if (exportIndex.has(testPath)) {
|
|
78
|
+
targetFile = testPath;
|
|
79
|
+
targetExports = exportIndex.get(testPath);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
// Also check modulesByFile in case exports haven't been indexed yet
|
|
83
|
+
if (!targetFile && modulesByFile.has(testPath)) {
|
|
84
|
+
targetFile = testPath;
|
|
85
|
+
targetExports = exportIndex.get(testPath) || new Map();
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!targetFile || !targetExports) {
|
|
90
|
+
notFound++;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// Find matching export based on import type
|
|
94
|
+
const importType = imp.importType; // 'default', 'named', or 'namespace'
|
|
95
|
+
let targetExport;
|
|
96
|
+
if (importType === 'namespace') {
|
|
97
|
+
// import * as foo - already linked to MODULE in GraphBuilder
|
|
98
|
+
skipped++;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
else if (importType === 'default') {
|
|
102
|
+
// import foo from './bar' -> find default export
|
|
103
|
+
targetExport = targetExports.get('default');
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// import { foo } from './bar' -> find named export 'foo'
|
|
107
|
+
const exportKey = `named:${imp.imported}`;
|
|
108
|
+
targetExport = targetExports.get(exportKey);
|
|
109
|
+
}
|
|
110
|
+
if (targetExport) {
|
|
111
|
+
await graph.addEdge({
|
|
112
|
+
type: 'IMPORTS_FROM',
|
|
113
|
+
src: imp.id,
|
|
114
|
+
dst: targetExport.id
|
|
115
|
+
});
|
|
116
|
+
edgesCreated++;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
notFound++;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const totalTime = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
123
|
+
console.log(`[ImportExportLinker] Complete: ${edgesCreated} edges created, ${skipped} skipped, ${notFound} not found (${totalTime}s)`);
|
|
124
|
+
return createSuccessResult({ nodes: 0, edges: edgesCreated }, {
|
|
125
|
+
importsProcessed: imports.length,
|
|
126
|
+
edgesCreated,
|
|
127
|
+
skipped,
|
|
128
|
+
notFound,
|
|
129
|
+
timeMs: Date.now() - startTime
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Build index of all EXPORT nodes: Map<file, Map<exportKey, exportNode>>
|
|
134
|
+
* exportKey = "default" | "named:functionName" | "all"
|
|
135
|
+
*/
|
|
136
|
+
async buildExportIndex(graph) {
|
|
137
|
+
const index = new Map();
|
|
138
|
+
for await (const node of graph.queryNodes({ nodeType: 'EXPORT' })) {
|
|
139
|
+
const exportNode = node;
|
|
140
|
+
if (!exportNode.file)
|
|
141
|
+
continue;
|
|
142
|
+
if (!index.has(exportNode.file)) {
|
|
143
|
+
index.set(exportNode.file, new Map());
|
|
144
|
+
}
|
|
145
|
+
const fileExports = index.get(exportNode.file);
|
|
146
|
+
// Build export key based on type
|
|
147
|
+
let exportKey;
|
|
148
|
+
if (exportNode.exportType === 'default') {
|
|
149
|
+
exportKey = 'default';
|
|
150
|
+
}
|
|
151
|
+
else if (exportNode.exportType === 'named') {
|
|
152
|
+
exportKey = `named:${exportNode.name}`;
|
|
153
|
+
}
|
|
154
|
+
else if (exportNode.exportType === 'all') {
|
|
155
|
+
exportKey = 'all';
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
exportKey = `unknown:${exportNode.name || 'anonymous'}`;
|
|
159
|
+
}
|
|
160
|
+
fileExports.set(exportKey, exportNode);
|
|
161
|
+
}
|
|
162
|
+
return index;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Build MODULE lookup: Map<file, moduleNode>
|
|
166
|
+
*/
|
|
167
|
+
async buildModuleLookup(graph) {
|
|
168
|
+
const lookup = new Map();
|
|
169
|
+
for await (const node of graph.queryNodes({ nodeType: 'MODULE' })) {
|
|
170
|
+
if (node.file) {
|
|
171
|
+
lookup.set(node.file, node);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return lookup;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InstanceOfResolver - резолвит INSTANCE_OF edges к правильным CLASS нодам
|
|
3
|
+
*
|
|
4
|
+
* Проблема: При параллельном анализе модулей, CLASS ноды для импортированных
|
|
5
|
+
* классов создаются как "заглушки" (isInstantiationRef: true) потому что
|
|
6
|
+
* исходный модуль может ещё не быть проанализирован.
|
|
7
|
+
*
|
|
8
|
+
* Решение: После анализа всех модулей этот плагин:
|
|
9
|
+
* 1. Находит все INSTANCE_OF edges
|
|
10
|
+
* 2. Для edges указывающих на "заглушки" (CLASS с isInstantiationRef)
|
|
11
|
+
* 3. Ищет настоящую CLASS декларацию через IMPORT → MODULE → CLASS
|
|
12
|
+
* 4. Перенаправляет INSTANCE_OF edge на настоящий CLASS
|
|
13
|
+
* 5. Удаляет "заглушку" CLASS ноду
|
|
14
|
+
*/
|
|
15
|
+
import { Plugin } from '../Plugin.js';
|
|
16
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
17
|
+
export declare class InstanceOfResolver extends Plugin {
|
|
18
|
+
get metadata(): PluginMetadata;
|
|
19
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=InstanceOfResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstanceOfResolver.d.ts","sourceRoot":"","sources":["../../../src/plugins/enrichment/InstanceOfResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA4BhF,qBAAa,kBAAmB,SAAQ,MAAM;IAC5C,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA0G7D"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InstanceOfResolver - резолвит INSTANCE_OF edges к правильным CLASS нодам
|
|
3
|
+
*
|
|
4
|
+
* Проблема: При параллельном анализе модулей, CLASS ноды для импортированных
|
|
5
|
+
* классов создаются как "заглушки" (isInstantiationRef: true) потому что
|
|
6
|
+
* исходный модуль может ещё не быть проанализирован.
|
|
7
|
+
*
|
|
8
|
+
* Решение: После анализа всех модулей этот плагин:
|
|
9
|
+
* 1. Находит все INSTANCE_OF edges
|
|
10
|
+
* 2. Для edges указывающих на "заглушки" (CLASS с isInstantiationRef)
|
|
11
|
+
* 3. Ищет настоящую CLASS декларацию через IMPORT → MODULE → CLASS
|
|
12
|
+
* 4. Перенаправляет INSTANCE_OF edge на настоящий CLASS
|
|
13
|
+
* 5. Удаляет "заглушку" CLASS ноду
|
|
14
|
+
*/
|
|
15
|
+
import { dirname, resolve } from 'path';
|
|
16
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
17
|
+
export class InstanceOfResolver extends Plugin {
|
|
18
|
+
get metadata() {
|
|
19
|
+
return {
|
|
20
|
+
name: 'InstanceOfResolver',
|
|
21
|
+
phase: 'ENRICHMENT',
|
|
22
|
+
priority: 100, // Высокий приоритет - должен выполняться перед другими enrichment плагинами
|
|
23
|
+
creates: {
|
|
24
|
+
nodes: [],
|
|
25
|
+
edges: ['INSTANCE_OF'] // Пере-создаёт INSTANCE_OF edges
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async execute(context) {
|
|
30
|
+
const { graph } = context;
|
|
31
|
+
let resolvedCount = 0;
|
|
32
|
+
let removedStubs = 0;
|
|
33
|
+
// 1. Собираем все CLASS ноды (декларации и заглушки)
|
|
34
|
+
const classDeclarations = new Map(); // file:name → classId (только настоящие декларации)
|
|
35
|
+
const classStubs = new Map(); // classId → { name, file }
|
|
36
|
+
for await (const node of graph.queryNodes({ type: 'CLASS' })) {
|
|
37
|
+
if (node.isInstantiationRef) {
|
|
38
|
+
classStubs.set(node.id, { name: node.name, file: node.file });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// Настоящая декларация
|
|
42
|
+
const key = `${node.file}:${node.name}`;
|
|
43
|
+
classDeclarations.set(key, node.id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (classStubs.size === 0) {
|
|
47
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { resolvedInstanceOf: 0, removedStubs: 0 });
|
|
48
|
+
}
|
|
49
|
+
// 2. Собираем импорты для резолва
|
|
50
|
+
const importMap = new Map(); // file:localName → { source, imported }
|
|
51
|
+
for await (const node of graph.queryNodes({ type: 'IMPORT' })) {
|
|
52
|
+
const importNode = node;
|
|
53
|
+
const key = `${node.file}:${importNode.local}`;
|
|
54
|
+
importMap.set(key, { source: importNode.source, imported: importNode.imported });
|
|
55
|
+
}
|
|
56
|
+
// 3. Для каждой заглушки пытаемся найти настоящую декларацию
|
|
57
|
+
const edgesToUpdate = [];
|
|
58
|
+
const stubsToRemove = [];
|
|
59
|
+
for (const [stubId, stubInfo] of classStubs) {
|
|
60
|
+
const { name, file } = stubInfo;
|
|
61
|
+
// Проверяем есть ли импорт для этого класса
|
|
62
|
+
const importKey = `${file}:${name}`;
|
|
63
|
+
const importInfo = importMap.get(importKey);
|
|
64
|
+
if (!importInfo)
|
|
65
|
+
continue;
|
|
66
|
+
const { source, imported } = importInfo;
|
|
67
|
+
// Только относительные импорты (локальные модули)
|
|
68
|
+
if (!source.startsWith('./') && !source.startsWith('../'))
|
|
69
|
+
continue;
|
|
70
|
+
// Резолвим путь к исходному модулю
|
|
71
|
+
const moduleDir = dirname(file);
|
|
72
|
+
let resolvedPath = resolve(moduleDir, source);
|
|
73
|
+
if (!resolvedPath.endsWith('.js') && !resolvedPath.endsWith('.ts') && !resolvedPath.endsWith('.mjs')) {
|
|
74
|
+
resolvedPath += '.js';
|
|
75
|
+
}
|
|
76
|
+
// Ищем CLASS декларацию в исходном модуле
|
|
77
|
+
const importedClassName = imported === 'default' ? name : imported;
|
|
78
|
+
const declarationKey = `${resolvedPath}:${importedClassName}`;
|
|
79
|
+
const realClassId = classDeclarations.get(declarationKey);
|
|
80
|
+
if (realClassId) {
|
|
81
|
+
// Нашли настоящий класс!
|
|
82
|
+
// Собираем INSTANCE_OF edges указывающие на заглушку
|
|
83
|
+
const incomingEdges = await graph.getIncomingEdges(stubId, ['INSTANCE_OF']);
|
|
84
|
+
for (const edge of incomingEdges) {
|
|
85
|
+
edgesToUpdate.push({
|
|
86
|
+
src: edge.src,
|
|
87
|
+
oldDst: stubId,
|
|
88
|
+
newDst: realClassId
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
stubsToRemove.push(stubId);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// 4. Обновляем edges (удаляем старые, создаём новые)
|
|
95
|
+
for (const update of edgesToUpdate) {
|
|
96
|
+
// Удаляем старый edge (if supported)
|
|
97
|
+
if (graph.deleteEdge) {
|
|
98
|
+
await graph.deleteEdge(update.src, update.oldDst, 'INSTANCE_OF');
|
|
99
|
+
}
|
|
100
|
+
// Создаём новый edge
|
|
101
|
+
await graph.addEdge({
|
|
102
|
+
type: 'INSTANCE_OF',
|
|
103
|
+
src: update.src,
|
|
104
|
+
dst: update.newDst
|
|
105
|
+
});
|
|
106
|
+
resolvedCount++;
|
|
107
|
+
}
|
|
108
|
+
// 5. Удаляем заглушки (if supported)
|
|
109
|
+
for (const stubId of stubsToRemove) {
|
|
110
|
+
if (graph.deleteNode) {
|
|
111
|
+
await graph.deleteNode(stubId);
|
|
112
|
+
removedStubs++;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return createSuccessResult({ nodes: 0, edges: resolvedCount }, { resolvedInstanceOf: resolvedCount, removedStubs: removedStubs });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import { Plugin } from '../Plugin.js';
|
|
14
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
15
|
+
export declare class MethodCallResolver extends Plugin {
|
|
16
|
+
private _containingClassCache?;
|
|
17
|
+
get metadata(): PluginMetadata;
|
|
18
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Строит индекс классов и их методов
|
|
21
|
+
*/
|
|
22
|
+
private buildClassMethodIndex;
|
|
23
|
+
/**
|
|
24
|
+
* Строит индекс переменных и их типов (из INSTANCE_OF рёбер)
|
|
25
|
+
*/
|
|
26
|
+
private buildVariableTypeIndex;
|
|
27
|
+
/**
|
|
28
|
+
* Пытается найти определение метода
|
|
29
|
+
*/
|
|
30
|
+
private resolveMethodCall;
|
|
31
|
+
/**
|
|
32
|
+
* Находит класс, содержащий данный method call
|
|
33
|
+
*/
|
|
34
|
+
private findContainingClass;
|
|
35
|
+
private findContainingClassRecursive;
|
|
36
|
+
/**
|
|
37
|
+
* Проверяет является ли метод внешним (console, Array, Promise, etc.)
|
|
38
|
+
*/
|
|
39
|
+
private isExternalMethod;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=MethodCallResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodCallResolver.d.ts","sourceRoot":"","sources":["../../../src/plugins/enrichment/MethodCallResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAmBhF,qBAAa,kBAAmB,SAAQ,MAAM;IAC5C,OAAO,CAAC,qBAAqB,CAAC,CAAqC;IAEnE,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA8F5D;;OAEG;YACW,qBAAqB;IA0CnC;;OAEG;YACW,sBAAsB;IAkBpC;;OAEG;YACW,iBAAiB;IA0D/B;;OAEG;YACW,mBAAmB;YAqBnB,4BAA4B;IAyB1C;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAWzB"}
|