@grafema/core 0.1.0-alpha.5 → 0.1.1-alpha
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/README.md +0 -1
- package/dist/Orchestrator.d.ts +24 -2
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +197 -24
- package/dist/config/ConfigLoader.d.ts +72 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +187 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/core/ASTWorker.d.ts +11 -36
- package/dist/core/ASTWorker.d.ts.map +1 -1
- package/dist/core/ASTWorker.js +93 -99
- package/dist/core/CoverageAnalyzer.d.ts +65 -0
- package/dist/core/CoverageAnalyzer.d.ts.map +1 -0
- package/dist/core/CoverageAnalyzer.js +198 -0
- package/dist/core/FileNodeManager.d.ts +40 -0
- package/dist/core/FileNodeManager.d.ts.map +1 -0
- package/dist/core/FileNodeManager.js +84 -0
- package/dist/core/GraphFreshnessChecker.d.ts +33 -0
- package/dist/core/GraphFreshnessChecker.d.ts.map +1 -0
- package/dist/core/GraphFreshnessChecker.js +101 -0
- package/dist/core/HashUtils.d.ts +24 -0
- package/dist/core/HashUtils.d.ts.map +1 -0
- package/dist/core/HashUtils.js +45 -0
- package/dist/core/IncrementalReanalyzer.d.ts +36 -0
- package/dist/core/IncrementalReanalyzer.d.ts.map +1 -0
- package/dist/core/IncrementalReanalyzer.js +132 -0
- package/dist/core/NodeFactory.d.ts +225 -17
- package/dist/core/NodeFactory.d.ts.map +1 -1
- package/dist/core/NodeFactory.js +208 -18
- package/dist/core/ScopeTracker.d.ts +84 -0
- package/dist/core/ScopeTracker.d.ts.map +1 -0
- package/dist/core/ScopeTracker.js +116 -0
- package/dist/core/SemanticId.d.ts +90 -0
- package/dist/core/SemanticId.d.ts.map +1 -0
- package/dist/core/SemanticId.js +115 -0
- package/dist/core/VersionManager.d.ts.map +1 -1
- package/dist/core/VersionManager.js +3 -2
- package/dist/core/nodes/ArgumentExpressionNode.d.ts +43 -0
- package/dist/core/nodes/ArgumentExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ArgumentExpressionNode.js +60 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ArrayLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ArrayLiteralNode.js +41 -0
- package/dist/core/nodes/CallSiteNode.d.ts +28 -0
- package/dist/core/nodes/CallSiteNode.d.ts.map +1 -1
- package/dist/core/nodes/CallSiteNode.js +46 -0
- package/dist/core/nodes/ClassNode.d.ts +33 -1
- package/dist/core/nodes/ClassNode.d.ts.map +1 -1
- package/dist/core/nodes/ClassNode.js +46 -2
- package/dist/core/nodes/DecoratorNode.d.ts +42 -0
- package/dist/core/nodes/DecoratorNode.d.ts.map +1 -0
- package/dist/core/nodes/DecoratorNode.js +62 -0
- package/dist/core/nodes/EnumNode.d.ts +42 -0
- package/dist/core/nodes/EnumNode.d.ts.map +1 -0
- package/dist/core/nodes/EnumNode.js +54 -0
- package/dist/core/nodes/ExportNode.d.ts +37 -1
- package/dist/core/nodes/ExportNode.d.ts.map +1 -1
- package/dist/core/nodes/ExportNode.js +48 -2
- package/dist/core/nodes/ExpressionNode.d.ts +97 -0
- package/dist/core/nodes/ExpressionNode.d.ts.map +1 -0
- package/dist/core/nodes/ExpressionNode.js +178 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts +28 -0
- package/dist/core/nodes/ExternalModuleNode.d.ts.map +1 -0
- package/dist/core/nodes/ExternalModuleNode.js +41 -0
- package/dist/core/nodes/ExternalStdioNode.d.ts +13 -6
- package/dist/core/nodes/ExternalStdioNode.d.ts.map +1 -1
- package/dist/core/nodes/ExternalStdioNode.js +15 -8
- package/dist/core/nodes/FunctionNode.d.ts +36 -0
- package/dist/core/nodes/FunctionNode.d.ts.map +1 -1
- package/dist/core/nodes/FunctionNode.js +80 -1
- package/dist/core/nodes/ImportNode.d.ts +19 -5
- package/dist/core/nodes/ImportNode.d.ts.map +1 -1
- package/dist/core/nodes/ImportNode.js +23 -5
- package/dist/core/nodes/InterfaceNode.d.ts +46 -0
- package/dist/core/nodes/InterfaceNode.d.ts.map +1 -0
- package/dist/core/nodes/InterfaceNode.js +55 -0
- package/dist/core/nodes/IssueNode.d.ts +73 -0
- package/dist/core/nodes/IssueNode.d.ts.map +1 -0
- package/dist/core/nodes/IssueNode.js +129 -0
- package/dist/core/nodes/MethodCallNode.d.ts +30 -0
- package/dist/core/nodes/MethodCallNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodCallNode.js +49 -0
- package/dist/core/nodes/MethodNode.d.ts +32 -0
- package/dist/core/nodes/MethodNode.d.ts.map +1 -1
- package/dist/core/nodes/MethodNode.js +48 -0
- package/dist/core/nodes/ModuleNode.d.ts +31 -0
- package/dist/core/nodes/ModuleNode.d.ts.map +1 -1
- package/dist/core/nodes/ModuleNode.js +37 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts +54 -0
- package/dist/core/nodes/NetworkRequestNode.d.ts.map +1 -0
- package/dist/core/nodes/NetworkRequestNode.js +65 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts +27 -0
- package/dist/core/nodes/ObjectLiteralNode.d.ts.map +1 -0
- package/dist/core/nodes/ObjectLiteralNode.js +41 -0
- package/dist/core/nodes/ScopeNode.d.ts +31 -0
- package/dist/core/nodes/ScopeNode.d.ts.map +1 -1
- package/dist/core/nodes/ScopeNode.js +49 -0
- package/dist/core/nodes/TypeNode.d.ts +36 -0
- package/dist/core/nodes/TypeNode.d.ts.map +1 -0
- package/dist/core/nodes/TypeNode.js +53 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts +27 -0
- package/dist/core/nodes/VariableDeclarationNode.d.ts.map +1 -1
- package/dist/core/nodes/VariableDeclarationNode.js +40 -0
- package/dist/core/nodes/index.d.ts +12 -1
- package/dist/core/nodes/index.d.ts.map +1 -1
- package/dist/core/nodes/index.js +14 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts +98 -0
- package/dist/diagnostics/DiagnosticCollector.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticCollector.js +129 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts +77 -0
- package/dist/diagnostics/DiagnosticReporter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticReporter.js +159 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts +31 -0
- package/dist/diagnostics/DiagnosticWriter.d.ts.map +1 -0
- package/dist/diagnostics/DiagnosticWriter.js +43 -0
- package/dist/diagnostics/index.d.ts +14 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/index.js +11 -0
- package/dist/errors/GrafemaError.d.ts +118 -0
- package/dist/errors/GrafemaError.d.ts.map +1 -0
- package/dist/errors/GrafemaError.js +131 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -1
- package/dist/logging/Logger.d.ts +48 -0
- package/dist/logging/Logger.d.ts.map +1 -0
- package/dist/logging/Logger.js +134 -0
- package/dist/plugins/Plugin.d.ts +5 -1
- package/dist/plugins/Plugin.d.ts.map +1 -1
- package/dist/plugins/Plugin.js +33 -0
- package/dist/plugins/analysis/DatabaseAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/DatabaseAnalyzer.js +13 -6
- package/dist/plugins/analysis/ExpressAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressAnalyzer.js +27 -19
- package/dist/plugins/analysis/ExpressRouteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ExpressRouteAnalyzer.js +21 -14
- package/dist/plugins/analysis/FetchAnalyzer.d.ts +1 -0
- package/dist/plugins/analysis/FetchAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/FetchAnalyzer.js +34 -14
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts +6 -3
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.d.ts.map +1 -1
- package/dist/plugins/analysis/IncrementalAnalysisPlugin.js +76 -80
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts +180 -17
- package/dist/plugins/analysis/JSASTAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/JSASTAnalyzer.js +1171 -471
- package/dist/plugins/analysis/ReactAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ReactAnalyzer.js +56 -57
- package/dist/plugins/analysis/RustAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/RustAnalyzer.js +15 -10
- package/dist/plugins/analysis/SQLiteAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SQLiteAnalyzer.js +9 -7
- package/dist/plugins/analysis/ServiceLayerAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/ServiceLayerAnalyzer.js +21 -9
- package/dist/plugins/analysis/SocketIOAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SocketIOAnalyzer.js +27 -15
- package/dist/plugins/analysis/SystemDbAnalyzer.d.ts.map +1 -1
- package/dist/plugins/analysis/SystemDbAnalyzer.js +15 -5
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts +34 -4
- package/dist/plugins/analysis/ast/GraphBuilder.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/GraphBuilder.js +318 -298
- package/dist/plugins/analysis/ast/IdGenerator.d.ts +105 -0
- package/dist/plugins/analysis/ast/IdGenerator.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/IdGenerator.js +116 -0
- package/dist/plugins/analysis/ast/types.d.ts +176 -5
- package/dist/plugins/analysis/ast/types.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts +33 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/createParameterNodes.js +89 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts +6 -0
- package/dist/plugins/analysis/ast/utils/index.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/index.js +5 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts +87 -0
- package/dist/plugins/analysis/ast/utils/location.d.ts.map +1 -0
- package/dist/plugins/analysis/ast/utils/location.js +78 -0
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts +9 -4
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ASTVisitor.js +6 -5
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts +99 -9
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/CallExpressionVisitor.js +663 -125
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ClassVisitor.js +72 -32
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/FunctionVisitor.js +128 -63
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/ImportExportVisitor.js +11 -8
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts +12 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/TypeScriptVisitor.js +36 -14
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts +4 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.d.ts.map +1 -1
- package/dist/plugins/analysis/ast/visitors/VariableVisitor.js +17 -13
- package/dist/plugins/discovery/MonorepoServiceDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/MonorepoServiceDiscovery.js +3 -2
- package/dist/plugins/discovery/SimpleProjectDiscovery.d.ts.map +1 -1
- package/dist/plugins/discovery/SimpleProjectDiscovery.js +5 -1
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts +22 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.d.ts.map +1 -0
- package/dist/plugins/discovery/WorkspaceDiscovery.js +136 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts +46 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.d.ts.map +1 -0
- package/dist/plugins/discovery/resolveSourceEntrypoint.js +86 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts +21 -0
- package/dist/plugins/discovery/workspaces/detector.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/detector.js +49 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts +35 -0
- package/dist/plugins/discovery/workspaces/globResolver.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/globResolver.js +184 -0
- package/dist/plugins/discovery/workspaces/index.d.ts +9 -0
- package/dist/plugins/discovery/workspaces/index.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/index.js +8 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts +38 -0
- package/dist/plugins/discovery/workspaces/parsers.d.ts.map +1 -0
- package/dist/plugins/discovery/workspaces/parsers.js +80 -0
- package/dist/plugins/enrichment/AliasTracker.d.ts.map +1 -1
- package/dist/plugins/enrichment/AliasTracker.js +14 -8
- package/dist/plugins/enrichment/HTTPConnectionEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/HTTPConnectionEnricher.js +14 -7
- package/dist/plugins/enrichment/ImportExportLinker.d.ts.map +1 -1
- package/dist/plugins/enrichment/ImportExportLinker.js +23 -6
- package/dist/plugins/enrichment/MethodCallResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MethodCallResolver.js +18 -12
- package/dist/plugins/enrichment/MountPointResolver.d.ts.map +1 -1
- package/dist/plugins/enrichment/MountPointResolver.js +8 -3
- package/dist/plugins/enrichment/PrefixEvaluator.d.ts.map +1 -1
- package/dist/plugins/enrichment/PrefixEvaluator.js +16 -7
- package/dist/plugins/enrichment/RustFFIEnricher.d.ts.map +1 -1
- package/dist/plugins/enrichment/RustFFIEnricher.js +6 -5
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts +17 -0
- package/dist/plugins/enrichment/ValueDomainAnalyzer.d.ts.map +1 -1
- package/dist/plugins/enrichment/ValueDomainAnalyzer.js +129 -10
- package/dist/plugins/indexing/IncrementalModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/IncrementalModuleIndexer.js +23 -14
- package/dist/plugins/indexing/JSModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/JSModuleIndexer.js +63 -31
- package/dist/plugins/indexing/RustModuleIndexer.d.ts.map +1 -1
- package/dist/plugins/indexing/RustModuleIndexer.js +5 -4
- package/dist/plugins/indexing/ServiceDetector.d.ts +10 -0
- package/dist/plugins/indexing/ServiceDetector.d.ts.map +1 -1
- package/dist/plugins/indexing/ServiceDetector.js +28 -15
- package/dist/plugins/validation/CallResolverValidator.d.ts.map +1 -1
- package/dist/plugins/validation/CallResolverValidator.js +8 -7
- package/dist/plugins/validation/DataFlowValidator.d.ts.map +1 -1
- package/dist/plugins/validation/DataFlowValidator.js +17 -12
- package/dist/plugins/validation/EvalBanValidator.d.ts.map +1 -1
- package/dist/plugins/validation/EvalBanValidator.js +17 -16
- package/dist/plugins/validation/GraphConnectivityValidator.d.ts.map +1 -1
- package/dist/plugins/validation/GraphConnectivityValidator.js +19 -23
- package/dist/plugins/validation/NodeCreationValidator.d.ts +85 -0
- package/dist/plugins/validation/NodeCreationValidator.d.ts.map +1 -0
- package/dist/plugins/validation/NodeCreationValidator.js +415 -0
- package/dist/plugins/validation/SQLInjectionValidator.d.ts.map +1 -1
- package/dist/plugins/validation/SQLInjectionValidator.js +59 -16
- package/dist/plugins/validation/ShadowingDetector.d.ts.map +1 -1
- package/dist/plugins/validation/ShadowingDetector.js +6 -5
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.d.ts.map +1 -1
- package/dist/plugins/validation/TypeScriptDeadCodeValidator.js +12 -11
- package/dist/plugins/vcs/GitPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/GitPlugin.js +10 -12
- package/dist/plugins/vcs/VCSPlugin.d.ts +3 -2
- package/dist/plugins/vcs/VCSPlugin.d.ts.map +1 -1
- package/dist/plugins/vcs/VCSPlugin.js +5 -5
- package/dist/storage/backends/RFDBServerBackend.d.ts +10 -17
- package/dist/storage/backends/RFDBServerBackend.d.ts.map +1 -1
- package/dist/storage/backends/RFDBServerBackend.js +31 -10
- package/dist/validation/PathValidator.d.ts +1 -2
- package/dist/validation/PathValidator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/Orchestrator.ts +237 -24
- package/src/config/ConfigLoader.ts +263 -0
- package/src/config/index.ts +5 -0
- package/src/core/ASTWorker.ts +143 -139
- package/src/core/CoverageAnalyzer.ts +243 -0
- package/src/core/FileNodeManager.ts +100 -0
- package/src/core/GraphFreshnessChecker.ts +143 -0
- package/src/core/HashUtils.ts +48 -0
- package/src/core/IncrementalReanalyzer.ts +192 -0
- package/src/core/NodeFactory.ts +401 -18
- package/src/core/ScopeTracker.ts +154 -0
- package/src/core/SemanticId.ts +192 -0
- package/src/core/VersionManager.ts +3 -2
- package/src/core/nodes/ArgumentExpressionNode.ts +89 -0
- package/src/core/nodes/ArrayLiteralNode.ts +65 -0
- package/src/core/nodes/CallSiteNode.ts +58 -0
- package/src/core/nodes/ClassNode.ts +63 -2
- package/src/core/nodes/DecoratorNode.ts +91 -0
- package/src/core/nodes/EnumNode.ts +86 -0
- package/src/core/nodes/ExportNode.ts +70 -2
- package/src/core/nodes/ExpressionNode.ts +231 -0
- package/src/core/nodes/ExternalModuleNode.ts +56 -0
- package/src/core/nodes/ExternalStdioNode.ts +17 -9
- package/src/core/nodes/FunctionNode.ts +101 -1
- package/src/core/nodes/ImportNode.ts +32 -10
- package/src/core/nodes/InterfaceNode.ts +91 -0
- package/src/core/nodes/IssueNode.ts +177 -0
- package/src/core/nodes/MethodCallNode.ts +64 -0
- package/src/core/nodes/MethodNode.ts +63 -0
- package/src/core/nodes/ModuleNode.ts +50 -0
- package/src/core/nodes/NetworkRequestNode.ts +77 -0
- package/src/core/nodes/ObjectLiteralNode.ts +65 -0
- package/src/core/nodes/ScopeNode.ts +65 -0
- package/src/core/nodes/TypeNode.ts +78 -0
- package/src/core/nodes/VariableDeclarationNode.ts +52 -0
- package/src/core/nodes/index.ts +18 -1
- package/src/diagnostics/DiagnosticCollector.ts +163 -0
- package/src/diagnostics/DiagnosticReporter.ts +204 -0
- package/src/diagnostics/DiagnosticWriter.ts +50 -0
- package/src/diagnostics/index.ts +16 -0
- package/src/errors/GrafemaError.ts +174 -0
- package/src/index.ts +148 -1
- package/src/logging/Logger.ts +152 -0
- package/src/plugins/Plugin.ts +42 -0
- package/src/plugins/analysis/DatabaseAnalyzer.ts +14 -8
- package/src/plugins/analysis/ExpressAnalyzer.ts +29 -19
- package/src/plugins/analysis/ExpressRouteAnalyzer.ts +22 -21
- package/src/plugins/analysis/FetchAnalyzer.ts +39 -16
- package/src/plugins/analysis/IncrementalAnalysisPlugin.ts +84 -101
- package/src/plugins/analysis/JSASTAnalyzer.ts +1483 -503
- package/src/plugins/analysis/ReactAnalyzer.ts +57 -57
- package/src/plugins/analysis/RustAnalyzer.ts +15 -10
- package/src/plugins/analysis/SQLiteAnalyzer.ts +10 -7
- package/src/plugins/analysis/ServiceLayerAnalyzer.ts +22 -16
- package/src/plugins/analysis/SocketIOAnalyzer.ts +31 -22
- package/src/plugins/analysis/SystemDbAnalyzer.ts +16 -11
- package/src/plugins/analysis/ast/GraphBuilder.ts +439 -327
- package/src/plugins/analysis/ast/IdGenerator.ts +177 -0
- package/src/plugins/analysis/ast/types.ts +209 -6
- package/src/plugins/analysis/ast/utils/createParameterNodes.ts +104 -0
- package/src/plugins/analysis/ast/utils/index.ts +12 -0
- package/src/plugins/analysis/ast/utils/location.ts +103 -0
- package/src/plugins/analysis/ast/visitors/ASTVisitor.ts +11 -8
- package/src/plugins/analysis/ast/visitors/CallExpressionVisitor.ts +909 -83
- package/src/plugins/analysis/ast/visitors/ClassVisitor.ts +97 -44
- package/src/plugins/analysis/ast/visitors/FunctionVisitor.ts +159 -93
- package/src/plugins/analysis/ast/visitors/ImportExportVisitor.ts +12 -8
- package/src/plugins/analysis/ast/visitors/TypeScriptVisitor.ts +41 -14
- package/src/plugins/analysis/ast/visitors/VariableVisitor.ts +37 -17
- package/src/plugins/discovery/MonorepoServiceDiscovery.ts +3 -2
- package/src/plugins/discovery/SimpleProjectDiscovery.ts +6 -1
- package/src/plugins/discovery/WorkspaceDiscovery.ts +177 -0
- package/src/plugins/discovery/resolveSourceEntrypoint.ts +103 -0
- package/src/plugins/discovery/workspaces/detector.ts +63 -0
- package/src/plugins/discovery/workspaces/globResolver.ts +229 -0
- package/src/plugins/discovery/workspaces/index.ts +23 -0
- package/src/plugins/discovery/workspaces/parsers.ts +99 -0
- package/src/plugins/enrichment/AliasTracker.ts +14 -8
- package/src/plugins/enrichment/HTTPConnectionEnricher.ts +14 -7
- package/src/plugins/enrichment/ImportExportLinker.ts +24 -6
- package/src/plugins/enrichment/MethodCallResolver.ts +18 -12
- package/src/plugins/enrichment/MountPointResolver.ts +8 -3
- package/src/plugins/enrichment/PrefixEvaluator.ts +16 -7
- package/src/plugins/enrichment/RustFFIEnricher.ts +6 -5
- package/src/plugins/enrichment/ValueDomainAnalyzer.ts +149 -12
- package/src/plugins/indexing/IncrementalModuleIndexer.ts +23 -14
- package/src/plugins/indexing/JSModuleIndexer.ts +74 -34
- package/src/plugins/indexing/RustModuleIndexer.ts +5 -4
- package/src/plugins/validation/CallResolverValidator.ts +8 -7
- package/src/plugins/validation/DataFlowValidator.ts +16 -12
- package/src/plugins/validation/EvalBanValidator.ts +17 -16
- package/src/plugins/validation/GraphConnectivityValidator.ts +19 -23
- package/src/plugins/validation/NodeCreationValidator.ts +554 -0
- package/src/plugins/validation/SQLInjectionValidator.ts +61 -15
- package/src/plugins/validation/ShadowingDetector.ts +6 -5
- package/src/plugins/validation/TypeScriptDeadCodeValidator.ts +12 -11
- package/src/plugins/vcs/GitPlugin.ts +40 -12
- package/src/plugins/vcs/VCSPlugin.ts +7 -5
- package/src/storage/backends/RFDBServerBackend.ts +43 -29
- package/src/validation/PathValidator.ts +1 -1
- package/dist/core/AnalysisWorker.d.ts +0 -14
- package/dist/core/AnalysisWorker.d.ts.map +0 -1
- package/dist/core/AnalysisWorker.js +0 -307
- package/dist/core/ParallelAnalyzer.d.ts +0 -120
- package/dist/core/ParallelAnalyzer.d.ts.map +0 -1
- package/dist/core/ParallelAnalyzer.js +0 -331
- package/dist/core/QueueWorker.d.ts +0 -12
- package/dist/core/QueueWorker.d.ts.map +0 -1
- package/dist/core/QueueWorker.js +0 -567
- package/dist/core/RFDBClient.d.ts +0 -179
- package/dist/core/RFDBClient.d.ts.map +0 -1
- package/dist/core/RFDBClient.js +0 -429
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts +0 -19
- package/dist/plugins/discovery/ZonServiceDiscovery.d.ts.map +0 -1
- package/dist/plugins/discovery/ZonServiceDiscovery.js +0 -204
- package/src/core/AnalysisWorker.ts +0 -410
- package/src/core/ParallelAnalyzer.ts +0 -476
- package/src/core/QueueWorker.ts +0 -780
- package/src/plugins/indexing/ServiceDetector.ts +0 -230
|
@@ -11,6 +11,7 @@ import type { NodePath } from '@babel/traverse';
|
|
|
11
11
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
12
12
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
13
13
|
import type { NodeRecord } from '@grafema/types';
|
|
14
|
+
import { getLine } from './ast/utils/location.js';
|
|
14
15
|
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
17
|
const traverse = (traverseModule as any).default || traverseModule;
|
|
@@ -55,12 +56,14 @@ export class DatabaseAnalyzer extends Plugin {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
59
|
+
const logger = this.log(context);
|
|
60
|
+
|
|
58
61
|
try {
|
|
59
62
|
const { graph } = context;
|
|
60
63
|
|
|
61
64
|
// Получаем все MODULE ноды
|
|
62
65
|
const modules = await this.getModules(graph);
|
|
63
|
-
|
|
66
|
+
logger.info('Processing modules', { count: modules.length });
|
|
64
67
|
|
|
65
68
|
// Получаем все FUNCTION ноды для связывания
|
|
66
69
|
const functions = await this.getFunctions(graph);
|
|
@@ -82,13 +85,16 @@ export class DatabaseAnalyzer extends Plugin {
|
|
|
82
85
|
if ((i + 1) % 20 === 0 || i === modules.length - 1) {
|
|
83
86
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
84
87
|
const avgTime = ((Date.now() - startTime) / (i + 1)).toFixed(0);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
logger.debug('Progress', {
|
|
89
|
+
current: i + 1,
|
|
90
|
+
total: modules.length,
|
|
91
|
+
elapsed: `${elapsed}s`,
|
|
92
|
+
avgTime: `${avgTime}ms/module`
|
|
93
|
+
});
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
|
|
97
|
+
logger.info('Analysis complete', { queriesCreated, tablesCreated });
|
|
92
98
|
|
|
93
99
|
return createSuccessResult(
|
|
94
100
|
{
|
|
@@ -101,7 +107,7 @@ export class DatabaseAnalyzer extends Plugin {
|
|
|
101
107
|
}
|
|
102
108
|
);
|
|
103
109
|
} catch (error) {
|
|
104
|
-
|
|
110
|
+
logger.error('Analysis failed', { error });
|
|
105
111
|
return createErrorResult(error as Error);
|
|
106
112
|
}
|
|
107
113
|
}
|
|
@@ -218,7 +224,7 @@ export class DatabaseAnalyzer extends Plugin {
|
|
|
218
224
|
object: objectName,
|
|
219
225
|
method: methodName,
|
|
220
226
|
file: module.file!,
|
|
221
|
-
line: node
|
|
227
|
+
line: getLine(node)
|
|
222
228
|
});
|
|
223
229
|
}
|
|
224
230
|
}
|
|
@@ -292,7 +298,7 @@ export class DatabaseAnalyzer extends Plugin {
|
|
|
292
298
|
}
|
|
293
299
|
}
|
|
294
300
|
} catch (error) {
|
|
295
|
-
|
|
301
|
+
// Silent - per-module errors shouldn't spam logs
|
|
296
302
|
}
|
|
297
303
|
|
|
298
304
|
return {
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
import { readFileSync } from 'fs';
|
|
7
7
|
import { parse, ParserPlugin } from '@babel/parser';
|
|
8
8
|
import traverseModule from '@babel/traverse';
|
|
9
|
-
import { dirname, resolve } from 'path';
|
|
9
|
+
import { dirname, resolve, relative } from 'path';
|
|
10
10
|
import type { CallExpression, ImportDeclaration, StringLiteral, TemplateLiteral, Identifier, MemberExpression } from '@babel/types';
|
|
11
11
|
import type { NodePath } from '@babel/traverse';
|
|
12
12
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
13
13
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
14
14
|
import type { NodeRecord } from '@grafema/types';
|
|
15
|
+
import { NetworkRequestNode } from '../../core/nodes/NetworkRequestNode.js';
|
|
16
|
+
import { getLine } from './ast/utils/location.js';
|
|
15
17
|
|
|
16
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
19
|
const traverse = (traverseModule as any).default || traverseModule;
|
|
@@ -77,17 +79,14 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
82
|
+
const logger = this.log(context);
|
|
83
|
+
|
|
80
84
|
try {
|
|
81
85
|
const { graph } = context;
|
|
82
86
|
|
|
83
|
-
//
|
|
84
|
-
const
|
|
85
|
-
await graph.addNode(
|
|
86
|
-
id: networkId,
|
|
87
|
-
type: 'net:request',
|
|
88
|
-
name: '__network__',
|
|
89
|
-
description: 'External HTTP network'
|
|
90
|
-
});
|
|
87
|
+
// Create net:request singleton (GraphBackend handles deduplication)
|
|
88
|
+
const networkNode = NetworkRequestNode.create();
|
|
89
|
+
await graph.addNode(networkNode);
|
|
91
90
|
|
|
92
91
|
// Получаем все MODULE ноды
|
|
93
92
|
const modules = await this.getModules(graph);
|
|
@@ -98,13 +97,13 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
98
97
|
|
|
99
98
|
// Анализируем каждый модуль
|
|
100
99
|
for (const module of modules) {
|
|
101
|
-
const result = await this.analyzeModule(module, graph,
|
|
100
|
+
const result = await this.analyzeModule(module, graph, networkNode.id);
|
|
102
101
|
endpointsCreated += result.endpoints;
|
|
103
102
|
mountPointsCreated += result.mountPoints;
|
|
104
103
|
edgesCreated += result.edges;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
logger.info('Analysis complete', { endpointsCreated, mountPointsCreated });
|
|
108
107
|
|
|
109
108
|
return createSuccessResult(
|
|
110
109
|
{
|
|
@@ -117,7 +116,7 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
117
116
|
}
|
|
118
117
|
);
|
|
119
118
|
} catch (error) {
|
|
120
|
-
|
|
119
|
+
logger.error('Analysis failed', { error });
|
|
121
120
|
return createErrorResult(error as Error);
|
|
122
121
|
}
|
|
123
122
|
}
|
|
@@ -169,7 +168,7 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
169
168
|
imports.push({
|
|
170
169
|
source,
|
|
171
170
|
specifiers,
|
|
172
|
-
line: importNode
|
|
171
|
+
line: getLine(importNode)
|
|
173
172
|
});
|
|
174
173
|
}
|
|
175
174
|
});
|
|
@@ -204,13 +203,13 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
204
203
|
if (routePath) {
|
|
205
204
|
const method = methodName.toUpperCase();
|
|
206
205
|
endpoints.push({
|
|
207
|
-
id: `http:route#${method}:${routePath}#${module.file}#${node
|
|
206
|
+
id: `http:route#${method}:${routePath}#${module.file}#${getLine(node)}`,
|
|
208
207
|
type: 'http:route',
|
|
209
208
|
method: method,
|
|
210
209
|
path: routePath,
|
|
211
210
|
localPath: routePath,
|
|
212
211
|
file: module.file!,
|
|
213
|
-
line: node
|
|
212
|
+
line: getLine(node),
|
|
214
213
|
mountedOn: objectName
|
|
215
214
|
});
|
|
216
215
|
}
|
|
@@ -281,13 +280,13 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
281
280
|
// Создаём mount point
|
|
282
281
|
if ((targetFunction || targetVariable) && prefix) {
|
|
283
282
|
mountPoints.push({
|
|
284
|
-
id: `express:mount#${prefix}#${module.file}#${node
|
|
283
|
+
id: `express:mount#${prefix}#${module.file}#${getLine(node)}`,
|
|
285
284
|
type: 'express:mount',
|
|
286
285
|
prefix: prefix,
|
|
287
286
|
targetFunction: targetFunction,
|
|
288
287
|
targetVariable: targetVariable,
|
|
289
288
|
file: module.file!,
|
|
290
|
-
line: node
|
|
289
|
+
line: getLine(node),
|
|
291
290
|
mountedOn: objectName
|
|
292
291
|
});
|
|
293
292
|
}
|
|
@@ -336,7 +335,7 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
336
335
|
edgesCreated += mountEdges;
|
|
337
336
|
}
|
|
338
337
|
} catch (error) {
|
|
339
|
-
|
|
338
|
+
// Silent - per-module errors shouldn't spam logs
|
|
340
339
|
}
|
|
341
340
|
|
|
342
341
|
return {
|
|
@@ -382,7 +381,18 @@ export class ExpressAnalyzer extends Plugin {
|
|
|
382
381
|
|
|
383
382
|
// Если нашли целевой модуль, создаем MOUNTS ребро
|
|
384
383
|
if (targetModulePath) {
|
|
385
|
-
|
|
384
|
+
// Derive project root from module's absolute and relative paths
|
|
385
|
+
// module.file is absolute path, module.name is relative path
|
|
386
|
+
const moduleAbsPath = module.file!;
|
|
387
|
+
const moduleRelPath = module.name!;
|
|
388
|
+
// projectRoot = absolute path minus relative path suffix
|
|
389
|
+
const projectRoot = moduleAbsPath.endsWith(moduleRelPath)
|
|
390
|
+
? moduleAbsPath.slice(0, moduleAbsPath.length - moduleRelPath.length)
|
|
391
|
+
: dirname(moduleAbsPath); // fallback
|
|
392
|
+
|
|
393
|
+
// Convert target absolute path to relative path for semantic ID
|
|
394
|
+
const targetRelativePath = relative(projectRoot, targetModulePath);
|
|
395
|
+
const targetModuleId = `${targetRelativePath}->global->MODULE->module`;
|
|
386
396
|
|
|
387
397
|
// Проверяем что модуль существует в графе
|
|
388
398
|
const targetModule = await graph.getNode(targetModuleId);
|
|
@@ -16,6 +16,7 @@ import type { NodePath } from '@babel/traverse';
|
|
|
16
16
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
17
17
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
18
18
|
import type { NodeRecord } from '@grafema/types';
|
|
19
|
+
import { getLine } from './ast/utils/location.js';
|
|
19
20
|
|
|
20
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
22
|
const traverse = (traverseModule as any).default || traverseModule;
|
|
@@ -75,12 +76,14 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
79
|
+
const logger = this.log(context);
|
|
80
|
+
|
|
78
81
|
try {
|
|
79
82
|
const { graph } = context;
|
|
80
83
|
|
|
81
84
|
// Получаем все MODULE ноды
|
|
82
85
|
const modules = await this.getModules(graph);
|
|
83
|
-
|
|
86
|
+
logger.info('Processing modules', { count: modules.length });
|
|
84
87
|
|
|
85
88
|
let endpointsCreated = 0;
|
|
86
89
|
let middlewareCreated = 0;
|
|
@@ -99,15 +102,16 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
99
102
|
if ((i + 1) % 20 === 0 || i === modules.length - 1) {
|
|
100
103
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
101
104
|
const avgTime = ((Date.now() - startTime) / (i + 1)).toFixed(0);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
logger.debug('Progress', {
|
|
106
|
+
current: i + 1,
|
|
107
|
+
total: modules.length,
|
|
108
|
+
elapsed: `${elapsed}s`,
|
|
109
|
+
avgTime: `${avgTime}ms/module`
|
|
110
|
+
});
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
`[ExpressRouteAnalyzer] Found ${endpointsCreated} endpoints, ${middlewareCreated} middleware`
|
|
110
|
-
);
|
|
114
|
+
logger.info('Analysis complete', { endpointsCreated, middlewareCreated });
|
|
111
115
|
|
|
112
116
|
return createSuccessResult(
|
|
113
117
|
{
|
|
@@ -117,7 +121,7 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
117
121
|
{ modulesAnalyzed: modules.length }
|
|
118
122
|
);
|
|
119
123
|
} catch (error) {
|
|
120
|
-
|
|
124
|
+
logger.error('Analysis failed', { error });
|
|
121
125
|
return createErrorResult(error as Error);
|
|
122
126
|
}
|
|
123
127
|
}
|
|
@@ -216,7 +220,7 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
216
220
|
const middlewareHandlers = handlers.slice(0, -1);
|
|
217
221
|
|
|
218
222
|
// Создаём http:route
|
|
219
|
-
const endpointId = `http:route#${method.toUpperCase()}:${routePath}#${module.file}#${node
|
|
223
|
+
const endpointId = `http:route#${method.toUpperCase()}:${routePath}#${module.file}#${getLine(node)}`;
|
|
220
224
|
|
|
221
225
|
endpoints.push({
|
|
222
226
|
id: endpointId,
|
|
@@ -224,11 +228,11 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
224
228
|
method: method.toUpperCase(),
|
|
225
229
|
path: routePath,
|
|
226
230
|
file: module.file!,
|
|
227
|
-
line: node
|
|
231
|
+
line: getLine(node),
|
|
228
232
|
routerName: objectName,
|
|
229
233
|
handlerLine: (mainHandler as Node).loc
|
|
230
|
-
? (mainHandler as Node)
|
|
231
|
-
: node
|
|
234
|
+
? getLine(mainHandler as Node)
|
|
235
|
+
: getLine(node)
|
|
232
236
|
});
|
|
233
237
|
|
|
234
238
|
// Обрабатываем middleware
|
|
@@ -249,18 +253,18 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
249
253
|
mwNode.type === 'ArrowFunctionExpression' ||
|
|
250
254
|
mwNode.type === 'FunctionExpression'
|
|
251
255
|
) {
|
|
252
|
-
middlewareName = `inline:${mwNode
|
|
256
|
+
middlewareName = `inline:${getLine(mwNode)}`;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
if (middlewareName) {
|
|
256
|
-
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${mwNode
|
|
260
|
+
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${getLine(mwNode)}`;
|
|
257
261
|
|
|
258
262
|
middlewares.push({
|
|
259
263
|
id: middlewareId,
|
|
260
264
|
type: 'express:middleware',
|
|
261
265
|
name: middlewareName,
|
|
262
266
|
file: module.file!,
|
|
263
|
-
line: mwNode.loc ? mwNode
|
|
267
|
+
line: mwNode.loc ? getLine(mwNode) : getLine(node),
|
|
264
268
|
endpointId: endpointId,
|
|
265
269
|
order: index // Порядок в цепочке
|
|
266
270
|
});
|
|
@@ -297,14 +301,14 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
297
301
|
}
|
|
298
302
|
|
|
299
303
|
if (middlewareName) {
|
|
300
|
-
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${node
|
|
304
|
+
const middlewareId = `express:middleware#${middlewareName}#${module.file}#${getLine(node)}`;
|
|
301
305
|
|
|
302
306
|
middlewares.push({
|
|
303
307
|
id: middlewareId,
|
|
304
308
|
type: 'express:middleware',
|
|
305
309
|
name: middlewareName,
|
|
306
310
|
file: module.file!,
|
|
307
|
-
line: node
|
|
311
|
+
line: getLine(node),
|
|
308
312
|
mountPath: mountPath,
|
|
309
313
|
isGlobal: mountPath === '/' // Global middleware если нет path
|
|
310
314
|
});
|
|
@@ -399,10 +403,7 @@ export class ExpressRouteAnalyzer extends Plugin {
|
|
|
399
403
|
}
|
|
400
404
|
}
|
|
401
405
|
} catch (error) {
|
|
402
|
-
|
|
403
|
-
`[ExpressRouteAnalyzer] Error analyzing ${module.file}:`,
|
|
404
|
-
(error as Error).message
|
|
405
|
-
);
|
|
406
|
+
// Silent - per-module errors shouldn't spam logs
|
|
406
407
|
}
|
|
407
408
|
|
|
408
409
|
return {
|
|
@@ -17,6 +17,8 @@ import type { NodePath } from '@babel/traverse';
|
|
|
17
17
|
import { Plugin, createSuccessResult, createErrorResult } from '../Plugin.js';
|
|
18
18
|
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
19
19
|
import type { NodeRecord } from '@grafema/types';
|
|
20
|
+
import { NetworkRequestNode } from '../../core/nodes/NetworkRequestNode.js';
|
|
21
|
+
import { getLine } from './ast/utils/location.js';
|
|
20
22
|
|
|
21
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
24
|
const traverse = (traverseModule as any).default || traverseModule;
|
|
@@ -44,6 +46,8 @@ interface AnalysisResult {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
export class FetchAnalyzer extends Plugin {
|
|
49
|
+
private networkNodeCreated = false;
|
|
50
|
+
|
|
47
51
|
get metadata(): PluginMetadata {
|
|
48
52
|
return {
|
|
49
53
|
name: 'FetchAnalyzer',
|
|
@@ -58,12 +62,19 @@ export class FetchAnalyzer extends Plugin {
|
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
async execute(context: PluginContext): Promise<PluginResult> {
|
|
65
|
+
const logger = this.log(context);
|
|
66
|
+
|
|
61
67
|
try {
|
|
62
68
|
const { graph } = context;
|
|
63
69
|
|
|
70
|
+
// Create net:request singleton (GraphBackend handles deduplication)
|
|
71
|
+
const networkNode = NetworkRequestNode.create();
|
|
72
|
+
await graph.addNode(networkNode);
|
|
73
|
+
this.networkNodeCreated = true;
|
|
74
|
+
|
|
64
75
|
// Получаем все модули
|
|
65
76
|
const modules = await this.getModules(graph);
|
|
66
|
-
|
|
77
|
+
logger.info('Processing modules', { count: modules.length });
|
|
67
78
|
|
|
68
79
|
let requestsCount = 0;
|
|
69
80
|
let apisCount = 0;
|
|
@@ -71,7 +82,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
71
82
|
|
|
72
83
|
for (let i = 0; i < modules.length; i++) {
|
|
73
84
|
const module = modules[i];
|
|
74
|
-
const result = await this.analyzeModule(module, graph);
|
|
85
|
+
const result = await this.analyzeModule(module, graph, networkNode.id);
|
|
75
86
|
requestsCount += result.requests;
|
|
76
87
|
apisCount += result.apis;
|
|
77
88
|
|
|
@@ -79,33 +90,38 @@ export class FetchAnalyzer extends Plugin {
|
|
|
79
90
|
if ((i + 1) % 20 === 0 || i === modules.length - 1) {
|
|
80
91
|
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
81
92
|
const avgTime = ((Date.now() - startTime) / (i + 1)).toFixed(0);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
logger.debug('Progress', {
|
|
94
|
+
current: i + 1,
|
|
95
|
+
total: modules.length,
|
|
96
|
+
elapsed: `${elapsed}s`,
|
|
97
|
+
avgTime: `${avgTime}ms/module`
|
|
98
|
+
});
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
101
|
|
|
88
|
-
|
|
102
|
+
logger.info('Analysis complete', { requestsCount, apisCount });
|
|
89
103
|
|
|
90
104
|
return createSuccessResult(
|
|
91
105
|
{
|
|
92
|
-
nodes: requestsCount + apisCount,
|
|
93
|
-
edges:
|
|
106
|
+
nodes: requestsCount + apisCount + (this.networkNodeCreated ? 1 : 0),
|
|
107
|
+
edges: requestsCount // CALLS edges from http:request to net:request
|
|
94
108
|
},
|
|
95
109
|
{
|
|
96
110
|
requestsCount,
|
|
97
|
-
apisCount
|
|
111
|
+
apisCount,
|
|
112
|
+
networkSingletonCreated: this.networkNodeCreated
|
|
98
113
|
}
|
|
99
114
|
);
|
|
100
115
|
} catch (error) {
|
|
101
|
-
|
|
116
|
+
logger.error('Analysis failed', { error });
|
|
102
117
|
return createErrorResult(error as Error);
|
|
103
118
|
}
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
private async analyzeModule(
|
|
107
122
|
module: NodeRecord,
|
|
108
|
-
graph: PluginContext['graph']
|
|
123
|
+
graph: PluginContext['graph'],
|
|
124
|
+
networkId: string
|
|
109
125
|
): Promise<AnalysisResult> {
|
|
110
126
|
try {
|
|
111
127
|
const code = readFileSync(module.file!, 'utf-8');
|
|
@@ -138,7 +154,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
138
154
|
const urlArg = node.arguments[0];
|
|
139
155
|
const url = this.extractURL(urlArg);
|
|
140
156
|
const method = this.extractMethod(node.arguments[1]) || 'GET';
|
|
141
|
-
const line = node
|
|
157
|
+
const line = getLine(node);
|
|
142
158
|
|
|
143
159
|
const request: HttpRequestNode = {
|
|
144
160
|
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
@@ -169,7 +185,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
169
185
|
const method = ((callee as MemberExpression).property as Identifier).name.toUpperCase();
|
|
170
186
|
const urlArg = node.arguments[0];
|
|
171
187
|
const url = this.extractURL(urlArg);
|
|
172
|
-
const line = node
|
|
188
|
+
const line = getLine(node);
|
|
173
189
|
|
|
174
190
|
const request: HttpRequestNode = {
|
|
175
191
|
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
@@ -213,7 +229,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
213
229
|
const method = methodProp
|
|
214
230
|
? this.extractString((methodProp as { value: Node }).value) || 'GET'
|
|
215
231
|
: 'GET';
|
|
216
|
-
const line = node
|
|
232
|
+
const line = getLine(node);
|
|
217
233
|
|
|
218
234
|
const request: HttpRequestNode = {
|
|
219
235
|
id: `http:request#${method.toUpperCase()}:${url}#${module.file}#${line}`,
|
|
@@ -245,7 +261,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
245
261
|
const urlArg = node.arguments[0];
|
|
246
262
|
const url = this.extractURL(urlArg);
|
|
247
263
|
const method = this.extractMethod(node.arguments[1]) || 'GET';
|
|
248
|
-
const line = node
|
|
264
|
+
const line = getLine(node);
|
|
249
265
|
|
|
250
266
|
const request: HttpRequestNode = {
|
|
251
267
|
id: `http:request#${method}:${url}#${module.file}#${line}`,
|
|
@@ -279,6 +295,13 @@ export class FetchAnalyzer extends Plugin {
|
|
|
279
295
|
dst: request.id
|
|
280
296
|
});
|
|
281
297
|
|
|
298
|
+
// http:request --CALLS--> net:request singleton
|
|
299
|
+
await graph.addEdge({
|
|
300
|
+
type: 'CALLS',
|
|
301
|
+
src: request.id,
|
|
302
|
+
dst: networkId
|
|
303
|
+
});
|
|
304
|
+
|
|
282
305
|
// Ищем FUNCTION node которая делает запрос
|
|
283
306
|
const functions: NodeRecord[] = [];
|
|
284
307
|
for await (const fn of graph.queryNodes({ type: 'FUNCTION' })) {
|
|
@@ -339,7 +362,7 @@ export class FetchAnalyzer extends Plugin {
|
|
|
339
362
|
apis: externalAPIs.size
|
|
340
363
|
};
|
|
341
364
|
} catch (error) {
|
|
342
|
-
|
|
365
|
+
// Silent - per-module errors shouldn't spam logs
|
|
343
366
|
return { requests: 0, apis: 0 };
|
|
344
367
|
}
|
|
345
368
|
}
|