@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,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FunctionVisitor - handles function declarations and arrow functions
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - FunctionDeclaration
|
|
6
|
+
* - ArrowFunctionExpression (module-level)
|
|
7
|
+
*/
|
|
8
|
+
import { ASTVisitor } from './ASTVisitor.js';
|
|
9
|
+
export class FunctionVisitor extends ASTVisitor {
|
|
10
|
+
analyzeFunctionBody;
|
|
11
|
+
/**
|
|
12
|
+
* @param module - Current module being analyzed
|
|
13
|
+
* @param collections - Must contain arrays and counter refs
|
|
14
|
+
* @param analyzeFunctionBody - Callback to analyze function internals
|
|
15
|
+
*/
|
|
16
|
+
constructor(module, collections, analyzeFunctionBody) {
|
|
17
|
+
super(module, collections);
|
|
18
|
+
this.analyzeFunctionBody = analyzeFunctionBody;
|
|
19
|
+
}
|
|
20
|
+
getHandlers() {
|
|
21
|
+
const { module } = this;
|
|
22
|
+
const functions = this.collections.functions ?? [];
|
|
23
|
+
const parameters = this.collections.parameters ?? [];
|
|
24
|
+
const scopes = this.collections.scopes ?? [];
|
|
25
|
+
const functionCounterRef = (this.collections.functionCounterRef ?? { value: 0 });
|
|
26
|
+
const moduleScopeCtx = this.collections.moduleScopeCtx;
|
|
27
|
+
const analyzeFunctionBody = this.analyzeFunctionBody;
|
|
28
|
+
const collections = this.collections;
|
|
29
|
+
// Helper function to generate stable anonymous function name
|
|
30
|
+
const generateAnonymousName = () => {
|
|
31
|
+
if (!moduleScopeCtx)
|
|
32
|
+
return 'anonymous';
|
|
33
|
+
const index = moduleScopeCtx.siblingCounters.get('anonymous') || 0;
|
|
34
|
+
moduleScopeCtx.siblingCounters.set('anonymous', index + 1);
|
|
35
|
+
return `anonymous[${index}]`;
|
|
36
|
+
};
|
|
37
|
+
// Helper function to create PARAMETER nodes for function params
|
|
38
|
+
const createParameterNodes = (params, functionId, file, line) => {
|
|
39
|
+
if (!parameters)
|
|
40
|
+
return; // Guard for backward compatibility
|
|
41
|
+
params.forEach((param, index) => {
|
|
42
|
+
// Handle different parameter types
|
|
43
|
+
if (param.type === 'Identifier') {
|
|
44
|
+
const paramId = `PARAMETER#${param.name}#${file}#${line}:${index}`;
|
|
45
|
+
parameters.push({
|
|
46
|
+
id: paramId,
|
|
47
|
+
type: 'PARAMETER',
|
|
48
|
+
name: param.name,
|
|
49
|
+
file: file,
|
|
50
|
+
line: param.loc?.start.line || line,
|
|
51
|
+
index: index,
|
|
52
|
+
parentFunctionId: functionId
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else if (param.type === 'AssignmentPattern') {
|
|
56
|
+
// Default parameter: function(a = 1)
|
|
57
|
+
const assignmentParam = param;
|
|
58
|
+
if (assignmentParam.left.type === 'Identifier') {
|
|
59
|
+
const paramId = `PARAMETER#${assignmentParam.left.name}#${file}#${line}:${index}`;
|
|
60
|
+
parameters.push({
|
|
61
|
+
id: paramId,
|
|
62
|
+
type: 'PARAMETER',
|
|
63
|
+
name: assignmentParam.left.name,
|
|
64
|
+
file: file,
|
|
65
|
+
line: assignmentParam.left.loc?.start.line || line,
|
|
66
|
+
index: index,
|
|
67
|
+
hasDefault: true,
|
|
68
|
+
parentFunctionId: functionId
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (param.type === 'RestElement') {
|
|
73
|
+
// Rest parameter: function(...args)
|
|
74
|
+
const restParam = param;
|
|
75
|
+
if (restParam.argument.type === 'Identifier') {
|
|
76
|
+
const paramId = `PARAMETER#${restParam.argument.name}#${file}#${line}:${index}`;
|
|
77
|
+
parameters.push({
|
|
78
|
+
id: paramId,
|
|
79
|
+
type: 'PARAMETER',
|
|
80
|
+
name: restParam.argument.name,
|
|
81
|
+
file: file,
|
|
82
|
+
line: restParam.argument.loc?.start.line || line,
|
|
83
|
+
index: index,
|
|
84
|
+
isRest: true,
|
|
85
|
+
parentFunctionId: functionId
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// ObjectPattern and ArrayPattern (destructuring parameters) can be added later
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
// Regular function declarations
|
|
94
|
+
FunctionDeclaration: (path) => {
|
|
95
|
+
const node = path.node;
|
|
96
|
+
if (!node.id)
|
|
97
|
+
return; // Skip anonymous function declarations
|
|
98
|
+
const functionId = `FUNCTION#${node.id.name}#${module.file}#${node.loc.start.line}`;
|
|
99
|
+
functions.push({
|
|
100
|
+
id: functionId,
|
|
101
|
+
stableId: functionId,
|
|
102
|
+
type: 'FUNCTION',
|
|
103
|
+
name: node.id.name,
|
|
104
|
+
file: module.file,
|
|
105
|
+
line: node.loc.start.line,
|
|
106
|
+
async: node.async || false,
|
|
107
|
+
generator: node.generator || false
|
|
108
|
+
});
|
|
109
|
+
// Create PARAMETER nodes for function parameters
|
|
110
|
+
createParameterNodes(node.params, functionId, module.file, node.loc.start.line);
|
|
111
|
+
// Create SCOPE for function body
|
|
112
|
+
const functionBodyScopeId = `SCOPE#${node.id.name}:body#${module.file}#${node.loc.start.line}`;
|
|
113
|
+
scopes.push({
|
|
114
|
+
id: functionBodyScopeId,
|
|
115
|
+
type: 'SCOPE',
|
|
116
|
+
scopeType: 'function_body',
|
|
117
|
+
name: `${node.id.name}:body`,
|
|
118
|
+
conditional: false,
|
|
119
|
+
file: module.file,
|
|
120
|
+
line: node.loc.start.line,
|
|
121
|
+
parentFunctionId: functionId
|
|
122
|
+
});
|
|
123
|
+
// Analyze function body
|
|
124
|
+
analyzeFunctionBody(path, functionBodyScopeId, module, collections);
|
|
125
|
+
// Stop traversal - analyzeFunctionBody already processed contents
|
|
126
|
+
path.skip();
|
|
127
|
+
},
|
|
128
|
+
// Arrow functions (module-level, assigned to variables or as callbacks)
|
|
129
|
+
ArrowFunctionExpression: (path) => {
|
|
130
|
+
const node = path.node;
|
|
131
|
+
const line = node.loc.start.line;
|
|
132
|
+
const column = node.loc.start.column;
|
|
133
|
+
// Determine arrow function name (use scope-level counter for stable semanticId)
|
|
134
|
+
let functionName = generateAnonymousName();
|
|
135
|
+
// If arrow function is assigned to variable: const add = () => {}
|
|
136
|
+
const parent = path.parent;
|
|
137
|
+
if (parent.type === 'VariableDeclarator') {
|
|
138
|
+
const declarator = parent;
|
|
139
|
+
if (declarator.id.type === 'Identifier') {
|
|
140
|
+
functionName = declarator.id.name;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const functionId = `FUNCTION#${functionName}#${module.file}#${line}:${column}:${functionCounterRef.value++}`;
|
|
144
|
+
functions.push({
|
|
145
|
+
id: functionId,
|
|
146
|
+
stableId: functionId,
|
|
147
|
+
type: 'FUNCTION',
|
|
148
|
+
name: functionName,
|
|
149
|
+
file: module.file,
|
|
150
|
+
line,
|
|
151
|
+
column,
|
|
152
|
+
async: node.async || false,
|
|
153
|
+
arrowFunction: true
|
|
154
|
+
});
|
|
155
|
+
// Create PARAMETER nodes for arrow function parameters
|
|
156
|
+
createParameterNodes(node.params, functionId, module.file, line);
|
|
157
|
+
// Create SCOPE for arrow function body
|
|
158
|
+
const bodyScope = `SCOPE#${functionName}:body#${module.file}#${line}:${column}`;
|
|
159
|
+
scopes.push({
|
|
160
|
+
id: bodyScope,
|
|
161
|
+
type: 'SCOPE',
|
|
162
|
+
name: `${functionName}:body`,
|
|
163
|
+
file: module.file,
|
|
164
|
+
line,
|
|
165
|
+
scopeType: 'function-body',
|
|
166
|
+
parentFunctionId: functionId
|
|
167
|
+
});
|
|
168
|
+
analyzeFunctionBody(path, bodyScope, module, collections);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImportExportVisitor - handles import and export declarations
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - ImportDeclaration: import { foo } from './module'
|
|
6
|
+
* - ExportDefaultDeclaration: export default foo
|
|
7
|
+
* - ExportNamedDeclaration: export { foo, bar }
|
|
8
|
+
* - ExportAllDeclaration: export * from './module'
|
|
9
|
+
*/
|
|
10
|
+
import type { Node } from '@babel/types';
|
|
11
|
+
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
|
|
12
|
+
import type { VariableInfo } from './VariableVisitor.js';
|
|
13
|
+
/**
|
|
14
|
+
* Callback type for extracting variable names from patterns
|
|
15
|
+
*/
|
|
16
|
+
export type ExtractVariableNamesCallback = (pattern: Node) => VariableInfo[];
|
|
17
|
+
export declare class ImportExportVisitor extends ASTVisitor {
|
|
18
|
+
private extractVariableNamesFromPattern;
|
|
19
|
+
/**
|
|
20
|
+
* @param module - Current module being analyzed
|
|
21
|
+
* @param collections - Must contain 'imports' and 'exports' arrays
|
|
22
|
+
* @param extractVariableNamesFromPattern - Helper from JSASTAnalyzer
|
|
23
|
+
*/
|
|
24
|
+
constructor(module: VisitorModule, collections: VisitorCollections, extractVariableNamesFromPattern: ExtractVariableNamesCallback);
|
|
25
|
+
getImportHandlers(): VisitorHandlers;
|
|
26
|
+
getExportHandlers(): VisitorHandlers;
|
|
27
|
+
getHandlers(): VisitorHandlers;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ImportExportVisitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportExportVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/ImportExportVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAaV,IAAI,EACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;AAuC7E,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,OAAO,CAAC,+BAA+B,CAA+B;IAEtE;;;;OAIG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,+BAA+B,EAAE,4BAA4B;IAM/D,iBAAiB,IAAI,eAAe;IA+CpC,iBAAiB,IAAI,eAAe;IAqHpC,WAAW,IAAI,eAAe;CAM/B"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ImportExportVisitor - handles import and export declarations
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - ImportDeclaration: import { foo } from './module'
|
|
6
|
+
* - ExportDefaultDeclaration: export default foo
|
|
7
|
+
* - ExportNamedDeclaration: export { foo, bar }
|
|
8
|
+
* - ExportAllDeclaration: export * from './module'
|
|
9
|
+
*/
|
|
10
|
+
import { ASTVisitor } from './ASTVisitor.js';
|
|
11
|
+
export class ImportExportVisitor extends ASTVisitor {
|
|
12
|
+
extractVariableNamesFromPattern;
|
|
13
|
+
/**
|
|
14
|
+
* @param module - Current module being analyzed
|
|
15
|
+
* @param collections - Must contain 'imports' and 'exports' arrays
|
|
16
|
+
* @param extractVariableNamesFromPattern - Helper from JSASTAnalyzer
|
|
17
|
+
*/
|
|
18
|
+
constructor(module, collections, extractVariableNamesFromPattern) {
|
|
19
|
+
super(module, collections);
|
|
20
|
+
this.extractVariableNamesFromPattern = extractVariableNamesFromPattern;
|
|
21
|
+
}
|
|
22
|
+
getImportHandlers() {
|
|
23
|
+
const { imports } = this.collections;
|
|
24
|
+
return {
|
|
25
|
+
ImportDeclaration: (path) => {
|
|
26
|
+
const node = path.node;
|
|
27
|
+
const source = node.source.value;
|
|
28
|
+
// Collect imported names
|
|
29
|
+
const specifiers = [];
|
|
30
|
+
node.specifiers.forEach((spec) => {
|
|
31
|
+
if (spec.type === 'ImportSpecifier') {
|
|
32
|
+
// import { foo, bar } from './module'
|
|
33
|
+
const importSpec = spec;
|
|
34
|
+
const importedName = importSpec.imported.type === 'Identifier'
|
|
35
|
+
? importSpec.imported.name
|
|
36
|
+
: importSpec.imported.value;
|
|
37
|
+
specifiers.push({
|
|
38
|
+
imported: importedName,
|
|
39
|
+
local: importSpec.local.name
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else if (spec.type === 'ImportDefaultSpecifier') {
|
|
43
|
+
// import foo from './module'
|
|
44
|
+
const defaultSpec = spec;
|
|
45
|
+
specifiers.push({
|
|
46
|
+
imported: 'default',
|
|
47
|
+
local: defaultSpec.local.name
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
51
|
+
// import * as foo from './module'
|
|
52
|
+
const namespaceSpec = spec;
|
|
53
|
+
specifiers.push({
|
|
54
|
+
imported: '*',
|
|
55
|
+
local: namespaceSpec.local.name
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
imports.push({
|
|
60
|
+
source,
|
|
61
|
+
specifiers,
|
|
62
|
+
line: node.loc.start.line
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
getExportHandlers() {
|
|
68
|
+
const { exports } = this.collections;
|
|
69
|
+
const extractVariableNamesFromPattern = this.extractVariableNamesFromPattern;
|
|
70
|
+
return {
|
|
71
|
+
ExportDefaultDeclaration: (path) => {
|
|
72
|
+
const node = path.node;
|
|
73
|
+
exports.push({
|
|
74
|
+
type: 'default',
|
|
75
|
+
line: node.loc.start.line,
|
|
76
|
+
declaration: node.declaration
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
ExportNamedDeclaration: (path) => {
|
|
80
|
+
const node = path.node;
|
|
81
|
+
// export { foo, bar } from './module'
|
|
82
|
+
if (node.source) {
|
|
83
|
+
const specifiers = node.specifiers.map((spec) => {
|
|
84
|
+
const exportSpec = spec;
|
|
85
|
+
const exportedName = exportSpec.exported.type === 'Identifier'
|
|
86
|
+
? exportSpec.exported.name
|
|
87
|
+
: exportSpec.exported.value;
|
|
88
|
+
const localName = exportSpec.local.type === 'Identifier'
|
|
89
|
+
? exportSpec.local.name
|
|
90
|
+
: exportedName;
|
|
91
|
+
return {
|
|
92
|
+
exported: exportedName,
|
|
93
|
+
local: localName
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
exports.push({
|
|
97
|
+
type: 'named',
|
|
98
|
+
line: node.loc.start.line,
|
|
99
|
+
specifiers,
|
|
100
|
+
source: node.source.value
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// export { foo, bar }
|
|
104
|
+
else if (node.specifiers.length > 0) {
|
|
105
|
+
const specifiers = node.specifiers.map((spec) => {
|
|
106
|
+
const exportSpec = spec;
|
|
107
|
+
const exportedName = exportSpec.exported.type === 'Identifier'
|
|
108
|
+
? exportSpec.exported.name
|
|
109
|
+
: exportSpec.exported.value;
|
|
110
|
+
return {
|
|
111
|
+
exported: exportedName,
|
|
112
|
+
local: exportSpec.local.name
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
exports.push({
|
|
116
|
+
type: 'named',
|
|
117
|
+
line: node.loc.start.line,
|
|
118
|
+
specifiers
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// export const foo = 42 or export function bar() {}
|
|
122
|
+
else if (node.declaration) {
|
|
123
|
+
const declaration = node.declaration;
|
|
124
|
+
// export function foo() {}
|
|
125
|
+
if (declaration.type === 'FunctionDeclaration') {
|
|
126
|
+
const funcDecl = declaration;
|
|
127
|
+
if (funcDecl.id) {
|
|
128
|
+
exports.push({
|
|
129
|
+
type: 'named',
|
|
130
|
+
line: node.loc.start.line,
|
|
131
|
+
name: funcDecl.id.name
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// export const foo = 42, bar = 43
|
|
136
|
+
else if (declaration.type === 'VariableDeclaration') {
|
|
137
|
+
const varDecl = declaration;
|
|
138
|
+
varDecl.declarations.forEach((declarator) => {
|
|
139
|
+
// Handle destructuring: export const { a, b } = obj
|
|
140
|
+
const variables = extractVariableNamesFromPattern(declarator.id);
|
|
141
|
+
variables.forEach((varInfo) => {
|
|
142
|
+
exports.push({
|
|
143
|
+
type: 'named',
|
|
144
|
+
line: node.loc.start.line,
|
|
145
|
+
name: varInfo.name
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// export class Foo {}
|
|
151
|
+
else if (declaration.type === 'ClassDeclaration') {
|
|
152
|
+
const classDecl = declaration;
|
|
153
|
+
if (classDecl.id) {
|
|
154
|
+
exports.push({
|
|
155
|
+
type: 'named',
|
|
156
|
+
line: node.loc.start.line,
|
|
157
|
+
name: classDecl.id.name
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
ExportAllDeclaration: (path) => {
|
|
164
|
+
const node = path.node;
|
|
165
|
+
// export * from './module'
|
|
166
|
+
exports.push({
|
|
167
|
+
type: 'all',
|
|
168
|
+
line: node.loc.start.line,
|
|
169
|
+
source: node.source.value
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
getHandlers() {
|
|
175
|
+
return {
|
|
176
|
+
...this.getImportHandlers(),
|
|
177
|
+
...this.getExportHandlers()
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScriptVisitor - handles TypeScript-specific AST nodes
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - TSInterfaceDeclaration
|
|
6
|
+
* - TSTypeAliasDeclaration
|
|
7
|
+
* - TSEnumDeclaration
|
|
8
|
+
*/
|
|
9
|
+
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers } from './ASTVisitor.js';
|
|
10
|
+
export declare class TypeScriptVisitor extends ASTVisitor {
|
|
11
|
+
constructor(module: VisitorModule, collections: VisitorCollections);
|
|
12
|
+
getHandlers(): VisitorHandlers;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=TypeScriptVisitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeScriptVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AA8EhH,qBAAa,iBAAkB,SAAQ,UAAU;gBACnC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB;IAIlE,WAAW,IAAI,eAAe;CAmI/B"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScriptVisitor - handles TypeScript-specific AST nodes
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - TSInterfaceDeclaration
|
|
6
|
+
* - TSTypeAliasDeclaration
|
|
7
|
+
* - TSEnumDeclaration
|
|
8
|
+
*/
|
|
9
|
+
import { ASTVisitor } from './ASTVisitor.js';
|
|
10
|
+
/**
|
|
11
|
+
* Extracts a string representation of a TypeScript type node
|
|
12
|
+
*/
|
|
13
|
+
function typeNodeToString(node) {
|
|
14
|
+
if (!node || typeof node !== 'object')
|
|
15
|
+
return 'unknown';
|
|
16
|
+
const typeNode = node;
|
|
17
|
+
switch (typeNode.type) {
|
|
18
|
+
case 'TSStringKeyword':
|
|
19
|
+
return 'string';
|
|
20
|
+
case 'TSNumberKeyword':
|
|
21
|
+
return 'number';
|
|
22
|
+
case 'TSBooleanKeyword':
|
|
23
|
+
return 'boolean';
|
|
24
|
+
case 'TSAnyKeyword':
|
|
25
|
+
return 'any';
|
|
26
|
+
case 'TSUnknownKeyword':
|
|
27
|
+
return 'unknown';
|
|
28
|
+
case 'TSVoidKeyword':
|
|
29
|
+
return 'void';
|
|
30
|
+
case 'TSNullKeyword':
|
|
31
|
+
return 'null';
|
|
32
|
+
case 'TSUndefinedKeyword':
|
|
33
|
+
return 'undefined';
|
|
34
|
+
case 'TSNeverKeyword':
|
|
35
|
+
return 'never';
|
|
36
|
+
case 'TSObjectKeyword':
|
|
37
|
+
return 'object';
|
|
38
|
+
case 'TSSymbolKeyword':
|
|
39
|
+
return 'symbol';
|
|
40
|
+
case 'TSBigIntKeyword':
|
|
41
|
+
return 'bigint';
|
|
42
|
+
case 'TSTypeReference':
|
|
43
|
+
const typeName = typeNode.typeName;
|
|
44
|
+
if (typeName?.type === 'Identifier') {
|
|
45
|
+
return typeName.name || 'unknown';
|
|
46
|
+
}
|
|
47
|
+
return 'unknown';
|
|
48
|
+
case 'TSArrayType':
|
|
49
|
+
return `${typeNodeToString(typeNode.elementType)}[]`;
|
|
50
|
+
case 'TSUnionType':
|
|
51
|
+
const unionTypes = typeNode.types;
|
|
52
|
+
return unionTypes.map(t => typeNodeToString(t)).join(' | ');
|
|
53
|
+
case 'TSIntersectionType':
|
|
54
|
+
const intersectionTypes = typeNode.types;
|
|
55
|
+
return intersectionTypes.map(t => typeNodeToString(t)).join(' & ');
|
|
56
|
+
case 'TSLiteralType':
|
|
57
|
+
const literal = typeNode.literal;
|
|
58
|
+
if (literal?.type === 'StringLiteral') {
|
|
59
|
+
return `'${literal.value}'`;
|
|
60
|
+
}
|
|
61
|
+
else if (literal?.type === 'NumericLiteral') {
|
|
62
|
+
return String(literal.value);
|
|
63
|
+
}
|
|
64
|
+
else if (literal?.type === 'BooleanLiteral') {
|
|
65
|
+
return String(literal.value);
|
|
66
|
+
}
|
|
67
|
+
return 'unknown';
|
|
68
|
+
case 'TSFunctionType':
|
|
69
|
+
return 'function';
|
|
70
|
+
case 'TSTupleType':
|
|
71
|
+
const tupleTypes = typeNode.elementTypes;
|
|
72
|
+
return `[${tupleTypes.map(t => typeNodeToString(t)).join(', ')}]`;
|
|
73
|
+
case 'TSTypeLiteral':
|
|
74
|
+
return 'object';
|
|
75
|
+
default:
|
|
76
|
+
return 'unknown';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export class TypeScriptVisitor extends ASTVisitor {
|
|
80
|
+
constructor(module, collections) {
|
|
81
|
+
super(module, collections);
|
|
82
|
+
}
|
|
83
|
+
getHandlers() {
|
|
84
|
+
const { module } = this;
|
|
85
|
+
const { interfaces, typeAliases, enums } = this.collections;
|
|
86
|
+
return {
|
|
87
|
+
TSInterfaceDeclaration: (path) => {
|
|
88
|
+
const node = path.node;
|
|
89
|
+
if (!node.id)
|
|
90
|
+
return;
|
|
91
|
+
const interfaceName = node.id.name;
|
|
92
|
+
const interfaceId = `INTERFACE#${interfaceName}#${module.file}#${node.loc.start.line}`;
|
|
93
|
+
// Extract extends
|
|
94
|
+
const extendsNames = [];
|
|
95
|
+
if (node.extends && node.extends.length > 0) {
|
|
96
|
+
for (const ext of node.extends) {
|
|
97
|
+
if (ext.expression.type === 'Identifier') {
|
|
98
|
+
extendsNames.push(ext.expression.name);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Extract properties
|
|
103
|
+
const properties = [];
|
|
104
|
+
if (node.body && node.body.body) {
|
|
105
|
+
for (const member of node.body.body) {
|
|
106
|
+
if (member.type === 'TSPropertySignature') {
|
|
107
|
+
const prop = member;
|
|
108
|
+
if (prop.key.type === 'Identifier') {
|
|
109
|
+
properties.push({
|
|
110
|
+
name: prop.key.name,
|
|
111
|
+
type: prop.typeAnnotation ? typeNodeToString(prop.typeAnnotation.typeAnnotation) : undefined,
|
|
112
|
+
optional: prop.optional || false,
|
|
113
|
+
readonly: prop.readonly || false
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (member.type === 'TSMethodSignature') {
|
|
118
|
+
const method = member;
|
|
119
|
+
if (method.key.type === 'Identifier') {
|
|
120
|
+
properties.push({
|
|
121
|
+
name: method.key.name,
|
|
122
|
+
type: 'function',
|
|
123
|
+
optional: method.optional || false,
|
|
124
|
+
readonly: false
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
interfaces.push({
|
|
131
|
+
id: interfaceId,
|
|
132
|
+
type: 'INTERFACE',
|
|
133
|
+
name: interfaceName,
|
|
134
|
+
file: module.file,
|
|
135
|
+
line: node.loc.start.line,
|
|
136
|
+
column: node.loc.start.column,
|
|
137
|
+
extends: extendsNames.length > 0 ? extendsNames : undefined,
|
|
138
|
+
properties
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
TSTypeAliasDeclaration: (path) => {
|
|
142
|
+
const node = path.node;
|
|
143
|
+
if (!node.id)
|
|
144
|
+
return;
|
|
145
|
+
const typeName = node.id.name;
|
|
146
|
+
const typeId = `TYPE#${typeName}#${module.file}#${node.loc.start.line}`;
|
|
147
|
+
// Extract the type being aliased
|
|
148
|
+
const aliasOf = typeNodeToString(node.typeAnnotation);
|
|
149
|
+
typeAliases.push({
|
|
150
|
+
id: typeId,
|
|
151
|
+
type: 'TYPE',
|
|
152
|
+
name: typeName,
|
|
153
|
+
file: module.file,
|
|
154
|
+
line: node.loc.start.line,
|
|
155
|
+
column: node.loc.start.column,
|
|
156
|
+
aliasOf
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
TSEnumDeclaration: (path) => {
|
|
160
|
+
const node = path.node;
|
|
161
|
+
if (!node.id)
|
|
162
|
+
return;
|
|
163
|
+
const enumName = node.id.name;
|
|
164
|
+
const enumId = `ENUM#${enumName}#${module.file}#${node.loc.start.line}`;
|
|
165
|
+
// Extract members
|
|
166
|
+
const members = [];
|
|
167
|
+
if (node.members) {
|
|
168
|
+
for (const member of node.members) {
|
|
169
|
+
if (member.id.type === 'Identifier') {
|
|
170
|
+
const memberInfo = {
|
|
171
|
+
name: member.id.name
|
|
172
|
+
};
|
|
173
|
+
// Extract value if present
|
|
174
|
+
if (member.initializer) {
|
|
175
|
+
const init = member.initializer;
|
|
176
|
+
if (init.type === 'StringLiteral') {
|
|
177
|
+
memberInfo.value = init.value;
|
|
178
|
+
}
|
|
179
|
+
else if (init.type === 'NumericLiteral') {
|
|
180
|
+
memberInfo.value = init.value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
members.push(memberInfo);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
enums.push({
|
|
188
|
+
id: enumId,
|
|
189
|
+
type: 'ENUM',
|
|
190
|
+
name: enumName,
|
|
191
|
+
file: module.file,
|
|
192
|
+
line: node.loc.start.line,
|
|
193
|
+
column: node.loc.start.column,
|
|
194
|
+
isConst: node.const || false,
|
|
195
|
+
members
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VariableVisitor - handles module-level variable declarations
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - VariableDeclaration (const, let, var at module level)
|
|
6
|
+
* - NewExpression tracking for class instantiation
|
|
7
|
+
* - Destructuring patterns
|
|
8
|
+
*/
|
|
9
|
+
import type { Node } from '@babel/types';
|
|
10
|
+
import { ASTVisitor, type VisitorModule, type VisitorCollections, type VisitorHandlers, type CounterRef } from './ASTVisitor.js';
|
|
11
|
+
/**
|
|
12
|
+
* Variable info extracted from pattern
|
|
13
|
+
*/
|
|
14
|
+
export interface VariableInfo {
|
|
15
|
+
name: string;
|
|
16
|
+
loc: {
|
|
17
|
+
start: {
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
propertyPath?: string[];
|
|
23
|
+
arrayIndex?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Callback type for extracting variable names from patterns
|
|
27
|
+
*/
|
|
28
|
+
export type ExtractVariableNamesCallback = (pattern: Node) => VariableInfo[];
|
|
29
|
+
/**
|
|
30
|
+
* Callback type for tracking variable assignments
|
|
31
|
+
*/
|
|
32
|
+
export type TrackVariableAssignmentCallback = (initNode: Node, variableId: string, variableName: string, module: VisitorModule, line: number, literals: unknown[], variableAssignments: unknown[], literalCounterRef: CounterRef) => void;
|
|
33
|
+
export declare class VariableVisitor extends ASTVisitor {
|
|
34
|
+
private extractVariableNamesFromPattern;
|
|
35
|
+
private trackVariableAssignment;
|
|
36
|
+
/**
|
|
37
|
+
* @param module - Current module being analyzed
|
|
38
|
+
* @param collections - Must contain arrays and counter refs
|
|
39
|
+
* @param extractVariableNamesFromPattern - Helper for destructuring
|
|
40
|
+
* @param trackVariableAssignment - Helper for data flow tracking
|
|
41
|
+
*/
|
|
42
|
+
constructor(module: VisitorModule, collections: VisitorCollections, extractVariableNamesFromPattern: ExtractVariableNamesCallback, trackVariableAssignment: TrackVariableAssignmentCallback);
|
|
43
|
+
getHandlers(): VisitorHandlers;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=VariableVisitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VariableVisitor.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/analysis/ast/visitors/VariableVisitor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAKV,IAAI,EACL,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGjI;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE;QAAE,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACjD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,OAAO,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,+BAA+B,GAAG,CAC5C,QAAQ,EAAE,IAAI,EACd,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,EAAE,EACnB,mBAAmB,EAAE,OAAO,EAAE,EAC9B,iBAAiB,EAAE,UAAU,KAC1B,IAAI,CAAC;AAoDV,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAO,CAAC,+BAA+B,CAA+B;IACtE,OAAO,CAAC,uBAAuB,CAAkC;IAEjE;;;;;OAKG;gBAED,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,kBAAkB,EAC/B,+BAA+B,EAAE,4BAA4B,EAC7D,uBAAuB,EAAE,+BAA+B;IAO1D,WAAW,IAAI,eAAe;CAmJ/B"}
|