@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,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZonServiceDiscovery - плагин для поиска сервисов в zon1 монорепозитории
|
|
3
|
+
*
|
|
4
|
+
* Точная реализация логики из file2host.js:
|
|
5
|
+
* 1. Читает servers.js - база данных серверов
|
|
6
|
+
* 2. Использует zserver_conf.prepare_conf() для получения конфигурации каждого сервера
|
|
7
|
+
* 3. Читает k8s/deploy/configs/apps.json - kubernetes приложения
|
|
8
|
+
* 4. Извлекает entrypoint'ы для каждого сервиса
|
|
9
|
+
*/
|
|
10
|
+
import { DiscoveryPlugin } from './DiscoveryPlugin.js';
|
|
11
|
+
import { createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
12
|
+
import { existsSync, readFileSync } from 'fs';
|
|
13
|
+
import { join } from 'path';
|
|
14
|
+
import { createRequire } from 'module';
|
|
15
|
+
export class ZonServiceDiscovery extends DiscoveryPlugin {
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
super(config);
|
|
18
|
+
}
|
|
19
|
+
// Debug: show which file was loaded at runtime
|
|
20
|
+
static __loaded = (() => {
|
|
21
|
+
try {
|
|
22
|
+
console.log('[ZonServiceDiscovery] module loaded from', import.meta.url);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Ignore
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
})();
|
|
29
|
+
get metadata() {
|
|
30
|
+
return {
|
|
31
|
+
name: 'ZonServiceDiscovery',
|
|
32
|
+
phase: 'DISCOVERY',
|
|
33
|
+
priority: 100,
|
|
34
|
+
creates: {
|
|
35
|
+
nodes: ['SERVICE'],
|
|
36
|
+
edges: []
|
|
37
|
+
},
|
|
38
|
+
dependencies: []
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
hostname_base(hostname) {
|
|
42
|
+
return hostname.replace(/(-ec2)?\d*$/, '$1');
|
|
43
|
+
}
|
|
44
|
+
async execute(context) {
|
|
45
|
+
const { projectPath, graph } = context;
|
|
46
|
+
console.log(`[ZonServiceDiscovery] Scanning ${projectPath}`);
|
|
47
|
+
try {
|
|
48
|
+
// Set environment variable to avoid BUILD error
|
|
49
|
+
process.env.ZON_CONFIG_FALLBACK = '1';
|
|
50
|
+
const services = [];
|
|
51
|
+
const require = createRequire(import.meta.url);
|
|
52
|
+
// Paths
|
|
53
|
+
const serversDbPath = join(projectPath, 'pkg/system/db/servers.js');
|
|
54
|
+
const zserverConfPath = join(projectPath, 'pkg/system/agent/zserver_conf.js');
|
|
55
|
+
const appsJsonPath = join(projectPath, 'pkg/k8s/deploy/configs/apps.json');
|
|
56
|
+
// Check if this is zon1 repository
|
|
57
|
+
if (!existsSync(serversDbPath)) {
|
|
58
|
+
console.log(`[ZonServiceDiscovery] servers.js not found - not a zon1 repository`);
|
|
59
|
+
return createErrorResult(new Error(`Not a zon1 repository - servers.js not found`));
|
|
60
|
+
}
|
|
61
|
+
console.log(`[ZonServiceDiscovery] Loading servers.js...`);
|
|
62
|
+
// Load modules
|
|
63
|
+
let servers_js;
|
|
64
|
+
let zserver_conf;
|
|
65
|
+
let k8s_apps = {};
|
|
66
|
+
try {
|
|
67
|
+
// Clear require cache to get fresh modules
|
|
68
|
+
delete require.cache[require.resolve(serversDbPath)];
|
|
69
|
+
delete require.cache[require.resolve(zserverConfPath)];
|
|
70
|
+
servers_js = require(serversDbPath);
|
|
71
|
+
console.log(`[ZonServiceDiscovery] Loaded servers.js`);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
console.log(`[ZonServiceDiscovery] Failed to load servers.js:`, err.message);
|
|
75
|
+
return createErrorResult(err);
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
zserver_conf = require(zserverConfPath);
|
|
79
|
+
console.log(`[ZonServiceDiscovery] Loaded zserver_conf.js`);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
console.log(`[ZonServiceDiscovery] Failed to load zserver_conf.js:`, err.message);
|
|
83
|
+
return createErrorResult(err);
|
|
84
|
+
}
|
|
85
|
+
// Load k8s apps (optional)
|
|
86
|
+
if (existsSync(appsJsonPath)) {
|
|
87
|
+
try {
|
|
88
|
+
const appsContent = readFileSync(appsJsonPath, 'utf-8');
|
|
89
|
+
k8s_apps = JSON.parse(appsContent);
|
|
90
|
+
console.log(`[ZonServiceDiscovery] Loaded k8s apps.json`);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
console.log(`[ZonServiceDiscovery] Warning: Failed to load apps.json:`, err.message);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Build service tree - exact logic from file2host.js
|
|
97
|
+
const allServers = Object.entries(servers_js.servers);
|
|
98
|
+
// Note: file2host uses v.file2host filter, but we'll use entrypoint presence
|
|
99
|
+
const k8sEntries = Object.entries(k8s_apps).filter(([, v]) => v.entrypoint);
|
|
100
|
+
console.log(`[ZonServiceDiscovery] Processing ${allServers.length} servers and ${k8sEntries.length} k8s apps...`);
|
|
101
|
+
const processedGroups = new Set();
|
|
102
|
+
const serviceMap = new Map(); // entrypoint -> {hosts: [...]}
|
|
103
|
+
// Process traditional servers - exact logic from file2host.js
|
|
104
|
+
for (const [hostname, serverConfig] of allServers) {
|
|
105
|
+
const is_zagent = servers_js.lib.re.zagent.test(hostname);
|
|
106
|
+
// Skip LPM zagents (util files are transcoded during build)
|
|
107
|
+
if (is_zagent && serverConfig.type === 'lpm') {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const hostGroup = is_zagent
|
|
111
|
+
? `${serverConfig.type} zagents`
|
|
112
|
+
: this.hostname_base(hostname);
|
|
113
|
+
if (processedGroups.has(hostGroup)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
processedGroups.add(hostGroup);
|
|
117
|
+
try {
|
|
118
|
+
// Get configuration - exact call from file2host.js
|
|
119
|
+
const conf = zserver_conf.prepare_conf(hostname)
|
|
120
|
+
.filter(c => (c.conf || c.init) && c.file)
|
|
121
|
+
.map(({ init, file }) => {
|
|
122
|
+
if (!init) {
|
|
123
|
+
return file.split('.conf')[0];
|
|
124
|
+
}
|
|
125
|
+
return init.upstart.xvfs.split(' ')[0];
|
|
126
|
+
});
|
|
127
|
+
for (const service of conf) {
|
|
128
|
+
if (!serviceMap.has(service)) {
|
|
129
|
+
serviceMap.set(service, { hosts: [] });
|
|
130
|
+
}
|
|
131
|
+
serviceMap.get(service).hosts.push({
|
|
132
|
+
hostGroup,
|
|
133
|
+
hostname,
|
|
134
|
+
type: 'traditional'
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
console.log(`[ZonServiceDiscovery] Error processing ${hostname}:`, err.message);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Process k8s applications - exact logic from file2host.js
|
|
143
|
+
for (const [name, config] of k8sEntries) {
|
|
144
|
+
if (config.entrypoint) {
|
|
145
|
+
const entrypoint = config.entrypoint.replace('pkg/', '');
|
|
146
|
+
if (!serviceMap.has(entrypoint)) {
|
|
147
|
+
serviceMap.set(entrypoint, { hosts: [] });
|
|
148
|
+
}
|
|
149
|
+
serviceMap.get(entrypoint).hosts.push({
|
|
150
|
+
hostGroup: name,
|
|
151
|
+
hostname: name,
|
|
152
|
+
type: 'k8s'
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
console.log(`[ZonServiceDiscovery] Found ${serviceMap.size} unique services`);
|
|
157
|
+
// Show first 20 services as preview
|
|
158
|
+
const serviceList = Array.from(serviceMap.keys()).sort();
|
|
159
|
+
console.log(`[ZonServiceDiscovery] Services (showing first 20 of ${serviceList.length}):`);
|
|
160
|
+
serviceList.slice(0, 20).forEach(s => {
|
|
161
|
+
const hosts = serviceMap.get(s).hosts;
|
|
162
|
+
console.log(` - ${s} (${hosts.length} host${hosts.length > 1 ? 's' : ''})`);
|
|
163
|
+
});
|
|
164
|
+
if (serviceList.length > 20) {
|
|
165
|
+
console.log(` ... and ${serviceList.length - 20} more`);
|
|
166
|
+
}
|
|
167
|
+
// Create SERVICE nodes
|
|
168
|
+
for (const [entrypoint, data] of serviceMap) {
|
|
169
|
+
// Use format matching VersionManager.generateStableId()
|
|
170
|
+
const serviceId = `SERVICE:${entrypoint}`;
|
|
171
|
+
const servicePath = join(projectPath, 'pkg', entrypoint);
|
|
172
|
+
// Cast through unknown since we're creating a dynamic service node
|
|
173
|
+
const metadata = {
|
|
174
|
+
discoveryMethod: 'zon',
|
|
175
|
+
entrypoint,
|
|
176
|
+
hosts: data.hosts,
|
|
177
|
+
hostCount: data.hosts.length
|
|
178
|
+
};
|
|
179
|
+
const serviceNode = {
|
|
180
|
+
id: serviceId,
|
|
181
|
+
type: 'SERVICE',
|
|
182
|
+
name: entrypoint,
|
|
183
|
+
path: servicePath,
|
|
184
|
+
metadata
|
|
185
|
+
};
|
|
186
|
+
await graph.addNode(serviceNode);
|
|
187
|
+
services.push({
|
|
188
|
+
id: serviceId,
|
|
189
|
+
name: entrypoint,
|
|
190
|
+
path: servicePath,
|
|
191
|
+
type: 'zon-service',
|
|
192
|
+
metadata
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
console.log(`[ZonServiceDiscovery] Created ${services.length} SERVICE nodes`);
|
|
196
|
+
return createSuccessResult({ nodes: services.length, edges: 0 }, { services });
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
console.error(`[ZonServiceDiscovery] Fatal error:`, error);
|
|
200
|
+
console.error(error.stack);
|
|
201
|
+
return createErrorResult(error);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AliasTracker - резолвит вызовы через алиасы
|
|
3
|
+
*
|
|
4
|
+
* Проблема: `const m = obj.method; m()` не резолвится как method call
|
|
5
|
+
* Решение: трассируем ASSIGNED_FROM цепочки чтобы найти оригинальный источник
|
|
6
|
+
*
|
|
7
|
+
* ИСПОЛЬЗУЕТ:
|
|
8
|
+
* - VARIABLE -> ASSIGNED_FROM -> EXPRESSION (из JSASTAnalyzer)
|
|
9
|
+
* - EXPRESSION с expressionType='MemberExpression'
|
|
10
|
+
*
|
|
11
|
+
* СОЗДАЁТ:
|
|
12
|
+
* - CALL -> CALLS -> METHOD/FUNCTION (когда алиас резолвится)
|
|
13
|
+
* - CALL -> ALIAS_OF -> EXPRESSION (для трассировки)
|
|
14
|
+
*/
|
|
15
|
+
import { Plugin } from '../Plugin.js';
|
|
16
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
17
|
+
export declare class AliasTracker extends Plugin {
|
|
18
|
+
static MAX_DEPTH: number;
|
|
19
|
+
private depthExceeded;
|
|
20
|
+
get metadata(): PluginMetadata;
|
|
21
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Строит индекс алиасов: file:variableName -> EXPRESSION info
|
|
24
|
+
* Поддерживает транзитивные цепочки: a = b; b = c; c = obj.method
|
|
25
|
+
*/
|
|
26
|
+
private buildAliasIndex;
|
|
27
|
+
/**
|
|
28
|
+
* Рекурсивно ищет EXPRESSION источник через цепочки ASSIGNED_FROM
|
|
29
|
+
*/
|
|
30
|
+
private findExpressionSource;
|
|
31
|
+
/**
|
|
32
|
+
* Строит индекс методов для резолвинга: className:methodName -> METHOD node
|
|
33
|
+
*/
|
|
34
|
+
private buildMethodIndex;
|
|
35
|
+
/**
|
|
36
|
+
* Пытается резолвить алиасированный method call
|
|
37
|
+
*/
|
|
38
|
+
private resolveAliasedMethodCall;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=AliasTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AliasTracker.d.ts","sourceRoot":"","sources":["../../../src/plugins/enrichment/AliasTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAgDhF,qBAAa,YAAa,SAAQ,MAAM;IACtC,MAAM,CAAC,SAAS,SAAM;IACtB,OAAO,CAAC,aAAa,CAA2B;IAEhD,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAmH5D;;;OAGG;YACW,eAAe;IAkC7B;;OAEG;YACW,oBAAoB;IAsDlC;;OAEG;YACW,gBAAgB;IAyB9B;;OAEG;YACW,wBAAwB;CA6EvC"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AliasTracker - резолвит вызовы через алиасы
|
|
3
|
+
*
|
|
4
|
+
* Проблема: `const m = obj.method; m()` не резолвится как method call
|
|
5
|
+
* Решение: трассируем ASSIGNED_FROM цепочки чтобы найти оригинальный источник
|
|
6
|
+
*
|
|
7
|
+
* ИСПОЛЬЗУЕТ:
|
|
8
|
+
* - VARIABLE -> ASSIGNED_FROM -> EXPRESSION (из JSASTAnalyzer)
|
|
9
|
+
* - EXPRESSION с expressionType='MemberExpression'
|
|
10
|
+
*
|
|
11
|
+
* СОЗДАЁТ:
|
|
12
|
+
* - CALL -> CALLS -> METHOD/FUNCTION (когда алиас резолвится)
|
|
13
|
+
* - CALL -> ALIAS_OF -> EXPRESSION (для трассировки)
|
|
14
|
+
*/
|
|
15
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
16
|
+
export class AliasTracker extends Plugin {
|
|
17
|
+
static MAX_DEPTH = 10;
|
|
18
|
+
depthExceeded = [];
|
|
19
|
+
get metadata() {
|
|
20
|
+
return {
|
|
21
|
+
name: 'AliasTracker',
|
|
22
|
+
phase: 'ENRICHMENT',
|
|
23
|
+
priority: 60, // После MethodCallResolver (50)
|
|
24
|
+
creates: {
|
|
25
|
+
nodes: [],
|
|
26
|
+
edges: ['CALLS', 'ALIAS_OF']
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async execute(context) {
|
|
31
|
+
const { graph, onProgress } = context;
|
|
32
|
+
console.log('[AliasTracker] Starting alias resolution...');
|
|
33
|
+
let callsProcessed = 0;
|
|
34
|
+
let aliasesFound = 0;
|
|
35
|
+
let edgesCreated = 0;
|
|
36
|
+
let resolvedToMethod = 0;
|
|
37
|
+
// Трекинг превышений глубины
|
|
38
|
+
this.depthExceeded = [];
|
|
39
|
+
// 1. Найти все CALL без object (call sites) которые ещё не резолвлены
|
|
40
|
+
const unresolvedCalls = [];
|
|
41
|
+
for await (const node of graph.queryNodes({ nodeType: 'CALL' })) {
|
|
42
|
+
const callNode = node;
|
|
43
|
+
// Пропускаем method calls (у них есть object)
|
|
44
|
+
if (callNode.object)
|
|
45
|
+
continue;
|
|
46
|
+
// Пропускаем уже резолвленные
|
|
47
|
+
const existingEdges = await graph.getOutgoingEdges(node.id, ['CALLS']);
|
|
48
|
+
if (existingEdges.length > 0)
|
|
49
|
+
continue;
|
|
50
|
+
unresolvedCalls.push(callNode);
|
|
51
|
+
}
|
|
52
|
+
console.log(`[AliasTracker] Found ${unresolvedCalls.length} unresolved call sites`);
|
|
53
|
+
// 2. Строим индекс алиасов: variableName -> EXPRESSION info
|
|
54
|
+
const aliasIndex = await this.buildAliasIndex(graph);
|
|
55
|
+
console.log(`[AliasTracker] Found ${aliasIndex.size} potential aliases`);
|
|
56
|
+
// 3. Строим индекс методов для резолвинга
|
|
57
|
+
const methodIndex = await this.buildMethodIndex(graph);
|
|
58
|
+
// 4. Обрабатываем каждый нерезолвленный вызов
|
|
59
|
+
for (const call of unresolvedCalls) {
|
|
60
|
+
callsProcessed++;
|
|
61
|
+
// Report progress every 50 calls
|
|
62
|
+
if (onProgress && callsProcessed % 50 === 0) {
|
|
63
|
+
onProgress({
|
|
64
|
+
phase: 'enrichment',
|
|
65
|
+
currentPlugin: 'AliasTracker',
|
|
66
|
+
message: `Tracking aliases ${callsProcessed}/${unresolvedCalls.length}`,
|
|
67
|
+
totalFiles: unresolvedCalls.length,
|
|
68
|
+
processedFiles: callsProcessed
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const callName = call.name;
|
|
72
|
+
const callFile = call.file;
|
|
73
|
+
// Ищем алиас с таким же именем в том же файле
|
|
74
|
+
const aliasKey = `${callFile}:${callName}`;
|
|
75
|
+
const alias = aliasIndex.get(aliasKey);
|
|
76
|
+
if (!alias)
|
|
77
|
+
continue;
|
|
78
|
+
aliasesFound++;
|
|
79
|
+
// Создаём ALIAS_OF ребро для трассировки
|
|
80
|
+
await graph.addEdge({
|
|
81
|
+
src: call.id,
|
|
82
|
+
dst: alias.expressionId,
|
|
83
|
+
type: 'ALIAS_OF'
|
|
84
|
+
});
|
|
85
|
+
edgesCreated++;
|
|
86
|
+
// Если это MemberExpression - пробуем резолвить как method call
|
|
87
|
+
if (alias.expressionType === 'MemberExpression') {
|
|
88
|
+
const targetMethod = await this.resolveAliasedMethodCall(alias.object, alias.property, callFile, methodIndex, graph, alias.computedPropertyVar // Pass variable name for computed access
|
|
89
|
+
);
|
|
90
|
+
if (targetMethod) {
|
|
91
|
+
await graph.addEdge({
|
|
92
|
+
src: call.id,
|
|
93
|
+
dst: targetMethod.id,
|
|
94
|
+
type: 'CALLS'
|
|
95
|
+
});
|
|
96
|
+
edgesCreated++;
|
|
97
|
+
resolvedToMethod++;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const summary = {
|
|
102
|
+
callsProcessed,
|
|
103
|
+
aliasesFound,
|
|
104
|
+
edgesCreated,
|
|
105
|
+
resolvedToMethod,
|
|
106
|
+
aliasesIndexed: aliasIndex.size,
|
|
107
|
+
depthExceeded: this.depthExceeded.length
|
|
108
|
+
};
|
|
109
|
+
// Алярм если были превышения глубины
|
|
110
|
+
if (this.depthExceeded.length > 0) {
|
|
111
|
+
console.warn(`[AliasTracker] ⚠️ WARNING: ${this.depthExceeded.length} alias chain(s) exceeded max depth (${AliasTracker.MAX_DEPTH}):`);
|
|
112
|
+
for (const info of this.depthExceeded) {
|
|
113
|
+
console.warn(` - ${info.file}:${info.name} (chain: ${info.chain.join(' → ')}...)`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
console.log('[AliasTracker] Summary:', summary);
|
|
117
|
+
return createSuccessResult({ nodes: 0, edges: edgesCreated }, summary);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Строит индекс алиасов: file:variableName -> EXPRESSION info
|
|
121
|
+
* Поддерживает транзитивные цепочки: a = b; b = c; c = obj.method
|
|
122
|
+
*/
|
|
123
|
+
async buildAliasIndex(graph) {
|
|
124
|
+
const index = new Map();
|
|
125
|
+
// Находим все VARIABLE ноды
|
|
126
|
+
for await (const varNode of graph.queryNodes({ nodeType: 'VARIABLE' })) {
|
|
127
|
+
const expressionSource = await this.findExpressionSource(varNode, graph, new Set());
|
|
128
|
+
if (expressionSource) {
|
|
129
|
+
const key = `${varNode.file}:${varNode.name}`;
|
|
130
|
+
index.set(key, {
|
|
131
|
+
variableId: varNode.id,
|
|
132
|
+
variableName: varNode.name,
|
|
133
|
+
...expressionSource,
|
|
134
|
+
file: varNode.file
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Также проверяем CONSTANT ноды (const m = obj.method)
|
|
139
|
+
for await (const constNode of graph.queryNodes({ nodeType: 'CONSTANT' })) {
|
|
140
|
+
const expressionSource = await this.findExpressionSource(constNode, graph, new Set());
|
|
141
|
+
if (expressionSource) {
|
|
142
|
+
const key = `${constNode.file}:${constNode.name}`;
|
|
143
|
+
index.set(key, {
|
|
144
|
+
variableId: constNode.id,
|
|
145
|
+
variableName: constNode.name,
|
|
146
|
+
...expressionSource,
|
|
147
|
+
file: constNode.file
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return index;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Рекурсивно ищет EXPRESSION источник через цепочки ASSIGNED_FROM
|
|
155
|
+
*/
|
|
156
|
+
async findExpressionSource(node, graph, visited, depth = 0, chain = []) {
|
|
157
|
+
// Добавляем текущую ноду в цепочку
|
|
158
|
+
chain.push(node.name || node.id);
|
|
159
|
+
// Защита от бесконечных циклов
|
|
160
|
+
if (visited.has(node.id.toString()))
|
|
161
|
+
return null;
|
|
162
|
+
visited.add(node.id.toString());
|
|
163
|
+
// Защита от слишком глубоких цепочек
|
|
164
|
+
if (depth > AliasTracker.MAX_DEPTH) {
|
|
165
|
+
this.depthExceeded.push({
|
|
166
|
+
file: node.file,
|
|
167
|
+
name: chain[0],
|
|
168
|
+
chain: chain.slice(0, 5),
|
|
169
|
+
depth: depth
|
|
170
|
+
});
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
// Получаем ASSIGNED_FROM рёбра
|
|
174
|
+
const assignedFromEdges = await graph.getOutgoingEdges(node.id, ['ASSIGNED_FROM']);
|
|
175
|
+
for (const edge of assignedFromEdges) {
|
|
176
|
+
const targetNode = await graph.getNode(edge.dst);
|
|
177
|
+
if (!targetNode)
|
|
178
|
+
continue;
|
|
179
|
+
// Если это EXPRESSION - нашли источник!
|
|
180
|
+
if (targetNode.type === 'EXPRESSION') {
|
|
181
|
+
return {
|
|
182
|
+
expressionId: targetNode.id,
|
|
183
|
+
expressionType: targetNode.expressionType,
|
|
184
|
+
object: targetNode.object,
|
|
185
|
+
property: targetNode.property,
|
|
186
|
+
computed: targetNode.computed,
|
|
187
|
+
computedPropertyVar: targetNode.computedPropertyVar
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// Если это VARIABLE или CONSTANT - идём глубже (транзитивно)
|
|
191
|
+
if (targetNode.type === 'VARIABLE' || targetNode.type === 'CONSTANT') {
|
|
192
|
+
const result = await this.findExpressionSource(targetNode, graph, visited, depth + 1, chain);
|
|
193
|
+
if (result)
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Строит индекс методов для резолвинга: className:methodName -> METHOD node
|
|
201
|
+
*/
|
|
202
|
+
async buildMethodIndex(graph) {
|
|
203
|
+
const index = new Map();
|
|
204
|
+
// Индексируем методы классов
|
|
205
|
+
for await (const classNode of graph.queryNodes({ nodeType: 'CLASS' })) {
|
|
206
|
+
const className = classNode.name;
|
|
207
|
+
if (!className)
|
|
208
|
+
continue;
|
|
209
|
+
const containsEdges = await graph.getOutgoingEdges(classNode.id, ['CONTAINS']);
|
|
210
|
+
for (const edge of containsEdges) {
|
|
211
|
+
const childNode = await graph.getNode(edge.dst);
|
|
212
|
+
if (childNode && (childNode.type === 'METHOD' || childNode.type === 'FUNCTION')) {
|
|
213
|
+
if (childNode.name) {
|
|
214
|
+
// По имени класса
|
|
215
|
+
index.set(`${className}:${childNode.name}`, childNode);
|
|
216
|
+
// По файлу и имени класса
|
|
217
|
+
index.set(`${classNode.file}:${className}:${childNode.name}`, childNode);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return index;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Пытается резолвить алиасированный method call
|
|
226
|
+
*/
|
|
227
|
+
async resolveAliasedMethodCall(objectName, propertyName, file, methodIndex, graph, computedPropertyVar = null) {
|
|
228
|
+
if (!objectName || !propertyName)
|
|
229
|
+
return null;
|
|
230
|
+
// Если property вычисляемый - пробуем трассировать через computedPropertyVar
|
|
231
|
+
if (propertyName === '<computed>') {
|
|
232
|
+
if (!computedPropertyVar) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
if (!graph.findByAttr) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
const varNodes = await graph.findByAttr({
|
|
239
|
+
name: computedPropertyVar,
|
|
240
|
+
file: file
|
|
241
|
+
});
|
|
242
|
+
for (const varId of varNodes) {
|
|
243
|
+
const assignedFromEdges = await graph.getOutgoingEdges(varId, ['ASSIGNED_FROM']);
|
|
244
|
+
for (const edge of assignedFromEdges) {
|
|
245
|
+
const targetNode = await graph.getNode(edge.dst);
|
|
246
|
+
if (targetNode && targetNode.type === 'LITERAL' && typeof targetNode.value === 'string') {
|
|
247
|
+
propertyName = targetNode.value;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (propertyName !== '<computed>')
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
if (propertyName === '<computed>') {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// 1. Проверяем прямое имя класса
|
|
259
|
+
const directKey = `${objectName}:${propertyName}`;
|
|
260
|
+
if (methodIndex.has(directKey)) {
|
|
261
|
+
return methodIndex.get(directKey);
|
|
262
|
+
}
|
|
263
|
+
// 2. Проверяем локальный класс в том же файле
|
|
264
|
+
const localKey = `${file}:${objectName}:${propertyName}`;
|
|
265
|
+
if (methodIndex.has(localKey)) {
|
|
266
|
+
return methodIndex.get(localKey);
|
|
267
|
+
}
|
|
268
|
+
// 3. Ищем переменную с типом (INSTANCE_OF)
|
|
269
|
+
if (!graph.findByAttr) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const varNodes = await graph.findByAttr({
|
|
273
|
+
name: objectName,
|
|
274
|
+
file: file
|
|
275
|
+
});
|
|
276
|
+
for (const varId of varNodes) {
|
|
277
|
+
const instanceOfEdges = await graph.getOutgoingEdges(varId, ['INSTANCE_OF']);
|
|
278
|
+
for (const edge of instanceOfEdges) {
|
|
279
|
+
const classNode = await graph.getNode(edge.dst);
|
|
280
|
+
if (classNode && classNode.name) {
|
|
281
|
+
const classKey = `${classNode.name}:${propertyName}`;
|
|
282
|
+
if (methodIndex.has(classKey)) {
|
|
283
|
+
return methodIndex.get(classKey);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 } from '../Plugin.js';
|
|
12
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
13
|
+
export declare class HTTPConnectionEnricher extends Plugin {
|
|
14
|
+
get metadata(): PluginMetadata;
|
|
15
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Проверяет совпадают ли пути
|
|
18
|
+
* Поддерживает параметризованные пути: /api/users/:id матчится с /api/users/123
|
|
19
|
+
*/
|
|
20
|
+
private pathsMatch;
|
|
21
|
+
/**
|
|
22
|
+
* Проверяет есть ли параметры в пути
|
|
23
|
+
*/
|
|
24
|
+
private hasParams;
|
|
25
|
+
/**
|
|
26
|
+
* Убирает дубликаты по ID
|
|
27
|
+
*/
|
|
28
|
+
private deduplicateById;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=HTTPConnectionEnricher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTTPConnectionEnricher.d.ts","sourceRoot":"","sources":["../../../src/plugins/enrichment/HTTPConnectionEnricher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA8BhF,qBAAa,sBAAuB,SAAQ,MAAM;IAChD,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAuF5D;;;OAGG;IACH,OAAO,CAAC,UAAU;IAqBlB;;OAEG;IACH,OAAO,CAAC,SAAS;IAIjB;;OAEG;IACH,OAAO,CAAC,eAAe;CAaxB"}
|