@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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RustAnalyzer - plugin for analyzing Rust source files
|
|
3
|
+
* Uses syn parser via NAPI to extract functions, structs, impl blocks, traits
|
|
4
|
+
* Detects #[napi] attributes for FFI linking
|
|
5
|
+
*/
|
|
6
|
+
import { Plugin } from '../Plugin.js';
|
|
7
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
8
|
+
export declare class RustAnalyzer extends Plugin {
|
|
9
|
+
get metadata(): PluginMetadata;
|
|
10
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
11
|
+
private processParseResult;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=RustAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RustAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/RustAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAsJhF,qBAAa,YAAa,SAAQ,MAAM;IACtC,IAAI,QAAQ,IAAI,cAAc,CAkB7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;YA4E9C,kBAAkB;CAsLjC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RustAnalyzer - plugin for analyzing Rust source files
|
|
3
|
+
* Uses syn parser via NAPI to extract functions, structs, impl blocks, traits
|
|
4
|
+
* Detects #[napi] attributes for FFI linking
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync } from 'fs';
|
|
7
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
8
|
+
// NAPI binding - will be exported from rust-engine after build
|
|
9
|
+
let parseRustFile;
|
|
10
|
+
// Try to load the native binding
|
|
11
|
+
try {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
const nativeBinding = await import('../../../../rust-engine/grafema-graph-engine.node');
|
|
14
|
+
parseRustFile = nativeBinding.parseRustFile;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Fallback: try require
|
|
18
|
+
try {
|
|
19
|
+
const { createRequire } = await import('module');
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
21
|
+
const nativeBinding = require('../../../../rust-engine/grafema-graph-engine.node');
|
|
22
|
+
parseRustFile = nativeBinding.parseRustFile;
|
|
23
|
+
}
|
|
24
|
+
catch (e2) {
|
|
25
|
+
console.warn('[RustAnalyzer] Native binding not available:', e2.message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class RustAnalyzer extends Plugin {
|
|
29
|
+
get metadata() {
|
|
30
|
+
return {
|
|
31
|
+
name: 'RustAnalyzer',
|
|
32
|
+
phase: 'ANALYSIS',
|
|
33
|
+
priority: 75, // Lower than JSASTAnalyzer (80)
|
|
34
|
+
creates: {
|
|
35
|
+
nodes: [
|
|
36
|
+
'RUST_FUNCTION',
|
|
37
|
+
'RUST_STRUCT',
|
|
38
|
+
'RUST_IMPL',
|
|
39
|
+
'RUST_METHOD',
|
|
40
|
+
'RUST_TRAIT',
|
|
41
|
+
'RUST_CALL'
|
|
42
|
+
],
|
|
43
|
+
edges: ['CONTAINS', 'IMPLEMENTS']
|
|
44
|
+
},
|
|
45
|
+
dependencies: ['RustModuleIndexer']
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async execute(context) {
|
|
49
|
+
const { graph, onProgress } = context;
|
|
50
|
+
if (!parseRustFile) {
|
|
51
|
+
console.log('[RustAnalyzer] Skipping - native binding not available');
|
|
52
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { skipped: true, reason: 'Native binding not available' });
|
|
53
|
+
}
|
|
54
|
+
// Get all RUST_MODULE nodes
|
|
55
|
+
const modules = [];
|
|
56
|
+
for await (const node of graph.queryNodes({ nodeType: 'RUST_MODULE' })) {
|
|
57
|
+
modules.push(node);
|
|
58
|
+
}
|
|
59
|
+
if (modules.length === 0) {
|
|
60
|
+
console.log('[RustAnalyzer] No RUST_MODULE nodes found, skipping');
|
|
61
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { skipped: true, reason: 'No modules' });
|
|
62
|
+
}
|
|
63
|
+
console.log(`[RustAnalyzer] Analyzing ${modules.length} Rust modules...`);
|
|
64
|
+
const stats = {
|
|
65
|
+
functions: 0,
|
|
66
|
+
structs: 0,
|
|
67
|
+
impls: 0,
|
|
68
|
+
methods: 0,
|
|
69
|
+
traits: 0,
|
|
70
|
+
calls: 0,
|
|
71
|
+
edges: 0
|
|
72
|
+
};
|
|
73
|
+
const errors = [];
|
|
74
|
+
for (let i = 0; i < modules.length; i++) {
|
|
75
|
+
const module = modules[i];
|
|
76
|
+
try {
|
|
77
|
+
const code = readFileSync(module.file, 'utf-8');
|
|
78
|
+
const parseResult = parseRustFile(code);
|
|
79
|
+
const result = await this.processParseResult(parseResult, module, graph);
|
|
80
|
+
stats.functions += result.functions;
|
|
81
|
+
stats.structs += result.structs;
|
|
82
|
+
stats.impls += result.impls;
|
|
83
|
+
stats.methods += result.methods;
|
|
84
|
+
stats.traits += result.traits;
|
|
85
|
+
stats.calls += result.calls;
|
|
86
|
+
stats.edges += result.edges;
|
|
87
|
+
if (onProgress && (i + 1) % 5 === 0) {
|
|
88
|
+
onProgress({
|
|
89
|
+
phase: 'analysis',
|
|
90
|
+
currentPlugin: 'RustAnalyzer',
|
|
91
|
+
message: `Analyzed ${i + 1}/${modules.length} Rust modules`,
|
|
92
|
+
totalFiles: modules.length,
|
|
93
|
+
processedFiles: i + 1
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
errors.push({ file: module.file, error: err.message });
|
|
99
|
+
console.error(`[RustAnalyzer] Error parsing ${module.file}:`, err.message);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (errors.length > 0) {
|
|
103
|
+
console.warn(`[RustAnalyzer] ${errors.length} errors during analysis`);
|
|
104
|
+
}
|
|
105
|
+
console.log(`[RustAnalyzer] Created: ${JSON.stringify(stats)}`);
|
|
106
|
+
return createSuccessResult({ nodes: stats.functions + stats.structs + stats.impls + stats.methods + stats.traits + stats.calls, edges: stats.edges }, { ...stats, errors: errors.length });
|
|
107
|
+
}
|
|
108
|
+
async processParseResult(parseResult, module, graph) {
|
|
109
|
+
const edges = [];
|
|
110
|
+
let methodCount = 0;
|
|
111
|
+
let callCount = 0;
|
|
112
|
+
// Helper to process calls within a function/method
|
|
113
|
+
const processCalls = async (calls, parentId, parentName) => {
|
|
114
|
+
for (const call of calls || []) {
|
|
115
|
+
const callId = `RUST_CALL#${parentName}#${call.line}#${call.column}#${module.file}`;
|
|
116
|
+
await graph.addNode({
|
|
117
|
+
id: callId,
|
|
118
|
+
type: 'RUST_CALL',
|
|
119
|
+
file: module.file,
|
|
120
|
+
line: call.line,
|
|
121
|
+
column: call.column,
|
|
122
|
+
callType: call.callType, // "function" | "method" | "macro"
|
|
123
|
+
name: call.name || null,
|
|
124
|
+
receiver: call.receiver || null,
|
|
125
|
+
method: call.method || null,
|
|
126
|
+
argsCount: call.argsCount,
|
|
127
|
+
sideEffect: call.sideEffect || null // "fs:write", "panic", "io:print", etc.
|
|
128
|
+
});
|
|
129
|
+
edges.push({ src: parentId, dst: callId, type: 'CONTAINS' });
|
|
130
|
+
callCount++;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
// 1. Process top-level functions
|
|
134
|
+
for (const fn of parseResult.functions) {
|
|
135
|
+
const nodeId = `RUST_FUNCTION#${fn.name}#${module.file}#${fn.line}`;
|
|
136
|
+
await graph.addNode({
|
|
137
|
+
id: nodeId,
|
|
138
|
+
type: 'RUST_FUNCTION',
|
|
139
|
+
name: fn.name,
|
|
140
|
+
file: module.file,
|
|
141
|
+
line: fn.line,
|
|
142
|
+
column: fn.column,
|
|
143
|
+
pub: fn.isPub,
|
|
144
|
+
async: fn.isAsync,
|
|
145
|
+
unsafe: fn.isUnsafe,
|
|
146
|
+
const: fn.isConst,
|
|
147
|
+
napi: fn.isNapi,
|
|
148
|
+
napiJsName: fn.napiJsName || null,
|
|
149
|
+
napiConstructor: fn.napiConstructor || false,
|
|
150
|
+
napiGetter: fn.napiGetter || null,
|
|
151
|
+
napiSetter: fn.napiSetter || null,
|
|
152
|
+
params: fn.params || [],
|
|
153
|
+
returnType: fn.returnType || null,
|
|
154
|
+
unsafeBlocks: fn.unsafeBlocks?.length || 0 // Count of unsafe blocks in body
|
|
155
|
+
});
|
|
156
|
+
edges.push({ src: module.id, dst: nodeId, type: 'CONTAINS' });
|
|
157
|
+
// Process calls within this function
|
|
158
|
+
await processCalls(fn.calls, nodeId, fn.name);
|
|
159
|
+
}
|
|
160
|
+
// 2. Process structs
|
|
161
|
+
for (const s of parseResult.structs) {
|
|
162
|
+
const nodeId = `RUST_STRUCT#${s.name}#${module.file}#${s.line}`;
|
|
163
|
+
await graph.addNode({
|
|
164
|
+
id: nodeId,
|
|
165
|
+
type: 'RUST_STRUCT',
|
|
166
|
+
name: s.name,
|
|
167
|
+
file: module.file,
|
|
168
|
+
line: s.line,
|
|
169
|
+
pub: s.isPub,
|
|
170
|
+
napi: s.isNapi,
|
|
171
|
+
fields: s.fields || []
|
|
172
|
+
});
|
|
173
|
+
edges.push({ src: module.id, dst: nodeId, type: 'CONTAINS' });
|
|
174
|
+
}
|
|
175
|
+
// 3. Process impl blocks and their methods
|
|
176
|
+
for (const impl of parseResult.impls) {
|
|
177
|
+
const implId = `RUST_IMPL#${impl.targetType}${impl.traitName ? ':' + impl.traitName : ''}#${module.file}#${impl.line}`;
|
|
178
|
+
await graph.addNode({
|
|
179
|
+
id: implId,
|
|
180
|
+
type: 'RUST_IMPL',
|
|
181
|
+
name: impl.targetType,
|
|
182
|
+
traitName: impl.traitName || null,
|
|
183
|
+
file: module.file,
|
|
184
|
+
line: impl.line
|
|
185
|
+
});
|
|
186
|
+
edges.push({ src: module.id, dst: implId, type: 'CONTAINS' });
|
|
187
|
+
// IMPLEMENTS edge if trait impl
|
|
188
|
+
if (impl.traitName) {
|
|
189
|
+
edges.push({
|
|
190
|
+
src: implId,
|
|
191
|
+
dst: `RUST_TRAIT#${impl.traitName}`,
|
|
192
|
+
type: 'IMPLEMENTS'
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
// Process methods inside impl
|
|
196
|
+
for (const method of impl.methods) {
|
|
197
|
+
const methodId = `RUST_METHOD#${method.name}#${module.file}#${method.line}`;
|
|
198
|
+
await graph.addNode({
|
|
199
|
+
id: methodId,
|
|
200
|
+
type: 'RUST_METHOD',
|
|
201
|
+
name: method.name,
|
|
202
|
+
file: module.file,
|
|
203
|
+
line: method.line,
|
|
204
|
+
column: method.column,
|
|
205
|
+
pub: method.isPub,
|
|
206
|
+
async: method.isAsync,
|
|
207
|
+
unsafe: method.isUnsafe,
|
|
208
|
+
const: method.isConst,
|
|
209
|
+
napi: method.isNapi,
|
|
210
|
+
napiJsName: method.napiJsName || null,
|
|
211
|
+
napiConstructor: method.napiConstructor || false,
|
|
212
|
+
napiGetter: method.napiGetter || null,
|
|
213
|
+
napiSetter: method.napiSetter || null,
|
|
214
|
+
params: method.params || [],
|
|
215
|
+
returnType: method.returnType || null,
|
|
216
|
+
selfType: method.selfType || null,
|
|
217
|
+
implId: implId,
|
|
218
|
+
implType: impl.targetType,
|
|
219
|
+
unsafeBlocks: method.unsafeBlocks?.length || 0 // Count of unsafe blocks in body
|
|
220
|
+
});
|
|
221
|
+
edges.push({ src: implId, dst: methodId, type: 'CONTAINS' });
|
|
222
|
+
methodCount++;
|
|
223
|
+
// Process calls within this method
|
|
224
|
+
await processCalls(method.calls, methodId, `${impl.targetType}::${method.name}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// 4. Process traits
|
|
228
|
+
for (const t of parseResult.traits) {
|
|
229
|
+
const nodeId = `RUST_TRAIT#${t.name}#${module.file}#${t.line}`;
|
|
230
|
+
await graph.addNode({
|
|
231
|
+
id: nodeId,
|
|
232
|
+
type: 'RUST_TRAIT',
|
|
233
|
+
name: t.name,
|
|
234
|
+
file: module.file,
|
|
235
|
+
line: t.line,
|
|
236
|
+
pub: t.isPub,
|
|
237
|
+
methods: (t.methods || []).map(m => ({
|
|
238
|
+
name: m.name,
|
|
239
|
+
params: m.params,
|
|
240
|
+
returnType: m.returnType
|
|
241
|
+
}))
|
|
242
|
+
});
|
|
243
|
+
edges.push({ src: module.id, dst: nodeId, type: 'CONTAINS' });
|
|
244
|
+
}
|
|
245
|
+
// 5. Write all edges
|
|
246
|
+
for (const edge of edges) {
|
|
247
|
+
await graph.addEdge(edge);
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
functions: parseResult.functions.length,
|
|
251
|
+
structs: parseResult.structs.length,
|
|
252
|
+
impls: parseResult.impls.length,
|
|
253
|
+
methods: methodCount,
|
|
254
|
+
traits: parseResult.traits.length,
|
|
255
|
+
calls: callCount,
|
|
256
|
+
edges: edges.length
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLiteAnalyzer - детектит SQLite database operations
|
|
3
|
+
*
|
|
4
|
+
* Паттерны:
|
|
5
|
+
* - database.getDb().all(query, params, callback)
|
|
6
|
+
* - database.getDb().get(query, params, callback)
|
|
7
|
+
* - database.getDb().run(query, params, callback)
|
|
8
|
+
* - Promise-wrapped: new Promise((resolve, reject) => { db.all(...) })
|
|
9
|
+
*/
|
|
10
|
+
import { Plugin } from '../Plugin.js';
|
|
11
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
12
|
+
export declare class SQLiteAnalyzer extends Plugin {
|
|
13
|
+
get metadata(): PluginMetadata;
|
|
14
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
15
|
+
private analyzeModule;
|
|
16
|
+
private getObjectName;
|
|
17
|
+
private extractTemplateLiteral;
|
|
18
|
+
private detectOperationType;
|
|
19
|
+
private extractTableName;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=SQLiteAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLiteAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/SQLiteAnalyzer.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;AAiChF,qBAAa,cAAe,SAAQ,MAAM;IACxC,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;YA+B9C,aAAa;IAiO3B,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,gBAAgB;CAiCzB"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLiteAnalyzer - детектит SQLite database operations
|
|
3
|
+
*
|
|
4
|
+
* Паттерны:
|
|
5
|
+
* - database.getDb().all(query, params, callback)
|
|
6
|
+
* - database.getDb().get(query, params, callback)
|
|
7
|
+
* - database.getDb().run(query, params, callback)
|
|
8
|
+
* - Promise-wrapped: new Promise((resolve, reject) => { db.all(...) })
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync } from 'fs';
|
|
11
|
+
import { parse } from '@babel/parser';
|
|
12
|
+
import traverseModule from '@babel/traverse';
|
|
13
|
+
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const traverse = traverseModule.default || traverseModule;
|
|
16
|
+
const SQLITE_METHODS = ['all', 'get', 'run', 'exec', 'prepare', 'query', 'execute'];
|
|
17
|
+
export class SQLiteAnalyzer extends Plugin {
|
|
18
|
+
get metadata() {
|
|
19
|
+
return {
|
|
20
|
+
name: 'SQLiteAnalyzer',
|
|
21
|
+
phase: 'ANALYSIS',
|
|
22
|
+
priority: 75, // После JSASTAnalyzer (80)
|
|
23
|
+
creates: {
|
|
24
|
+
nodes: ['db:query'],
|
|
25
|
+
edges: ['CONTAINS', 'EXECUTES_QUERY']
|
|
26
|
+
},
|
|
27
|
+
dependencies: ['JSModuleIndexer', 'JSASTAnalyzer']
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async execute(context) {
|
|
31
|
+
try {
|
|
32
|
+
const { graph } = context;
|
|
33
|
+
// Получаем все MODULE ноды
|
|
34
|
+
const modules = await this.getModules(graph);
|
|
35
|
+
let queriesCreated = 0;
|
|
36
|
+
let operationsCreated = 0;
|
|
37
|
+
let edgesCreated = 0;
|
|
38
|
+
// Анализируем каждый модуль
|
|
39
|
+
for (const module of modules) {
|
|
40
|
+
const result = await this.analyzeModule(module, graph);
|
|
41
|
+
queriesCreated += result.queries;
|
|
42
|
+
operationsCreated += result.operations;
|
|
43
|
+
edgesCreated += result.edges;
|
|
44
|
+
}
|
|
45
|
+
console.log(`[SQLiteAnalyzer] Found ${queriesCreated} queries, ${operationsCreated} operations`);
|
|
46
|
+
return createSuccessResult({ nodes: queriesCreated + operationsCreated, edges: edgesCreated }, { modulesAnalyzed: modules.length, queries: queriesCreated, operations: operationsCreated });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error(`[SQLiteAnalyzer] Error:`, error);
|
|
50
|
+
return createErrorResult(error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async analyzeModule(module, graph) {
|
|
54
|
+
let queriesCreated = 0;
|
|
55
|
+
let operationsCreated = 0;
|
|
56
|
+
let edgesCreated = 0;
|
|
57
|
+
try {
|
|
58
|
+
// Читаем файл
|
|
59
|
+
const code = readFileSync(module.file, 'utf-8');
|
|
60
|
+
// Парсим AST
|
|
61
|
+
const ast = parse(code, {
|
|
62
|
+
sourceType: 'module',
|
|
63
|
+
plugins: ['jsx', 'typescript']
|
|
64
|
+
});
|
|
65
|
+
const queries = [];
|
|
66
|
+
traverse(ast, {
|
|
67
|
+
CallExpression: (path) => {
|
|
68
|
+
const node = path.node;
|
|
69
|
+
const callee = node.callee;
|
|
70
|
+
// Паттерн 1: database.getDb().METHOD(query, params, callback)
|
|
71
|
+
// или db.METHOD(query, params, callback)
|
|
72
|
+
if (callee.type === 'MemberExpression' &&
|
|
73
|
+
callee.property.type === 'Identifier' &&
|
|
74
|
+
SQLITE_METHODS.includes(callee.property.name)) {
|
|
75
|
+
const method = callee.property.name;
|
|
76
|
+
const args = node.arguments;
|
|
77
|
+
// Проверяем что это database/db объект, а не router/app
|
|
78
|
+
const objectName = this.getObjectName(callee.object);
|
|
79
|
+
if (objectName === 'router' || objectName === 'app') {
|
|
80
|
+
// Это Express router, а не database
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (args.length >= 1) {
|
|
84
|
+
let query = null;
|
|
85
|
+
let params = null;
|
|
86
|
+
// Первый аргумент - SQL query
|
|
87
|
+
const queryArg = args[0];
|
|
88
|
+
if (queryArg.type === 'StringLiteral') {
|
|
89
|
+
query = queryArg.value;
|
|
90
|
+
}
|
|
91
|
+
else if (queryArg.type === 'TemplateLiteral') {
|
|
92
|
+
// Template literal SQL: `SELECT * FROM ${table}`
|
|
93
|
+
query = this.extractTemplateLiteral(queryArg);
|
|
94
|
+
}
|
|
95
|
+
// Второй аргумент - параметры (если есть)
|
|
96
|
+
if (args.length >= 2 && args[1].type === 'ArrayExpression') {
|
|
97
|
+
params = args[1].elements
|
|
98
|
+
.map(el => {
|
|
99
|
+
if (!el)
|
|
100
|
+
return '?';
|
|
101
|
+
if (el.type === 'StringLiteral' || el.type === 'NumericLiteral') {
|
|
102
|
+
return String(el.value);
|
|
103
|
+
}
|
|
104
|
+
else if (el.type === 'Identifier') {
|
|
105
|
+
return `$${el.name}`;
|
|
106
|
+
}
|
|
107
|
+
return '?';
|
|
108
|
+
})
|
|
109
|
+
.join(', ');
|
|
110
|
+
}
|
|
111
|
+
if (query) {
|
|
112
|
+
// Определяем тип операции из SQL
|
|
113
|
+
const operationType = this.detectOperationType(query);
|
|
114
|
+
const tableName = this.extractTableName(query, operationType);
|
|
115
|
+
const queryId = `${module.file}:DATABASE_QUERY:${method}:${node.loc.start.line}`;
|
|
116
|
+
queries.push({
|
|
117
|
+
id: queryId,
|
|
118
|
+
type: 'db:query',
|
|
119
|
+
method: method.toUpperCase(),
|
|
120
|
+
query: query,
|
|
121
|
+
params: params,
|
|
122
|
+
operationType: operationType,
|
|
123
|
+
tableName: tableName,
|
|
124
|
+
file: module.file,
|
|
125
|
+
line: node.loc.start.line
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Паттерн 2: Promise-wrapped pattern
|
|
131
|
+
// new Promise((resolve, reject) => { db.all(...) })
|
|
132
|
+
if (callee.type === 'Identifier' && callee.name === 'Promise') {
|
|
133
|
+
// Ищем внутри Promise executor function
|
|
134
|
+
const executorArg = node.arguments[0];
|
|
135
|
+
if (executorArg &&
|
|
136
|
+
(executorArg.type === 'ArrowFunctionExpression' ||
|
|
137
|
+
executorArg.type === 'FunctionExpression')) {
|
|
138
|
+
// Обходим тело executor function для поиска db calls
|
|
139
|
+
const executorPath = path.get('arguments.0');
|
|
140
|
+
executorPath.traverse({
|
|
141
|
+
CallExpression: (innerPath) => {
|
|
142
|
+
const innerNode = innerPath.node;
|
|
143
|
+
const innerCallee = innerNode.callee;
|
|
144
|
+
if (innerCallee.type === 'MemberExpression' &&
|
|
145
|
+
innerCallee.property.type === 'Identifier' &&
|
|
146
|
+
SQLITE_METHODS.includes(innerCallee.property.name)) {
|
|
147
|
+
const method = innerCallee.property.name;
|
|
148
|
+
const innerArgs = innerNode.arguments;
|
|
149
|
+
if (innerArgs.length >= 1) {
|
|
150
|
+
let query = null;
|
|
151
|
+
let params = null;
|
|
152
|
+
const queryArg = innerArgs[0];
|
|
153
|
+
if (queryArg.type === 'StringLiteral') {
|
|
154
|
+
query = queryArg.value;
|
|
155
|
+
}
|
|
156
|
+
else if (queryArg.type === 'TemplateLiteral') {
|
|
157
|
+
query = this.extractTemplateLiteral(queryArg);
|
|
158
|
+
}
|
|
159
|
+
if (innerArgs.length >= 2 && innerArgs[1].type === 'ArrayExpression') {
|
|
160
|
+
params = innerArgs[1].elements
|
|
161
|
+
.map(el => {
|
|
162
|
+
if (!el)
|
|
163
|
+
return '?';
|
|
164
|
+
if (el.type === 'StringLiteral' || el.type === 'NumericLiteral') {
|
|
165
|
+
return String(el.value);
|
|
166
|
+
}
|
|
167
|
+
else if (el.type === 'Identifier') {
|
|
168
|
+
return `$${el.name}`;
|
|
169
|
+
}
|
|
170
|
+
return '?';
|
|
171
|
+
})
|
|
172
|
+
.join(', ');
|
|
173
|
+
}
|
|
174
|
+
if (query) {
|
|
175
|
+
const operationType = this.detectOperationType(query);
|
|
176
|
+
const tableName = this.extractTableName(query, operationType);
|
|
177
|
+
const queryId = `${module.file}:DATABASE_QUERY:${method}:${innerNode.loc.start.line}`;
|
|
178
|
+
queries.push({
|
|
179
|
+
id: queryId,
|
|
180
|
+
type: 'db:query',
|
|
181
|
+
method: method.toUpperCase(),
|
|
182
|
+
query: query,
|
|
183
|
+
params: params,
|
|
184
|
+
operationType: operationType,
|
|
185
|
+
tableName: tableName,
|
|
186
|
+
file: module.file,
|
|
187
|
+
line: innerNode.loc.start.line,
|
|
188
|
+
promiseWrapped: true
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
// Создаём DATABASE_QUERY ноды
|
|
200
|
+
for (const query of queries) {
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
202
|
+
const { promiseWrapped, ...queryData } = query;
|
|
203
|
+
await graph.addNode(queryData);
|
|
204
|
+
queriesCreated++;
|
|
205
|
+
// MODULE -> CONTAINS -> DATABASE_QUERY
|
|
206
|
+
await graph.addEdge({
|
|
207
|
+
type: 'CONTAINS',
|
|
208
|
+
src: module.id,
|
|
209
|
+
dst: query.id
|
|
210
|
+
});
|
|
211
|
+
edgesCreated++;
|
|
212
|
+
// Ищем FUNCTION ноду которая содержит этот query
|
|
213
|
+
const containingFunctions = [];
|
|
214
|
+
for await (const n of graph.queryNodes({ type: 'FUNCTION' })) {
|
|
215
|
+
if (n.file === module.file &&
|
|
216
|
+
(n.line ?? 0) <= query.line &&
|
|
217
|
+
query.line - (n.line ?? 0) < 100) {
|
|
218
|
+
containingFunctions.push(n);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (containingFunctions.length > 0) {
|
|
222
|
+
// Берём ближайшую функцию
|
|
223
|
+
const closestFunction = containingFunctions.reduce((prev, curr) => query.line - (curr.line ?? 0) < query.line - (prev.line ?? 0) ? curr : prev);
|
|
224
|
+
// FUNCTION -> EXECUTES_QUERY -> DATABASE_QUERY
|
|
225
|
+
await graph.addEdge({
|
|
226
|
+
type: 'EXECUTES_QUERY',
|
|
227
|
+
src: closestFunction.id,
|
|
228
|
+
dst: query.id
|
|
229
|
+
});
|
|
230
|
+
edgesCreated++;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error(`[SQLiteAnalyzer] Error analyzing ${module.file}:`, error.message);
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
queries: queriesCreated,
|
|
239
|
+
operations: operationsCreated,
|
|
240
|
+
edges: edgesCreated
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
getObjectName(node) {
|
|
244
|
+
// Извлекаем имя объекта из call expression
|
|
245
|
+
if (node.type === 'Identifier') {
|
|
246
|
+
return node.name;
|
|
247
|
+
}
|
|
248
|
+
else if (node.type === 'MemberExpression') {
|
|
249
|
+
// database.getDb() → 'database'
|
|
250
|
+
return this.getObjectName(node.object);
|
|
251
|
+
}
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
extractTemplateLiteral(node) {
|
|
255
|
+
// Извлекаем SQL из template literal
|
|
256
|
+
const parts = [];
|
|
257
|
+
for (let i = 0; i < node.quasis.length; i++) {
|
|
258
|
+
parts.push(node.quasis[i].value.raw);
|
|
259
|
+
if (i < node.expressions.length) {
|
|
260
|
+
parts.push('${...}');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return parts.join('');
|
|
264
|
+
}
|
|
265
|
+
detectOperationType(query) {
|
|
266
|
+
const upperQuery = query.toUpperCase().trim();
|
|
267
|
+
if (upperQuery.startsWith('SELECT'))
|
|
268
|
+
return 'SELECT';
|
|
269
|
+
if (upperQuery.startsWith('INSERT'))
|
|
270
|
+
return 'INSERT';
|
|
271
|
+
if (upperQuery.startsWith('UPDATE'))
|
|
272
|
+
return 'UPDATE';
|
|
273
|
+
if (upperQuery.startsWith('DELETE'))
|
|
274
|
+
return 'DELETE';
|
|
275
|
+
if (upperQuery.startsWith('CREATE'))
|
|
276
|
+
return 'CREATE';
|
|
277
|
+
if (upperQuery.startsWith('DROP'))
|
|
278
|
+
return 'DROP';
|
|
279
|
+
if (upperQuery.startsWith('ALTER'))
|
|
280
|
+
return 'ALTER';
|
|
281
|
+
return 'UNKNOWN';
|
|
282
|
+
}
|
|
283
|
+
extractTableName(query, operationType) {
|
|
284
|
+
const upperQuery = query.toUpperCase();
|
|
285
|
+
try {
|
|
286
|
+
if (operationType === 'SELECT') {
|
|
287
|
+
// SELECT ... FROM table_name
|
|
288
|
+
const match = upperQuery.match(/FROM\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
289
|
+
return match ? match[1].toLowerCase() : null;
|
|
290
|
+
}
|
|
291
|
+
else if (operationType === 'INSERT') {
|
|
292
|
+
// INSERT INTO table_name
|
|
293
|
+
const match = upperQuery.match(/INSERT\s+INTO\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
294
|
+
return match ? match[1].toLowerCase() : null;
|
|
295
|
+
}
|
|
296
|
+
else if (operationType === 'UPDATE') {
|
|
297
|
+
// UPDATE table_name
|
|
298
|
+
const match = upperQuery.match(/UPDATE\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
299
|
+
return match ? match[1].toLowerCase() : null;
|
|
300
|
+
}
|
|
301
|
+
else if (operationType === 'DELETE') {
|
|
302
|
+
// DELETE FROM table_name
|
|
303
|
+
const match = upperQuery.match(/DELETE\s+FROM\s+([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
304
|
+
return match ? match[1].toLowerCase() : null;
|
|
305
|
+
}
|
|
306
|
+
else if (operationType === 'CREATE') {
|
|
307
|
+
// CREATE TABLE table_name
|
|
308
|
+
const match = upperQuery.match(/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
309
|
+
return match ? match[1].toLowerCase() : null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ServiceLayerAnalyzer - детектит Service Layer Pattern
|
|
3
|
+
*
|
|
4
|
+
* Паттерны:
|
|
5
|
+
* - class XxxService { ... } - Service classes
|
|
6
|
+
* - new XxxService() - Service instantiation
|
|
7
|
+
* - app.set('service', instance) - DI registration
|
|
8
|
+
* - req.app.get('service') - Service usage
|
|
9
|
+
* - export class XxxService - Service exports
|
|
10
|
+
*/
|
|
11
|
+
import { Plugin } from '../Plugin.js';
|
|
12
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
13
|
+
export declare class ServiceLayerAnalyzer extends Plugin {
|
|
14
|
+
get metadata(): PluginMetadata;
|
|
15
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
16
|
+
private analyzeModule;
|
|
17
|
+
/**
|
|
18
|
+
* Проверяет является ли класс Service классом
|
|
19
|
+
* (заканчивается на Service или содержит Service в имени)
|
|
20
|
+
*/
|
|
21
|
+
private isServiceClass;
|
|
22
|
+
/**
|
|
23
|
+
* Извлекает имя объекта из MemberExpression
|
|
24
|
+
*/
|
|
25
|
+
private getObjectName;
|
|
26
|
+
/**
|
|
27
|
+
* Извлекает цепочку объектов (для req.app.get)
|
|
28
|
+
*/
|
|
29
|
+
private getObjectChain;
|
|
30
|
+
/**
|
|
31
|
+
* Извлекает строковое значение из аргумента
|
|
32
|
+
*/
|
|
33
|
+
private extractStringArg;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ServiceLayerAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceLayerAnalyzer.d.ts","sourceRoot":"","sources":["../../../src/plugins/analysis/ServiceLayerAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAcH,OAAO,EAAE,MAAM,EAA0C,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AA8DhF,qBAAa,oBAAqB,SAAQ,MAAM;IAC9C,IAAI,QAAQ,IAAI,cAAc,CAW7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;YAsD9C,aAAa;IAsN3B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAatB;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAczB"}
|