@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,441 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FetchAnalyzer - детектит HTTP requests (fetch, axios, custom wrappers)
|
|
3
|
+
*
|
|
4
|
+
* Паттерны:
|
|
5
|
+
* - fetch(url, options) - Native Fetch API
|
|
6
|
+
* - await fetch(url) - Async fetch
|
|
7
|
+
* - axios.get(url) - Axios GET
|
|
8
|
+
* - axios.post(url, data) - Axios POST
|
|
9
|
+
* - customFetch(url, options) - Custom wrappers (authFetch, apiFetch, etc.)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { readFileSync } from 'fs';
|
|
13
|
+
import { parse, ParserPlugin } from '@babel/parser';
|
|
14
|
+
import traverseModule from '@babel/traverse';
|
|
15
|
+
import type { CallExpression, Identifier, MemberExpression, ObjectExpression, Node } from '@babel/types';
|
|
16
|
+
import type { NodePath } from '@babel/traverse';
|
|
17
|
+
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
18
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
19
|
+
import type { NodeRecord } from '@grafema/types';
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
const traverse = (traverseModule as any).default || traverseModule;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* HTTP request node
|
|
26
|
+
*/
|
|
27
|
+
interface HttpRequestNode {
|
|
28
|
+
id: string;
|
|
29
|
+
type: 'http:request';
|
|
30
|
+
method: string;
|
|
31
|
+
url: string;
|
|
32
|
+
library: string;
|
|
33
|
+
file: string;
|
|
34
|
+
line: number;
|
|
35
|
+
staticUrl: 'yes' | 'no';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Analysis result
|
|
40
|
+
*/
|
|
41
|
+
interface AnalysisResult {
|
|
42
|
+
requests: number;
|
|
43
|
+
apis: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class FetchAnalyzer extends Plugin {
|
|
47
|
+
get metadata(): PluginMetadata {
|
|
48
|
+
return {
|
|
49
|
+
name: 'FetchAnalyzer',
|
|
50
|
+
phase: 'ANALYSIS',
|
|
51
|
+
priority: 75, // После JSASTAnalyzer (80)
|
|
52
|
+
creates: {
|
|
53
|
+
nodes: ['http:request', 'EXTERNAL'],
|
|
54
|
+
edges: ['CONTAINS', 'MAKES_REQUEST', 'CALLS_API']
|
|
55
|
+
},
|
|
56
|
+
dependencies: ['JSModuleIndexer', 'JSASTAnalyzer']
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async execute(context: PluginContext): Promise<PluginResult> {
|
|
61
|
+
try {
|
|
62
|
+
const { graph } = context;
|
|
63
|
+
|
|
64
|
+
// Получаем все модули
|
|
65
|
+
const modules = await this.getModules(graph);
|
|
66
|
+
console.log(`[FetchAnalyzer] Processing ${modules.length} modules...`);
|
|
67
|
+
|
|
68
|
+
let requestsCount = 0;
|
|
69
|
+
let apisCount = 0;
|
|
70
|
+
const startTime = Date.now();
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < modules.length; i++) {
|
|
73
|
+
const module = modules[i];
|
|
74
|
+
const result = await this.analyzeModule(module, graph);
|
|
75
|
+
requestsCount += result.requests;
|
|
76
|
+
apisCount += result.apis;
|
|
77
|
+
|
|
78
|
+
// Progress every 20 modules
|
|
79
|
+
if ((i + 1) % 20 === 0 || i === modules.length - 1) {
|
|
80
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
81
|
+
const avgTime = ((Date.now() - startTime) / (i + 1)).toFixed(0);
|
|
82
|
+
console.log(
|
|
83
|
+
`[FetchAnalyzer] Progress: ${i + 1}/${modules.length} (${elapsed}s, avg ${avgTime}ms/module)`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.log(`[FetchAnalyzer] Found ${requestsCount} HTTP requests, ${apisCount} external APIs`);
|
|
89
|
+
|
|
90
|
+
return createSuccessResult(
|
|
91
|
+
{
|
|
92
|
+
nodes: requestsCount + apisCount,
|
|
93
|
+
edges: 0
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
requestsCount,
|
|
97
|
+
apisCount
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('[FetchAnalyzer] Error:', error);
|
|
102
|
+
return createErrorResult(error as Error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private async analyzeModule(
|
|
107
|
+
module: NodeRecord,
|
|
108
|
+
graph: PluginContext['graph']
|
|
109
|
+
): Promise<AnalysisResult> {
|
|
110
|
+
try {
|
|
111
|
+
const code = readFileSync(module.file!, 'utf-8');
|
|
112
|
+
|
|
113
|
+
const ast = parse(code, {
|
|
114
|
+
sourceType: 'module',
|
|
115
|
+
plugins: [
|
|
116
|
+
'jsx',
|
|
117
|
+
'typescript',
|
|
118
|
+
'classProperties',
|
|
119
|
+
'decorators-legacy',
|
|
120
|
+
'asyncGenerators',
|
|
121
|
+
'dynamicImport',
|
|
122
|
+
'optionalChaining',
|
|
123
|
+
'nullishCoalescingOperator'
|
|
124
|
+
] as ParserPlugin[]
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const httpRequests: HttpRequestNode[] = [];
|
|
128
|
+
const externalAPIs = new Set<string>();
|
|
129
|
+
|
|
130
|
+
// Детект HTTP request паттернов
|
|
131
|
+
traverse(ast, {
|
|
132
|
+
CallExpression: (path: NodePath<CallExpression>) => {
|
|
133
|
+
const node = path.node;
|
|
134
|
+
const callee = node.callee;
|
|
135
|
+
|
|
136
|
+
// Pattern 1: fetch(url, options)
|
|
137
|
+
if (callee.type === 'Identifier' && (callee as Identifier).name === 'fetch') {
|
|
138
|
+
const urlArg = node.arguments[0];
|
|
139
|
+
const url = this.extractURL(urlArg);
|
|
140
|
+
const method = this.extractMethod(node.arguments[1]) || 'GET';
|
|
141
|
+
const line = node.loc!.start.line;
|
|
142
|
+
|
|
143
|
+
const request: HttpRequestNode = {
|
|
144
|
+
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
145
|
+
type: 'http:request',
|
|
146
|
+
method: method,
|
|
147
|
+
url: url,
|
|
148
|
+
library: 'fetch',
|
|
149
|
+
file: module.file!,
|
|
150
|
+
line: line,
|
|
151
|
+
staticUrl: url !== 'dynamic' && url !== 'unknown' ? 'yes' : 'no'
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
httpRequests.push(request);
|
|
155
|
+
|
|
156
|
+
// Определяем внешний ли это API
|
|
157
|
+
if (this.isExternalAPI(url)) {
|
|
158
|
+
externalAPIs.add(this.extractDomain(url));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Pattern 2: axios.get(url), axios.post(url, data), etc.
|
|
163
|
+
if (
|
|
164
|
+
callee.type === 'MemberExpression' &&
|
|
165
|
+
(callee as MemberExpression).object.type === 'Identifier' &&
|
|
166
|
+
((callee as MemberExpression).object as Identifier).name === 'axios' &&
|
|
167
|
+
(callee as MemberExpression).property.type === 'Identifier'
|
|
168
|
+
) {
|
|
169
|
+
const method = ((callee as MemberExpression).property as Identifier).name.toUpperCase();
|
|
170
|
+
const urlArg = node.arguments[0];
|
|
171
|
+
const url = this.extractURL(urlArg);
|
|
172
|
+
const line = node.loc!.start.line;
|
|
173
|
+
|
|
174
|
+
const request: HttpRequestNode = {
|
|
175
|
+
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
176
|
+
type: 'http:request',
|
|
177
|
+
method: method,
|
|
178
|
+
url: url,
|
|
179
|
+
library: 'axios',
|
|
180
|
+
file: module.file!,
|
|
181
|
+
line: line,
|
|
182
|
+
staticUrl: url !== 'dynamic' && url !== 'unknown' ? 'yes' : 'no'
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
httpRequests.push(request);
|
|
186
|
+
|
|
187
|
+
if (this.isExternalAPI(url)) {
|
|
188
|
+
externalAPIs.add(this.extractDomain(url));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Pattern 3: axios(config) - generic
|
|
193
|
+
if (callee.type === 'Identifier' && (callee as Identifier).name === 'axios') {
|
|
194
|
+
const config = node.arguments[0];
|
|
195
|
+
if (config && config.type === 'ObjectExpression') {
|
|
196
|
+
const objExpr = config as ObjectExpression;
|
|
197
|
+
const urlProp = objExpr.properties.find(
|
|
198
|
+
p =>
|
|
199
|
+
p.type === 'ObjectProperty' &&
|
|
200
|
+
(p.key as Identifier).type === 'Identifier' &&
|
|
201
|
+
(p.key as Identifier).name === 'url'
|
|
202
|
+
);
|
|
203
|
+
const methodProp = objExpr.properties.find(
|
|
204
|
+
p =>
|
|
205
|
+
p.type === 'ObjectProperty' &&
|
|
206
|
+
(p.key as Identifier).type === 'Identifier' &&
|
|
207
|
+
(p.key as Identifier).name === 'method'
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
const url = urlProp
|
|
211
|
+
? this.extractURL((urlProp as { value: Node }).value)
|
|
212
|
+
: 'unknown';
|
|
213
|
+
const method = methodProp
|
|
214
|
+
? this.extractString((methodProp as { value: Node }).value) || 'GET'
|
|
215
|
+
: 'GET';
|
|
216
|
+
const line = node.loc!.start.line;
|
|
217
|
+
|
|
218
|
+
const request: HttpRequestNode = {
|
|
219
|
+
id: `http:request#${method.toUpperCase()}:${url}#${module.file}#${line}`,
|
|
220
|
+
type: 'http:request',
|
|
221
|
+
method: method.toUpperCase(),
|
|
222
|
+
url: url,
|
|
223
|
+
library: 'axios',
|
|
224
|
+
file: module.file!,
|
|
225
|
+
line: line,
|
|
226
|
+
staticUrl: url !== 'dynamic' && url !== 'unknown' ? 'yes' : 'no'
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
httpRequests.push(request);
|
|
230
|
+
|
|
231
|
+
if (this.isExternalAPI(url)) {
|
|
232
|
+
externalAPIs.add(this.extractDomain(url));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Pattern 4: Custom fetch wrappers (authFetch, apiFetch, etc.)
|
|
238
|
+
if (callee.type === 'Identifier') {
|
|
239
|
+
const calleeName = (callee as Identifier).name;
|
|
240
|
+
if (
|
|
241
|
+
calleeName !== 'fetch' &&
|
|
242
|
+
(calleeName.toLowerCase().includes('fetch') ||
|
|
243
|
+
calleeName.toLowerCase().includes('request'))
|
|
244
|
+
) {
|
|
245
|
+
const urlArg = node.arguments[0];
|
|
246
|
+
const url = this.extractURL(urlArg);
|
|
247
|
+
const method = this.extractMethod(node.arguments[1]) || 'GET';
|
|
248
|
+
const line = node.loc!.start.line;
|
|
249
|
+
|
|
250
|
+
const request: HttpRequestNode = {
|
|
251
|
+
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
252
|
+
type: 'http:request',
|
|
253
|
+
method: method,
|
|
254
|
+
url: url,
|
|
255
|
+
library: calleeName,
|
|
256
|
+
file: module.file!,
|
|
257
|
+
line: line,
|
|
258
|
+
staticUrl: url !== 'dynamic' && url !== 'unknown' ? 'yes' : 'no'
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
httpRequests.push(request);
|
|
262
|
+
|
|
263
|
+
if (this.isExternalAPI(url)) {
|
|
264
|
+
externalAPIs.add(this.extractDomain(url));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// Создаём HTTP_REQUEST ноды
|
|
272
|
+
for (const request of httpRequests) {
|
|
273
|
+
await graph.addNode(request as unknown as NodeRecord);
|
|
274
|
+
|
|
275
|
+
// Создаём ребро от модуля к request
|
|
276
|
+
await graph.addEdge({
|
|
277
|
+
type: 'CONTAINS',
|
|
278
|
+
src: module.id,
|
|
279
|
+
dst: request.id
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Ищем FUNCTION node которая делает запрос
|
|
283
|
+
const functions: NodeRecord[] = [];
|
|
284
|
+
for await (const fn of graph.queryNodes({ type: 'FUNCTION' })) {
|
|
285
|
+
if (
|
|
286
|
+
fn.file === request.file &&
|
|
287
|
+
(fn.line ?? 0) <= request.line &&
|
|
288
|
+
(fn.line ?? 0) + 50 >= request.line
|
|
289
|
+
) {
|
|
290
|
+
functions.push(fn);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (functions.length > 0) {
|
|
295
|
+
// Берём ближайшую функцию
|
|
296
|
+
const closestFunction = functions.reduce((closest, func) => {
|
|
297
|
+
const currentDistance = Math.abs((func.line ?? 0) - request.line);
|
|
298
|
+
const closestDistance = Math.abs((closest.line ?? 0) - request.line);
|
|
299
|
+
return currentDistance < closestDistance ? func : closest;
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
await graph.addEdge({
|
|
303
|
+
type: 'MAKES_REQUEST',
|
|
304
|
+
src: closestFunction.id,
|
|
305
|
+
dst: request.id
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Создаём EXTERNAL ноды для внешних API
|
|
311
|
+
for (const apiDomain of externalAPIs) {
|
|
312
|
+
const apiId = `EXTERNAL#${apiDomain}`;
|
|
313
|
+
|
|
314
|
+
// Проверяем что нода ещё не создана
|
|
315
|
+
const existingApi = await graph.getNode(apiId);
|
|
316
|
+
if (!existingApi) {
|
|
317
|
+
await graph.addNode({
|
|
318
|
+
id: apiId,
|
|
319
|
+
type: 'EXTERNAL',
|
|
320
|
+
domain: apiDomain,
|
|
321
|
+
name: apiDomain
|
|
322
|
+
} as unknown as NodeRecord);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Создаём рёбра от http:request к EXTERNAL
|
|
326
|
+
const apiRequests = httpRequests.filter(r => r.url.includes(apiDomain));
|
|
327
|
+
|
|
328
|
+
for (const request of apiRequests) {
|
|
329
|
+
await graph.addEdge({
|
|
330
|
+
type: 'CALLS_API',
|
|
331
|
+
src: request.id,
|
|
332
|
+
dst: apiId
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
requests: httpRequests.length,
|
|
339
|
+
apis: externalAPIs.size
|
|
340
|
+
};
|
|
341
|
+
} catch (error) {
|
|
342
|
+
console.error(`[FetchAnalyzer] Error analyzing ${module.file}:`, (error as Error).message);
|
|
343
|
+
return { requests: 0, apis: 0 };
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Извлекает URL из аргумента
|
|
349
|
+
*/
|
|
350
|
+
private extractURL(arg: Node | undefined): string {
|
|
351
|
+
if (!arg) return 'unknown';
|
|
352
|
+
|
|
353
|
+
if (arg.type === 'StringLiteral') {
|
|
354
|
+
return (arg as { value: string }).value;
|
|
355
|
+
} else if (arg.type === 'TemplateLiteral') {
|
|
356
|
+
// Template literal - возвращаем паттерн
|
|
357
|
+
const tl = arg as { quasis: Array<{ value: { raw: string } }>; expressions: unknown[] };
|
|
358
|
+
const parts = tl.quasis.map(q => q.value.raw);
|
|
359
|
+
const expressions = tl.expressions.map(() => '${...}');
|
|
360
|
+
|
|
361
|
+
let result = '';
|
|
362
|
+
for (let i = 0; i < parts.length; i++) {
|
|
363
|
+
result += parts[i];
|
|
364
|
+
if (i < expressions.length) {
|
|
365
|
+
result += expressions[i];
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return result;
|
|
369
|
+
} else if (arg.type === 'BinaryExpression') {
|
|
370
|
+
const binExpr = arg as { operator: string; left: Node; right: Node };
|
|
371
|
+
if (binExpr.operator === '+') {
|
|
372
|
+
// String concatenation
|
|
373
|
+
return this.extractURL(binExpr.left) + this.extractURL(binExpr.right);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return 'dynamic';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Извлекает HTTP method из options объекта
|
|
382
|
+
*/
|
|
383
|
+
private extractMethod(optionsArg: Node | undefined): string | null {
|
|
384
|
+
if (!optionsArg || optionsArg.type !== 'ObjectExpression') {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const objExpr = optionsArg as ObjectExpression;
|
|
389
|
+
const methodProp = objExpr.properties.find(
|
|
390
|
+
p =>
|
|
391
|
+
p.type === 'ObjectProperty' &&
|
|
392
|
+
(p.key as Identifier).type === 'Identifier' &&
|
|
393
|
+
(p.key as Identifier).name === 'method'
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
if (methodProp && (methodProp as { value: Node }).value) {
|
|
397
|
+
return this.extractString((methodProp as { value: Node }).value);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Извлекает строковое значение
|
|
405
|
+
*/
|
|
406
|
+
private extractString(node: Node | undefined): string | null {
|
|
407
|
+
if (!node) return null;
|
|
408
|
+
|
|
409
|
+
if (node.type === 'StringLiteral') {
|
|
410
|
+
return (node as { value: string }).value;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Проверяет является ли URL внешним API
|
|
418
|
+
*/
|
|
419
|
+
private isExternalAPI(url: string): boolean {
|
|
420
|
+
if (!url || url === 'unknown' || url === 'dynamic') {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Внешний API - начинается с http:// или https://
|
|
425
|
+
return url.startsWith('http://') || url.startsWith('https://');
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Извлекает домен из URL
|
|
430
|
+
*/
|
|
431
|
+
private extractDomain(url: string): string {
|
|
432
|
+
try {
|
|
433
|
+
const urlObj = new URL(url);
|
|
434
|
+
return urlObj.hostname;
|
|
435
|
+
} catch {
|
|
436
|
+
// Если не получилось распарсить - пытаемся извлечь вручную
|
|
437
|
+
const match = url.match(/https?:\/\/([^\/\?]+)/);
|
|
438
|
+
return match ? match[1] : url;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|