api-tests-coverage 1.0.0
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 +703 -0
- package/config.yaml.example +227 -0
- package/dist/action/src/index.d.ts +2 -0
- package/dist/action/src/index.d.ts.map +1 -0
- package/dist/action/src/index.js +349 -0
- package/dist/action/src/prComment.d.ts +34 -0
- package/dist/action/src/prComment.d.ts.map +1 -0
- package/dist/action/src/prComment.js +146 -0
- package/dist/src/ast/astAnalysisOrchestrator.d.ts +36 -0
- package/dist/src/ast/astAnalysisOrchestrator.d.ts.map +1 -0
- package/dist/src/ast/astAnalysisOrchestrator.js +123 -0
- package/dist/src/ast/astTypes.d.ts +105 -0
- package/dist/src/ast/astTypes.d.ts.map +1 -0
- package/dist/src/ast/astTypes.js +9 -0
- package/dist/src/ast/languageAnalyzer.d.ts +46 -0
- package/dist/src/ast/languageAnalyzer.d.ts.map +1 -0
- package/dist/src/ast/languageAnalyzer.js +9 -0
- package/dist/src/ast/languageCapabilities.d.ts +24 -0
- package/dist/src/ast/languageCapabilities.d.ts.map +1 -0
- package/dist/src/ast/languageCapabilities.js +92 -0
- package/dist/src/ast/parseFile.d.ts +16 -0
- package/dist/src/ast/parseFile.d.ts.map +1 -0
- package/dist/src/ast/parseFile.js +65 -0
- package/dist/src/ast/parserRegistry.d.ts +39 -0
- package/dist/src/ast/parserRegistry.d.ts.map +1 -0
- package/dist/src/ast/parserRegistry.js +66 -0
- package/dist/src/buildSummary.d.ts +26 -0
- package/dist/src/buildSummary.d.ts.map +1 -0
- package/dist/src/buildSummary.js +193 -0
- package/dist/src/businessCoverage.d.ts +68 -0
- package/dist/src/businessCoverage.d.ts.map +1 -0
- package/dist/src/businessCoverage.js +290 -0
- package/dist/src/compatibilityCoverage.d.ts +83 -0
- package/dist/src/compatibilityCoverage.d.ts.map +1 -0
- package/dist/src/compatibilityCoverage.js +501 -0
- package/dist/src/config/defaultConfig.d.ts +9 -0
- package/dist/src/config/defaultConfig.d.ts.map +1 -0
- package/dist/src/config/defaultConfig.js +97 -0
- package/dist/src/config/index.d.ts +12 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +37 -0
- package/dist/src/config/loadConfig.d.ts +29 -0
- package/dist/src/config/loadConfig.d.ts.map +1 -0
- package/dist/src/config/loadConfig.js +135 -0
- package/dist/src/config/mergeConfig.d.ts +15 -0
- package/dist/src/config/mergeConfig.d.ts.map +1 -0
- package/dist/src/config/mergeConfig.js +57 -0
- package/dist/src/config/schema.d.ts +15 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +30 -0
- package/dist/src/config/types.d.ts +175 -0
- package/dist/src/config/types.d.ts.map +1 -0
- package/dist/src/config/types.js +9 -0
- package/dist/src/config/validateConfig.d.ts +22 -0
- package/dist/src/config/validateConfig.d.ts.map +1 -0
- package/dist/src/config/validateConfig.js +171 -0
- package/dist/src/config.d.ts +168 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +204 -0
- package/dist/src/coverage/deep-analysis/callGraph.d.ts +67 -0
- package/dist/src/coverage/deep-analysis/callGraph.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/callGraph.js +275 -0
- package/dist/src/coverage/deep-analysis/deepEndpointResolver.d.ts +23 -0
- package/dist/src/coverage/deep-analysis/deepEndpointResolver.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/deepEndpointResolver.js +394 -0
- package/dist/src/coverage/deep-analysis/index.d.ts +17 -0
- package/dist/src/coverage/deep-analysis/index.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/index.js +63 -0
- package/dist/src/coverage/deep-analysis/resolveAssertions.d.ts +60 -0
- package/dist/src/coverage/deep-analysis/resolveAssertions.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveAssertions.js +121 -0
- package/dist/src/coverage/deep-analysis/resolveConstants.d.ts +36 -0
- package/dist/src/coverage/deep-analysis/resolveConstants.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveConstants.js +92 -0
- package/dist/src/coverage/deep-analysis/resolveEnums.d.ts +55 -0
- package/dist/src/coverage/deep-analysis/resolveEnums.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveEnums.js +152 -0
- package/dist/src/coverage/deep-analysis/resolveMethodChains.d.ts +70 -0
- package/dist/src/coverage/deep-analysis/resolveMethodChains.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveMethodChains.js +152 -0
- package/dist/src/coverage/deep-analysis/resolvePaths.d.ts +80 -0
- package/dist/src/coverage/deep-analysis/resolvePaths.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolvePaths.js +216 -0
- package/dist/src/coverage/deep-analysis/resolveRequestWrappers.d.ts +71 -0
- package/dist/src/coverage/deep-analysis/resolveRequestWrappers.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/resolveRequestWrappers.js +226 -0
- package/dist/src/coverage/deep-analysis/symbolTable.d.ts +58 -0
- package/dist/src/coverage/deep-analysis/symbolTable.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/symbolTable.js +230 -0
- package/dist/src/coverage/deep-analysis/types.d.ts +122 -0
- package/dist/src/coverage/deep-analysis/types.d.ts.map +1 -0
- package/dist/src/coverage/deep-analysis/types.js +21 -0
- package/dist/src/discovery/fileClassifier.d.ts +50 -0
- package/dist/src/discovery/fileClassifier.d.ts.map +1 -0
- package/dist/src/discovery/fileClassifier.js +238 -0
- package/dist/src/discovery/projectDiscovery.d.ts +66 -0
- package/dist/src/discovery/projectDiscovery.d.ts.map +1 -0
- package/dist/src/discovery/projectDiscovery.js +287 -0
- package/dist/src/endpointCoverage.d.ts +70 -0
- package/dist/src/endpointCoverage.d.ts.map +1 -0
- package/dist/src/endpointCoverage.js +381 -0
- package/dist/src/errorCoverage.d.ts +93 -0
- package/dist/src/errorCoverage.d.ts.map +1 -0
- package/dist/src/errorCoverage.js +698 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +1441 -0
- package/dist/src/inference/businessRuleInference.d.ts +63 -0
- package/dist/src/inference/businessRuleInference.d.ts.map +1 -0
- package/dist/src/inference/businessRuleInference.js +268 -0
- package/dist/src/inference/integrationFlowInference.d.ts +56 -0
- package/dist/src/inference/integrationFlowInference.d.ts.map +1 -0
- package/dist/src/inference/integrationFlowInference.js +266 -0
- package/dist/src/integrationCoverage.d.ts +72 -0
- package/dist/src/integrationCoverage.d.ts.map +1 -0
- package/dist/src/integrationCoverage.js +317 -0
- package/dist/src/intelligence/index.d.ts +20 -0
- package/dist/src/intelligence/index.d.ts.map +1 -0
- package/dist/src/intelligence/index.js +105 -0
- package/dist/src/intelligence/linkageEngine.d.ts +20 -0
- package/dist/src/intelligence/linkageEngine.d.ts.map +1 -0
- package/dist/src/intelligence/linkageEngine.js +522 -0
- package/dist/src/intelligence/markdownReporter.d.ts +12 -0
- package/dist/src/intelligence/markdownReporter.d.ts.map +1 -0
- package/dist/src/intelligence/markdownReporter.js +265 -0
- package/dist/src/intelligence/riskScoring.d.ts +53 -0
- package/dist/src/intelligence/riskScoring.d.ts.map +1 -0
- package/dist/src/intelligence/riskScoring.js +181 -0
- package/dist/src/intelligence/types.d.ts +121 -0
- package/dist/src/intelligence/types.d.ts.map +1 -0
- package/dist/src/intelligence/types.js +8 -0
- package/dist/src/languageDetection.d.ts +100 -0
- package/dist/src/languageDetection.d.ts.map +1 -0
- package/dist/src/languageDetection.js +349 -0
- package/dist/src/languages/java/index.d.ts +16 -0
- package/dist/src/languages/java/index.d.ts.map +1 -0
- package/dist/src/languages/java/index.js +103 -0
- package/dist/src/languages/java/parser.d.ts +7 -0
- package/dist/src/languages/java/parser.d.ts.map +1 -0
- package/dist/src/languages/java/parser.js +50 -0
- package/dist/src/languages/java/semanticBuilder.d.ts +21 -0
- package/dist/src/languages/java/semanticBuilder.d.ts.map +1 -0
- package/dist/src/languages/java/semanticBuilder.js +358 -0
- package/dist/src/languages/javascript/annotationExtractor.d.ts +20 -0
- package/dist/src/languages/javascript/annotationExtractor.d.ts.map +1 -0
- package/dist/src/languages/javascript/annotationExtractor.js +94 -0
- package/dist/src/languages/javascript/assertionResolver.d.ts +18 -0
- package/dist/src/languages/javascript/assertionResolver.d.ts.map +1 -0
- package/dist/src/languages/javascript/assertionResolver.js +150 -0
- package/dist/src/languages/javascript/callResolver.d.ts +23 -0
- package/dist/src/languages/javascript/callResolver.d.ts.map +1 -0
- package/dist/src/languages/javascript/callResolver.js +236 -0
- package/dist/src/languages/javascript/httpInteractionExtractor.d.ts +23 -0
- package/dist/src/languages/javascript/httpInteractionExtractor.d.ts.map +1 -0
- package/dist/src/languages/javascript/httpInteractionExtractor.js +205 -0
- package/dist/src/languages/javascript/index.d.ts +20 -0
- package/dist/src/languages/javascript/index.d.ts.map +1 -0
- package/dist/src/languages/javascript/index.js +136 -0
- package/dist/src/languages/javascript/parser.d.ts +14 -0
- package/dist/src/languages/javascript/parser.d.ts.map +1 -0
- package/dist/src/languages/javascript/parser.js +38 -0
- package/dist/src/languages/javascript/symbolResolver.d.ts +31 -0
- package/dist/src/languages/javascript/symbolResolver.d.ts.map +1 -0
- package/dist/src/languages/javascript/symbolResolver.js +183 -0
- package/dist/src/languages/kotlin/index.d.ts +16 -0
- package/dist/src/languages/kotlin/index.d.ts.map +1 -0
- package/dist/src/languages/kotlin/index.js +151 -0
- package/dist/src/languages/kotlin/parser.d.ts +11 -0
- package/dist/src/languages/kotlin/parser.d.ts.map +1 -0
- package/dist/src/languages/kotlin/parser.js +74 -0
- package/dist/src/languages/python/index.d.ts +15 -0
- package/dist/src/languages/python/index.d.ts.map +1 -0
- package/dist/src/languages/python/index.js +293 -0
- package/dist/src/languages/ruby/index.d.ts +15 -0
- package/dist/src/languages/ruby/index.d.ts.map +1 -0
- package/dist/src/languages/ruby/index.js +274 -0
- package/dist/src/languages/shared/treeSitterUtils.d.ts +43 -0
- package/dist/src/languages/shared/treeSitterUtils.d.ts.map +1 -0
- package/dist/src/languages/shared/treeSitterUtils.js +100 -0
- package/dist/src/languages/typescript/index.d.ts +14 -0
- package/dist/src/languages/typescript/index.d.ts.map +1 -0
- package/dist/src/languages/typescript/index.js +25 -0
- package/dist/src/lib/index.d.ts +228 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +486 -0
- package/dist/src/mcp/client/index.d.ts +37 -0
- package/dist/src/mcp/client/index.d.ts.map +1 -0
- package/dist/src/mcp/client/index.js +235 -0
- package/dist/src/mcp/config.d.ts +50 -0
- package/dist/src/mcp/config.d.ts.map +1 -0
- package/dist/src/mcp/config.js +125 -0
- package/dist/src/mcp/events.d.ts +24 -0
- package/dist/src/mcp/events.d.ts.map +1 -0
- package/dist/src/mcp/events.js +48 -0
- package/dist/src/mcp/fallback/index.d.ts +50 -0
- package/dist/src/mcp/fallback/index.d.ts.map +1 -0
- package/dist/src/mcp/fallback/index.js +216 -0
- package/dist/src/mcp/index.d.ts +67 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +212 -0
- package/dist/src/mcp/normalizer.d.ts +21 -0
- package/dist/src/mcp/normalizer.d.ts.map +1 -0
- package/dist/src/mcp/normalizer.js +99 -0
- package/dist/src/mcp/prompts/index.d.ts +86 -0
- package/dist/src/mcp/prompts/index.d.ts.map +1 -0
- package/dist/src/mcp/prompts/index.js +304 -0
- package/dist/src/mcp/templates/index.d.ts +35 -0
- package/dist/src/mcp/templates/index.d.ts.map +1 -0
- package/dist/src/mcp/templates/index.js +143 -0
- package/dist/src/mcp/testing/mock-server/index.d.ts +47 -0
- package/dist/src/mcp/testing/mock-server/index.d.ts.map +1 -0
- package/dist/src/mcp/testing/mock-server/index.js +157 -0
- package/dist/src/mcp/types.d.ts +127 -0
- package/dist/src/mcp/types.d.ts.map +1 -0
- package/dist/src/mcp/types.js +8 -0
- package/dist/src/observability.d.ts +138 -0
- package/dist/src/observability.d.ts.map +1 -0
- package/dist/src/observability.js +519 -0
- package/dist/src/parameterCoverage.d.ts +75 -0
- package/dist/src/parameterCoverage.d.ts.map +1 -0
- package/dist/src/parameterCoverage.js +629 -0
- package/dist/src/perfResilienceCoverage.d.ts +155 -0
- package/dist/src/perfResilienceCoverage.d.ts.map +1 -0
- package/dist/src/perfResilienceCoverage.js +670 -0
- package/dist/src/pluginLoader.d.ts +51 -0
- package/dist/src/pluginLoader.d.ts.map +1 -0
- package/dist/src/pluginLoader.js +72 -0
- package/dist/src/publishing.d.ts +63 -0
- package/dist/src/publishing.d.ts.map +1 -0
- package/dist/src/publishing.js +379 -0
- package/dist/src/qualityGate.d.ts +58 -0
- package/dist/src/qualityGate.d.ts.map +1 -0
- package/dist/src/qualityGate.js +118 -0
- package/dist/src/reporting.d.ts +41 -0
- package/dist/src/reporting.d.ts.map +1 -0
- package/dist/src/reporting.js +278 -0
- package/dist/src/screenshots.d.ts +71 -0
- package/dist/src/screenshots.d.ts.map +1 -0
- package/dist/src/screenshots.js +141 -0
- package/dist/src/security/gate/index.d.ts +11 -0
- package/dist/src/security/gate/index.d.ts.map +1 -0
- package/dist/src/security/gate/index.js +65 -0
- package/dist/src/security/index.d.ts +30 -0
- package/dist/src/security/index.d.ts.map +1 -0
- package/dist/src/security/index.js +342 -0
- package/dist/src/security/normalizers/semgrep.d.ts +10 -0
- package/dist/src/security/normalizers/semgrep.d.ts.map +1 -0
- package/dist/src/security/normalizers/semgrep.js +104 -0
- package/dist/src/security/normalizers/trivy.d.ts +10 -0
- package/dist/src/security/normalizers/trivy.d.ts.map +1 -0
- package/dist/src/security/normalizers/trivy.js +78 -0
- package/dist/src/security/normalizers/zap.d.ts +10 -0
- package/dist/src/security/normalizers/zap.d.ts.map +1 -0
- package/dist/src/security/normalizers/zap.js +104 -0
- package/dist/src/security/scanners/semgrep.d.ts +6 -0
- package/dist/src/security/scanners/semgrep.d.ts.map +1 -0
- package/dist/src/security/scanners/semgrep.js +125 -0
- package/dist/src/security/scanners/trivy.d.ts +6 -0
- package/dist/src/security/scanners/trivy.d.ts.map +1 -0
- package/dist/src/security/scanners/trivy.js +115 -0
- package/dist/src/security/scanners/zap.d.ts +6 -0
- package/dist/src/security/scanners/zap.d.ts.map +1 -0
- package/dist/src/security/scanners/zap.js +135 -0
- package/dist/src/security/types.d.ts +146 -0
- package/dist/src/security/types.d.ts.map +1 -0
- package/dist/src/security/types.js +6 -0
- package/dist/src/securityCoverage.d.ts +116 -0
- package/dist/src/securityCoverage.d.ts.map +1 -0
- package/dist/src/securityCoverage.js +725 -0
- package/dist/src/summary/buildSummary.d.ts +28 -0
- package/dist/src/summary/buildSummary.d.ts.map +1 -0
- package/dist/src/summary/buildSummary.js +257 -0
- package/dist/src/summary/evaluateMetrics.d.ts +31 -0
- package/dist/src/summary/evaluateMetrics.d.ts.map +1 -0
- package/dist/src/summary/evaluateMetrics.js +118 -0
- package/dist/src/summary/index.d.ts +10 -0
- package/dist/src/summary/index.d.ts.map +1 -0
- package/dist/src/summary/index.js +22 -0
- package/dist/src/summary/markdownRenderer.d.ts +139 -0
- package/dist/src/summary/markdownRenderer.d.ts.map +1 -0
- package/dist/src/summary/markdownRenderer.js +459 -0
- package/dist/src/summary/prSummary.d.ts +24 -0
- package/dist/src/summary/prSummary.d.ts.map +1 -0
- package/dist/src/summary/prSummary.js +233 -0
- package/dist/src/summary/summaryTypes.d.ts +35 -0
- package/dist/src/summary/summaryTypes.d.ts.map +1 -0
- package/dist/src/summary/summaryTypes.js +27 -0
- package/package.json +84 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP integration – client.
|
|
4
|
+
*
|
|
5
|
+
* Manages transport connections, sends prompts, and returns raw MCP responses.
|
|
6
|
+
* Supports stdio (child-process) and HTTP transports.
|
|
7
|
+
*
|
|
8
|
+
* Security:
|
|
9
|
+
* - Server URLs validated against allowlist before connection.
|
|
10
|
+
* - Transports validated against allowlist.
|
|
11
|
+
* - Payload size validated before sending.
|
|
12
|
+
* - Secrets redacted from all outgoing payloads.
|
|
13
|
+
* - Hard timeout enforced per request.
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.McpClient = void 0;
|
|
50
|
+
const http = __importStar(require("http"));
|
|
51
|
+
const https = __importStar(require("https"));
|
|
52
|
+
const childProcess = __importStar(require("child_process"));
|
|
53
|
+
const url_1 = require("url");
|
|
54
|
+
const config_1 = require("../config");
|
|
55
|
+
// ─── MCP Client ───────────────────────────────────────────────────────────────
|
|
56
|
+
class McpClient {
|
|
57
|
+
/**
|
|
58
|
+
* @param globalConfig MCP configuration block
|
|
59
|
+
* @param spawnFn Optional spawn override (useful in unit tests to avoid
|
|
60
|
+
* spawning real child processes)
|
|
61
|
+
*/
|
|
62
|
+
constructor(globalConfig, spawnFn) {
|
|
63
|
+
this.globalConfig = globalConfig;
|
|
64
|
+
this.spawnFn = spawnFn !== null && spawnFn !== void 0 ? spawnFn : childProcess.spawn;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Send a prompt to the named MCP server and return the raw response.
|
|
68
|
+
*
|
|
69
|
+
* @param serverName Key in config.servers (e.g. "coverageSummary")
|
|
70
|
+
* @param request Prompt request to send
|
|
71
|
+
*/
|
|
72
|
+
async send(serverName, request) {
|
|
73
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
74
|
+
const serverCfg = (0, config_1.resolveServerConfig)(this.globalConfig, serverName);
|
|
75
|
+
const transport = (_a = serverCfg.transport) !== null && _a !== void 0 ? _a : 'stdio';
|
|
76
|
+
// Security: validate transport and server URL
|
|
77
|
+
(0, config_1.validateTransport)(this.globalConfig, transport);
|
|
78
|
+
if (transport === 'http' && serverCfg.url) {
|
|
79
|
+
(0, config_1.validateServerUrl)(this.globalConfig, serverCfg.url);
|
|
80
|
+
}
|
|
81
|
+
// Security: redact secrets from context before serialising
|
|
82
|
+
const sanitisedRequest = {
|
|
83
|
+
...request,
|
|
84
|
+
context: (0, config_1.redactSecrets)(request.context),
|
|
85
|
+
};
|
|
86
|
+
const payload = JSON.stringify(sanitisedRequest);
|
|
87
|
+
(0, config_1.validatePayloadSize)(this.globalConfig, payload);
|
|
88
|
+
const maxRetries = (_c = (_b = this.globalConfig.retryPolicy) === null || _b === void 0 ? void 0 : _b.maxRetries) !== null && _c !== void 0 ? _c : config_1.MCP_DEFAULT_MAX_RETRIES;
|
|
89
|
+
const retryDelayMs = (_e = (_d = this.globalConfig.retryPolicy) === null || _d === void 0 ? void 0 : _d.retryDelayMs) !== null && _e !== void 0 ? _e : config_1.MCP_DEFAULT_RETRY_DELAY_MS;
|
|
90
|
+
const timeoutMs = (_f = serverCfg.timeoutMs) !== null && _f !== void 0 ? _f : config_1.MCP_DEFAULT_TIMEOUT_MS;
|
|
91
|
+
let lastError;
|
|
92
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
93
|
+
if (attempt > 0) {
|
|
94
|
+
await sleep(retryDelayMs);
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
if (transport === 'http') {
|
|
98
|
+
return await this.sendHttp(serverCfg.url, payload, timeoutMs);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return await this.sendStdio((_g = serverCfg.command) !== null && _g !== void 0 ? _g : 'node', (_h = serverCfg.args) !== null && _h !== void 0 ? _h : [], payload, timeoutMs);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { ok: false, error: (_j = lastError === null || lastError === void 0 ? void 0 : lastError.message) !== null && _j !== void 0 ? _j : 'Unknown MCP error' };
|
|
109
|
+
}
|
|
110
|
+
// ─── HTTP transport ─────────────────────────────────────────────────────────
|
|
111
|
+
sendHttp(url, payload, timeoutMs) {
|
|
112
|
+
return new Promise((resolve) => {
|
|
113
|
+
var _a;
|
|
114
|
+
const start = Date.now();
|
|
115
|
+
let resolved = false;
|
|
116
|
+
const timer = setTimeout(() => {
|
|
117
|
+
if (!resolved) {
|
|
118
|
+
resolved = true;
|
|
119
|
+
resolve({ ok: false, error: 'MCP HTTP request timed out', latencyMs: timeoutMs });
|
|
120
|
+
}
|
|
121
|
+
}, timeoutMs);
|
|
122
|
+
try {
|
|
123
|
+
const parsedUrl = new url_1.URL(url);
|
|
124
|
+
const isHttps = parsedUrl.protocol === 'https:';
|
|
125
|
+
const lib = isHttps ? https : http;
|
|
126
|
+
const options = {
|
|
127
|
+
hostname: parsedUrl.hostname,
|
|
128
|
+
port: parsedUrl.port || (isHttps ? 443 : 80),
|
|
129
|
+
path: parsedUrl.pathname + ((_a = parsedUrl.search) !== null && _a !== void 0 ? _a : ''),
|
|
130
|
+
method: 'POST',
|
|
131
|
+
headers: {
|
|
132
|
+
'Content-Type': 'application/json',
|
|
133
|
+
'Content-Length': Buffer.byteLength(payload),
|
|
134
|
+
},
|
|
135
|
+
timeout: timeoutMs,
|
|
136
|
+
};
|
|
137
|
+
const req = lib.request(options, (res) => {
|
|
138
|
+
const chunks = [];
|
|
139
|
+
res.on('data', (chunk) => chunks.push(chunk));
|
|
140
|
+
res.on('end', () => {
|
|
141
|
+
var _a, _b;
|
|
142
|
+
clearTimeout(timer);
|
|
143
|
+
if (!resolved) {
|
|
144
|
+
resolved = true;
|
|
145
|
+
const body = Buffer.concat(chunks).toString('utf-8');
|
|
146
|
+
const latencyMs = Date.now() - start;
|
|
147
|
+
if (((_a = res.statusCode) !== null && _a !== void 0 ? _a : 0) >= 200 && ((_b = res.statusCode) !== null && _b !== void 0 ? _b : 0) < 300) {
|
|
148
|
+
resolve({ ok: true, content: body, latencyMs });
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
resolve({
|
|
152
|
+
ok: false,
|
|
153
|
+
error: `HTTP ${res.statusCode}: ${body.slice(0, 200)}`,
|
|
154
|
+
latencyMs,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
req.on('error', (err) => {
|
|
161
|
+
clearTimeout(timer);
|
|
162
|
+
if (!resolved) {
|
|
163
|
+
resolved = true;
|
|
164
|
+
resolve({ ok: false, error: err.message, latencyMs: Date.now() - start });
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
req.write(payload);
|
|
168
|
+
req.end();
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
clearTimeout(timer);
|
|
172
|
+
if (!resolved) {
|
|
173
|
+
resolved = true;
|
|
174
|
+
resolve({
|
|
175
|
+
ok: false,
|
|
176
|
+
error: err instanceof Error ? err.message : String(err),
|
|
177
|
+
latencyMs: Date.now() - start,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
// ─── stdio transport ────────────────────────────────────────────────────────
|
|
184
|
+
sendStdio(command, args, payload, timeoutMs) {
|
|
185
|
+
return new Promise((resolve) => {
|
|
186
|
+
const start = Date.now();
|
|
187
|
+
let resolved = false;
|
|
188
|
+
const timer = setTimeout(() => {
|
|
189
|
+
if (!resolved) {
|
|
190
|
+
resolved = true;
|
|
191
|
+
child.kill();
|
|
192
|
+
resolve({ ok: false, error: 'MCP stdio process timed out', latencyMs: timeoutMs });
|
|
193
|
+
}
|
|
194
|
+
}, timeoutMs);
|
|
195
|
+
const child = this.spawnFn(command, args, { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
196
|
+
const chunks = [];
|
|
197
|
+
const errChunks = [];
|
|
198
|
+
child.stdout.on('data', (chunk) => chunks.push(chunk));
|
|
199
|
+
child.stderr.on('data', (chunk) => errChunks.push(chunk));
|
|
200
|
+
child.on('close', (code) => {
|
|
201
|
+
clearTimeout(timer);
|
|
202
|
+
if (!resolved) {
|
|
203
|
+
resolved = true;
|
|
204
|
+
const latencyMs = Date.now() - start;
|
|
205
|
+
if (code === 0) {
|
|
206
|
+
const content = Buffer.concat(chunks).toString('utf-8');
|
|
207
|
+
resolve({ ok: true, content, latencyMs });
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const stderr = Buffer.concat(errChunks).toString('utf-8');
|
|
211
|
+
resolve({
|
|
212
|
+
ok: false,
|
|
213
|
+
error: `MCP stdio process exited with code ${code}: ${stderr.slice(0, 200)}`,
|
|
214
|
+
latencyMs,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
child.on('error', (err) => {
|
|
220
|
+
clearTimeout(timer);
|
|
221
|
+
if (!resolved) {
|
|
222
|
+
resolved = true;
|
|
223
|
+
resolve({ ok: false, error: err.message, latencyMs: Date.now() - start });
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
child.stdin.write(payload + '\n');
|
|
227
|
+
child.stdin.end();
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exports.McpClient = McpClient;
|
|
232
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
233
|
+
function sleep(ms) {
|
|
234
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
235
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP integration – configuration loader and validator.
|
|
3
|
+
*
|
|
4
|
+
* Handles loading the `mcp` block from the project config file, applying
|
|
5
|
+
* defaults, validating allowed transports and server URLs, and providing a
|
|
6
|
+
* single function to resolve the effective configuration for a named server.
|
|
7
|
+
*/
|
|
8
|
+
import type { McpConfig, McpServerConfig, McpTransport } from './types';
|
|
9
|
+
export declare const MCP_DEFAULT_TIMEOUT_MS = 30000;
|
|
10
|
+
export declare const MCP_DEFAULT_MAX_PAYLOAD_BYTES = 1048576;
|
|
11
|
+
export declare const MCP_DEFAULT_MAX_RETRIES = 2;
|
|
12
|
+
export declare const MCP_DEFAULT_RETRY_DELAY_MS = 500;
|
|
13
|
+
export declare const MCP_DEFAULT_TRANSPORT: McpTransport;
|
|
14
|
+
export declare const MCP_ALLOWED_TRANSPORTS: McpTransport[];
|
|
15
|
+
/** Sensitive key patterns that must never appear in MCP prompts */
|
|
16
|
+
export declare const REDACTED_KEYS: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Merge per-server overrides with global defaults.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveServerConfig(global: McpConfig, serverName: string): McpServerConfig & {
|
|
21
|
+
timeoutMs: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Return true if MCP is globally enabled AND the named server is enabled.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isMcpEnabledFor(config: McpConfig, serverName: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Validate that the transport is in the allowlist (if configured).
|
|
29
|
+
* Throws when the transport is not permitted.
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateTransport(config: McpConfig, transport: McpTransport): void;
|
|
32
|
+
/**
|
|
33
|
+
* Validate that an HTTP server URL is in the allowlist (if configured).
|
|
34
|
+
* Throws when the URL does not match any allowed prefix.
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateServerUrl(config: McpConfig, url: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Validate that a payload string does not exceed the configured size limit.
|
|
39
|
+
* Throws when the limit is exceeded.
|
|
40
|
+
*/
|
|
41
|
+
export declare function validatePayloadSize(config: McpConfig, payload: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Recursively redact sensitive values from a plain object.
|
|
44
|
+
* Keys matching any of the REDACTED_KEYS patterns (case-insensitive) have
|
|
45
|
+
* their values replaced with "[REDACTED]".
|
|
46
|
+
*
|
|
47
|
+
* Returns a deep-cloned sanitised copy; never mutates the original.
|
|
48
|
+
*/
|
|
49
|
+
export declare function redactSecrets(obj: unknown): unknown;
|
|
50
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/mcp/config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,YAAY,EACb,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,eAAO,MAAM,6BAA6B,UAAY,CAAC;AACvD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,EAAE,YAAsB,CAAC;AAE3D,eAAO,MAAM,sBAAsB,EAAE,YAAY,EAAsB,CAAC;AAExE,mEAAmE;AACnE,eAAO,MAAM,aAAa,UAczB,CAAC;AAIF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,GACjB,eAAe,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAOzC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAK9E;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,GAAG,IAAI,CAQlF;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAStE;AAID;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQ5E;AAID;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAYnD"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP integration – configuration loader and validator.
|
|
4
|
+
*
|
|
5
|
+
* Handles loading the `mcp` block from the project config file, applying
|
|
6
|
+
* defaults, validating allowed transports and server URLs, and providing a
|
|
7
|
+
* single function to resolve the effective configuration for a named server.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.REDACTED_KEYS = exports.MCP_ALLOWED_TRANSPORTS = exports.MCP_DEFAULT_TRANSPORT = exports.MCP_DEFAULT_RETRY_DELAY_MS = exports.MCP_DEFAULT_MAX_RETRIES = exports.MCP_DEFAULT_MAX_PAYLOAD_BYTES = exports.MCP_DEFAULT_TIMEOUT_MS = void 0;
|
|
11
|
+
exports.resolveServerConfig = resolveServerConfig;
|
|
12
|
+
exports.isMcpEnabledFor = isMcpEnabledFor;
|
|
13
|
+
exports.validateTransport = validateTransport;
|
|
14
|
+
exports.validateServerUrl = validateServerUrl;
|
|
15
|
+
exports.validatePayloadSize = validatePayloadSize;
|
|
16
|
+
exports.redactSecrets = redactSecrets;
|
|
17
|
+
// ─── Defaults ─────────────────────────────────────────────────────────────────
|
|
18
|
+
exports.MCP_DEFAULT_TIMEOUT_MS = 30000;
|
|
19
|
+
exports.MCP_DEFAULT_MAX_PAYLOAD_BYTES = 1048576; // 1 MB
|
|
20
|
+
exports.MCP_DEFAULT_MAX_RETRIES = 2;
|
|
21
|
+
exports.MCP_DEFAULT_RETRY_DELAY_MS = 500;
|
|
22
|
+
exports.MCP_DEFAULT_TRANSPORT = 'stdio';
|
|
23
|
+
exports.MCP_ALLOWED_TRANSPORTS = ['stdio', 'http'];
|
|
24
|
+
/** Sensitive key patterns that must never appear in MCP prompts */
|
|
25
|
+
exports.REDACTED_KEYS = [
|
|
26
|
+
'token',
|
|
27
|
+
'password',
|
|
28
|
+
'secret',
|
|
29
|
+
'apikey',
|
|
30
|
+
'api_key',
|
|
31
|
+
'connectionstring',
|
|
32
|
+
'connection_string',
|
|
33
|
+
'authorization',
|
|
34
|
+
'bearer',
|
|
35
|
+
'private_key',
|
|
36
|
+
'privatekey',
|
|
37
|
+
'access_key',
|
|
38
|
+
'accesskey',
|
|
39
|
+
];
|
|
40
|
+
// ─── Effective config resolution ──────────────────────────────────────────────
|
|
41
|
+
/**
|
|
42
|
+
* Merge per-server overrides with global defaults.
|
|
43
|
+
*/
|
|
44
|
+
function resolveServerConfig(global, serverName) {
|
|
45
|
+
var _a, _b, _c, _d, _e, _f;
|
|
46
|
+
const server = (_b = (_a = global.servers) === null || _a === void 0 ? void 0 : _a[serverName]) !== null && _b !== void 0 ? _b : {};
|
|
47
|
+
return {
|
|
48
|
+
...server,
|
|
49
|
+
transport: (_d = (_c = server.transport) !== null && _c !== void 0 ? _c : global.defaultTransport) !== null && _d !== void 0 ? _d : exports.MCP_DEFAULT_TRANSPORT,
|
|
50
|
+
timeoutMs: (_f = (_e = server.timeoutMs) !== null && _e !== void 0 ? _e : global.timeoutMs) !== null && _f !== void 0 ? _f : exports.MCP_DEFAULT_TIMEOUT_MS,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Return true if MCP is globally enabled AND the named server is enabled.
|
|
55
|
+
*/
|
|
56
|
+
function isMcpEnabledFor(config, serverName) {
|
|
57
|
+
var _a;
|
|
58
|
+
if (!config.enabled)
|
|
59
|
+
return false;
|
|
60
|
+
const server = (_a = config.servers) === null || _a === void 0 ? void 0 : _a[serverName];
|
|
61
|
+
// If the server key is omitted entirely it defaults to disabled.
|
|
62
|
+
return (server === null || server === void 0 ? void 0 : server.enabled) === true;
|
|
63
|
+
}
|
|
64
|
+
// ─── Transport validation ─────────────────────────────────────────────────────
|
|
65
|
+
/**
|
|
66
|
+
* Validate that the transport is in the allowlist (if configured).
|
|
67
|
+
* Throws when the transport is not permitted.
|
|
68
|
+
*/
|
|
69
|
+
function validateTransport(config, transport) {
|
|
70
|
+
const allowlist = config.transportAllowlist;
|
|
71
|
+
if (!allowlist || allowlist.length === 0)
|
|
72
|
+
return;
|
|
73
|
+
if (!allowlist.includes(transport)) {
|
|
74
|
+
throw new Error(`MCP transport "${transport}" is not in the configured allowlist [${allowlist.join(', ')}]`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate that an HTTP server URL is in the allowlist (if configured).
|
|
79
|
+
* Throws when the URL does not match any allowed prefix.
|
|
80
|
+
*/
|
|
81
|
+
function validateServerUrl(config, url) {
|
|
82
|
+
const allowlist = config.serverAllowlist;
|
|
83
|
+
if (!allowlist || allowlist.length === 0)
|
|
84
|
+
return;
|
|
85
|
+
const permitted = allowlist.some((prefix) => url.startsWith(prefix));
|
|
86
|
+
if (!permitted) {
|
|
87
|
+
throw new Error(`MCP server URL "${url}" is not in the configured server allowlist`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// ─── Payload size validation ──────────────────────────────────────────────────
|
|
91
|
+
/**
|
|
92
|
+
* Validate that a payload string does not exceed the configured size limit.
|
|
93
|
+
* Throws when the limit is exceeded.
|
|
94
|
+
*/
|
|
95
|
+
function validatePayloadSize(config, payload) {
|
|
96
|
+
var _a;
|
|
97
|
+
const limitBytes = (_a = config.maxPayloadBytes) !== null && _a !== void 0 ? _a : exports.MCP_DEFAULT_MAX_PAYLOAD_BYTES;
|
|
98
|
+
const sizeBytes = Buffer.byteLength(payload, 'utf-8');
|
|
99
|
+
if (sizeBytes > limitBytes) {
|
|
100
|
+
throw new Error(`MCP prompt payload size ${sizeBytes} B exceeds the configured limit of ${limitBytes} B`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// ─── Secret redaction ─────────────────────────────────────────────────────────
|
|
104
|
+
/**
|
|
105
|
+
* Recursively redact sensitive values from a plain object.
|
|
106
|
+
* Keys matching any of the REDACTED_KEYS patterns (case-insensitive) have
|
|
107
|
+
* their values replaced with "[REDACTED]".
|
|
108
|
+
*
|
|
109
|
+
* Returns a deep-cloned sanitised copy; never mutates the original.
|
|
110
|
+
*/
|
|
111
|
+
function redactSecrets(obj) {
|
|
112
|
+
if (obj === null || obj === undefined)
|
|
113
|
+
return obj;
|
|
114
|
+
if (typeof obj !== 'object')
|
|
115
|
+
return obj;
|
|
116
|
+
if (Array.isArray(obj))
|
|
117
|
+
return obj.map(redactSecrets);
|
|
118
|
+
const out = {};
|
|
119
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
120
|
+
const lowerKey = key.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
121
|
+
const isSensitive = exports.REDACTED_KEYS.some((k) => lowerKey.includes(k.replace(/[^a-z0-9]/g, '')));
|
|
122
|
+
out[key] = isSensitive ? '[REDACTED]' : redactSecrets(val);
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP integration – real-time scan event adapter.
|
|
3
|
+
*
|
|
4
|
+
* Provides a lightweight event bus that emits AnalysisEvent objects during a
|
|
5
|
+
* scan run. When MCP real-time mode is enabled the events are buffered and
|
|
6
|
+
* forwarded to the configured MCP server; when disabled they are buffered for
|
|
7
|
+
* inclusion in the final report prompt only.
|
|
8
|
+
*/
|
|
9
|
+
import type { AnalysisEvent, AnalysisEventType } from './types';
|
|
10
|
+
export declare class AnalysisEventStream {
|
|
11
|
+
private readonly _events;
|
|
12
|
+
private readonly _handlers;
|
|
13
|
+
/** Emit an event onto the stream */
|
|
14
|
+
emit(type: AnalysisEventType, payload?: Record<string, unknown>): void;
|
|
15
|
+
/** Subscribe to all events emitted on this stream */
|
|
16
|
+
subscribe(handler: (event: AnalysisEvent) => void): void;
|
|
17
|
+
/** Return a snapshot of all events emitted so far */
|
|
18
|
+
getEvents(): ReadonlyArray<AnalysisEvent>;
|
|
19
|
+
/** Clear buffered events (useful between scan phases) */
|
|
20
|
+
clear(): void;
|
|
21
|
+
}
|
|
22
|
+
/** Create a pre-wired event stream that does nothing (no-op) when MCP is off */
|
|
23
|
+
export declare function createNoOpStream(): AnalysisEventStream;
|
|
24
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/mcp/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAIhE,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;IAEvE,oCAAoC;IACpC,IAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,IAAI;IAQ1E,qDAAqD;IACrD,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI;IAIxD,qDAAqD;IACrD,SAAS,IAAI,aAAa,CAAC,aAAa,CAAC;IAIzC,yDAAyD;IACzD,KAAK,IAAI,IAAI;CAGd;AAID,gFAAgF;AAChF,wBAAgB,gBAAgB,IAAI,mBAAmB,CAEtD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP integration – real-time scan event adapter.
|
|
4
|
+
*
|
|
5
|
+
* Provides a lightweight event bus that emits AnalysisEvent objects during a
|
|
6
|
+
* scan run. When MCP real-time mode is enabled the events are buffered and
|
|
7
|
+
* forwarded to the configured MCP server; when disabled they are buffered for
|
|
8
|
+
* inclusion in the final report prompt only.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.AnalysisEventStream = void 0;
|
|
12
|
+
exports.createNoOpStream = createNoOpStream;
|
|
13
|
+
// ─── Event emitter ────────────────────────────────────────────────────────────
|
|
14
|
+
class AnalysisEventStream {
|
|
15
|
+
constructor() {
|
|
16
|
+
this._events = [];
|
|
17
|
+
this._handlers = [];
|
|
18
|
+
}
|
|
19
|
+
/** Emit an event onto the stream */
|
|
20
|
+
emit(type, payload = {}) {
|
|
21
|
+
const event = { type, timestamp: Date.now(), payload };
|
|
22
|
+
this._events.push(event);
|
|
23
|
+
for (const handler of this._handlers) {
|
|
24
|
+
try {
|
|
25
|
+
handler(event);
|
|
26
|
+
}
|
|
27
|
+
catch { /* never let handlers crash the scan */ }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Subscribe to all events emitted on this stream */
|
|
31
|
+
subscribe(handler) {
|
|
32
|
+
this._handlers.push(handler);
|
|
33
|
+
}
|
|
34
|
+
/** Return a snapshot of all events emitted so far */
|
|
35
|
+
getEvents() {
|
|
36
|
+
return [...this._events];
|
|
37
|
+
}
|
|
38
|
+
/** Clear buffered events (useful between scan phases) */
|
|
39
|
+
clear() {
|
|
40
|
+
this._events.length = 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.AnalysisEventStream = AnalysisEventStream;
|
|
44
|
+
// ─── Convenience helpers ──────────────────────────────────────────────────────
|
|
45
|
+
/** Create a pre-wired event stream that does nothing (no-op) when MCP is off */
|
|
46
|
+
function createNoOpStream() {
|
|
47
|
+
return new AnalysisEventStream();
|
|
48
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP integration – fallback AI interpreter.
|
|
3
|
+
*
|
|
4
|
+
* When MCP is disabled or unavailable this module generates a deterministic,
|
|
5
|
+
* rule-based NormalizedAiAnalysis so that pipelines never break.
|
|
6
|
+
*
|
|
7
|
+
* Outputs are fully deterministic given the same inputs, making them suitable
|
|
8
|
+
* for snapshot testing.
|
|
9
|
+
*/
|
|
10
|
+
import type { NormalizedAiAnalysis } from '../types';
|
|
11
|
+
import type { CoverageResult } from '../../reporting';
|
|
12
|
+
import type { SecurityScanSummary } from '../../security/types';
|
|
13
|
+
export interface FallbackCoverageInput {
|
|
14
|
+
results: CoverageResult[];
|
|
15
|
+
thresholds?: Record<string, number | undefined>;
|
|
16
|
+
gatePassed?: boolean;
|
|
17
|
+
failedCategories?: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Generate a deterministic AI-style coverage summary without MCP.
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateFallbackCoverageAnalysis(input: FallbackCoverageInput): NormalizedAiAnalysis;
|
|
23
|
+
export interface FallbackSecurityInput {
|
|
24
|
+
scanSummary: SecurityScanSummary;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generate a deterministic AI-style security analysis without MCP.
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateFallbackSecurityAnalysis(input: FallbackSecurityInput): NormalizedAiAnalysis;
|
|
30
|
+
export interface FallbackIntelligenceInput {
|
|
31
|
+
totalFindings: number;
|
|
32
|
+
totalRecommendations: number;
|
|
33
|
+
maxRiskScore: number;
|
|
34
|
+
avgRiskScore: number;
|
|
35
|
+
criticalUncoveredItems: number;
|
|
36
|
+
unprotectedSecurityFindings: number;
|
|
37
|
+
recommendationsByPriority: Record<string, number>;
|
|
38
|
+
topRiskAreas?: string[];
|
|
39
|
+
languages?: string[];
|
|
40
|
+
frameworks?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate a deterministic AI-style intelligence analysis without MCP.
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateFallbackIntelligenceAnalysis(input: FallbackIntelligenceInput): NormalizedAiAnalysis;
|
|
46
|
+
/**
|
|
47
|
+
* Generate a minimal deterministic AI analysis for any coverage category.
|
|
48
|
+
*/
|
|
49
|
+
export declare function generateFallbackAnalysis(category: string, coveragePercent: number, threshold?: number): NormalizedAiAnalysis;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp/fallback/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhE,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,qBAAqB,GAC3B,oBAAoB,CAmDtB;AAID,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,mBAAmB,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,KAAK,EAAE,qBAAqB,GAC3B,oBAAoB,CA4DtB;AAID,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;IACpC,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,oCAAoC,CAClD,KAAK,EAAE,yBAAyB,GAC/B,oBAAoB,CAkEtB;AAID;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EACvB,SAAS,CAAC,EAAE,MAAM,GACjB,oBAAoB,CAiBtB"}
|