@nahisaho/musubix-security 1.8.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 +105 -0
- package/bin/musubix-security-mcp.js +12 -0
- package/bin/musubix-security.js +12 -0
- package/dist/analysis/dependency-auditor.d.ts +30 -0
- package/dist/analysis/dependency-auditor.d.ts.map +1 -0
- package/dist/analysis/dependency-auditor.js +325 -0
- package/dist/analysis/dependency-auditor.js.map +1 -0
- package/dist/analysis/index.d.ts +9 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +9 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/secret-detector.d.ts +44 -0
- package/dist/analysis/secret-detector.d.ts.map +1 -0
- package/dist/analysis/secret-detector.js +465 -0
- package/dist/analysis/secret-detector.js.map +1 -0
- package/dist/analysis/taint-analyzer.d.ts +62 -0
- package/dist/analysis/taint-analyzer.d.ts.map +1 -0
- package/dist/analysis/taint-analyzer.js +519 -0
- package/dist/analysis/taint-analyzer.js.map +1 -0
- package/dist/analysis/vulnerability-scanner.d.ts +58 -0
- package/dist/analysis/vulnerability-scanner.d.ts.map +1 -0
- package/dist/analysis/vulnerability-scanner.js +417 -0
- package/dist/analysis/vulnerability-scanner.js.map +1 -0
- package/dist/cli/commands.d.ts +15 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +405 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/ast-parser.d.ts +87 -0
- package/dist/infrastructure/ast-parser.d.ts.map +1 -0
- package/dist/infrastructure/ast-parser.js +273 -0
- package/dist/infrastructure/ast-parser.js.map +1 -0
- package/dist/infrastructure/cache.d.ts +100 -0
- package/dist/infrastructure/cache.d.ts.map +1 -0
- package/dist/infrastructure/cache.js +288 -0
- package/dist/infrastructure/cache.js.map +1 -0
- package/dist/infrastructure/config-loader.d.ts +35 -0
- package/dist/infrastructure/config-loader.d.ts.map +1 -0
- package/dist/infrastructure/config-loader.js +358 -0
- package/dist/infrastructure/config-loader.js.map +1 -0
- package/dist/infrastructure/file-scanner.d.ts +94 -0
- package/dist/infrastructure/file-scanner.d.ts.map +1 -0
- package/dist/infrastructure/file-scanner.js +189 -0
- package/dist/infrastructure/file-scanner.js.map +1 -0
- package/dist/infrastructure/index.d.ts +9 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +9 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +7 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +34 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +88 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +88 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +443 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/services/fix-generator.d.ts +56 -0
- package/dist/services/fix-generator.d.ts.map +1 -0
- package/dist/services/fix-generator.js +346 -0
- package/dist/services/fix-generator.js.map +1 -0
- package/dist/services/fix-verifier.d.ts +62 -0
- package/dist/services/fix-verifier.d.ts.map +1 -0
- package/dist/services/fix-verifier.js +224 -0
- package/dist/services/fix-verifier.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +13 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/report-generator.d.ts +87 -0
- package/dist/services/report-generator.d.ts.map +1 -0
- package/dist/services/report-generator.js +463 -0
- package/dist/services/report-generator.js.map +1 -0
- package/dist/services/security-service.d.ts +151 -0
- package/dist/services/security-service.d.ts.map +1 -0
- package/dist/services/security-service.js +279 -0
- package/dist/services/security-service.js.map +1 -0
- package/dist/types/config.d.ts +188 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +89 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/dependency.d.ts +266 -0
- package/dist/types/dependency.d.ts.map +1 -0
- package/dist/types/dependency.js +7 -0
- package/dist/types/dependency.js.map +1 -0
- package/dist/types/fix.d.ts +213 -0
- package/dist/types/fix.d.ts.map +1 -0
- package/dist/types/fix.js +7 -0
- package/dist/types/fix.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/secret.d.ts +151 -0
- package/dist/types/secret.d.ts.map +1 -0
- package/dist/types/secret.js +91 -0
- package/dist/types/secret.js.map +1 -0
- package/dist/types/taint.d.ts +182 -0
- package/dist/types/taint.d.ts.map +1 -0
- package/dist/types/taint.js +24 -0
- package/dist/types/taint.js.map +1 -0
- package/dist/types/vulnerability.d.ts +136 -0
- package/dist/types/vulnerability.d.ts.map +1 -0
- package/dist/types/vulnerability.js +7 -0
- package/dist/types/vulnerability.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview MCP Tools for security scanning
|
|
3
|
+
* @module @nahisaho/musubix-security/mcp/tools
|
|
4
|
+
* @trace REQ-SEC-MCP-001
|
|
5
|
+
*/
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import { createSecurityService, } from '../services/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Security scan tool definitions
|
|
10
|
+
*/
|
|
11
|
+
export const SECURITY_TOOLS = [
|
|
12
|
+
{
|
|
13
|
+
name: 'security_scan',
|
|
14
|
+
description: 'Run a comprehensive security scan on the target path. Detects vulnerabilities, hardcoded secrets, tainted data flows, and vulnerable dependencies.',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
target: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'Target path to scan (file or directory)',
|
|
21
|
+
},
|
|
22
|
+
vulnerabilities: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
description: 'Enable vulnerability scanning',
|
|
25
|
+
default: true,
|
|
26
|
+
},
|
|
27
|
+
taint: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
description: 'Enable taint analysis',
|
|
30
|
+
default: true,
|
|
31
|
+
},
|
|
32
|
+
secrets: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
description: 'Enable secret detection',
|
|
35
|
+
default: true,
|
|
36
|
+
},
|
|
37
|
+
dependencies: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
description: 'Enable dependency audit',
|
|
40
|
+
default: true,
|
|
41
|
+
},
|
|
42
|
+
generateFixes: {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
description: 'Generate fix suggestions',
|
|
45
|
+
default: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ['target'],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'security_quick_scan',
|
|
53
|
+
description: 'Quick vulnerability scan without taint analysis, secret detection, or dependency audit.',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
target: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Target path to scan',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ['target'],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'security_taint_analysis',
|
|
67
|
+
description: 'Run taint analysis to trace data flow from untrusted sources to sensitive sinks.',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
target: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'Target path to analyze',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ['target'],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'security_detect_secrets',
|
|
81
|
+
description: 'Detect hardcoded secrets like API keys, passwords, and tokens.',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
target: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: 'Target path to scan',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
required: ['target'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'security_audit_deps',
|
|
95
|
+
description: 'Audit project dependencies for known vulnerabilities.',
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {
|
|
99
|
+
target: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
description: 'Project directory containing package.json',
|
|
102
|
+
},
|
|
103
|
+
generateSBOM: {
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
description: 'Generate Software Bill of Materials',
|
|
106
|
+
default: false,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
required: ['target'],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'security_generate_fix',
|
|
114
|
+
description: 'Generate a fix for a specific vulnerability.',
|
|
115
|
+
inputSchema: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
vulnerabilityId: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
description: 'ID of the vulnerability to fix',
|
|
121
|
+
},
|
|
122
|
+
scanResultJson: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
description: 'JSON string of previous scan result',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
required: ['vulnerabilityId', 'scanResultJson'],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'security_generate_report',
|
|
132
|
+
description: 'Generate a security report from scan results.',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
scanResultJson: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'JSON string of scan result',
|
|
139
|
+
},
|
|
140
|
+
format: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
description: 'Report format',
|
|
143
|
+
enum: ['json', 'sarif', 'markdown', 'html'],
|
|
144
|
+
default: 'markdown',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
required: ['scanResultJson'],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
];
|
|
151
|
+
/**
|
|
152
|
+
* Security tool handlers
|
|
153
|
+
*/
|
|
154
|
+
export class SecurityToolHandler {
|
|
155
|
+
service;
|
|
156
|
+
constructor() {
|
|
157
|
+
this.service = createSecurityService();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Handle tool call
|
|
161
|
+
*/
|
|
162
|
+
async handleTool(name, args) {
|
|
163
|
+
try {
|
|
164
|
+
switch (name) {
|
|
165
|
+
case 'security_scan':
|
|
166
|
+
return this.handleScan(args);
|
|
167
|
+
case 'security_quick_scan':
|
|
168
|
+
return this.handleQuickScan(args);
|
|
169
|
+
case 'security_taint_analysis':
|
|
170
|
+
return this.handleTaintAnalysis(args);
|
|
171
|
+
case 'security_detect_secrets':
|
|
172
|
+
return this.handleDetectSecrets(args);
|
|
173
|
+
case 'security_audit_deps':
|
|
174
|
+
return this.handleAuditDeps(args);
|
|
175
|
+
case 'security_generate_fix':
|
|
176
|
+
return this.handleGenerateFix(args);
|
|
177
|
+
case 'security_generate_report':
|
|
178
|
+
return this.handleGenerateReport(args);
|
|
179
|
+
default:
|
|
180
|
+
return {
|
|
181
|
+
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
|
182
|
+
isError: true,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
return {
|
|
188
|
+
content: [{ type: 'text', text: `Error: ${error.message}` }],
|
|
189
|
+
isError: true,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Handle full security scan
|
|
195
|
+
*/
|
|
196
|
+
async handleScan(args) {
|
|
197
|
+
const target = String(args.target);
|
|
198
|
+
const result = await this.service.scan({
|
|
199
|
+
target: path.resolve(target),
|
|
200
|
+
vulnerabilities: args.vulnerabilities !== false,
|
|
201
|
+
taint: args.taint !== false,
|
|
202
|
+
secrets: args.secrets !== false,
|
|
203
|
+
dependencies: args.dependencies !== false,
|
|
204
|
+
generateFixes: args.generateFixes !== false,
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
content: [{
|
|
208
|
+
type: 'text',
|
|
209
|
+
text: this.formatScanResult(result),
|
|
210
|
+
}],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Handle quick scan
|
|
215
|
+
*/
|
|
216
|
+
async handleQuickScan(args) {
|
|
217
|
+
const target = String(args.target);
|
|
218
|
+
const result = await this.service.quickScan(path.resolve(target));
|
|
219
|
+
return {
|
|
220
|
+
content: [{
|
|
221
|
+
type: 'text',
|
|
222
|
+
text: `# Quick Scan Results
|
|
223
|
+
|
|
224
|
+
**Files Scanned:** ${result.scannedFiles}
|
|
225
|
+
**Vulnerabilities Found:** ${result.vulnerabilities.length}
|
|
226
|
+
|
|
227
|
+
${result.vulnerabilities.map(v => `- **${v.severity.toUpperCase()}**: ${v.type}
|
|
228
|
+
- File: ${v.location.file}:${v.location.startLine}
|
|
229
|
+
- ${v.description}`).join('\n\n')}
|
|
230
|
+
|
|
231
|
+
${result.vulnerabilities.length === 0 ? '✅ No vulnerabilities found.' : ''}`,
|
|
232
|
+
}],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Handle taint analysis
|
|
237
|
+
*/
|
|
238
|
+
async handleTaintAnalysis(args) {
|
|
239
|
+
const target = String(args.target);
|
|
240
|
+
const result = await this.service.analyzeTaint(path.resolve(target));
|
|
241
|
+
return {
|
|
242
|
+
content: [{
|
|
243
|
+
type: 'text',
|
|
244
|
+
text: `# Taint Analysis Results
|
|
245
|
+
|
|
246
|
+
**Sources Found:** ${result.sources.length}
|
|
247
|
+
**Sinks Found:** ${result.sinks.length}
|
|
248
|
+
**Tainted Paths:** ${result.unsafePaths.length}
|
|
249
|
+
|
|
250
|
+
## Tainted Data Flows
|
|
251
|
+
${result.unsafePaths.map((p, idx) => `
|
|
252
|
+
### Path ${idx + 1}
|
|
253
|
+
- **Source:** ${p.source.variableName ?? p.source.expression} (${p.source.category})
|
|
254
|
+
- ${p.source.location.file}:${p.source.location.startLine}
|
|
255
|
+
- **Sink:** ${p.sink.functionName} (${p.sink.category})
|
|
256
|
+
- ${p.sink.location.file}:${p.sink.location.startLine}
|
|
257
|
+
- **Sanitized:** ${p.sanitized ? '✅ Yes' : '❌ No'}
|
|
258
|
+
`).join('\n')}
|
|
259
|
+
|
|
260
|
+
${result.unsafePaths.length === 0 ? '✅ No tainted paths found.' : ''}`,
|
|
261
|
+
}],
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Handle secret detection
|
|
266
|
+
*/
|
|
267
|
+
async handleDetectSecrets(args) {
|
|
268
|
+
const target = String(args.target);
|
|
269
|
+
const result = await this.service.detectSecrets(path.resolve(target));
|
|
270
|
+
return {
|
|
271
|
+
content: [{
|
|
272
|
+
type: 'text',
|
|
273
|
+
text: `# Secret Detection Results
|
|
274
|
+
|
|
275
|
+
**Files Scanned:** ${result.scannedFiles}
|
|
276
|
+
**Secrets Found:** ${result.summary.total}
|
|
277
|
+
|
|
278
|
+
${result.secrets.map(s => `- **${s.type}** in \`${s.location.file}:${s.location.startLine}\`
|
|
279
|
+
- Value: \`${s.maskedValue}\`
|
|
280
|
+
- Confidence: ${(s.confidence * 100).toFixed(0)}%`).join('\n\n')}
|
|
281
|
+
|
|
282
|
+
${result.summary.total === 0 ? '✅ No hardcoded secrets detected.' : '⚠️ Please rotate any exposed secrets immediately.'}`,
|
|
283
|
+
}],
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Handle dependency audit
|
|
288
|
+
*/
|
|
289
|
+
async handleAuditDeps(args) {
|
|
290
|
+
const target = String(args.target);
|
|
291
|
+
if (args.generateSBOM) {
|
|
292
|
+
const { DependencyAuditor } = await import('../analysis/index.js');
|
|
293
|
+
const auditor = new DependencyAuditor();
|
|
294
|
+
const sbom = await auditor.generateSBOM(path.resolve(target));
|
|
295
|
+
return {
|
|
296
|
+
content: [{
|
|
297
|
+
type: 'text',
|
|
298
|
+
text: `# Software Bill of Materials (SBOM)
|
|
299
|
+
|
|
300
|
+
\`\`\`json
|
|
301
|
+
${JSON.stringify(sbom, null, 2)}
|
|
302
|
+
\`\`\``,
|
|
303
|
+
}],
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const result = await this.service.auditDependencies(path.resolve(target));
|
|
307
|
+
return {
|
|
308
|
+
content: [{
|
|
309
|
+
type: 'text',
|
|
310
|
+
text: `# Dependency Audit Results
|
|
311
|
+
|
|
312
|
+
**Vulnerable Dependencies:** ${result.vulnerableDependencies.length}
|
|
313
|
+
|
|
314
|
+
${result.vulnerableDependencies.map(d => `- **${d.highestSeverity.toUpperCase()}**: ${d.name}@${d.installedVersion}
|
|
315
|
+
- Title: ${d.vulnerabilities[0]?.title ?? 'N/A'}
|
|
316
|
+
- Patched: ${d.vulnerabilities[0]?.patchedVersion ?? 'No patch available'}
|
|
317
|
+
- ${d.vulnerabilities[0]?.url ?? ''}`).join('\n\n')}
|
|
318
|
+
|
|
319
|
+
${result.vulnerableDependencies.length === 0 ? '✅ No vulnerable dependencies found.' : ''}`,
|
|
320
|
+
}],
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Handle fix generation
|
|
325
|
+
*/
|
|
326
|
+
async handleGenerateFix(args) {
|
|
327
|
+
const vulnerabilityId = String(args.vulnerabilityId);
|
|
328
|
+
const scanResult = JSON.parse(String(args.scanResultJson));
|
|
329
|
+
const fix = await this.service.generateFix(vulnerabilityId, scanResult.vulnerabilities);
|
|
330
|
+
if (!fix) {
|
|
331
|
+
return {
|
|
332
|
+
content: [{
|
|
333
|
+
type: 'text',
|
|
334
|
+
text: `No fix found for vulnerability: ${vulnerabilityId}`,
|
|
335
|
+
}],
|
|
336
|
+
isError: true,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
content: [{
|
|
341
|
+
type: 'text',
|
|
342
|
+
text: `# Fix Suggestion
|
|
343
|
+
|
|
344
|
+
**Description:** ${fix.description}
|
|
345
|
+
**Strategy:** ${fix.strategy}
|
|
346
|
+
**Confidence:** ${(fix.confidence * 100).toFixed(0)}%
|
|
347
|
+
|
|
348
|
+
## Code Changes
|
|
349
|
+
|
|
350
|
+
${fix.edits.map(e => `### ${e.location.file}:${e.location.startLine}-${e.location.endLine}
|
|
351
|
+
|
|
352
|
+
**Before:**
|
|
353
|
+
\`\`\`
|
|
354
|
+
${e.originalCode}
|
|
355
|
+
\`\`\`
|
|
356
|
+
|
|
357
|
+
**After:**
|
|
358
|
+
\`\`\`
|
|
359
|
+
${e.newCode}
|
|
360
|
+
\`\`\``).join('\n\n')}
|
|
361
|
+
|
|
362
|
+
**Note:** Please review the fix carefully before applying.`,
|
|
363
|
+
}],
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Handle report generation
|
|
368
|
+
*/
|
|
369
|
+
async handleGenerateReport(args) {
|
|
370
|
+
const scanResult = JSON.parse(String(args.scanResultJson));
|
|
371
|
+
const format = args.format || 'markdown';
|
|
372
|
+
const report = await this.service.generateReport(scanResult, format);
|
|
373
|
+
return {
|
|
374
|
+
content: [{
|
|
375
|
+
type: 'text',
|
|
376
|
+
text: report,
|
|
377
|
+
}],
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Format scan result for display
|
|
382
|
+
*/
|
|
383
|
+
formatScanResult(result) {
|
|
384
|
+
const s = result.summary;
|
|
385
|
+
let output = `# Security Scan Results
|
|
386
|
+
|
|
387
|
+
## Summary
|
|
388
|
+
- **Target:** ${result.metadata.target}
|
|
389
|
+
- **Duration:** ${result.metadata.duration}ms
|
|
390
|
+
- **Files Scanned:** ${result.metadata.filesScanned}
|
|
391
|
+
|
|
392
|
+
### Vulnerabilities by Severity
|
|
393
|
+
| Severity | Count |
|
|
394
|
+
|----------|-------|
|
|
395
|
+
| Critical | ${s.bySeverity.critical} |
|
|
396
|
+
| High | ${s.bySeverity.high} |
|
|
397
|
+
| Medium | ${s.bySeverity.medium} |
|
|
398
|
+
| Low | ${s.bySeverity.low} |
|
|
399
|
+
| Info | ${s.bySeverity.info} |
|
|
400
|
+
| **Total** | **${s.totalVulnerabilities}** |
|
|
401
|
+
|
|
402
|
+
`;
|
|
403
|
+
if (result.vulnerabilities && result.vulnerabilities.vulnerabilities.length > 0) {
|
|
404
|
+
output += `## Vulnerabilities\n\n`;
|
|
405
|
+
for (const v of result.vulnerabilities.vulnerabilities.slice(0, 10)) {
|
|
406
|
+
output += `### ${v.type} (${v.severity.toUpperCase()})\n`;
|
|
407
|
+
output += `- **Location:** ${v.location.file}:${v.location.startLine}\n`;
|
|
408
|
+
output += `- **CWE:** ${v.cwes[0] ?? 'N/A'}\n`;
|
|
409
|
+
output += `- **Description:** ${v.description}\n\n`;
|
|
410
|
+
}
|
|
411
|
+
if (result.vulnerabilities.vulnerabilities.length > 10) {
|
|
412
|
+
output += `... and ${result.vulnerabilities.vulnerabilities.length - 10} more\n\n`;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (s.secretsFound > 0) {
|
|
416
|
+
output += `## ⚠️ Secrets Detected: ${s.secretsFound}\n\n`;
|
|
417
|
+
}
|
|
418
|
+
if (s.taintedPaths > 0) {
|
|
419
|
+
output += `## Tainted Data Flows: ${s.taintedPaths}\n\n`;
|
|
420
|
+
}
|
|
421
|
+
if (s.vulnerableDependencies > 0) {
|
|
422
|
+
output += `## Vulnerable Dependencies: ${s.vulnerableDependencies}\n\n`;
|
|
423
|
+
}
|
|
424
|
+
if (result.fixes && result.fixes.length > 0) {
|
|
425
|
+
output += `## Fixes Available: ${s.fixesGenerated}\n\n`;
|
|
426
|
+
output += `Use \`security_generate_fix\` to get detailed fix suggestions.\n`;
|
|
427
|
+
}
|
|
428
|
+
return output;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Get all tool schemas
|
|
433
|
+
*/
|
|
434
|
+
export function getToolSchemas() {
|
|
435
|
+
return SECURITY_TOOLS;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Create tool handler
|
|
439
|
+
*/
|
|
440
|
+
export function createToolHandler() {
|
|
441
|
+
return new SecurityToolHandler();
|
|
442
|
+
}
|
|
443
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAEL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AA+B9B;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,oJAAoJ;QACjK,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yCAAyC;iBACvD;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,+BAA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;QACH,CAAC;QAED,IAAI,CAAC,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,2BAA2B,CAAC,CAAC,YAAY,MAAM,CAAC;QAC5D,CAAC;QAED,IAAI,CAAC,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,0BAA0B,CAAC,CAAC,YAAY,MAAM,CAAC;QAC3D,CAAC;QAED,IAAI,CAAC,CAAC,sBAAsB,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,+BAA+B,CAAC,CAAC,sBAAsB,MAAM,CAAC;QAC1E,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,uBAAuB,CAAC,CAAC,cAAc,MAAM,CAAC;YACxD,MAAM,IAAI,kEAAkE,CAAC;QAC/E,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,mBAAmB,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fix generator service - generates fix suggestions for vulnerabilities
|
|
3
|
+
* @module @nahisaho/musubix-security/services/fix-generator
|
|
4
|
+
* @trace REQ-SEC-FIX-001
|
|
5
|
+
*/
|
|
6
|
+
import type { Fix, FixStrategy, CodeEdit, ImportEdit, FixGenerationOptions, Vulnerability, VulnerabilityType } from '../types/index.js';
|
|
7
|
+
import type { TaintPath } from '../types/taint.js';
|
|
8
|
+
/**
|
|
9
|
+
* Reset fix counter (for testing)
|
|
10
|
+
*/
|
|
11
|
+
export declare function resetFixCounter(): void;
|
|
12
|
+
/**
|
|
13
|
+
* Fix template for a vulnerability type
|
|
14
|
+
*/
|
|
15
|
+
interface FixTemplate {
|
|
16
|
+
type: VulnerabilityType;
|
|
17
|
+
strategy: FixStrategy;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
rationale: string;
|
|
21
|
+
imports: ImportEdit[];
|
|
22
|
+
transform: (vuln: Vulnerability) => CodeEdit[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Fix generator service
|
|
26
|
+
*/
|
|
27
|
+
export declare class FixGenerator {
|
|
28
|
+
private templates;
|
|
29
|
+
constructor(_options?: FixGenerationOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Generate a fix for a vulnerability
|
|
32
|
+
*/
|
|
33
|
+
generateFix(vuln: Vulnerability): Fix | null;
|
|
34
|
+
/**
|
|
35
|
+
* Generate fixes for multiple vulnerabilities
|
|
36
|
+
*/
|
|
37
|
+
generateFixes(vulnerabilities: Vulnerability[]): Fix[];
|
|
38
|
+
/**
|
|
39
|
+
* Generate a fix for a taint path
|
|
40
|
+
*/
|
|
41
|
+
generateTaintFix(path: TaintPath): Fix | null;
|
|
42
|
+
/**
|
|
43
|
+
* Add a custom fix template
|
|
44
|
+
*/
|
|
45
|
+
addTemplate(template: FixTemplate): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get available strategies
|
|
48
|
+
*/
|
|
49
|
+
getStrategies(): FixStrategy[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a fix generator
|
|
53
|
+
*/
|
|
54
|
+
export declare function createFixGenerator(options?: FixGenerationOptions): FixGenerator;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=fix-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-generator.d.ts","sourceRoot":"","sources":["../../src/services/fix-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,GAAG,EACH,WAAW,EACX,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAYnD;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;GAEG;AACH,UAAU,WAAW;IACnB,IAAI,EAAE,iBAAiB,CAAC;IACxB,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,SAAS,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,QAAQ,EAAE,CAAC;CAChD;AAiQD;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAgB;gBAErB,QAAQ,GAAE,oBAAyB;IAI/C;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,GAAG,GAAG,IAAI;IA4B5C;;OAEG;IACH,aAAa,CAAC,eAAe,EAAE,aAAa,EAAE,GAAG,GAAG,EAAE;IAatD;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,SAAS,GAAG,GAAG,GAAG,IAAI;IAuC7C;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI;IAIxC;;OAEG;IACH,aAAa,IAAI,WAAW,EAAE;CAG/B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,YAAY,CAE/E"}
|