@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,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EvalBanValidator - запрещает использование eval и Function
|
|
3
|
+
*
|
|
4
|
+
* Security инвариант: код не должен использовать динамическое выполнение.
|
|
5
|
+
*
|
|
6
|
+
* Детектирует:
|
|
7
|
+
* - eval("code") - прямой вызов eval
|
|
8
|
+
* - new Function("code") - конструктор Function
|
|
9
|
+
* - Function("code") - вызов Function без new
|
|
10
|
+
* - window.eval("code") - eval через window
|
|
11
|
+
* - globalThis.eval("code") - eval через globalThis
|
|
12
|
+
* - Aliased eval: const e = eval; e("code") - через AliasTracker
|
|
13
|
+
*
|
|
14
|
+
* ПРАВИЛА (Datalog):
|
|
15
|
+
* violation(X) :- node(X, "CALL"), attr(X, "name", "eval").
|
|
16
|
+
* violation(X) :- node(X, "CALL"), attr(X, "name", "Function").
|
|
17
|
+
* violation(X) :- node(X, "CALL"), attr(X, "method", "eval").
|
|
18
|
+
*/
|
|
19
|
+
import { Plugin } from '../Plugin.js';
|
|
20
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
21
|
+
export declare class EvalBanValidator extends Plugin {
|
|
22
|
+
get metadata(): PluginMetadata;
|
|
23
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=EvalBanValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvalBanValidator.d.ts","sourceRoot":"","sources":["../../../src/plugins/validation/EvalBanValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAoChF,qBAAa,gBAAiB,SAAQ,MAAM;IAC1C,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAyG7D"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EvalBanValidator - запрещает использование eval и Function
|
|
3
|
+
*
|
|
4
|
+
* Security инвариант: код не должен использовать динамическое выполнение.
|
|
5
|
+
*
|
|
6
|
+
* Детектирует:
|
|
7
|
+
* - eval("code") - прямой вызов eval
|
|
8
|
+
* - new Function("code") - конструктор Function
|
|
9
|
+
* - Function("code") - вызов Function без new
|
|
10
|
+
* - window.eval("code") - eval через window
|
|
11
|
+
* - globalThis.eval("code") - eval через globalThis
|
|
12
|
+
* - Aliased eval: const e = eval; e("code") - через AliasTracker
|
|
13
|
+
*
|
|
14
|
+
* ПРАВИЛА (Datalog):
|
|
15
|
+
* violation(X) :- node(X, "CALL"), attr(X, "name", "eval").
|
|
16
|
+
* violation(X) :- node(X, "CALL"), attr(X, "name", "Function").
|
|
17
|
+
* violation(X) :- node(X, "CALL"), attr(X, "method", "eval").
|
|
18
|
+
*/
|
|
19
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
20
|
+
export class EvalBanValidator extends Plugin {
|
|
21
|
+
get metadata() {
|
|
22
|
+
return {
|
|
23
|
+
name: 'EvalBanValidator',
|
|
24
|
+
phase: 'VALIDATION',
|
|
25
|
+
priority: 95, // Высокий приоритет - security check
|
|
26
|
+
creates: {
|
|
27
|
+
nodes: [],
|
|
28
|
+
edges: []
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async execute(context) {
|
|
33
|
+
const { graph } = context;
|
|
34
|
+
console.log('[EvalBanValidator] Checking for eval/Function usage...');
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
const issues = [];
|
|
37
|
+
// ОПТИМИЗАЦИЯ: вместо Datalog (медленный full scan), используем прямые graph queries
|
|
38
|
+
// Datalog зависает на больших графах из-за отсутствия индексов
|
|
39
|
+
// 1. Прямой вызов eval("code") - ищем все CALL ноды с name="eval"
|
|
40
|
+
console.log('[EvalBanValidator] Searching for eval() calls...');
|
|
41
|
+
const evalStart = Date.now();
|
|
42
|
+
let evalCount = 0;
|
|
43
|
+
for await (const node of graph.queryNodes({ nodeType: 'CALL' })) {
|
|
44
|
+
if (node.name === 'eval') {
|
|
45
|
+
evalCount++;
|
|
46
|
+
issues.push({
|
|
47
|
+
type: 'EVAL_USAGE',
|
|
48
|
+
severity: 'ERROR',
|
|
49
|
+
message: `Direct eval() call at ${node.file}:${node.line || '?'} - dynamic code execution is forbidden`,
|
|
50
|
+
nodeId: node.id,
|
|
51
|
+
file: node.file,
|
|
52
|
+
line: node.line
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
console.log(`[EvalBanValidator] eval() search took ${Date.now() - evalStart}ms, found ${evalCount} violations`);
|
|
57
|
+
// 2. Вызов Function("code") или new Function("code")
|
|
58
|
+
console.log('[EvalBanValidator] Searching for Function() calls...');
|
|
59
|
+
const funcStart = Date.now();
|
|
60
|
+
let funcCount = 0;
|
|
61
|
+
for await (const node of graph.queryNodes({ nodeType: 'CALL' })) {
|
|
62
|
+
if (node.name === 'Function') {
|
|
63
|
+
funcCount++;
|
|
64
|
+
issues.push({
|
|
65
|
+
type: 'FUNCTION_CONSTRUCTOR',
|
|
66
|
+
severity: 'ERROR',
|
|
67
|
+
message: `Function() constructor at ${node.file}:${node.line || '?'} - dynamic code execution is forbidden`,
|
|
68
|
+
nodeId: node.id,
|
|
69
|
+
file: node.file,
|
|
70
|
+
line: node.line
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
console.log(`[EvalBanValidator] Function() search took ${Date.now() - funcStart}ms, found ${funcCount} violations`);
|
|
75
|
+
// 3. Method call: window.eval, globalThis.eval, this.eval
|
|
76
|
+
// Note: METHOD_CALL was merged into CALL - method calls have 'method' attribute
|
|
77
|
+
console.log('[EvalBanValidator] Searching for method eval() calls...');
|
|
78
|
+
const methodStart = Date.now();
|
|
79
|
+
let methodCount = 0;
|
|
80
|
+
for await (const node of graph.queryNodes({ nodeType: 'CALL' })) {
|
|
81
|
+
const callNode = node;
|
|
82
|
+
// Method calls have 'method' attribute (e.g., window.eval())
|
|
83
|
+
if (callNode.method === 'eval' && callNode.object) {
|
|
84
|
+
methodCount++;
|
|
85
|
+
const objectName = callNode.object;
|
|
86
|
+
issues.push({
|
|
87
|
+
type: 'EVAL_METHOD',
|
|
88
|
+
severity: 'ERROR',
|
|
89
|
+
message: `${objectName}.eval() call at ${node.file}:${node.line || '?'} - dynamic code execution is forbidden`,
|
|
90
|
+
nodeId: node.id,
|
|
91
|
+
file: node.file,
|
|
92
|
+
line: node.line,
|
|
93
|
+
object: objectName
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
console.log(`[EvalBanValidator] method eval() search took ${Date.now() - methodStart}ms, found ${methodCount} violations`);
|
|
98
|
+
// 4. Aliased eval - SKIP for now (complex Datalog query causes OOM)
|
|
99
|
+
console.log('[EvalBanValidator] Skipping aliased eval detection (requires optimized implementation)');
|
|
100
|
+
const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
101
|
+
const summary = {
|
|
102
|
+
evalCalls: evalCount,
|
|
103
|
+
functionCalls: funcCount,
|
|
104
|
+
methodEvalCalls: methodCount,
|
|
105
|
+
aliasedEvalCalls: 0, // Skipped for now
|
|
106
|
+
totalViolations: issues.length,
|
|
107
|
+
timeSeconds: totalTime
|
|
108
|
+
};
|
|
109
|
+
console.log('[EvalBanValidator] Summary:', summary);
|
|
110
|
+
if (issues.length > 0) {
|
|
111
|
+
console.log('[EvalBanValidator] ❌ Security violations found:');
|
|
112
|
+
for (const issue of issues) {
|
|
113
|
+
console.log(` 🚫 ${issue.message}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
console.log('[EvalBanValidator] ✅ No eval/Function usage detected');
|
|
118
|
+
}
|
|
119
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, // created - validator doesn't create nodes/edges
|
|
120
|
+
{ summary, issues } // metadata
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphConnectivityValidator - проверяет что все узлы связаны с корневыми узлами
|
|
3
|
+
* Находит "островки" - узлы которые не имеют путей до SERVICE/MODULE
|
|
4
|
+
*/
|
|
5
|
+
import { Plugin } from '../Plugin.js';
|
|
6
|
+
import type { PluginContext, PluginMetadata, PluginResult } from '../Plugin.js';
|
|
7
|
+
export declare class GraphConnectivityValidator extends Plugin {
|
|
8
|
+
get metadata(): PluginMetadata;
|
|
9
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=GraphConnectivityValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphConnectivityValidator.d.ts","sourceRoot":"","sources":["../../../src/plugins/validation/GraphConnectivityValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAyChF,qBAAa,0BAA2B,SAAQ,MAAM;IACpD,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA4I7D"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphConnectivityValidator - проверяет что все узлы связаны с корневыми узлами
|
|
3
|
+
* Находит "островки" - узлы которые не имеют путей до SERVICE/MODULE
|
|
4
|
+
*/
|
|
5
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
6
|
+
export class GraphConnectivityValidator extends Plugin {
|
|
7
|
+
get metadata() {
|
|
8
|
+
return {
|
|
9
|
+
name: 'GraphConnectivityValidator',
|
|
10
|
+
phase: 'VALIDATION',
|
|
11
|
+
priority: 100,
|
|
12
|
+
creates: {
|
|
13
|
+
nodes: [],
|
|
14
|
+
edges: []
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async execute(context) {
|
|
19
|
+
const { graph, manifest } = context;
|
|
20
|
+
const manifestWithValidation = manifest;
|
|
21
|
+
console.log('[GraphConnectivityValidator] Starting connectivity validation...');
|
|
22
|
+
// Получаем все узлы
|
|
23
|
+
const allNodes = await graph.getAllNodes();
|
|
24
|
+
console.log(`[GraphConnectivityValidator] Total nodes: ${allNodes.length}`);
|
|
25
|
+
// Находим корневые узлы (SERVICE, MODULE)
|
|
26
|
+
const rootTypes = ['SERVICE', 'MODULE', 'PROJECT'];
|
|
27
|
+
const rootNodes = allNodes.filter(n => rootTypes.includes(n.type));
|
|
28
|
+
console.log(`[GraphConnectivityValidator] Root nodes: ${rootNodes.length}`);
|
|
29
|
+
if (rootNodes.length === 0) {
|
|
30
|
+
console.warn('[GraphConnectivityValidator] No root nodes found!');
|
|
31
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { skipped: true, reason: 'No root nodes' });
|
|
32
|
+
}
|
|
33
|
+
// Check if graph supports getAllEdges
|
|
34
|
+
if (!graph.getAllEdges) {
|
|
35
|
+
console.log('[GraphConnectivityValidator] Graph does not support getAllEdges, skipping validation');
|
|
36
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { skipped: true, reason: 'No getAllEdges support' });
|
|
37
|
+
}
|
|
38
|
+
// Собираем все ребра
|
|
39
|
+
const allEdges = await graph.getAllEdges();
|
|
40
|
+
console.log(`[GraphConnectivityValidator] Total edges: ${allEdges.length}`);
|
|
41
|
+
// Строим карты смежности (обе направления)
|
|
42
|
+
const adjacencyOut = new Map(); // nodeId -> [targetIds]
|
|
43
|
+
const adjacencyIn = new Map(); // nodeId -> [sourceIds]
|
|
44
|
+
for (const edge of allEdges) {
|
|
45
|
+
// Outgoing edges
|
|
46
|
+
if (!adjacencyOut.has(edge.src)) {
|
|
47
|
+
adjacencyOut.set(edge.src, []);
|
|
48
|
+
}
|
|
49
|
+
adjacencyOut.get(edge.src).push(edge.dst);
|
|
50
|
+
// Incoming edges
|
|
51
|
+
if (!adjacencyIn.has(edge.dst)) {
|
|
52
|
+
adjacencyIn.set(edge.dst, []);
|
|
53
|
+
}
|
|
54
|
+
adjacencyIn.get(edge.dst).push(edge.src);
|
|
55
|
+
}
|
|
56
|
+
// BFS от корневых узлов для поиска достижимых узлов
|
|
57
|
+
const reachable = new Set();
|
|
58
|
+
const queue = [...rootNodes.map(n => n.id)];
|
|
59
|
+
while (queue.length > 0) {
|
|
60
|
+
const nodeId = queue.shift();
|
|
61
|
+
if (reachable.has(nodeId))
|
|
62
|
+
continue;
|
|
63
|
+
reachable.add(nodeId);
|
|
64
|
+
// Добавляем все связанные узлы (в обоих направлениях)
|
|
65
|
+
const outgoing = adjacencyOut.get(nodeId) || [];
|
|
66
|
+
const incoming = adjacencyIn.get(nodeId) || [];
|
|
67
|
+
for (const targetId of [...outgoing, ...incoming]) {
|
|
68
|
+
if (!reachable.has(targetId)) {
|
|
69
|
+
queue.push(targetId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Находим недостижимые узлы
|
|
74
|
+
const unreachable = allNodes.filter(n => !reachable.has(n.id));
|
|
75
|
+
if (unreachable.length > 0) {
|
|
76
|
+
// ЯРКОЕ ПРЕДУПРЕЖДЕНИЕ В КОНСОЛИ
|
|
77
|
+
console.error('\n' + '='.repeat(80));
|
|
78
|
+
console.error('⚠️ GRAPH VALIDATION ERROR: DISCONNECTED NODES FOUND');
|
|
79
|
+
console.error('='.repeat(80));
|
|
80
|
+
console.error(`Found ${unreachable.length} unreachable nodes (${((unreachable.length / allNodes.length) * 100).toFixed(1)}% of total)`);
|
|
81
|
+
console.error(`These nodes are not connected to the main graph (SERVICE/MODULE/PROJECT level)`);
|
|
82
|
+
console.error('');
|
|
83
|
+
// Группируем по типам для читаемости
|
|
84
|
+
const byType = {};
|
|
85
|
+
for (const node of unreachable) {
|
|
86
|
+
if (!byType[node.type])
|
|
87
|
+
byType[node.type] = [];
|
|
88
|
+
byType[node.type].push(node);
|
|
89
|
+
}
|
|
90
|
+
for (const [type, nodes] of Object.entries(byType)) {
|
|
91
|
+
console.error(` ${type}: ${nodes.length} nodes`);
|
|
92
|
+
// Показываем первые 5 для каждого типа
|
|
93
|
+
for (const node of nodes.slice(0, 5)) {
|
|
94
|
+
console.error(` - ${node.name || node.id}`);
|
|
95
|
+
// Показываем связи этого узла
|
|
96
|
+
const out = adjacencyOut.get(node.id) || [];
|
|
97
|
+
const incoming = adjacencyIn.get(node.id) || [];
|
|
98
|
+
if (out.length > 0 || incoming.length > 0) {
|
|
99
|
+
console.error(` Edges: ${incoming.length} incoming, ${out.length} outgoing`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (nodes.length > 5) {
|
|
103
|
+
console.error(` ... and ${nodes.length - 5} more`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
console.error('');
|
|
107
|
+
console.error('💡 ACTION REQUIRED: Fix analysis plugins to ensure all nodes are connected');
|
|
108
|
+
console.error(' Anonymous functions, callbacks, and method calls should be linked to parent nodes');
|
|
109
|
+
console.error('='.repeat(80) + '\n');
|
|
110
|
+
// Сохраняем информацию в manifest для дальнейшего использования
|
|
111
|
+
if (!manifestWithValidation.validation)
|
|
112
|
+
manifestWithValidation.validation = {};
|
|
113
|
+
manifestWithValidation.validation.unreachableNodes = unreachable.map(n => ({
|
|
114
|
+
id: n.id,
|
|
115
|
+
type: n.type,
|
|
116
|
+
name: n.name
|
|
117
|
+
}));
|
|
118
|
+
manifestWithValidation.validation.hasErrors = true;
|
|
119
|
+
manifestWithValidation.validation.totalNodes = allNodes.length;
|
|
120
|
+
manifestWithValidation.validation.reachableNodes = reachable.size;
|
|
121
|
+
manifestWithValidation.validation.unreachableCount = unreachable.length;
|
|
122
|
+
manifestWithValidation.validation.unreachableByType = Object.fromEntries(Object.entries(byType).map(([type, nodes]) => [type, nodes.length]));
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.log('[GraphConnectivityValidator] ✅ All nodes are reachable from root nodes');
|
|
126
|
+
if (!manifestWithValidation.validation)
|
|
127
|
+
manifestWithValidation.validation = {};
|
|
128
|
+
manifestWithValidation.validation.hasErrors = false;
|
|
129
|
+
manifestWithValidation.validation.totalNodes = allNodes.length;
|
|
130
|
+
manifestWithValidation.validation.reachableNodes = reachable.size;
|
|
131
|
+
}
|
|
132
|
+
console.log(`[GraphConnectivityValidator] Validation complete: ${reachable.size}/${allNodes.length} nodes reachable`);
|
|
133
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { totalNodes: allNodes.length, reachableNodes: reachable.size });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLInjectionValidator - детектирует SQL injection уязвимости
|
|
3
|
+
*
|
|
4
|
+
* Security инвариант: SQL запросы не должны содержать недетерминированные
|
|
5
|
+
* значения (user input) без параметризации.
|
|
6
|
+
*
|
|
7
|
+
* Детектирует:
|
|
8
|
+
* - Template literal с переменными от параметров: `SELECT * FROM users WHERE id = ${userId}`
|
|
9
|
+
* - String concatenation с user input: "SELECT * FROM users WHERE id = " + userId
|
|
10
|
+
*
|
|
11
|
+
* Безопасные паттерны (НЕ flagged):
|
|
12
|
+
* - Параметризованные запросы: db.query('SELECT * FROM users WHERE id = ?', [userId])
|
|
13
|
+
* - Только литералы: const query = 'SELECT * FROM users'
|
|
14
|
+
* - Литералы в template: const role = 'admin'; `SELECT * FROM users WHERE role = '${role}'`
|
|
15
|
+
*
|
|
16
|
+
* ПРАВИЛА:
|
|
17
|
+
* 1. Найти CALL с method = query/execute/run/all/get
|
|
18
|
+
* 2. Проверить первый аргумент - если содержит nondeterministic value → violation
|
|
19
|
+
* 3. Использовать ValueDomainAnalyzer для трассировки значений
|
|
20
|
+
*/
|
|
21
|
+
import { Plugin } from '../Plugin.js';
|
|
22
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
23
|
+
export declare class SQLInjectionValidator extends Plugin {
|
|
24
|
+
private valueAnalyzer;
|
|
25
|
+
constructor();
|
|
26
|
+
get metadata(): PluginMetadata;
|
|
27
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Analyze a SQL query call for injection vulnerabilities
|
|
30
|
+
*/
|
|
31
|
+
private analyzeQueryCall;
|
|
32
|
+
/**
|
|
33
|
+
* Check if an expression contains nondeterministic values
|
|
34
|
+
*/
|
|
35
|
+
private checkExpressionForNondeterminism;
|
|
36
|
+
/**
|
|
37
|
+
* Check via Datalog graph pattern for SQL injection
|
|
38
|
+
* Pattern: CALL -[PASSES_ARGUMENT]-> VARIABLE -[ASSIGNED_FROM*]-> PARAMETER
|
|
39
|
+
*/
|
|
40
|
+
private checkViaGraphPattern;
|
|
41
|
+
}
|
|
42
|
+
export default SQLInjectionValidator;
|
|
43
|
+
//# sourceMappingURL=SQLInjectionValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SQLInjectionValidator.d.ts","sourceRoot":"","sources":["../../../src/plugins/validation/SQLInjectionValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAsEhF,qBAAa,qBAAsB,SAAQ,MAAM;IAC/C,OAAO,CAAC,aAAa,CAAsB;;IAO3C,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAmE5D;;OAEG;YACW,gBAAgB;IAgF9B;;OAEG;YACW,gCAAgC;IAsC9C;;;OAGG;YACW,oBAAoB;CAqDnC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLInjectionValidator - детектирует SQL injection уязвимости
|
|
3
|
+
*
|
|
4
|
+
* Security инвариант: SQL запросы не должны содержать недетерминированные
|
|
5
|
+
* значения (user input) без параметризации.
|
|
6
|
+
*
|
|
7
|
+
* Детектирует:
|
|
8
|
+
* - Template literal с переменными от параметров: `SELECT * FROM users WHERE id = ${userId}`
|
|
9
|
+
* - String concatenation с user input: "SELECT * FROM users WHERE id = " + userId
|
|
10
|
+
*
|
|
11
|
+
* Безопасные паттерны (НЕ flagged):
|
|
12
|
+
* - Параметризованные запросы: db.query('SELECT * FROM users WHERE id = ?', [userId])
|
|
13
|
+
* - Только литералы: const query = 'SELECT * FROM users'
|
|
14
|
+
* - Литералы в template: const role = 'admin'; `SELECT * FROM users WHERE role = '${role}'`
|
|
15
|
+
*
|
|
16
|
+
* ПРАВИЛА:
|
|
17
|
+
* 1. Найти CALL с method = query/execute/run/all/get
|
|
18
|
+
* 2. Проверить первый аргумент - если содержит nondeterministic value → violation
|
|
19
|
+
* 3. Использовать ValueDomainAnalyzer для трассировки значений
|
|
20
|
+
*/
|
|
21
|
+
import { Plugin, createSuccessResult } from '../Plugin.js';
|
|
22
|
+
import { ValueDomainAnalyzer } from '../enrichment/ValueDomainAnalyzer.js';
|
|
23
|
+
// SQL query method names to detect
|
|
24
|
+
const SQL_METHODS = ['query', 'execute', 'exec', 'run', 'all', 'get', 'prepare', 'raw'];
|
|
25
|
+
export class SQLInjectionValidator extends Plugin {
|
|
26
|
+
valueAnalyzer;
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this.valueAnalyzer = new ValueDomainAnalyzer();
|
|
30
|
+
}
|
|
31
|
+
get metadata() {
|
|
32
|
+
return {
|
|
33
|
+
name: 'SQLInjectionValidator',
|
|
34
|
+
phase: 'VALIDATION',
|
|
35
|
+
priority: 90, // After ValueDomainAnalyzer (65)
|
|
36
|
+
creates: {
|
|
37
|
+
nodes: [],
|
|
38
|
+
edges: []
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async execute(context) {
|
|
43
|
+
const { graph } = context;
|
|
44
|
+
console.log('[SQLInjectionValidator] Checking for SQL injection vulnerabilities...');
|
|
45
|
+
const issues = [];
|
|
46
|
+
// 1. Find all CALL nodes that look like SQL queries
|
|
47
|
+
const sqlCalls = [];
|
|
48
|
+
for await (const node of graph.queryNodes({ nodeType: 'CALL' })) {
|
|
49
|
+
const callNode = node;
|
|
50
|
+
const method = callNode.method || callNode.name;
|
|
51
|
+
if (method && SQL_METHODS.includes(method)) {
|
|
52
|
+
sqlCalls.push(callNode);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
console.log(`[SQLInjectionValidator] Found ${sqlCalls.length} potential SQL calls`);
|
|
56
|
+
// 2. For each SQL call, analyze the query argument
|
|
57
|
+
for (const call of sqlCalls) {
|
|
58
|
+
const result = await this.analyzeQueryCall(call, graph);
|
|
59
|
+
if (result.isVulnerable) {
|
|
60
|
+
issues.push({
|
|
61
|
+
type: 'SQL_INJECTION',
|
|
62
|
+
severity: 'ERROR',
|
|
63
|
+
message: `Potential SQL injection at ${call.file}:${call.line || '?'} - ${result.reason}`,
|
|
64
|
+
nodeId: call.id,
|
|
65
|
+
file: call.file,
|
|
66
|
+
line: call.line,
|
|
67
|
+
reason: result.reason,
|
|
68
|
+
nondeterministicSources: result.sources
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// 3. Also check via graph pattern - CALL nodes that have ARGUMENT -> PARAMETER paths
|
|
73
|
+
const patternViolations = await this.checkViaGraphPattern(graph, sqlCalls);
|
|
74
|
+
for (const violation of patternViolations) {
|
|
75
|
+
// Avoid duplicates
|
|
76
|
+
if (!issues.find(i => i.nodeId === violation.nodeId)) {
|
|
77
|
+
issues.push(violation);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const summary = {
|
|
81
|
+
sqlCallsChecked: sqlCalls.length,
|
|
82
|
+
vulnerabilitiesFound: issues.length
|
|
83
|
+
};
|
|
84
|
+
console.log('[SQLInjectionValidator] Summary:', summary);
|
|
85
|
+
if (issues.length > 0) {
|
|
86
|
+
console.log('[SQLInjectionValidator] ❌ SQL injection vulnerabilities found:');
|
|
87
|
+
for (const issue of issues) {
|
|
88
|
+
console.log(` 🚫 ${issue.message}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.log('[SQLInjectionValidator] ✅ No SQL injection vulnerabilities detected');
|
|
93
|
+
}
|
|
94
|
+
return createSuccessResult({ nodes: 0, edges: 0 }, { summary, issues });
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Analyze a SQL query call for injection vulnerabilities
|
|
98
|
+
*/
|
|
99
|
+
async analyzeQueryCall(call, graph) {
|
|
100
|
+
const result = {
|
|
101
|
+
isVulnerable: false,
|
|
102
|
+
reason: null,
|
|
103
|
+
sources: []
|
|
104
|
+
};
|
|
105
|
+
// Get the query argument - usually first argument
|
|
106
|
+
// We need to check if it has nondeterministic content
|
|
107
|
+
// Check if this call has PASSES_ARGUMENT edges
|
|
108
|
+
const outgoing = await graph.getOutgoingEdges(call.id);
|
|
109
|
+
const argEdges = outgoing.filter(e => (e.edgeType || e.edge_type) === 'PASSES_ARGUMENT');
|
|
110
|
+
if (argEdges.length === 0) {
|
|
111
|
+
// No tracked arguments - check via queryArgName attribute if available
|
|
112
|
+
if (call.queryArgName) {
|
|
113
|
+
const valueSet = await this.valueAnalyzer.getValueSet(call.queryArgName, call.file, graph);
|
|
114
|
+
if (valueSet.hasUnknown) {
|
|
115
|
+
result.isVulnerable = true;
|
|
116
|
+
result.reason = `Query argument "${call.queryArgName}" contains user input`;
|
|
117
|
+
result.sources = ['unknown'];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
// Check each argument
|
|
123
|
+
for (const edge of argEdges) {
|
|
124
|
+
const argId = edge.dst || edge.target_id;
|
|
125
|
+
const argNode = await graph.getNode(argId);
|
|
126
|
+
if (!argNode)
|
|
127
|
+
continue;
|
|
128
|
+
const argIndex = edge.argIndex || edge.index;
|
|
129
|
+
if (argIndex !== 0 && argIndex !== undefined)
|
|
130
|
+
continue; // Only check first argument
|
|
131
|
+
// Check argument type
|
|
132
|
+
const argType = argNode.nodeType || argNode.type;
|
|
133
|
+
if (argType === 'LITERAL') {
|
|
134
|
+
// Pure literal - safe
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (argType === 'VARIABLE' || argType === 'CONSTANT') {
|
|
138
|
+
// Trace value domain
|
|
139
|
+
const varName = argNode.name || argNode.attrs?.name;
|
|
140
|
+
if (varName) {
|
|
141
|
+
const valueSet = await this.valueAnalyzer.getValueSet(varName, call.file, graph);
|
|
142
|
+
if (valueSet.hasUnknown) {
|
|
143
|
+
result.isVulnerable = true;
|
|
144
|
+
result.reason = `Query variable "${varName}" may contain user input`;
|
|
145
|
+
result.sources.push(varName);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (argType === 'PARAMETER') {
|
|
150
|
+
// Direct parameter in query - definitely vulnerable
|
|
151
|
+
result.isVulnerable = true;
|
|
152
|
+
result.reason = 'Query contains direct function parameter';
|
|
153
|
+
result.sources.push(argNode.name || 'parameter');
|
|
154
|
+
}
|
|
155
|
+
if (argType === 'EXPRESSION') {
|
|
156
|
+
// Template literal or concatenation - check for nondeterministic values
|
|
157
|
+
const { hasUnknown, sources } = await this.checkExpressionForNondeterminism(argNode, graph);
|
|
158
|
+
if (hasUnknown) {
|
|
159
|
+
result.isVulnerable = true;
|
|
160
|
+
result.reason = 'Query expression contains nondeterministic values';
|
|
161
|
+
result.sources.push(...sources);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Check if an expression contains nondeterministic values
|
|
169
|
+
*/
|
|
170
|
+
async checkExpressionForNondeterminism(exprNode, graph) {
|
|
171
|
+
const result = { hasUnknown: false, sources: [] };
|
|
172
|
+
// Check DERIVES_FROM edges
|
|
173
|
+
const outgoing = await graph.getOutgoingEdges(exprNode.id);
|
|
174
|
+
const derivesFromEdges = outgoing.filter(e => (e.edgeType || e.edge_type) === 'DERIVES_FROM' ||
|
|
175
|
+
(e.edgeType || e.edge_type) === 'ASSIGNED_FROM');
|
|
176
|
+
for (const edge of derivesFromEdges) {
|
|
177
|
+
const sourceId = edge.dst || edge.target_id;
|
|
178
|
+
const sourceNode = await graph.getNode(sourceId);
|
|
179
|
+
if (!sourceNode)
|
|
180
|
+
continue;
|
|
181
|
+
const sourceType = sourceNode.nodeType || sourceNode.type;
|
|
182
|
+
if (sourceType === 'PARAMETER') {
|
|
183
|
+
result.hasUnknown = true;
|
|
184
|
+
result.sources.push(sourceNode.name || 'parameter');
|
|
185
|
+
}
|
|
186
|
+
else if (sourceType === 'VARIABLE' || sourceType === 'CONSTANT') {
|
|
187
|
+
const varName = sourceNode.name || sourceNode.attrs?.name;
|
|
188
|
+
if (varName) {
|
|
189
|
+
const valueSet = await this.valueAnalyzer.getValueSet(varName, exprNode.file, graph);
|
|
190
|
+
if (valueSet.hasUnknown) {
|
|
191
|
+
result.hasUnknown = true;
|
|
192
|
+
result.sources.push(varName);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check via Datalog graph pattern for SQL injection
|
|
201
|
+
* Pattern: CALL -[PASSES_ARGUMENT]-> VARIABLE -[ASSIGNED_FROM*]-> PARAMETER
|
|
202
|
+
*/
|
|
203
|
+
async checkViaGraphPattern(graph, excludeCalls = []) {
|
|
204
|
+
const issues = [];
|
|
205
|
+
const excludeIds = new Set(excludeCalls.map(c => c.id));
|
|
206
|
+
// Find CALL nodes that have argument tracing to PARAMETER
|
|
207
|
+
try {
|
|
208
|
+
// Check if graph supports checkGuarantee
|
|
209
|
+
if (!graph.checkGuarantee) {
|
|
210
|
+
console.log('[SQLInjectionValidator] Graph does not support checkGuarantee, skipping pattern-based check');
|
|
211
|
+
return issues;
|
|
212
|
+
}
|
|
213
|
+
// Check guarantee for SQL method calls with parameter-derived arguments
|
|
214
|
+
const violations = await graph.checkGuarantee(`
|
|
215
|
+
violation(X) :-
|
|
216
|
+
node(X, "CALL"),
|
|
217
|
+
attr(X, "method", M),
|
|
218
|
+
edge(X, Arg, "PASSES_ARGUMENT"),
|
|
219
|
+
edge(Arg, P, "ASSIGNED_FROM"),
|
|
220
|
+
node(P, "PARAMETER").
|
|
221
|
+
`);
|
|
222
|
+
for (const v of violations) {
|
|
223
|
+
const nodeId = v.bindings.find(b => b.name === 'X')?.value;
|
|
224
|
+
if (nodeId && !excludeIds.has(nodeId)) {
|
|
225
|
+
const node = await graph.getNode(nodeId);
|
|
226
|
+
if (node) {
|
|
227
|
+
const method = node.method || node.name;
|
|
228
|
+
if (SQL_METHODS.includes(method)) {
|
|
229
|
+
issues.push({
|
|
230
|
+
type: 'SQL_INJECTION',
|
|
231
|
+
severity: 'ERROR',
|
|
232
|
+
message: `SQL injection via parameter flow at ${node.file}:${node.line || '?'}`,
|
|
233
|
+
nodeId,
|
|
234
|
+
file: node.file,
|
|
235
|
+
line: node.line,
|
|
236
|
+
reason: 'Parameter value flows into SQL query',
|
|
237
|
+
nondeterministicSources: ['parameter']
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
// Datalog query might fail if backend doesn't support it
|
|
246
|
+
console.log('[SQLInjectionValidator] Datalog check skipped:', err.message);
|
|
247
|
+
}
|
|
248
|
+
return issues;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
export default SQLInjectionValidator;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShadowingDetector - detects variable shadowing issues
|
|
3
|
+
*
|
|
4
|
+
* Detects two types of shadowing:
|
|
5
|
+
*
|
|
6
|
+
* 1. Cross-file shadowing:
|
|
7
|
+
* - CLASS `User` defined in models.js
|
|
8
|
+
* - VARIABLE `User` in handlers.js shadows the class
|
|
9
|
+
* - Method calls on the variable go to wrong target
|
|
10
|
+
*
|
|
11
|
+
* 2. Scope-aware shadowing:
|
|
12
|
+
* - import { User } from './models'
|
|
13
|
+
* - function handler() { const User = {...}; User.save(); }
|
|
14
|
+
* - Local variable shadows the imported class
|
|
15
|
+
*
|
|
16
|
+
* Implementation notes:
|
|
17
|
+
* - Datalog doesn't support inequality (\=), so we use JS filtering
|
|
18
|
+
* - queryNodes is an async generator, use getAllNodes for arrays
|
|
19
|
+
*/
|
|
20
|
+
import { Plugin } from '../Plugin.js';
|
|
21
|
+
import type { PluginContext, PluginResult, PluginMetadata } from '../Plugin.js';
|
|
22
|
+
export declare class ShadowingDetector extends Plugin {
|
|
23
|
+
get metadata(): PluginMetadata;
|
|
24
|
+
execute(context: PluginContext): Promise<PluginResult>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ShadowingDetector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShadowingDetector.d.ts","sourceRoot":"","sources":["../../../src/plugins/validation/ShadowingDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAoChF,qBAAa,iBAAkB,SAAQ,MAAM;IAC3C,IAAI,QAAQ,IAAI,cAAc,CAU7B;IAEK,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAsG7D"}
|