@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,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DatabaseAnalyzer - анализ database access patterns
|
|
3
|
+
* Детектирует db.query(), connection.query() и другие SQL вызовы
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import { parse } from '@babel/parser';
|
|
7
|
+
import traverseModule from '@babel/traverse';
|
|
8
|
+
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
const traverse = traverseModule.default || traverseModule;
|
|
11
|
+
export class DatabaseAnalyzer extends Plugin {
|
|
12
|
+
get metadata() {
|
|
13
|
+
return {
|
|
14
|
+
name: 'DatabaseAnalyzer',
|
|
15
|
+
phase: 'ANALYSIS',
|
|
16
|
+
priority: 75, // После JSASTAnalyzer (80)
|
|
17
|
+
creates: {
|
|
18
|
+
nodes: ['db:query', 'db:table', 'db:connection'],
|
|
19
|
+
edges: ['MAKES_QUERY', 'TARGETS', 'READS_FROM', 'WRITES_TO']
|
|
20
|
+
},
|
|
21
|
+
dependencies: ['JSASTAnalyzer'] // Требует MODULE и FUNCTION ноды
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async execute(context) {
|
|
25
|
+
try {
|
|
26
|
+
const { graph } = context;
|
|
27
|
+
// Получаем все MODULE ноды
|
|
28
|
+
const modules = await this.getModules(graph);
|
|
29
|
+
console.log(`[DatabaseAnalyzer] Processing ${modules.length} modules...`);
|
|
30
|
+
// Получаем все FUNCTION ноды для связывания
|
|
31
|
+
const functions = await this.getFunctions(graph);
|
|
32
|
+
let queriesCreated = 0;
|
|
33
|
+
let tablesCreated = 0;
|
|
34
|
+
let edgesCreated = 0;
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
// Анализируем каждый модуль
|
|
37
|
+
for (let i = 0; i < modules.length; i++) {
|
|
38
|
+
const module = modules[i];
|
|
39
|
+
const result = await this.analyzeModule(module, functions, graph);
|
|
40
|
+
queriesCreated += result.queries;
|
|
41
|
+
tablesCreated += result.tables;
|
|
42
|
+
edgesCreated += result.edges;
|
|
43
|
+
// Progress every 20 modules
|
|
44
|
+
if ((i + 1) % 20 === 0 || i === modules.length - 1) {
|
|
45
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
46
|
+
const avgTime = ((Date.now() - startTime) / (i + 1)).toFixed(0);
|
|
47
|
+
console.log(`[DatabaseAnalyzer] Progress: ${i + 1}/${modules.length} (${elapsed}s, avg ${avgTime}ms/module)`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
console.log(`[DatabaseAnalyzer] Created ${queriesCreated} queries, ${tablesCreated} tables`);
|
|
51
|
+
return createSuccessResult({
|
|
52
|
+
nodes: queriesCreated + tablesCreated,
|
|
53
|
+
edges: edgesCreated
|
|
54
|
+
}, {
|
|
55
|
+
queriesCreated,
|
|
56
|
+
tablesCreated
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error(`[DatabaseAnalyzer] Error:`, error);
|
|
61
|
+
return createErrorResult(error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Получить все FUNCTION ноды из графа
|
|
66
|
+
*/
|
|
67
|
+
async getFunctions(graph) {
|
|
68
|
+
const functions = [];
|
|
69
|
+
for await (const node of graph.queryNodes({ type: 'FUNCTION' })) {
|
|
70
|
+
functions.push(node);
|
|
71
|
+
}
|
|
72
|
+
return functions;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Анализировать один модуль на database patterns
|
|
76
|
+
*/
|
|
77
|
+
async analyzeModule(module, functions, graph) {
|
|
78
|
+
let queriesCreated = 0;
|
|
79
|
+
let tablesCreated = 0;
|
|
80
|
+
let edgesCreated = 0;
|
|
81
|
+
try {
|
|
82
|
+
// Читаем и парсим файл
|
|
83
|
+
const code = readFileSync(module.file, 'utf-8');
|
|
84
|
+
const ast = parse(code, {
|
|
85
|
+
sourceType: 'module',
|
|
86
|
+
plugins: ['jsx']
|
|
87
|
+
});
|
|
88
|
+
const databaseQueries = [];
|
|
89
|
+
const createdTables = new Set();
|
|
90
|
+
let queryCounter = 0;
|
|
91
|
+
// Ищем db.query() паттерны
|
|
92
|
+
traverse(ast, {
|
|
93
|
+
CallExpression: (path) => {
|
|
94
|
+
const node = path.node;
|
|
95
|
+
// Проверяем что это MemberExpression: db.query(), connection.execute()
|
|
96
|
+
if (node.callee.type === 'MemberExpression') {
|
|
97
|
+
const methodName = node.callee.property.name;
|
|
98
|
+
const objectName = node.callee.object.name;
|
|
99
|
+
// Детектируем database queries
|
|
100
|
+
const isDatabaseQuery = (methodName === 'query' || methodName === 'execute') &&
|
|
101
|
+
(objectName === 'db' || objectName === 'connection' || objectName === 'pool') &&
|
|
102
|
+
node.arguments.length >= 1;
|
|
103
|
+
if (isDatabaseQuery) {
|
|
104
|
+
const sqlArg = node.arguments[0];
|
|
105
|
+
let sql = null;
|
|
106
|
+
let operation = 'UNKNOWN';
|
|
107
|
+
// Извлекаем SQL строку
|
|
108
|
+
if (sqlArg.type === 'StringLiteral') {
|
|
109
|
+
sql = sqlArg.value;
|
|
110
|
+
}
|
|
111
|
+
else if (sqlArg.type === 'TemplateLiteral') {
|
|
112
|
+
// Template literal - собираем строку с placeholders
|
|
113
|
+
sql = sqlArg.quasis.map(q => q.value.raw).join('${...}');
|
|
114
|
+
}
|
|
115
|
+
// Определяем тип операции и таблицу из SQL
|
|
116
|
+
if (sql) {
|
|
117
|
+
const sqlUpper = sql.trim().toUpperCase();
|
|
118
|
+
let tableName = null;
|
|
119
|
+
if (sqlUpper.startsWith('SELECT')) {
|
|
120
|
+
operation = 'SELECT';
|
|
121
|
+
const fromMatch = sqlUpper.match(/FROM\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
122
|
+
if (fromMatch)
|
|
123
|
+
tableName = fromMatch[1].toLowerCase();
|
|
124
|
+
}
|
|
125
|
+
else if (sqlUpper.startsWith('INSERT')) {
|
|
126
|
+
operation = 'INSERT';
|
|
127
|
+
const intoMatch = sqlUpper.match(/INTO\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
128
|
+
if (intoMatch)
|
|
129
|
+
tableName = intoMatch[1].toLowerCase();
|
|
130
|
+
}
|
|
131
|
+
else if (sqlUpper.startsWith('UPDATE')) {
|
|
132
|
+
operation = 'UPDATE';
|
|
133
|
+
const updateMatch = sqlUpper.match(/UPDATE\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
134
|
+
if (updateMatch)
|
|
135
|
+
tableName = updateMatch[1].toLowerCase();
|
|
136
|
+
}
|
|
137
|
+
else if (sqlUpper.startsWith('DELETE')) {
|
|
138
|
+
operation = 'DELETE';
|
|
139
|
+
const deleteMatch = sqlUpper.match(/FROM\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
140
|
+
if (deleteMatch)
|
|
141
|
+
tableName = deleteMatch[1].toLowerCase();
|
|
142
|
+
}
|
|
143
|
+
else if (sqlUpper.startsWith('CREATE')) {
|
|
144
|
+
operation = 'CREATE';
|
|
145
|
+
const createMatch = sqlUpper.match(/TABLE\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
146
|
+
if (createMatch)
|
|
147
|
+
tableName = createMatch[1].toLowerCase();
|
|
148
|
+
}
|
|
149
|
+
else if (sqlUpper.startsWith('DROP')) {
|
|
150
|
+
operation = 'DROP';
|
|
151
|
+
const dropMatch = sqlUpper.match(/TABLE\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
152
|
+
if (dropMatch)
|
|
153
|
+
tableName = dropMatch[1].toLowerCase();
|
|
154
|
+
}
|
|
155
|
+
else if (sqlUpper.startsWith('ALTER')) {
|
|
156
|
+
operation = 'ALTER';
|
|
157
|
+
const alterMatch = sqlUpper.match(/TABLE\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
158
|
+
if (alterMatch)
|
|
159
|
+
tableName = alterMatch[1].toLowerCase();
|
|
160
|
+
}
|
|
161
|
+
const queryId = queryCounter++;
|
|
162
|
+
const sqlSnippet = sql.length > 50 ? sql.substring(0, 50) + '...' : sql;
|
|
163
|
+
databaseQueries.push({
|
|
164
|
+
id: `${module.file}:DATABASE_QUERY:${queryId}`,
|
|
165
|
+
type: 'db:query',
|
|
166
|
+
sql: sql,
|
|
167
|
+
sqlSnippet: sqlSnippet,
|
|
168
|
+
operation: operation,
|
|
169
|
+
tableName: tableName,
|
|
170
|
+
object: objectName,
|
|
171
|
+
method: methodName,
|
|
172
|
+
file: module.file,
|
|
173
|
+
line: node.loc.start.line
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
// Создаём EXTERNAL_DATABASE ноду если есть хотя бы один query
|
|
181
|
+
if (databaseQueries.length > 0) {
|
|
182
|
+
const databaseId = 'EXTERNAL_DATABASE:__database__';
|
|
183
|
+
const existingDb = await graph.getNode(databaseId);
|
|
184
|
+
if (!existingDb) {
|
|
185
|
+
await graph.addNode({
|
|
186
|
+
id: databaseId,
|
|
187
|
+
type: 'db:connection',
|
|
188
|
+
name: '__database__'
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// Создаём DATABASE_QUERY ноды
|
|
192
|
+
for (const query of databaseQueries) {
|
|
193
|
+
await graph.addNode(query);
|
|
194
|
+
queriesCreated++;
|
|
195
|
+
// Создаём TABLE ноду если есть tableName
|
|
196
|
+
if (query.tableName) {
|
|
197
|
+
const tableId = `TABLE:${query.tableName}`;
|
|
198
|
+
if (!createdTables.has(tableId)) {
|
|
199
|
+
await graph.addNode({
|
|
200
|
+
id: tableId,
|
|
201
|
+
type: 'db:table',
|
|
202
|
+
name: query.tableName
|
|
203
|
+
});
|
|
204
|
+
tablesCreated++;
|
|
205
|
+
createdTables.add(tableId);
|
|
206
|
+
}
|
|
207
|
+
// DATABASE_QUERY -> TARGETS -> TABLE
|
|
208
|
+
await graph.addEdge({
|
|
209
|
+
type: 'TARGETS',
|
|
210
|
+
src: query.id,
|
|
211
|
+
dst: tableId
|
|
212
|
+
});
|
|
213
|
+
edgesCreated++;
|
|
214
|
+
}
|
|
215
|
+
// DATABASE_QUERY -> (READS_FROM | WRITES_TO) -> __database__
|
|
216
|
+
const isReadOperation = query.operation === 'SELECT';
|
|
217
|
+
const edgeType = isReadOperation ? 'READS_FROM' : 'WRITES_TO';
|
|
218
|
+
await graph.addEdge({
|
|
219
|
+
type: edgeType,
|
|
220
|
+
src: query.id,
|
|
221
|
+
dst: databaseId
|
|
222
|
+
});
|
|
223
|
+
edgesCreated++;
|
|
224
|
+
// Находим родительскую функцию для MAKES_QUERY ребра
|
|
225
|
+
const parentFunction = this.findParentFunction(query, functions);
|
|
226
|
+
if (parentFunction) {
|
|
227
|
+
await graph.addEdge({
|
|
228
|
+
type: 'MAKES_QUERY',
|
|
229
|
+
src: parentFunction.id,
|
|
230
|
+
dst: query.id
|
|
231
|
+
});
|
|
232
|
+
edgesCreated++;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
console.error(`[DatabaseAnalyzer] Error analyzing ${module.file}:`, error.message);
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
queries: queriesCreated,
|
|
242
|
+
tables: tablesCreated,
|
|
243
|
+
edges: edgesCreated
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Найти родительскую функцию для database query
|
|
248
|
+
*/
|
|
249
|
+
findParentFunction(query, functions) {
|
|
250
|
+
// Ищем функцию в том же файле, которая содержит эту строку
|
|
251
|
+
const candidates = functions.filter(f => f.file === query.file && (f.line ?? 0) < query.line // Функция должна начинаться раньше query
|
|
252
|
+
);
|
|
253
|
+
// Берём ближайшую (с максимальным line number меньше query.line)
|
|
254
|
+
if (candidates.length > 0) {
|
|
255
|
+
candidates.sort((a, b) => (b.line ?? 0) - (a.line ?? 0));
|
|
256
|
+
return candidates[0];
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExpressAnalyzer - анализ Express.js patterns
|
|
3
|
+
* Детектирует HTTP routes и mount points через AST парсинг
|
|
4
|
+
*/
|
|
5
|
+
import { Plugin } from '../Plugin.js';
|
|
6
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
7
|
+
export declare class ExpressAnalyzer extends Plugin {
|
|
8
|
+
get metadata(): PluginMetadata;
|
|
9
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Анализировать один модуль на Express patterns
|
|
12
|
+
*/
|
|
13
|
+
private analyzeModule;
|
|
14
|
+
/**
|
|
15
|
+
* Создать MOUNTS рёбра для mount point
|
|
16
|
+
*/
|
|
17
|
+
private createMountEdges;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ExpressAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/ExpressAnalyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAoDhF,qBAAa,eAAgB,SAAQ,MAAM;IACzC,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA8C5D;;OAEG;YACW,aAAa;IA6N3B;;OAEG;YACW,gBAAgB;CAiD/B"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExpressAnalyzer - анализ Express.js patterns
|
|
3
|
+
* Детектирует HTTP routes и mount points через AST парсинг
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import { parse } from '@babel/parser';
|
|
7
|
+
import traverseModule from '@babel/traverse';
|
|
8
|
+
import { dirname, resolve } from 'path';
|
|
9
|
+
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
const traverse = traverseModule.default || traverseModule;
|
|
12
|
+
export class ExpressAnalyzer extends Plugin {
|
|
13
|
+
get metadata() {
|
|
14
|
+
return {
|
|
15
|
+
name: 'ExpressAnalyzer',
|
|
16
|
+
phase: 'ANALYSIS',
|
|
17
|
+
priority: 75, // После JSASTAnalyzer (80)
|
|
18
|
+
creates: {
|
|
19
|
+
nodes: ['http:route', 'express:mount'],
|
|
20
|
+
edges: ['EXPOSES', 'MOUNTS', 'DEFINES']
|
|
21
|
+
},
|
|
22
|
+
dependencies: ['JSASTAnalyzer'] // Требует MODULE ноды
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async execute(context) {
|
|
26
|
+
try {
|
|
27
|
+
const { graph } = context;
|
|
28
|
+
// Создаём net:request ноду (дедупликация в GraphBackend)
|
|
29
|
+
const networkId = 'net:request#__network__';
|
|
30
|
+
await graph.addNode({
|
|
31
|
+
id: networkId,
|
|
32
|
+
type: 'net:request',
|
|
33
|
+
name: '__network__',
|
|
34
|
+
description: 'External HTTP network'
|
|
35
|
+
});
|
|
36
|
+
// Получаем все MODULE ноды
|
|
37
|
+
const modules = await this.getModules(graph);
|
|
38
|
+
let endpointsCreated = 0;
|
|
39
|
+
let mountPointsCreated = 0;
|
|
40
|
+
let edgesCreated = 0;
|
|
41
|
+
// Анализируем каждый модуль
|
|
42
|
+
for (const module of modules) {
|
|
43
|
+
const result = await this.analyzeModule(module, graph, networkId);
|
|
44
|
+
endpointsCreated += result.endpoints;
|
|
45
|
+
mountPointsCreated += result.mountPoints;
|
|
46
|
+
edgesCreated += result.edges;
|
|
47
|
+
}
|
|
48
|
+
console.log(`[ExpressAnalyzer] Created ${endpointsCreated} endpoints, ${mountPointsCreated} mount points`);
|
|
49
|
+
return createSuccessResult({
|
|
50
|
+
nodes: endpointsCreated + mountPointsCreated + 1, // +1 для EXTERNAL_NETWORK
|
|
51
|
+
edges: edgesCreated
|
|
52
|
+
}, {
|
|
53
|
+
endpointsCreated,
|
|
54
|
+
mountPointsCreated
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error(`[ExpressAnalyzer] Error:`, error);
|
|
59
|
+
return createErrorResult(error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Анализировать один модуль на Express patterns
|
|
64
|
+
*/
|
|
65
|
+
async analyzeModule(module, graph, networkId) {
|
|
66
|
+
let endpointsCreated = 0;
|
|
67
|
+
let mountPointsCreated = 0;
|
|
68
|
+
let edgesCreated = 0;
|
|
69
|
+
try {
|
|
70
|
+
// Читаем и парсим файл
|
|
71
|
+
const code = readFileSync(module.file, 'utf-8');
|
|
72
|
+
const ast = parse(code, {
|
|
73
|
+
sourceType: 'module',
|
|
74
|
+
plugins: ['jsx']
|
|
75
|
+
});
|
|
76
|
+
const endpoints = [];
|
|
77
|
+
const mountPoints = [];
|
|
78
|
+
const imports = [];
|
|
79
|
+
// Собираем импорты для резолвинга mount points
|
|
80
|
+
traverse(ast, {
|
|
81
|
+
ImportDeclaration: (path) => {
|
|
82
|
+
const importNode = path.node;
|
|
83
|
+
const source = importNode.source.value;
|
|
84
|
+
// Собираем specifiers
|
|
85
|
+
const specifiers = importNode.specifiers
|
|
86
|
+
.map(spec => {
|
|
87
|
+
if (spec.type === 'ImportDefaultSpecifier') {
|
|
88
|
+
return { local: spec.local.name, imported: 'default' };
|
|
89
|
+
}
|
|
90
|
+
else if (spec.type === 'ImportSpecifier') {
|
|
91
|
+
const imported = spec.imported.type === 'Identifier' ? spec.imported.name : spec.imported.value;
|
|
92
|
+
return { local: spec.local.name, imported };
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
})
|
|
96
|
+
.filter((s) => s !== null);
|
|
97
|
+
imports.push({
|
|
98
|
+
source,
|
|
99
|
+
specifiers,
|
|
100
|
+
line: importNode.loc.start.line
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// Ищем Express patterns
|
|
105
|
+
traverse(ast, {
|
|
106
|
+
CallExpression: (path) => {
|
|
107
|
+
const node = path.node;
|
|
108
|
+
// Проверяем что это MemberExpression: app.get(), router.use(), и т.д.
|
|
109
|
+
if (node.callee.type === 'MemberExpression') {
|
|
110
|
+
const methodName = node.callee.property.name;
|
|
111
|
+
const objectName = node.callee.object.name;
|
|
112
|
+
// Детектируем routes
|
|
113
|
+
const httpMethods = ['get', 'post', 'put', 'delete', 'patch', 'options', 'head'];
|
|
114
|
+
const isRouteDefinition = httpMethods.includes(methodName?.toLowerCase()) &&
|
|
115
|
+
(objectName === 'app' || objectName === 'router') &&
|
|
116
|
+
node.arguments.length >= 2;
|
|
117
|
+
if (isRouteDefinition) {
|
|
118
|
+
const pathArg = node.arguments[0];
|
|
119
|
+
let routePath = null;
|
|
120
|
+
if (pathArg.type === 'StringLiteral') {
|
|
121
|
+
routePath = pathArg.value;
|
|
122
|
+
}
|
|
123
|
+
else if (pathArg.type === 'TemplateLiteral' && pathArg.quasis.length === 1) {
|
|
124
|
+
routePath = pathArg.quasis[0].value.raw;
|
|
125
|
+
}
|
|
126
|
+
if (routePath) {
|
|
127
|
+
const method = methodName.toUpperCase();
|
|
128
|
+
endpoints.push({
|
|
129
|
+
id: `http:route#${method}:${routePath}#${module.file}#${node.loc.start.line}`,
|
|
130
|
+
type: 'http:route',
|
|
131
|
+
method: method,
|
|
132
|
+
path: routePath,
|
|
133
|
+
localPath: routePath,
|
|
134
|
+
file: module.file,
|
|
135
|
+
line: node.loc.start.line,
|
|
136
|
+
mountedOn: objectName
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Детектируем mount points
|
|
141
|
+
const isMountPoint = methodName === 'use' &&
|
|
142
|
+
(objectName === 'app' || objectName === 'router') &&
|
|
143
|
+
node.arguments.length >= 1;
|
|
144
|
+
if (isMountPoint) {
|
|
145
|
+
let prefix = null;
|
|
146
|
+
let targetFunction = null;
|
|
147
|
+
let targetVariable = null;
|
|
148
|
+
let targetArg = null;
|
|
149
|
+
// Определяем структуру аргументов
|
|
150
|
+
if (node.arguments.length === 1) {
|
|
151
|
+
// app.use(middleware) - без префикса
|
|
152
|
+
targetArg = node.arguments[0];
|
|
153
|
+
prefix = '/';
|
|
154
|
+
}
|
|
155
|
+
else if (node.arguments.length >= 2) {
|
|
156
|
+
// app.use('/prefix', router) - с префиксом
|
|
157
|
+
const firstArg = node.arguments[0];
|
|
158
|
+
targetArg = node.arguments[1];
|
|
159
|
+
// Извлекаем префикс
|
|
160
|
+
if (firstArg.type === 'StringLiteral') {
|
|
161
|
+
prefix = firstArg.value;
|
|
162
|
+
}
|
|
163
|
+
else if (firstArg.type === 'TemplateLiteral') {
|
|
164
|
+
if (firstArg.quasis.length === 1 && firstArg.expressions.length === 0) {
|
|
165
|
+
prefix = firstArg.quasis[0].value.raw;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
prefix = '${template}';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else if (firstArg.type === 'BinaryExpression') {
|
|
172
|
+
prefix = '${binary}';
|
|
173
|
+
}
|
|
174
|
+
else if (firstArg.type === 'Identifier') {
|
|
175
|
+
prefix = '${variable}';
|
|
176
|
+
}
|
|
177
|
+
else if (firstArg.type === 'CallExpression') {
|
|
178
|
+
prefix = '${call}';
|
|
179
|
+
}
|
|
180
|
+
else if (firstArg.type === 'MemberExpression') {
|
|
181
|
+
prefix = '${member}';
|
|
182
|
+
}
|
|
183
|
+
else if (firstArg.type === 'ConditionalExpression') {
|
|
184
|
+
prefix = '${conditional}';
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
prefix = '${expression}';
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Извлекаем target
|
|
191
|
+
if (targetArg) {
|
|
192
|
+
if (targetArg.type === 'CallExpression') {
|
|
193
|
+
if (targetArg.callee.type === 'Identifier') {
|
|
194
|
+
targetFunction = targetArg.callee.name;
|
|
195
|
+
}
|
|
196
|
+
else if (targetArg.callee.type === 'MemberExpression' &&
|
|
197
|
+
targetArg.callee.object.type === 'Identifier') {
|
|
198
|
+
targetVariable = targetArg.callee.object.name;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (targetArg.type === 'Identifier') {
|
|
202
|
+
targetVariable = targetArg.name;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Создаём mount point
|
|
206
|
+
if ((targetFunction || targetVariable) && prefix) {
|
|
207
|
+
mountPoints.push({
|
|
208
|
+
id: `express:mount#${prefix}#${module.file}#${node.loc.start.line}`,
|
|
209
|
+
type: 'express:mount',
|
|
210
|
+
prefix: prefix,
|
|
211
|
+
targetFunction: targetFunction,
|
|
212
|
+
targetVariable: targetVariable,
|
|
213
|
+
file: module.file,
|
|
214
|
+
line: node.loc.start.line,
|
|
215
|
+
mountedOn: objectName
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
// Создаём ENDPOINT ноды
|
|
223
|
+
for (const endpoint of endpoints) {
|
|
224
|
+
await graph.addNode(endpoint);
|
|
225
|
+
endpointsCreated++;
|
|
226
|
+
// MODULE --EXPOSES--> ENDPOINT
|
|
227
|
+
await graph.addEdge({
|
|
228
|
+
type: 'EXPOSES',
|
|
229
|
+
src: module.id,
|
|
230
|
+
dst: endpoint.id
|
|
231
|
+
});
|
|
232
|
+
edgesCreated++;
|
|
233
|
+
// ENDPOINT --INTERACTS_WITH--> EXTERNAL_NETWORK
|
|
234
|
+
await graph.addEdge({
|
|
235
|
+
type: 'INTERACTS_WITH',
|
|
236
|
+
src: endpoint.id,
|
|
237
|
+
dst: networkId
|
|
238
|
+
});
|
|
239
|
+
edgesCreated++;
|
|
240
|
+
}
|
|
241
|
+
// Создаём MOUNT_POINT ноды
|
|
242
|
+
for (const mountPoint of mountPoints) {
|
|
243
|
+
await graph.addNode(mountPoint);
|
|
244
|
+
mountPointsCreated++;
|
|
245
|
+
// MODULE --DEFINES--> MOUNT_POINT
|
|
246
|
+
await graph.addEdge({
|
|
247
|
+
type: 'DEFINES',
|
|
248
|
+
src: module.id,
|
|
249
|
+
dst: mountPoint.id
|
|
250
|
+
});
|
|
251
|
+
edgesCreated++;
|
|
252
|
+
// Создаём MOUNTS рёбра
|
|
253
|
+
const mountEdges = await this.createMountEdges(mountPoint, module, imports, graph);
|
|
254
|
+
edgesCreated += mountEdges;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
console.error(`[ExpressAnalyzer] Error analyzing ${module.file}:`, error.message);
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
endpoints: endpointsCreated,
|
|
262
|
+
mountPoints: mountPointsCreated,
|
|
263
|
+
edges: edgesCreated
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Создать MOUNTS рёбра для mount point
|
|
268
|
+
*/
|
|
269
|
+
async createMountEdges(mountPoint, module, imports, graph) {
|
|
270
|
+
let edgesCreated = 0;
|
|
271
|
+
// Резолвим через импорты: какой модуль экспортирует targetFunction или targetVariable?
|
|
272
|
+
let targetModulePath = null;
|
|
273
|
+
const targetName = mountPoint.targetFunction || mountPoint.targetVariable;
|
|
274
|
+
if (targetName) {
|
|
275
|
+
for (const imp of imports) {
|
|
276
|
+
const isRelative = imp.source.startsWith('./') || imp.source.startsWith('../');
|
|
277
|
+
if (!isRelative)
|
|
278
|
+
continue;
|
|
279
|
+
// Проверяем есть ли targetName среди specifiers
|
|
280
|
+
const hasTarget = imp.specifiers &&
|
|
281
|
+
imp.specifiers.some(spec => spec.local === targetName || spec.imported === targetName);
|
|
282
|
+
if (hasTarget) {
|
|
283
|
+
// Резолвим путь к модулю
|
|
284
|
+
const currentDir = dirname(module.file);
|
|
285
|
+
targetModulePath = resolve(currentDir, imp.source);
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// Если нашли целевой модуль, создаем MOUNTS ребро
|
|
291
|
+
if (targetModulePath) {
|
|
292
|
+
const targetModuleId = `${targetModulePath}:MODULE:${targetModulePath}:0`;
|
|
293
|
+
// Проверяем что модуль существует в графе
|
|
294
|
+
const targetModule = await graph.getNode(targetModuleId);
|
|
295
|
+
if (targetModule) {
|
|
296
|
+
await graph.addEdge({
|
|
297
|
+
type: 'MOUNTS',
|
|
298
|
+
src: mountPoint.id,
|
|
299
|
+
dst: targetModuleId
|
|
300
|
+
});
|
|
301
|
+
edgesCreated++;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return edgesCreated;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExpressRouteAnalyzer - детектит Express/Router endpoints с middleware chains
|
|
3
|
+
*
|
|
4
|
+
* Паттерны:
|
|
5
|
+
* - router.get('/path', handler)
|
|
6
|
+
* - router.post('/path', middleware1, middleware2, handler)
|
|
7
|
+
* - app.use('/prefix', middleware)
|
|
8
|
+
* - router.get('/path', asyncHandler(async (req, res) => {...}))
|
|
9
|
+
*/
|
|
10
|
+
import { Plugin } from '../Plugin.js';
|
|
11
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
12
|
+
export declare class ExpressRouteAnalyzer extends Plugin {
|
|
13
|
+
get metadata(): PluginMetadata;
|
|
14
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
15
|
+
private analyzeModule;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ExpressRouteAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpressRouteAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/ExpressRouteAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA8ChF,qBAAa,oBAAqB,SAAQ,MAAM;IAC9C,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;YAgD9C,aAAa;CAiS5B"}
|