@bryan-thompson/inspector-assessment-client 1.26.7 → 1.28.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/dist/assets/{OAuthCallback-CCWVtjr7.js → OAuthCallback-JnKCxulS.js} +1 -1
- package/dist/assets/{OAuthDebugCallback-DqbXfUi4.js → OAuthDebugCallback-C2zSlEIQ.js} +1 -1
- package/dist/assets/{index-CsDJSSWq.js → index-C3xZdIFQ.js} +77 -39
- package/dist/index.html +1 -1
- package/lib/lib/assessment/configTypes.d.ts +1 -0
- package/lib/lib/assessment/configTypes.d.ts.map +1 -1
- package/lib/lib/assessment/configTypes.js +10 -0
- package/lib/lib/assessment/extendedTypes.d.ts +74 -0
- package/lib/lib/assessment/extendedTypes.d.ts.map +1 -1
- package/lib/lib/assessment/resultTypes.d.ts +3 -1
- package/lib/lib/assessment/resultTypes.d.ts.map +1 -1
- package/lib/lib/securityPatterns.d.ts +7 -2
- package/lib/lib/securityPatterns.d.ts.map +1 -1
- package/lib/lib/securityPatterns.js +204 -2
- package/lib/services/assessment/AssessmentOrchestrator.d.ts +1 -0
- package/lib/services/assessment/AssessmentOrchestrator.d.ts.map +1 -1
- package/lib/services/assessment/AssessmentOrchestrator.js +31 -1
- package/lib/services/assessment/modules/ErrorHandlingAssessor.d.ts +25 -0
- package/lib/services/assessment/modules/ErrorHandlingAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ErrorHandlingAssessor.js +119 -5
- package/lib/services/assessment/modules/FileModularizationAssessor.d.ts +87 -0
- package/lib/services/assessment/modules/FileModularizationAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/FileModularizationAssessor.js +475 -0
- package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts +27 -0
- package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.js +50 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.js +13 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts +14 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +45 -0
- package/package.json +1 -1
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Modularization Assessor (Issue #104)
|
|
3
|
+
* Detects large monolithic tool files and recommends modularization
|
|
4
|
+
*
|
|
5
|
+
* Checks:
|
|
6
|
+
* - Single file >1,000 lines (WARNING, MEDIUM severity)
|
|
7
|
+
* - Single file >2,000 lines (ERROR, HIGH severity)
|
|
8
|
+
* - Tool file with >10 tools (WARNING, MEDIUM severity)
|
|
9
|
+
* - Tool file with >20 tools (ERROR, HIGH severity)
|
|
10
|
+
* - No modular structure (INFO, LOW severity)
|
|
11
|
+
*
|
|
12
|
+
* Scoring:
|
|
13
|
+
* - Starts at 100 points
|
|
14
|
+
* - -15 per file >2,000 lines
|
|
15
|
+
* - -8 per file 1,000-2,000 lines
|
|
16
|
+
* - -12 per file with >20 tools
|
|
17
|
+
* - -6 per file with 10-20 tools
|
|
18
|
+
* - -10 for no modular structure
|
|
19
|
+
* - +5 for tools/ subdirectory
|
|
20
|
+
* - +3 for multiple tool files (>3)
|
|
21
|
+
*/
|
|
22
|
+
import { BaseAssessor } from "./BaseAssessor.js";
|
|
23
|
+
/**
|
|
24
|
+
* Tool detection patterns by language
|
|
25
|
+
*/
|
|
26
|
+
const TOOL_PATTERNS = {
|
|
27
|
+
python: [
|
|
28
|
+
/@mcp\.tool/g, // FastMCP decorator
|
|
29
|
+
/(?<!async\s)def\s+\w+_tool\s*\(/g, // Convention: *_tool functions (not async)
|
|
30
|
+
/async\s+def\s+\w+_tool\s*\(/g, // Async tool functions
|
|
31
|
+
/@server\.tool/g, // MCP server decorator
|
|
32
|
+
/@app\.tool/g, // Alternative app-based decorator
|
|
33
|
+
],
|
|
34
|
+
typescript: [
|
|
35
|
+
/server\.tool\s*\(/g, // MCP SDK tool registration
|
|
36
|
+
/\.setRequestHandler\s*\(/g, // Request handler pattern
|
|
37
|
+
/tools\.push\s*\(/g, // Array-based registration
|
|
38
|
+
/registerTool\s*\(/g, // Common pattern
|
|
39
|
+
/\.addTool\s*\(/g, // Add tool pattern
|
|
40
|
+
],
|
|
41
|
+
javascript: [
|
|
42
|
+
/server\.tool\s*\(/g,
|
|
43
|
+
/\.setRequestHandler\s*\(/g,
|
|
44
|
+
/tools\.push\s*\(/g,
|
|
45
|
+
/registerTool\s*\(/g,
|
|
46
|
+
/\.addTool\s*\(/g,
|
|
47
|
+
],
|
|
48
|
+
go: [
|
|
49
|
+
/func\s+\w*Tool\s*\(/g, // Go tool functions
|
|
50
|
+
/mcp\.NewTool\s*\(/g, // MCP Go SDK
|
|
51
|
+
/tools\.Register\s*\(/g, // Tool registration
|
|
52
|
+
],
|
|
53
|
+
rust: [
|
|
54
|
+
/fn\s+\w+_tool\s*\(/g, // Rust tool functions
|
|
55
|
+
/#\[tool\]/g, // Attribute macro
|
|
56
|
+
/\.register_tool\s*\(/g, // Registration pattern
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* File extension to language mapping
|
|
61
|
+
*/
|
|
62
|
+
const EXTENSION_TO_LANGUAGE = {
|
|
63
|
+
".py": "python",
|
|
64
|
+
".ts": "typescript",
|
|
65
|
+
".tsx": "typescript",
|
|
66
|
+
".js": "javascript",
|
|
67
|
+
".jsx": "javascript",
|
|
68
|
+
".mjs": "javascript",
|
|
69
|
+
".cjs": "javascript",
|
|
70
|
+
".go": "go",
|
|
71
|
+
".rs": "rust",
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Thresholds for modularization checks
|
|
75
|
+
*/
|
|
76
|
+
const THRESHOLDS = {
|
|
77
|
+
LINE_WARNING: 1000,
|
|
78
|
+
LINE_ERROR: 2000,
|
|
79
|
+
TOOL_COUNT_WARNING: 10,
|
|
80
|
+
TOOL_COUNT_ERROR: 20,
|
|
81
|
+
};
|
|
82
|
+
export class FileModularizationAssessor extends BaseAssessor {
|
|
83
|
+
/**
|
|
84
|
+
* Run file modularization assessment
|
|
85
|
+
*/
|
|
86
|
+
async assess(context) {
|
|
87
|
+
this.logger.info("Starting file modularization assessment");
|
|
88
|
+
this.testCount = 0;
|
|
89
|
+
// Check if source code analysis is enabled
|
|
90
|
+
if (!context.sourceCodeFiles || !context.config.enableSourceCodeAnalysis) {
|
|
91
|
+
this.logger.info("Source code analysis not enabled, returning NEED_MORE_INFO");
|
|
92
|
+
return this.createSkippedResult();
|
|
93
|
+
}
|
|
94
|
+
// Analyze each source file
|
|
95
|
+
const fileAnalyses = this.analyzeFiles(context.sourceCodeFiles);
|
|
96
|
+
// Calculate metrics
|
|
97
|
+
const metrics = this.calculateMetrics(fileAnalyses);
|
|
98
|
+
// Run checks against thresholds
|
|
99
|
+
const checks = this.runChecks(metrics, fileAnalyses);
|
|
100
|
+
// Determine status based on checks
|
|
101
|
+
const status = this.determineStatusFromChecks(checks);
|
|
102
|
+
// Generate explanation and recommendations
|
|
103
|
+
const explanation = this.generateExplanation(metrics, checks);
|
|
104
|
+
const recommendations = this.generateRecommendations(metrics, fileAnalyses);
|
|
105
|
+
this.logger.info(`Assessment complete: score=${metrics.modularizationScore}, status=${status}`);
|
|
106
|
+
return {
|
|
107
|
+
metrics,
|
|
108
|
+
checks,
|
|
109
|
+
status,
|
|
110
|
+
explanation,
|
|
111
|
+
recommendations,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create result when source code is not available
|
|
116
|
+
*/
|
|
117
|
+
createSkippedResult() {
|
|
118
|
+
return {
|
|
119
|
+
metrics: {
|
|
120
|
+
totalSourceFiles: 0,
|
|
121
|
+
totalLines: 0,
|
|
122
|
+
largestFiles: [],
|
|
123
|
+
filesOver1000Lines: 0,
|
|
124
|
+
filesOver2000Lines: 0,
|
|
125
|
+
filesWithOver10Tools: 0,
|
|
126
|
+
filesWithOver20Tools: 0,
|
|
127
|
+
hasModularStructure: false,
|
|
128
|
+
modularizationScore: 0,
|
|
129
|
+
},
|
|
130
|
+
checks: [],
|
|
131
|
+
status: "NEED_MORE_INFO",
|
|
132
|
+
explanation: "Source code analysis not enabled. Enable enableSourceCodeAnalysis in config to run file modularization checks.",
|
|
133
|
+
recommendations: [
|
|
134
|
+
"Enable source code analysis by setting enableSourceCodeAnalysis: true in assessment config",
|
|
135
|
+
"Provide sourceCodePath in assessment context to analyze file structure",
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Analyze all source files
|
|
141
|
+
*/
|
|
142
|
+
analyzeFiles(sourceCodeFiles) {
|
|
143
|
+
const analyses = new Map();
|
|
144
|
+
for (const [filePath, content] of sourceCodeFiles) {
|
|
145
|
+
if (!this.isSourceFile(filePath)) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
this.testCount++;
|
|
149
|
+
const lines = content.split("\n").length;
|
|
150
|
+
const language = this.detectLanguage(filePath);
|
|
151
|
+
const toolCount = this.countToolsInFile(content, language);
|
|
152
|
+
analyses.set(filePath, { lines, toolCount, language });
|
|
153
|
+
}
|
|
154
|
+
return analyses;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Check if file is a source file worth scanning
|
|
158
|
+
*/
|
|
159
|
+
isSourceFile(filePath) {
|
|
160
|
+
const sourceExtensions = Object.keys(EXTENSION_TO_LANGUAGE);
|
|
161
|
+
// Skip test files, node_modules, and build artifacts
|
|
162
|
+
// Check for paths containing these directories or starting with them
|
|
163
|
+
if (filePath.includes("node_modules") ||
|
|
164
|
+
filePath.includes(".test.") ||
|
|
165
|
+
filePath.includes(".spec.") ||
|
|
166
|
+
filePath.includes("__tests__") ||
|
|
167
|
+
filePath.includes("__pycache__") ||
|
|
168
|
+
filePath.includes("/dist/") ||
|
|
169
|
+
filePath.includes("/build/") ||
|
|
170
|
+
filePath.includes("/.venv/") ||
|
|
171
|
+
filePath.includes("/venv/") ||
|
|
172
|
+
filePath.startsWith("dist/") ||
|
|
173
|
+
filePath.startsWith("build/") ||
|
|
174
|
+
filePath.startsWith(".venv/") ||
|
|
175
|
+
filePath.startsWith("venv/")) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
return sourceExtensions.some((ext) => filePath.endsWith(ext));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Detect language from file extension
|
|
182
|
+
*/
|
|
183
|
+
detectLanguage(filePath) {
|
|
184
|
+
for (const [ext, lang] of Object.entries(EXTENSION_TO_LANGUAGE)) {
|
|
185
|
+
if (filePath.endsWith(ext)) {
|
|
186
|
+
return lang;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Count tool definitions in a file
|
|
193
|
+
*/
|
|
194
|
+
countToolsInFile(content, language) {
|
|
195
|
+
if (!language)
|
|
196
|
+
return 0;
|
|
197
|
+
const patterns = TOOL_PATTERNS[language] || [];
|
|
198
|
+
let count = 0;
|
|
199
|
+
for (const pattern of patterns) {
|
|
200
|
+
// Reset lastIndex since we're using global flags
|
|
201
|
+
pattern.lastIndex = 0;
|
|
202
|
+
const matches = content.match(pattern);
|
|
203
|
+
if (matches) {
|
|
204
|
+
count += matches.length;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return count;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Calculate aggregated metrics
|
|
211
|
+
*/
|
|
212
|
+
calculateMetrics(fileAnalyses) {
|
|
213
|
+
const largestFiles = [];
|
|
214
|
+
let totalLines = 0;
|
|
215
|
+
let filesOver1000Lines = 0;
|
|
216
|
+
let filesOver2000Lines = 0;
|
|
217
|
+
let filesWithOver10Tools = 0;
|
|
218
|
+
let filesWithOver20Tools = 0;
|
|
219
|
+
for (const [filePath, analysis] of fileAnalyses) {
|
|
220
|
+
totalLines += analysis.lines;
|
|
221
|
+
// Check line count thresholds
|
|
222
|
+
if (analysis.lines > THRESHOLDS.LINE_ERROR) {
|
|
223
|
+
filesOver2000Lines++;
|
|
224
|
+
filesOver1000Lines++; // Also counts for 1000+ threshold
|
|
225
|
+
}
|
|
226
|
+
else if (analysis.lines > THRESHOLDS.LINE_WARNING) {
|
|
227
|
+
filesOver1000Lines++;
|
|
228
|
+
}
|
|
229
|
+
// Check tool count thresholds
|
|
230
|
+
if (analysis.toolCount > THRESHOLDS.TOOL_COUNT_ERROR) {
|
|
231
|
+
filesWithOver20Tools++;
|
|
232
|
+
filesWithOver10Tools++; // Also counts for 10+ threshold
|
|
233
|
+
}
|
|
234
|
+
else if (analysis.toolCount > THRESHOLDS.TOOL_COUNT_WARNING) {
|
|
235
|
+
filesWithOver10Tools++;
|
|
236
|
+
}
|
|
237
|
+
// Track large files for reporting
|
|
238
|
+
if (analysis.lines > THRESHOLDS.LINE_WARNING ||
|
|
239
|
+
analysis.toolCount > THRESHOLDS.TOOL_COUNT_WARNING) {
|
|
240
|
+
const severity = this.determineSeverity(analysis.lines, analysis.toolCount);
|
|
241
|
+
const recommendation = this.generateFileRecommendation(filePath, analysis.lines, analysis.toolCount);
|
|
242
|
+
largestFiles.push({
|
|
243
|
+
path: filePath,
|
|
244
|
+
lines: analysis.lines,
|
|
245
|
+
toolCount: analysis.toolCount,
|
|
246
|
+
severity,
|
|
247
|
+
recommendation,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// Sort by lines descending
|
|
252
|
+
largestFiles.sort((a, b) => b.lines - a.lines);
|
|
253
|
+
// Check for modular structure
|
|
254
|
+
const hasModularStructure = this.checkModularStructure(fileAnalyses);
|
|
255
|
+
// Calculate modularization score
|
|
256
|
+
const modularizationScore = this.calculateScore(filesOver1000Lines, filesOver2000Lines, filesWithOver10Tools, filesWithOver20Tools, hasModularStructure, fileAnalyses);
|
|
257
|
+
return {
|
|
258
|
+
totalSourceFiles: fileAnalyses.size,
|
|
259
|
+
totalLines,
|
|
260
|
+
largestFiles,
|
|
261
|
+
filesOver1000Lines,
|
|
262
|
+
filesOver2000Lines,
|
|
263
|
+
filesWithOver10Tools,
|
|
264
|
+
filesWithOver20Tools,
|
|
265
|
+
hasModularStructure,
|
|
266
|
+
modularizationScore,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Determine severity for a file
|
|
271
|
+
*/
|
|
272
|
+
determineSeverity(lines, toolCount) {
|
|
273
|
+
// HIGH if either threshold is exceeded at error level
|
|
274
|
+
if (lines > THRESHOLDS.LINE_ERROR ||
|
|
275
|
+
toolCount > THRESHOLDS.TOOL_COUNT_ERROR) {
|
|
276
|
+
return "HIGH";
|
|
277
|
+
}
|
|
278
|
+
// MEDIUM if warning thresholds are exceeded
|
|
279
|
+
if (lines > THRESHOLDS.LINE_WARNING ||
|
|
280
|
+
toolCount > THRESHOLDS.TOOL_COUNT_WARNING) {
|
|
281
|
+
return "MEDIUM";
|
|
282
|
+
}
|
|
283
|
+
return "LOW";
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Generate recommendation for a specific file
|
|
287
|
+
*/
|
|
288
|
+
generateFileRecommendation(filePath, lines, toolCount) {
|
|
289
|
+
const fileName = filePath.split("/").pop() || filePath;
|
|
290
|
+
const parts = [];
|
|
291
|
+
if (lines > THRESHOLDS.LINE_ERROR) {
|
|
292
|
+
parts.push(`Split ${fileName} (${lines} lines) into smaller modules of <500 lines each`);
|
|
293
|
+
}
|
|
294
|
+
else if (lines > THRESHOLDS.LINE_WARNING) {
|
|
295
|
+
parts.push(`Consider splitting ${fileName} (${lines} lines) to improve maintainability`);
|
|
296
|
+
}
|
|
297
|
+
if (toolCount > THRESHOLDS.TOOL_COUNT_ERROR) {
|
|
298
|
+
parts.push(`Separate ${toolCount} tools into category-based modules (e.g., tools/auth/, tools/data/)`);
|
|
299
|
+
}
|
|
300
|
+
else if (toolCount > THRESHOLDS.TOOL_COUNT_WARNING) {
|
|
301
|
+
parts.push(`Consider grouping ${toolCount} tools into logical categories`);
|
|
302
|
+
}
|
|
303
|
+
return parts.join(". ");
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Check if codebase has modular structure
|
|
307
|
+
*/
|
|
308
|
+
checkModularStructure(fileAnalyses) {
|
|
309
|
+
const filePaths = Array.from(fileAnalyses.keys());
|
|
310
|
+
// Check for tools/ subdirectory pattern
|
|
311
|
+
const hasToolsDir = filePaths.some((f) => f.includes("/tools/") || f.includes("\\tools\\"));
|
|
312
|
+
// Check for multiple tool files (not all tools in one file)
|
|
313
|
+
const toolFiles = Array.from(fileAnalyses.entries()).filter(([, analysis]) => analysis.toolCount > 0);
|
|
314
|
+
// Has modular structure if: has tools/ dir OR has 3+ tool files
|
|
315
|
+
return hasToolsDir || toolFiles.length >= 3;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Calculate modularization score (0-100)
|
|
319
|
+
*/
|
|
320
|
+
calculateScore(filesOver1000Lines, filesOver2000Lines, filesWithOver10Tools, filesWithOver20Tools, hasModularStructure, fileAnalyses) {
|
|
321
|
+
let score = 100;
|
|
322
|
+
// Deductions
|
|
323
|
+
score -= filesOver2000Lines * 15; // -15 per file >2000 lines
|
|
324
|
+
score -= (filesOver1000Lines - filesOver2000Lines) * 8; // -8 per file 1000-2000 lines
|
|
325
|
+
score -= filesWithOver20Tools * 12; // -12 per file with >20 tools
|
|
326
|
+
score -= (filesWithOver10Tools - filesWithOver20Tools) * 6; // -6 per file 10-20 tools
|
|
327
|
+
if (!hasModularStructure) {
|
|
328
|
+
score -= 10; // -10 for no modular structure
|
|
329
|
+
}
|
|
330
|
+
// Positive signals (bonuses)
|
|
331
|
+
const filePaths = Array.from(fileAnalyses.keys());
|
|
332
|
+
const hasToolsDir = filePaths.some((f) => f.includes("/tools/") || f.includes("\\tools\\"));
|
|
333
|
+
const hasSharedUtils = filePaths.some((f) => f.includes("_common.") ||
|
|
334
|
+
f.includes("shared.") ||
|
|
335
|
+
f.includes("utils.") ||
|
|
336
|
+
f.includes("helpers."));
|
|
337
|
+
const toolFilesCount = Array.from(fileAnalyses.values()).filter((a) => a.toolCount > 0).length;
|
|
338
|
+
if (hasToolsDir)
|
|
339
|
+
score += 5; // +5 for tools/ subdirectory
|
|
340
|
+
if (toolFilesCount > 3)
|
|
341
|
+
score += 3; // +3 for multiple tool files
|
|
342
|
+
if (hasSharedUtils)
|
|
343
|
+
score += 2; // +2 for shared utilities
|
|
344
|
+
// Clamp to 0-100
|
|
345
|
+
return Math.max(0, Math.min(100, score));
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Run threshold checks
|
|
349
|
+
*/
|
|
350
|
+
runChecks(metrics, _fileAnalyses) {
|
|
351
|
+
const checks = [];
|
|
352
|
+
// Check 1: Files over 2000 lines (HIGH severity)
|
|
353
|
+
checks.push({
|
|
354
|
+
checkName: "file_line_count_error",
|
|
355
|
+
passed: metrics.filesOver2000Lines === 0,
|
|
356
|
+
severity: "HIGH",
|
|
357
|
+
evidence: metrics.filesOver2000Lines > 0
|
|
358
|
+
? `${metrics.filesOver2000Lines} file(s) exceed 2000 lines`
|
|
359
|
+
: "No files exceed 2000 lines",
|
|
360
|
+
threshold: THRESHOLDS.LINE_ERROR,
|
|
361
|
+
actualValue: metrics.filesOver2000Lines,
|
|
362
|
+
});
|
|
363
|
+
// Check 2: Files over 1000 lines (MEDIUM severity)
|
|
364
|
+
const filesOnlyOver1000 = metrics.filesOver1000Lines - metrics.filesOver2000Lines;
|
|
365
|
+
checks.push({
|
|
366
|
+
checkName: "file_line_count_warning",
|
|
367
|
+
passed: filesOnlyOver1000 === 0,
|
|
368
|
+
severity: "MEDIUM",
|
|
369
|
+
evidence: filesOnlyOver1000 > 0
|
|
370
|
+
? `${filesOnlyOver1000} file(s) exceed 1000 lines`
|
|
371
|
+
: "No additional files exceed 1000 lines",
|
|
372
|
+
threshold: THRESHOLDS.LINE_WARNING,
|
|
373
|
+
actualValue: filesOnlyOver1000,
|
|
374
|
+
});
|
|
375
|
+
// Check 3: Files with >20 tools (HIGH severity)
|
|
376
|
+
checks.push({
|
|
377
|
+
checkName: "tool_count_error",
|
|
378
|
+
passed: metrics.filesWithOver20Tools === 0,
|
|
379
|
+
severity: "HIGH",
|
|
380
|
+
evidence: metrics.filesWithOver20Tools > 0
|
|
381
|
+
? `${metrics.filesWithOver20Tools} file(s) contain more than 20 tools`
|
|
382
|
+
: "No files contain more than 20 tools",
|
|
383
|
+
threshold: THRESHOLDS.TOOL_COUNT_ERROR,
|
|
384
|
+
actualValue: metrics.filesWithOver20Tools,
|
|
385
|
+
});
|
|
386
|
+
// Check 4: Files with >10 tools (MEDIUM severity)
|
|
387
|
+
const filesOnlyOver10Tools = metrics.filesWithOver10Tools - metrics.filesWithOver20Tools;
|
|
388
|
+
checks.push({
|
|
389
|
+
checkName: "tool_count_warning",
|
|
390
|
+
passed: filesOnlyOver10Tools === 0,
|
|
391
|
+
severity: "MEDIUM",
|
|
392
|
+
evidence: filesOnlyOver10Tools > 0
|
|
393
|
+
? `${filesOnlyOver10Tools} file(s) contain more than 10 tools`
|
|
394
|
+
: "No additional files contain more than 10 tools",
|
|
395
|
+
threshold: THRESHOLDS.TOOL_COUNT_WARNING,
|
|
396
|
+
actualValue: filesOnlyOver10Tools,
|
|
397
|
+
});
|
|
398
|
+
// Check 5: Modular structure (LOW severity, info)
|
|
399
|
+
checks.push({
|
|
400
|
+
checkName: "modular_structure",
|
|
401
|
+
passed: metrics.hasModularStructure,
|
|
402
|
+
severity: "LOW",
|
|
403
|
+
evidence: metrics.hasModularStructure
|
|
404
|
+
? "Codebase has modular structure (tools/ directory or multiple tool files)"
|
|
405
|
+
: "No modular structure detected - all tools appear to be in single file",
|
|
406
|
+
});
|
|
407
|
+
return checks;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Determine status from checks
|
|
411
|
+
*/
|
|
412
|
+
determineStatusFromChecks(checks) {
|
|
413
|
+
// FAIL if any HIGH severity check fails
|
|
414
|
+
const highSeverityFailed = checks.some((c) => !c.passed && c.severity === "HIGH");
|
|
415
|
+
if (highSeverityFailed) {
|
|
416
|
+
return "FAIL";
|
|
417
|
+
}
|
|
418
|
+
// NEED_MORE_INFO if any MEDIUM severity check fails
|
|
419
|
+
const mediumSeverityFailed = checks.some((c) => !c.passed && c.severity === "MEDIUM");
|
|
420
|
+
if (mediumSeverityFailed) {
|
|
421
|
+
return "NEED_MORE_INFO";
|
|
422
|
+
}
|
|
423
|
+
return "PASS";
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Generate explanation
|
|
427
|
+
*/
|
|
428
|
+
generateExplanation(metrics, checks) {
|
|
429
|
+
const parts = [];
|
|
430
|
+
parts.push(`Analyzed ${metrics.totalSourceFiles} source files (${metrics.totalLines} total lines).`);
|
|
431
|
+
parts.push(`Modularization score: ${metrics.modularizationScore}/100.`);
|
|
432
|
+
const failedChecks = checks.filter((c) => !c.passed);
|
|
433
|
+
if (failedChecks.length === 0) {
|
|
434
|
+
parts.push("All modularization checks passed. Code structure appears well-organized.");
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
const highFailed = failedChecks.filter((c) => c.severity === "HIGH");
|
|
438
|
+
const mediumFailed = failedChecks.filter((c) => c.severity === "MEDIUM");
|
|
439
|
+
if (highFailed.length > 0) {
|
|
440
|
+
parts.push(`ERROR: ${highFailed.length} high-severity issue(s) - files are too large or contain too many tools.`);
|
|
441
|
+
}
|
|
442
|
+
if (mediumFailed.length > 0) {
|
|
443
|
+
parts.push(`WARNING: ${mediumFailed.length} medium-severity issue(s) - consider refactoring for better maintainability.`);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return parts.join(" ");
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Generate recommendations
|
|
450
|
+
*/
|
|
451
|
+
generateRecommendations(metrics, _fileAnalyses) {
|
|
452
|
+
const recommendations = [];
|
|
453
|
+
// Add specific file recommendations
|
|
454
|
+
for (const file of metrics.largestFiles) {
|
|
455
|
+
if (file.severity === "HIGH") {
|
|
456
|
+
recommendations.push(`HIGH: ${file.recommendation}`);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// Add general recommendations based on checks
|
|
460
|
+
if (metrics.filesOver2000Lines > 0) {
|
|
461
|
+
recommendations.push("Split large files (>2000 lines) into smaller modules to improve maintainability and IDE performance.");
|
|
462
|
+
}
|
|
463
|
+
if (metrics.filesWithOver20Tools > 0) {
|
|
464
|
+
recommendations.push("Group tools by category (e.g., auth tools, data tools, utility tools) into separate modules.");
|
|
465
|
+
}
|
|
466
|
+
if (!metrics.hasModularStructure) {
|
|
467
|
+
recommendations.push("Create a tools/ subdirectory to organize tool implementations by category.");
|
|
468
|
+
recommendations.push("Extract shared utilities into a common module (e.g., _common.py, shared.ts).");
|
|
469
|
+
}
|
|
470
|
+
if (recommendations.length === 0) {
|
|
471
|
+
recommendations.push("Code structure is well-modularized. Continue following current patterns.");
|
|
472
|
+
}
|
|
473
|
+
return recommendations;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
@@ -334,6 +334,33 @@ export declare const STRUCTURED_DATA_INDICATORS: {
|
|
|
334
334
|
readonly jsonPattern: RegExp;
|
|
335
335
|
readonly numericMetadataPattern: RegExp;
|
|
336
336
|
};
|
|
337
|
+
/**
|
|
338
|
+
* Patterns for detecting secret/credential leakage in tool responses
|
|
339
|
+
* Used by: checkSecretLeakage()
|
|
340
|
+
*/
|
|
341
|
+
export declare const SECRET_LEAKAGE_PATTERNS: {
|
|
342
|
+
/** Well-known API key formats */
|
|
343
|
+
readonly apiKeys: readonly [RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
344
|
+
/** Database connection strings with credentials */
|
|
345
|
+
readonly connectionStrings: readonly [RegExp];
|
|
346
|
+
/** Environment variable patterns with values */
|
|
347
|
+
readonly envVars: readonly [RegExp];
|
|
348
|
+
/** Partial key exposure patterns */
|
|
349
|
+
readonly partialKeys: readonly [RegExp];
|
|
350
|
+
/** Generic credential assignment patterns */
|
|
351
|
+
readonly credentialAssignment: readonly [RegExp];
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* Patterns for detecting tool output injection vulnerabilities
|
|
355
|
+
* Detects when user content is echoed unsanitized in tool output
|
|
356
|
+
* Used by: analyzeOutputInjection()
|
|
357
|
+
*/
|
|
358
|
+
export declare const OUTPUT_INJECTION_PATTERNS: {
|
|
359
|
+
/** LLM control patterns that should be sanitized */
|
|
360
|
+
readonly llmControl: readonly [RegExp, RegExp, RegExp, RegExp];
|
|
361
|
+
/** Canary markers for echo detection */
|
|
362
|
+
readonly canaryMarkers: readonly [RegExp];
|
|
363
|
+
};
|
|
337
364
|
/**
|
|
338
365
|
* Check if any pattern in array matches text
|
|
339
366
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityPatternLibrary.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityPatternLibrary.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;IAC9B,kEAAkE;;IAIlE,8DAA8D;;IAG9D,kCAAkC;;IAGlC,gCAAgC;;CAExB,CAAC;AAMX;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,2JAmB5B,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2LAuBvB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,2BAA2B;IACtC,iCAAiC;;IAejC,0DAA0D;;CAElD,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,yBAAyB;IACpC,oCAAoC;;IAqBpC,4DAA4D;;IAW5D,+BAA+B;;CAEvB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;CAMh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AcpB,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,uBAAuB,mFAU1B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,2BAA2B,mDAM9B,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,uBAAuB,2DAO1B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,yBAAyB,2DAO5B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,6BAA6B,yKAWhC,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,kBAAkB,mGAYrB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,2BAA2B,QACO,CAAC;AAMhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAC8B,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,2EAS3B,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,2BAA2B,oRA4B9B,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAC;AAMX;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD"}
|
|
1
|
+
{"version":3,"file":"SecurityPatternLibrary.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityPatternLibrary.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;IAC9B,kEAAkE;;IAIlE,8DAA8D;;IAG9D,kCAAkC;;IAGlC,gCAAgC;;CAExB,CAAC;AAMX;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,2JAmB5B,CAAC;AAMX;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2LA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I,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD"}
|
|
@@ -879,6 +879,56 @@ export const STRUCTURED_DATA_INDICATORS = {
|
|
|
879
879
|
numericMetadataPattern: /\b(score|count|trust|rating|id|version)\b/i,
|
|
880
880
|
};
|
|
881
881
|
// =============================================================================
|
|
882
|
+
// SECRET LEAKAGE PATTERNS (Issue #103, Challenge #9)
|
|
883
|
+
// =============================================================================
|
|
884
|
+
/**
|
|
885
|
+
* Patterns for detecting secret/credential leakage in tool responses
|
|
886
|
+
* Used by: checkSecretLeakage()
|
|
887
|
+
*/
|
|
888
|
+
export const SECRET_LEAKAGE_PATTERNS = {
|
|
889
|
+
/** Well-known API key formats */
|
|
890
|
+
apiKeys: [
|
|
891
|
+
/AKIA[A-Z0-9]{16}/, // AWS Access Key
|
|
892
|
+
/sk-[a-zA-Z0-9]{20,}/, // OpenAI Key
|
|
893
|
+
/ghp_[a-zA-Z0-9]{36}/, // GitHub PAT
|
|
894
|
+
/glpat-[a-zA-Z0-9]{20}/, // GitLab PAT
|
|
895
|
+
/xox[baprs]-[a-zA-Z0-9-]+/, // Slack tokens
|
|
896
|
+
],
|
|
897
|
+
/** Database connection strings with credentials */
|
|
898
|
+
connectionStrings: [
|
|
899
|
+
/(postgresql|mysql|mongodb|redis|mssql):\/\/[^:]+:[^@]+@/i,
|
|
900
|
+
],
|
|
901
|
+
/** Environment variable patterns with values */
|
|
902
|
+
envVars: [
|
|
903
|
+
/(SECRET_TOKEN|DATABASE_URL|API_KEY|PRIVATE_KEY|DB_PASSWORD)[^\s]*[:=]/i,
|
|
904
|
+
],
|
|
905
|
+
/** Partial key exposure patterns */
|
|
906
|
+
partialKeys: [/api_key_preview|key_fragment|partial_key/i],
|
|
907
|
+
/** Generic credential assignment patterns */
|
|
908
|
+
credentialAssignment: [
|
|
909
|
+
/(api[_-]?key|secret|password)[^\s]*[:=]\s*["']?[a-zA-Z0-9_-]{10,}/i,
|
|
910
|
+
],
|
|
911
|
+
};
|
|
912
|
+
// =============================================================================
|
|
913
|
+
// OUTPUT INJECTION PATTERNS (Issue #103, Challenge #8)
|
|
914
|
+
// =============================================================================
|
|
915
|
+
/**
|
|
916
|
+
* Patterns for detecting tool output injection vulnerabilities
|
|
917
|
+
* Detects when user content is echoed unsanitized in tool output
|
|
918
|
+
* Used by: analyzeOutputInjection()
|
|
919
|
+
*/
|
|
920
|
+
export const OUTPUT_INJECTION_PATTERNS = {
|
|
921
|
+
/** LLM control patterns that should be sanitized */
|
|
922
|
+
llmControl: [
|
|
923
|
+
/<IMPORTANT>.*<\/IMPORTANT>/is,
|
|
924
|
+
/\[INST\].*\[\/INST\]/is,
|
|
925
|
+
/<\|system\|>.*<\|end\|>/is,
|
|
926
|
+
/\{\{.*\}\}/, // Template vars
|
|
927
|
+
],
|
|
928
|
+
/** Canary markers for echo detection */
|
|
929
|
+
canaryMarkers: [/SENTINEL_OUTPUT_MARKER_\d+/],
|
|
930
|
+
};
|
|
931
|
+
// =============================================================================
|
|
882
932
|
// HELPER FUNCTIONS
|
|
883
933
|
// =============================================================================
|
|
884
934
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityPayloadGenerator.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityPayloadGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIzD;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,iBAAiB,CAAuC;IAEhE;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAUvC;;OAEG;IACH,oBAAoB,CAClB,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,IAAI,GACT,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"SecurityPayloadGenerator.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityPayloadGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIzD;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,iBAAiB,CAAuC;IAEhE;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAUvC;;OAEG;IACH,oBAAoB,CAClB,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,IAAI,GACT,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAwK1B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IASjC;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAQ7C"}
|
|
@@ -130,6 +130,19 @@ export class SecurityPayloadGenerator {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
// VERBOSE MODE TESTING (Issue #103, Challenge #9)
|
|
134
|
+
// For secret_leakage payloads, enable verbose mode to detect additional credential exposure
|
|
135
|
+
if (payload.payloadType === "secret_leakage") {
|
|
136
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
137
|
+
const propSchema = prop;
|
|
138
|
+
if (propSchema.type === "boolean" &&
|
|
139
|
+
key.toLowerCase() === "verbose" &&
|
|
140
|
+
!(key in params)) {
|
|
141
|
+
params[key] = true; // Enable verbose mode to test for additional leakage
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
133
146
|
// Fill required parameters with safe defaults
|
|
134
147
|
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
135
148
|
const propSchema = prop;
|
|
@@ -129,6 +129,20 @@ export declare class SecurityResponseAnalyzer {
|
|
|
129
129
|
* @returns Analysis result with vulnerability status and evidence
|
|
130
130
|
*/
|
|
131
131
|
analyzeChainExploitation(response: CompatibilityCallToolResult): ChainExploitationAnalysis;
|
|
132
|
+
/**
|
|
133
|
+
* Check for secret leakage in response (Issue #103, Challenge #9)
|
|
134
|
+
* Scans for credential patterns regardless of payload type.
|
|
135
|
+
*
|
|
136
|
+
* This method detects when tools inadvertently expose:
|
|
137
|
+
* - API keys (AWS, OpenAI, GitHub, GitLab, Slack)
|
|
138
|
+
* - Database connection strings with credentials
|
|
139
|
+
* - Environment variable values
|
|
140
|
+
* - Partial key previews
|
|
141
|
+
*/
|
|
142
|
+
checkSecretLeakage(response: CompatibilityCallToolResult): {
|
|
143
|
+
detected: boolean;
|
|
144
|
+
evidence?: string;
|
|
145
|
+
};
|
|
132
146
|
/**
|
|
133
147
|
* Check if response indicates connection/server failure
|
|
134
148
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityResponseAnalyzer.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityResponseAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,2BAA2B,EAC3B,IAAI,EACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAK1E,OAAO,EAAgB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAoB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAYxE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,OAAO,CAAC;IAC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CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAInD;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO;IAIpE;;OAEG;IACH,qCAAqC,CACnC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GACnB,OAAO;IAOV;;OAEG;IACH,yBAAyB,CACvB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,IAAI,GACV,kBAAkB;IAQrB;;OAEG;IACH,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAInD;;OAEG;IACH,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAIvD;;OAEG;IACH,8BAA8B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAI7D;;OAEG;IACH,qBAAqB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,OAAO;IAIrE;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO;IAOxE;;OAEG;IACH,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAIrD;;OAEG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAQjD;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAyB/B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IA+E7B;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAwClC;;OAEG;IACH,OAAO,CAAC,wBAAwB;CAoBjC"}
|
|
1
|
+
{"version":3,"file":"SecurityResponseAnalyzer.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityResponseAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,2BAA2B,EAC3B,IAAI,EACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAA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