@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,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OxcAdapter - адаптер для перехода с Babel на Oxc parser
|
|
3
|
+
* Предоставляет API совместимый с Babel parse и traverse
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { parseSync, Visitor } from 'oxc-parser';
|
|
7
|
+
import type * as t from '@babel/types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parse options
|
|
11
|
+
*/
|
|
12
|
+
interface ParseOptions {
|
|
13
|
+
filename?: string;
|
|
14
|
+
sourceType?: 'module' | 'script';
|
|
15
|
+
plugins?: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Visitor handlers type
|
|
20
|
+
*/
|
|
21
|
+
interface VisitorHandlers {
|
|
22
|
+
[key: string]: ((node: t.Node) => void) | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Parse code with Oxc (compatible with Babel parse API)
|
|
27
|
+
* @param code - Source code to parse
|
|
28
|
+
* @param options - Parse options
|
|
29
|
+
* @returns AST with program property
|
|
30
|
+
*/
|
|
31
|
+
export function parse(code: string, options: ParseOptions = {}): t.Program {
|
|
32
|
+
// Oxc doesn't need sourceType or plugins config
|
|
33
|
+
// It auto-detects JSX and handles all modern syntax
|
|
34
|
+
const filename = options.filename || 'unknown.js';
|
|
35
|
+
|
|
36
|
+
const result = parseSync(filename, code);
|
|
37
|
+
|
|
38
|
+
// Oxc returns { program, comments, errors }
|
|
39
|
+
// Babel returns just the program node
|
|
40
|
+
// For compatibility, return the program directly
|
|
41
|
+
return result.program as unknown as t.Program;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Traverse AST with Oxc Visitor (compatible with Babel traverse API)
|
|
46
|
+
* @param ast - AST to traverse
|
|
47
|
+
* @param visitors - Visitor handlers
|
|
48
|
+
*/
|
|
49
|
+
export function traverse(ast: t.Node, visitors: VisitorHandlers): void {
|
|
50
|
+
// Oxc Visitor accepts an object with node type handlers
|
|
51
|
+
// This is already compatible with our Babel usage pattern
|
|
52
|
+
const visitor = new Visitor(visitors as unknown as Record<string, (node: unknown) => void>);
|
|
53
|
+
// Cast to Oxc Program through unknown - types are structurally similar but from different packages
|
|
54
|
+
visitor.visit(ast as unknown as Parameters<typeof visitor.visit>[0]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Default export for compatibility
|
|
59
|
+
*/
|
|
60
|
+
export default {
|
|
61
|
+
parse,
|
|
62
|
+
traverse
|
|
63
|
+
};
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Analysis Types - общие типы для JSASTAnalyzer и GraphBuilder
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type * as t from '@babel/types';
|
|
6
|
+
import type { GraphBackend } from '@grafema/types';
|
|
7
|
+
|
|
8
|
+
// === MODULE NODE ===
|
|
9
|
+
export interface ModuleNode {
|
|
10
|
+
id: string;
|
|
11
|
+
type: 'MODULE';
|
|
12
|
+
name: string;
|
|
13
|
+
file: string;
|
|
14
|
+
line: number;
|
|
15
|
+
contentHash?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// === FUNCTION INFO ===
|
|
20
|
+
export interface FunctionInfo {
|
|
21
|
+
id: string;
|
|
22
|
+
stableId: string;
|
|
23
|
+
type: 'FUNCTION';
|
|
24
|
+
name: string;
|
|
25
|
+
file: string;
|
|
26
|
+
line: number;
|
|
27
|
+
column: number;
|
|
28
|
+
async?: boolean;
|
|
29
|
+
generator?: boolean;
|
|
30
|
+
arrowFunction?: boolean;
|
|
31
|
+
isAssignment?: boolean;
|
|
32
|
+
isCallback?: boolean;
|
|
33
|
+
parentScopeId?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// === PARAMETER INFO ===
|
|
37
|
+
export interface ParameterInfo {
|
|
38
|
+
id: string;
|
|
39
|
+
type: 'PARAMETER';
|
|
40
|
+
name: string;
|
|
41
|
+
file: string;
|
|
42
|
+
line: number;
|
|
43
|
+
index?: number;
|
|
44
|
+
functionId: string;
|
|
45
|
+
parentFunctionId?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// === SCOPE INFO ===
|
|
49
|
+
export interface ScopeInfo {
|
|
50
|
+
id: string;
|
|
51
|
+
type: 'SCOPE';
|
|
52
|
+
scopeType: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
semanticId?: string; // Stable ID for diff comparison (e.g., "MyClass.myMethod:if_statement[0]")
|
|
55
|
+
conditional?: boolean;
|
|
56
|
+
condition?: string;
|
|
57
|
+
constraints?: unknown[];
|
|
58
|
+
file?: string;
|
|
59
|
+
line: number;
|
|
60
|
+
parentScopeId?: string;
|
|
61
|
+
parentFunctionId?: string;
|
|
62
|
+
capturesFrom?: string;
|
|
63
|
+
modifies?: Array<{ variableId: string; variableName: string; line: number }>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// === VARIABLE DECLARATION INFO ===
|
|
67
|
+
export interface VariableDeclarationInfo {
|
|
68
|
+
id: string;
|
|
69
|
+
type: 'VARIABLE' | 'CONSTANT';
|
|
70
|
+
name: string;
|
|
71
|
+
file: string;
|
|
72
|
+
line: number;
|
|
73
|
+
column?: number;
|
|
74
|
+
value?: unknown;
|
|
75
|
+
parentScopeId?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// === CALL SITE INFO ===
|
|
79
|
+
export interface CallSiteInfo {
|
|
80
|
+
id: string;
|
|
81
|
+
type: 'CALL';
|
|
82
|
+
name: string;
|
|
83
|
+
file: string;
|
|
84
|
+
line: number;
|
|
85
|
+
column?: number;
|
|
86
|
+
parentScopeId?: string;
|
|
87
|
+
targetFunctionName?: string;
|
|
88
|
+
isNew?: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// === METHOD CALL INFO ===
|
|
92
|
+
export interface MethodCallInfo {
|
|
93
|
+
id: string;
|
|
94
|
+
type: 'CALL';
|
|
95
|
+
name: string;
|
|
96
|
+
object: string;
|
|
97
|
+
method: string;
|
|
98
|
+
file: string;
|
|
99
|
+
line: number;
|
|
100
|
+
column?: number;
|
|
101
|
+
parentScopeId?: string;
|
|
102
|
+
arguments?: unknown[];
|
|
103
|
+
isNew?: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// === EVENT LISTENER INFO ===
|
|
107
|
+
export interface EventListenerInfo {
|
|
108
|
+
id: string;
|
|
109
|
+
type: 'event:listener';
|
|
110
|
+
name: string;
|
|
111
|
+
object: string;
|
|
112
|
+
file: string;
|
|
113
|
+
line: number;
|
|
114
|
+
parentScopeId?: string;
|
|
115
|
+
callbackArg?: t.Node;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// === CLASS INSTANTIATION INFO ===
|
|
119
|
+
export interface ClassInstantiationInfo {
|
|
120
|
+
variableId: string;
|
|
121
|
+
variableName: string;
|
|
122
|
+
className: string;
|
|
123
|
+
line: number;
|
|
124
|
+
parentScopeId?: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// === CLASS DECLARATION INFO ===
|
|
128
|
+
export interface ClassDeclarationInfo {
|
|
129
|
+
id: string;
|
|
130
|
+
type: 'CLASS';
|
|
131
|
+
name: string;
|
|
132
|
+
file: string;
|
|
133
|
+
line: number;
|
|
134
|
+
column?: number;
|
|
135
|
+
superClass?: string;
|
|
136
|
+
implements?: string[]; // имена интерфейсов, которые реализует класс
|
|
137
|
+
methods: string[];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// === INTERFACE DECLARATION INFO ===
|
|
141
|
+
export interface InterfaceDeclarationInfo {
|
|
142
|
+
id: string;
|
|
143
|
+
type: 'INTERFACE';
|
|
144
|
+
name: string;
|
|
145
|
+
file: string;
|
|
146
|
+
line: number;
|
|
147
|
+
column?: number;
|
|
148
|
+
extends?: string[]; // имена родительских интерфейсов
|
|
149
|
+
properties: InterfacePropertyInfo[];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface InterfacePropertyInfo {
|
|
153
|
+
name: string;
|
|
154
|
+
type?: string;
|
|
155
|
+
optional?: boolean;
|
|
156
|
+
readonly?: boolean;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// === TYPE ALIAS INFO ===
|
|
160
|
+
export interface TypeAliasInfo {
|
|
161
|
+
id: string;
|
|
162
|
+
type: 'TYPE';
|
|
163
|
+
name: string;
|
|
164
|
+
file: string;
|
|
165
|
+
line: number;
|
|
166
|
+
column?: number;
|
|
167
|
+
aliasOf?: string; // строковое представление типа
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// === ENUM DECLARATION INFO ===
|
|
171
|
+
export interface EnumDeclarationInfo {
|
|
172
|
+
id: string;
|
|
173
|
+
type: 'ENUM';
|
|
174
|
+
name: string;
|
|
175
|
+
file: string;
|
|
176
|
+
line: number;
|
|
177
|
+
column?: number;
|
|
178
|
+
isConst?: boolean; // const enum
|
|
179
|
+
members: EnumMemberInfo[];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface EnumMemberInfo {
|
|
183
|
+
name: string;
|
|
184
|
+
value?: string | number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// === DECORATOR INFO ===
|
|
188
|
+
export interface DecoratorInfo {
|
|
189
|
+
id: string;
|
|
190
|
+
type: 'DECORATOR';
|
|
191
|
+
name: string;
|
|
192
|
+
file: string;
|
|
193
|
+
line: number;
|
|
194
|
+
column?: number;
|
|
195
|
+
arguments?: unknown[]; // аргументы декоратора
|
|
196
|
+
targetId: string; // ID класса/метода/свойства
|
|
197
|
+
targetType: 'CLASS' | 'METHOD' | 'PROPERTY' | 'PARAMETER';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// === METHOD CALLBACK INFO ===
|
|
201
|
+
export interface MethodCallbackInfo {
|
|
202
|
+
methodCallId: string;
|
|
203
|
+
callbackLine: number;
|
|
204
|
+
callbackColumn: number;
|
|
205
|
+
callbackType: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// === CALL ARGUMENT INFO ===
|
|
209
|
+
export interface CallArgumentInfo {
|
|
210
|
+
callId: string;
|
|
211
|
+
argIndex: number;
|
|
212
|
+
argValue?: unknown;
|
|
213
|
+
targetType?: string;
|
|
214
|
+
targetId?: string;
|
|
215
|
+
targetName?: string;
|
|
216
|
+
file?: string;
|
|
217
|
+
isSpread?: boolean;
|
|
218
|
+
functionLine?: number;
|
|
219
|
+
functionColumn?: number;
|
|
220
|
+
nestedCallLine?: number;
|
|
221
|
+
nestedCallColumn?: number;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// === IMPORT INFO ===
|
|
225
|
+
export interface ImportInfo {
|
|
226
|
+
id: string;
|
|
227
|
+
type: 'IMPORT';
|
|
228
|
+
name: string;
|
|
229
|
+
source: string;
|
|
230
|
+
file: string;
|
|
231
|
+
line: number;
|
|
232
|
+
specifiers: ImportSpecifier[];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface ImportSpecifier {
|
|
236
|
+
imported: string; // имя в экспортируемом модуле (default, *, или имя)
|
|
237
|
+
local: string; // имя в текущем модуле
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// === EXPORT INFO ===
|
|
241
|
+
export interface ExportInfo {
|
|
242
|
+
id: string;
|
|
243
|
+
type: 'EXPORT' | 'default' | 'named' | 'all';
|
|
244
|
+
name: string;
|
|
245
|
+
file: string;
|
|
246
|
+
line: number;
|
|
247
|
+
specifiers?: ExportSpecifier[];
|
|
248
|
+
source?: string; // для re-exports: export { foo } from './other'
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface ExportSpecifier {
|
|
252
|
+
local: string;
|
|
253
|
+
exported: string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// === HTTP REQUEST INFO ===
|
|
257
|
+
export interface HttpRequestInfo {
|
|
258
|
+
id: string;
|
|
259
|
+
type: 'http:request';
|
|
260
|
+
method: string;
|
|
261
|
+
url: string;
|
|
262
|
+
file: string;
|
|
263
|
+
line: number;
|
|
264
|
+
parentScopeId?: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// === LITERAL INFO ===
|
|
268
|
+
export interface LiteralInfo {
|
|
269
|
+
id: string;
|
|
270
|
+
type: 'LITERAL' | 'CALL';
|
|
271
|
+
value?: unknown;
|
|
272
|
+
valueType?: string;
|
|
273
|
+
name?: string;
|
|
274
|
+
object?: string;
|
|
275
|
+
method?: string;
|
|
276
|
+
arguments?: unknown[];
|
|
277
|
+
file: string;
|
|
278
|
+
line: number;
|
|
279
|
+
column?: number;
|
|
280
|
+
parentCallId?: string;
|
|
281
|
+
argIndex?: number;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// === VARIABLE ASSIGNMENT INFO ===
|
|
285
|
+
export interface VariableAssignmentInfo {
|
|
286
|
+
variableId: string;
|
|
287
|
+
sourceId?: string | null;
|
|
288
|
+
sourceType: string;
|
|
289
|
+
callName?: string;
|
|
290
|
+
callLine?: number;
|
|
291
|
+
callColumn?: number;
|
|
292
|
+
sourceName?: string;
|
|
293
|
+
sourceLine?: number;
|
|
294
|
+
sourceColumn?: number;
|
|
295
|
+
sourceFile?: string;
|
|
296
|
+
className?: string;
|
|
297
|
+
functionName?: string;
|
|
298
|
+
line?: number;
|
|
299
|
+
expressionType?: string;
|
|
300
|
+
object?: string;
|
|
301
|
+
property?: string;
|
|
302
|
+
computed?: boolean;
|
|
303
|
+
computedPropertyVar?: string | null;
|
|
304
|
+
objectSourceName?: string | null;
|
|
305
|
+
operator?: string;
|
|
306
|
+
leftSourceName?: string | null;
|
|
307
|
+
rightSourceName?: string | null;
|
|
308
|
+
consequentSourceName?: string | null;
|
|
309
|
+
alternateSourceName?: string | null;
|
|
310
|
+
expressionSourceNames?: string[];
|
|
311
|
+
file?: string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// === COUNTER REF ===
|
|
315
|
+
export interface CounterRef {
|
|
316
|
+
value: number;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// === PROCESSED NODES ===
|
|
320
|
+
export interface ProcessedNodes {
|
|
321
|
+
functions: Set<string>;
|
|
322
|
+
classes: Set<string>;
|
|
323
|
+
imports: Set<string>;
|
|
324
|
+
exports: Set<string>;
|
|
325
|
+
variables: Set<string>;
|
|
326
|
+
callSites: Set<string>;
|
|
327
|
+
methodCalls: Set<string>;
|
|
328
|
+
varDecls: Set<string>;
|
|
329
|
+
eventListeners: Set<string>;
|
|
330
|
+
[key: string]: Set<string>;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// === COLLECTIONS (все данные для GraphBuilder) ===
|
|
334
|
+
export interface ASTCollections {
|
|
335
|
+
functions: FunctionInfo[];
|
|
336
|
+
parameters?: ParameterInfo[];
|
|
337
|
+
scopes: ScopeInfo[];
|
|
338
|
+
variableDeclarations: VariableDeclarationInfo[];
|
|
339
|
+
callSites: CallSiteInfo[];
|
|
340
|
+
methodCalls?: MethodCallInfo[];
|
|
341
|
+
eventListeners?: EventListenerInfo[];
|
|
342
|
+
classInstantiations?: ClassInstantiationInfo[];
|
|
343
|
+
classDeclarations?: ClassDeclarationInfo[];
|
|
344
|
+
methodCallbacks?: MethodCallbackInfo[];
|
|
345
|
+
callArguments?: CallArgumentInfo[];
|
|
346
|
+
imports?: ImportInfo[];
|
|
347
|
+
exports?: ExportInfo[];
|
|
348
|
+
httpRequests?: HttpRequestInfo[];
|
|
349
|
+
literals?: LiteralInfo[];
|
|
350
|
+
variableAssignments?: VariableAssignmentInfo[];
|
|
351
|
+
// TypeScript-specific collections
|
|
352
|
+
interfaces?: InterfaceDeclarationInfo[];
|
|
353
|
+
typeAliases?: TypeAliasInfo[];
|
|
354
|
+
enums?: EnumDeclarationInfo[];
|
|
355
|
+
decorators?: DecoratorInfo[];
|
|
356
|
+
// Counter refs (used internally during collection)
|
|
357
|
+
ifScopeCounterRef?: CounterRef;
|
|
358
|
+
scopeCounterRef?: CounterRef;
|
|
359
|
+
varDeclCounterRef?: CounterRef;
|
|
360
|
+
callSiteCounterRef?: CounterRef;
|
|
361
|
+
functionCounterRef?: CounterRef;
|
|
362
|
+
httpRequestCounterRef?: CounterRef;
|
|
363
|
+
literalCounterRef?: CounterRef;
|
|
364
|
+
processedNodes?: ProcessedNodes;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// === EXTRACTED VARIABLE ===
|
|
368
|
+
export interface ExtractedVariable {
|
|
369
|
+
name: string;
|
|
370
|
+
loc: { start: { line: number; column: number } };
|
|
371
|
+
propertyPath?: string[];
|
|
372
|
+
arrayIndex?: number;
|
|
373
|
+
isRest?: boolean;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// === GRAPH NODE (generic node for buffer) ===
|
|
377
|
+
export interface GraphNode {
|
|
378
|
+
id: string;
|
|
379
|
+
type: string;
|
|
380
|
+
name?: string;
|
|
381
|
+
file?: string;
|
|
382
|
+
line?: number;
|
|
383
|
+
column?: number;
|
|
384
|
+
[key: string]: unknown;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// === GRAPH EDGE (generic edge for buffer) ===
|
|
388
|
+
export interface GraphEdge {
|
|
389
|
+
type: string;
|
|
390
|
+
src: string;
|
|
391
|
+
dst: string;
|
|
392
|
+
index?: number;
|
|
393
|
+
metadata?: Record<string, unknown>;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// === BUILD RESULT ===
|
|
397
|
+
export interface BuildResult {
|
|
398
|
+
nodes: number;
|
|
399
|
+
edges: number;
|
|
400
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for AST visitors
|
|
3
|
+
* Each visitor handles specific AST node types and collects relevant data
|
|
4
|
+
*/
|
|
5
|
+
import type { Node, SourceLocation } from '@babel/types';
|
|
6
|
+
import type { NodePath } from '@babel/traverse';
|
|
7
|
+
import type {
|
|
8
|
+
FunctionInfo,
|
|
9
|
+
ClassDeclarationInfo,
|
|
10
|
+
ClassInstantiationInfo,
|
|
11
|
+
ScopeInfo,
|
|
12
|
+
VariableDeclarationInfo,
|
|
13
|
+
CallSiteInfo,
|
|
14
|
+
MethodCallInfo,
|
|
15
|
+
EventListenerInfo,
|
|
16
|
+
MethodCallbackInfo,
|
|
17
|
+
LiteralInfo,
|
|
18
|
+
ImportInfo,
|
|
19
|
+
ExportInfo,
|
|
20
|
+
HttpRequestInfo,
|
|
21
|
+
VariableAssignmentInfo,
|
|
22
|
+
CallArgumentInfo,
|
|
23
|
+
ParameterInfo,
|
|
24
|
+
CounterRef,
|
|
25
|
+
ProcessedNodes
|
|
26
|
+
} from '../types.js';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Module info passed to visitors
|
|
30
|
+
*/
|
|
31
|
+
export interface VisitorModule {
|
|
32
|
+
id: string;
|
|
33
|
+
file: string;
|
|
34
|
+
name: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Re-export types that were previously defined locally
|
|
39
|
+
export type { CounterRef, ProcessedNodes, VariableAssignmentInfo as VariableAssignment };
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Shared collections populated by visitors
|
|
43
|
+
*/
|
|
44
|
+
export interface VisitorCollections {
|
|
45
|
+
// Core collections - all optional for partial passing
|
|
46
|
+
functions?: FunctionInfo[];
|
|
47
|
+
classes?: ClassDeclarationInfo[];
|
|
48
|
+
methods?: FunctionInfo[]; // Methods are also FunctionInfo
|
|
49
|
+
imports?: ImportInfo[];
|
|
50
|
+
exports?: ExportInfo[];
|
|
51
|
+
variables?: VariableDeclarationInfo[];
|
|
52
|
+
variableDeclarations?: VariableDeclarationInfo[]; // Alias for variables
|
|
53
|
+
variableAssignments?: VariableAssignmentInfo[];
|
|
54
|
+
callSites?: CallSiteInfo[];
|
|
55
|
+
methodCalls?: MethodCallInfo[];
|
|
56
|
+
eventListeners?: EventListenerInfo[];
|
|
57
|
+
methodCallbacks?: MethodCallbackInfo[];
|
|
58
|
+
classInstantiations?: ClassInstantiationInfo[];
|
|
59
|
+
classDeclarations?: ClassDeclarationInfo[]; // Alias for classes
|
|
60
|
+
literals?: LiteralInfo[];
|
|
61
|
+
callArguments?: CallArgumentInfo[];
|
|
62
|
+
scopes?: ScopeInfo[];
|
|
63
|
+
httpRequests?: HttpRequestInfo[];
|
|
64
|
+
parameters?: ParameterInfo[];
|
|
65
|
+
sideEffects?: unknown[]; // TODO: define SideEffectInfo type
|
|
66
|
+
code?: string; // Source code for condition extraction
|
|
67
|
+
|
|
68
|
+
// Counters - optional
|
|
69
|
+
functionCounterRef?: CounterRef;
|
|
70
|
+
callSiteCounterRef?: CounterRef;
|
|
71
|
+
literalCounterRef?: CounterRef;
|
|
72
|
+
variableCounterRef?: CounterRef;
|
|
73
|
+
scopeCounterRef?: CounterRef;
|
|
74
|
+
ifScopeCounterRef?: CounterRef;
|
|
75
|
+
varDeclCounterRef?: CounterRef;
|
|
76
|
+
httpRequestCounterRef?: CounterRef;
|
|
77
|
+
anonymousFunctionCounterRef?: CounterRef;
|
|
78
|
+
|
|
79
|
+
// Deduplication - optional
|
|
80
|
+
processedNodes?: ProcessedNodes;
|
|
81
|
+
|
|
82
|
+
// Allow additional collections
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Location info extracted from AST node
|
|
88
|
+
*/
|
|
89
|
+
export interface LocationInfo {
|
|
90
|
+
line: number | undefined;
|
|
91
|
+
column: number | undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Handler function type for Babel traverse
|
|
96
|
+
*/
|
|
97
|
+
export type VisitorHandler = (path: NodePath) => void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Visitor handlers object
|
|
101
|
+
*/
|
|
102
|
+
export interface VisitorHandlers {
|
|
103
|
+
[nodeType: string]: VisitorHandler;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Base class for AST visitors
|
|
108
|
+
*/
|
|
109
|
+
export abstract class ASTVisitor {
|
|
110
|
+
protected module: VisitorModule;
|
|
111
|
+
protected collections: VisitorCollections;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @param module - Current module being analyzed (file, path etc)
|
|
115
|
+
* @param collections - Shared collections to populate
|
|
116
|
+
*/
|
|
117
|
+
constructor(module: VisitorModule, collections: VisitorCollections) {
|
|
118
|
+
this.module = module;
|
|
119
|
+
this.collections = collections;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Returns the Babel traverse visitor handlers
|
|
124
|
+
* @returns Object with AST node type handlers
|
|
125
|
+
*/
|
|
126
|
+
abstract getHandlers(): VisitorHandlers;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Utility to get source location info
|
|
130
|
+
*/
|
|
131
|
+
protected getLoc(node: Node): LocationInfo {
|
|
132
|
+
return {
|
|
133
|
+
line: node.loc?.start?.line,
|
|
134
|
+
column: node.loc?.start?.column
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|