@bryan-thompson/inspector-assessment-client 1.6.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{OAuthCallback-ZcXdfhZQ.js → OAuthCallback-cGhwkoyY.js} +1 -1
- package/dist/assets/{OAuthDebugCallback-xt1SlIHS.js → OAuthDebugCallback-2rmUqser.js} +1 -1
- package/dist/assets/{index-B3lTiDVe.js → index-BnFixpvH.js} +4 -4
- package/dist/index.html +1 -1
- package/lib/lib/assessmentTypes.d.ts +670 -0
- package/lib/lib/assessmentTypes.d.ts.map +1 -0
- package/lib/lib/assessmentTypes.js +220 -0
- package/lib/lib/aupPatterns.d.ts +63 -0
- package/lib/lib/aupPatterns.d.ts.map +1 -0
- package/lib/lib/aupPatterns.js +344 -0
- package/lib/lib/prohibitedLibraries.d.ts +76 -0
- package/lib/lib/prohibitedLibraries.d.ts.map +1 -0
- package/lib/lib/prohibitedLibraries.js +364 -0
- package/lib/lib/securityPatterns.d.ts +64 -0
- package/lib/lib/securityPatterns.d.ts.map +1 -0
- package/lib/lib/securityPatterns.js +453 -0
- package/lib/services/assessment/AssessmentOrchestrator.d.ts +88 -0
- package/lib/services/assessment/AssessmentOrchestrator.d.ts.map +1 -0
- package/lib/services/assessment/AssessmentOrchestrator.js +418 -0
- package/lib/services/assessment/ResponseValidator.d.ts +69 -0
- package/lib/services/assessment/ResponseValidator.d.ts.map +1 -0
- package/lib/services/assessment/ResponseValidator.js +1038 -0
- package/lib/services/assessment/TestDataGenerator.d.ts +86 -0
- package/lib/services/assessment/TestDataGenerator.d.ts.map +1 -0
- package/lib/services/assessment/TestDataGenerator.js +669 -0
- package/lib/services/assessment/TestScenarioEngine.d.ts +91 -0
- package/lib/services/assessment/TestScenarioEngine.d.ts.map +1 -0
- package/lib/services/assessment/TestScenarioEngine.js +505 -0
- package/lib/services/assessment/ToolClassifier.d.ts +61 -0
- package/lib/services/assessment/ToolClassifier.d.ts.map +1 -0
- package/lib/services/assessment/ToolClassifier.js +349 -0
- package/lib/services/assessment/lib/claudeCodeBridge.d.ts +160 -0
- package/lib/services/assessment/lib/claudeCodeBridge.d.ts.map +1 -0
- package/lib/services/assessment/lib/claudeCodeBridge.js +357 -0
- package/lib/services/assessment/modules/AUPComplianceAssessor.d.ts +100 -0
- package/lib/services/assessment/modules/AUPComplianceAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/AUPComplianceAssessor.js +474 -0
- package/lib/services/assessment/modules/BaseAssessor.d.ts +71 -0
- package/lib/services/assessment/modules/BaseAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/BaseAssessor.js +171 -0
- package/lib/services/assessment/modules/DocumentationAssessor.d.ts +45 -0
- package/lib/services/assessment/modules/DocumentationAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/DocumentationAssessor.js +355 -0
- package/lib/services/assessment/modules/ErrorHandlingAssessor.d.ts +25 -0
- package/lib/services/assessment/modules/ErrorHandlingAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/ErrorHandlingAssessor.js +564 -0
- package/lib/services/assessment/modules/FunctionalityAssessor.d.ts +20 -0
- package/lib/services/assessment/modules/FunctionalityAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/FunctionalityAssessor.js +253 -0
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.d.ts +70 -0
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.js +508 -0
- package/lib/services/assessment/modules/ManifestValidationAssessor.d.ts +70 -0
- package/lib/services/assessment/modules/ManifestValidationAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/ManifestValidationAssessor.js +430 -0
- package/lib/services/assessment/modules/PortabilityAssessor.d.ts +43 -0
- package/lib/services/assessment/modules/PortabilityAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/PortabilityAssessor.js +347 -0
- package/lib/services/assessment/modules/ProhibitedLibrariesAssessor.d.ts +41 -0
- package/lib/services/assessment/modules/ProhibitedLibrariesAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/ProhibitedLibrariesAssessor.js +256 -0
- package/lib/services/assessment/modules/SecurityAssessor.d.ts +176 -0
- package/lib/services/assessment/modules/SecurityAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/SecurityAssessor.js +1333 -0
- package/lib/services/assessment/modules/ToolAnnotationAssessor.d.ts +96 -0
- package/lib/services/assessment/modules/ToolAnnotationAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/ToolAnnotationAssessor.js +593 -0
- package/lib/services/assessment/modules/UsabilityAssessor.d.ts +21 -0
- package/lib/services/assessment/modules/UsabilityAssessor.d.ts.map +1 -0
- package/lib/services/assessment/modules/UsabilityAssessor.js +241 -0
- package/lib/services/assessment/modules/index.d.ts +33 -0
- package/lib/services/assessment/modules/index.d.ts.map +1 -0
- package/lib/services/assessment/modules/index.js +35 -0
- package/package.json +15 -3
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Bridge
|
|
3
|
+
*
|
|
4
|
+
* Provides integration with Claude Code CLI for intelligent analysis tasks.
|
|
5
|
+
* Uses shell execution with `claude --print` for stateless reasoning.
|
|
6
|
+
*
|
|
7
|
+
* This bridge enables:
|
|
8
|
+
* - Intelligent test parameter generation
|
|
9
|
+
* - Semantic AUP violation analysis
|
|
10
|
+
* - Tool behavior inference for annotation validation
|
|
11
|
+
* - Documentation quality assessment
|
|
12
|
+
*/
|
|
13
|
+
import { execSync } from "child_process";
|
|
14
|
+
/**
|
|
15
|
+
* Default configuration with minimal features
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_CLAUDE_CODE_CONFIG = {
|
|
18
|
+
enabled: false,
|
|
19
|
+
timeout: 30000,
|
|
20
|
+
maxRetries: 1,
|
|
21
|
+
features: {
|
|
22
|
+
intelligentTestGeneration: false,
|
|
23
|
+
aupSemanticAnalysis: false,
|
|
24
|
+
behaviorInference: false,
|
|
25
|
+
annotationInference: false,
|
|
26
|
+
documentationAssessment: false,
|
|
27
|
+
documentationQuality: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Full configuration with all features enabled
|
|
32
|
+
*/
|
|
33
|
+
export const FULL_CLAUDE_CODE_CONFIG = {
|
|
34
|
+
enabled: true,
|
|
35
|
+
timeout: 60000,
|
|
36
|
+
maxRetries: 2,
|
|
37
|
+
features: {
|
|
38
|
+
intelligentTestGeneration: true,
|
|
39
|
+
aupSemanticAnalysis: true,
|
|
40
|
+
behaviorInference: true,
|
|
41
|
+
annotationInference: true,
|
|
42
|
+
documentationAssessment: true,
|
|
43
|
+
documentationQuality: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Claude Code Bridge
|
|
48
|
+
* Executes Claude CLI for intelligent analysis during MCP assessments
|
|
49
|
+
*/
|
|
50
|
+
export class ClaudeCodeBridge {
|
|
51
|
+
config;
|
|
52
|
+
isAvailable = false;
|
|
53
|
+
constructor(config) {
|
|
54
|
+
this.config = config;
|
|
55
|
+
this.isAvailable = this.checkClaudeAvailability();
|
|
56
|
+
if (!this.isAvailable) {
|
|
57
|
+
console.warn("[ClaudeCodeBridge] Claude CLI not available - features will be disabled");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if a specific feature is enabled
|
|
62
|
+
* Note: annotationInference is an alias for behaviorInference
|
|
63
|
+
*/
|
|
64
|
+
isFeatureEnabled(feature) {
|
|
65
|
+
if (!this.isAvailable || !this.config.enabled) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
// annotationInference is an alias for behaviorInference
|
|
69
|
+
if (feature === "annotationInference") {
|
|
70
|
+
return (this.config.features.annotationInference === true ||
|
|
71
|
+
this.config.features.behaviorInference === true);
|
|
72
|
+
}
|
|
73
|
+
return this.config.features[feature] === true;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check if Claude CLI is available on the system
|
|
77
|
+
*/
|
|
78
|
+
checkClaudeAvailability() {
|
|
79
|
+
try {
|
|
80
|
+
execSync("which claude", { stdio: "pipe", timeout: 5000 });
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Execute Claude CLI with a prompt
|
|
89
|
+
*/
|
|
90
|
+
executeClaudeCommand(prompt) {
|
|
91
|
+
const startTime = Date.now();
|
|
92
|
+
try {
|
|
93
|
+
const timeout = this.config.timeout || 30000;
|
|
94
|
+
// Escape the prompt for shell execution
|
|
95
|
+
const escapedPrompt = prompt.replace(/'/g, "'\\''");
|
|
96
|
+
const output = execSync(`claude --print '${escapedPrompt}'`, {
|
|
97
|
+
encoding: "utf-8",
|
|
98
|
+
timeout,
|
|
99
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
100
|
+
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
output: output.trim(),
|
|
105
|
+
executionTimeMs: Date.now() - startTime,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
output: "",
|
|
112
|
+
error: error instanceof Error ? error.message : String(error),
|
|
113
|
+
executionTimeMs: Date.now() - startTime,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Execute with retries
|
|
119
|
+
*/
|
|
120
|
+
async executeWithRetry(prompt) {
|
|
121
|
+
const maxRetries = this.config.maxRetries || 1;
|
|
122
|
+
let lastError = null;
|
|
123
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
124
|
+
const response = this.executeClaudeCommand(prompt);
|
|
125
|
+
if (response.success) {
|
|
126
|
+
return response;
|
|
127
|
+
}
|
|
128
|
+
lastError = response;
|
|
129
|
+
// Wait before retry (exponential backoff)
|
|
130
|
+
if (attempt < maxRetries) {
|
|
131
|
+
await new Promise((resolve) => setTimeout(resolve, 1000 * Math.pow(2, attempt)));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return lastError;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Parse JSON from Claude response, handling markdown code blocks
|
|
138
|
+
*/
|
|
139
|
+
parseJsonResponse(response) {
|
|
140
|
+
if (!response.success) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
let jsonStr = response.output;
|
|
145
|
+
// Handle markdown code blocks
|
|
146
|
+
const jsonMatch = jsonStr.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
147
|
+
if (jsonMatch) {
|
|
148
|
+
jsonStr = jsonMatch[1].trim();
|
|
149
|
+
}
|
|
150
|
+
return JSON.parse(jsonStr);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
console.warn("[ClaudeCodeBridge] Failed to parse JSON response");
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Analyze an AUP violation for false positives using semantic analysis
|
|
159
|
+
* @param matchedText - The text that matched the AUP pattern
|
|
160
|
+
* @param context - Context about the violation
|
|
161
|
+
*/
|
|
162
|
+
async analyzeAUPViolation(matchedText, context) {
|
|
163
|
+
if (!this.isFeatureEnabled("aupSemanticAnalysis")) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
const prompt = `You are analyzing a potential AUP (Acceptable Use Policy) violation detected in an MCP server tool.
|
|
167
|
+
|
|
168
|
+
CONTEXT:
|
|
169
|
+
- Flagged text: "${matchedText}"
|
|
170
|
+
- Tool name: ${context.toolName}
|
|
171
|
+
- Tool description: ${context.toolDescription || "No description"}
|
|
172
|
+
- Category: ${context.category} (${context.categoryName})
|
|
173
|
+
- Location: ${context.location}
|
|
174
|
+
|
|
175
|
+
TASK:
|
|
176
|
+
Determine if this is a TRUE violation or a FALSE POSITIVE. Consider:
|
|
177
|
+
1. Is this a legitimate security/defensive tool?
|
|
178
|
+
2. Is there appropriate context (disclaimers, educational purpose)?
|
|
179
|
+
3. Does the tool's purpose justify the flagged content?
|
|
180
|
+
|
|
181
|
+
Respond with JSON only:
|
|
182
|
+
{
|
|
183
|
+
"isViolation": boolean,
|
|
184
|
+
"confidence": number (0-100),
|
|
185
|
+
"reasoning": "explanation",
|
|
186
|
+
"category": "${context.category}",
|
|
187
|
+
"suggestedAction": "block" | "flag_for_review" | "allow",
|
|
188
|
+
"contextFactors": ["factor1", "factor2"]
|
|
189
|
+
}`;
|
|
190
|
+
const response = await this.executeWithRetry(prompt);
|
|
191
|
+
const result = this.parseJsonResponse(response);
|
|
192
|
+
// Normalize: ensure both isViolation and isConfirmedViolation are present
|
|
193
|
+
if (result) {
|
|
194
|
+
result.isViolation = result.isViolation ?? result.isConfirmedViolation;
|
|
195
|
+
result.isConfirmedViolation =
|
|
196
|
+
result.isConfirmedViolation ?? result.isViolation;
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Infer expected tool behavior for annotation validation
|
|
202
|
+
*/
|
|
203
|
+
async inferToolBehavior(tool, currentAnnotations) {
|
|
204
|
+
// Check both behaviorInference and annotationInference feature flags
|
|
205
|
+
if (!this.isFeatureEnabled("behaviorInference") &&
|
|
206
|
+
!this.isFeatureEnabled("annotationInference")) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const annotationsStr = currentAnnotations
|
|
210
|
+
? JSON.stringify(currentAnnotations, null, 2)
|
|
211
|
+
: "No annotations provided";
|
|
212
|
+
const prompt = `You are analyzing an MCP tool to infer its expected behavior and validate annotations.
|
|
213
|
+
|
|
214
|
+
TOOL:
|
|
215
|
+
- Name: ${tool.name}
|
|
216
|
+
- Description: ${tool.description || "No description provided"}
|
|
217
|
+
- Input Schema: ${JSON.stringify(tool.inputSchema, null, 2)}
|
|
218
|
+
|
|
219
|
+
CURRENT ANNOTATIONS:
|
|
220
|
+
${annotationsStr}
|
|
221
|
+
|
|
222
|
+
TASK:
|
|
223
|
+
Analyze the tool and determine:
|
|
224
|
+
1. Is this tool read-only (doesn't modify state)?
|
|
225
|
+
2. Is this tool destructive (can delete/destroy data)?
|
|
226
|
+
3. Do the current annotations match expected behavior?
|
|
227
|
+
|
|
228
|
+
Respond with JSON only:
|
|
229
|
+
{
|
|
230
|
+
"expectedReadOnly": boolean,
|
|
231
|
+
"expectedDestructive": boolean,
|
|
232
|
+
"confidence": number (0-100),
|
|
233
|
+
"reasoning": "explanation",
|
|
234
|
+
"suggestedAnnotations": {
|
|
235
|
+
"readOnlyHint": boolean,
|
|
236
|
+
"destructiveHint": boolean,
|
|
237
|
+
"idempotentHint": boolean
|
|
238
|
+
},
|
|
239
|
+
"misalignmentDetected": boolean,
|
|
240
|
+
"misalignmentDetails": "details if misaligned, null otherwise"
|
|
241
|
+
}`;
|
|
242
|
+
const response = await this.executeWithRetry(prompt);
|
|
243
|
+
return this.parseJsonResponse(response);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Generate intelligent test scenarios for a tool
|
|
247
|
+
*/
|
|
248
|
+
async generateTestScenarios(tool, existingScenarios) {
|
|
249
|
+
if (!this.isFeatureEnabled("intelligentTestGeneration")) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
const prompt = `You are generating test scenarios for an MCP tool.
|
|
253
|
+
|
|
254
|
+
TOOL:
|
|
255
|
+
- Name: ${tool.name}
|
|
256
|
+
- Description: ${tool.description || "No description provided"}
|
|
257
|
+
- Input Schema: ${JSON.stringify(tool.inputSchema, null, 2)}
|
|
258
|
+
|
|
259
|
+
EXISTING SCENARIOS: ${existingScenarios} already generated via schema analysis
|
|
260
|
+
|
|
261
|
+
TASK:
|
|
262
|
+
Generate 3-5 additional test scenarios that would catch edge cases the schema-based generator might miss. Focus on:
|
|
263
|
+
1. Real-world usage patterns
|
|
264
|
+
2. Boundary conditions
|
|
265
|
+
3. Error conditions
|
|
266
|
+
4. Security-relevant inputs
|
|
267
|
+
|
|
268
|
+
Respond with JSON only:
|
|
269
|
+
{
|
|
270
|
+
"scenarios": [
|
|
271
|
+
{
|
|
272
|
+
"name": "scenario_name",
|
|
273
|
+
"description": "what this tests",
|
|
274
|
+
"params": { "param1": "value1" },
|
|
275
|
+
"expectedBehavior": "what should happen",
|
|
276
|
+
"category": "happy_path" | "edge_case" | "boundary" | "error_case"
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
"reasoning": "why these scenarios are valuable"
|
|
280
|
+
}`;
|
|
281
|
+
const response = await this.executeWithRetry(prompt);
|
|
282
|
+
return this.parseJsonResponse(response);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Generate test parameters for a tool
|
|
286
|
+
* This returns just the parameter sets, used by TestDataGenerator
|
|
287
|
+
*/
|
|
288
|
+
async generateTestParameters(tool) {
|
|
289
|
+
if (!this.isFeatureEnabled("intelligentTestGeneration")) {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
const prompt = `You are generating test parameters for an MCP tool.
|
|
293
|
+
|
|
294
|
+
TOOL:
|
|
295
|
+
- Name: ${tool.name}
|
|
296
|
+
- Description: ${tool.description || "No description provided"}
|
|
297
|
+
- Input Schema: ${JSON.stringify(tool.inputSchema, null, 2)}
|
|
298
|
+
|
|
299
|
+
TASK:
|
|
300
|
+
Generate 3-5 sets of valid test parameters that exercise different scenarios:
|
|
301
|
+
1. Happy path / typical usage
|
|
302
|
+
2. Edge cases (empty strings, zeros, minimum values)
|
|
303
|
+
3. Boundary values (max length strings, large numbers)
|
|
304
|
+
4. Alternative valid inputs
|
|
305
|
+
|
|
306
|
+
Return ONLY valid parameter sets (no intentionally invalid inputs).
|
|
307
|
+
|
|
308
|
+
Respond with JSON only:
|
|
309
|
+
{
|
|
310
|
+
"parameters": [
|
|
311
|
+
{ "param1": "value1", "param2": 123 },
|
|
312
|
+
{ "param1": "", "param2": 0 },
|
|
313
|
+
{ "param1": "very long string...", "param2": 999999 }
|
|
314
|
+
]
|
|
315
|
+
}`;
|
|
316
|
+
const response = await this.executeWithRetry(prompt);
|
|
317
|
+
const result = this.parseJsonResponse(response);
|
|
318
|
+
return result?.parameters || null;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Assess documentation quality
|
|
322
|
+
*/
|
|
323
|
+
async assessDocumentation(readmeContent, toolCount) {
|
|
324
|
+
if (!this.isFeatureEnabled("documentationAssessment")) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
// Truncate very long READMEs
|
|
328
|
+
const truncatedReadme = readmeContent.length > 10000
|
|
329
|
+
? readmeContent.substring(0, 10000) + "\n...[truncated]..."
|
|
330
|
+
: readmeContent;
|
|
331
|
+
const prompt = `You are assessing the documentation quality of an MCP server.
|
|
332
|
+
|
|
333
|
+
README CONTENT:
|
|
334
|
+
${truncatedReadme}
|
|
335
|
+
|
|
336
|
+
SERVER INFO:
|
|
337
|
+
- Number of tools: ${toolCount}
|
|
338
|
+
|
|
339
|
+
TASK:
|
|
340
|
+
Assess the documentation quality. Check for:
|
|
341
|
+
1. Clear description of what the server does
|
|
342
|
+
2. Installation instructions
|
|
343
|
+
3. Configuration requirements
|
|
344
|
+
4. Tool documentation
|
|
345
|
+
5. Examples of usage
|
|
346
|
+
6. Security considerations
|
|
347
|
+
|
|
348
|
+
Respond with JSON only:
|
|
349
|
+
{
|
|
350
|
+
"score": number (0-100),
|
|
351
|
+
"issues": ["issue1", "issue2"],
|
|
352
|
+
"suggestions": ["suggestion1", "suggestion2"]
|
|
353
|
+
}`;
|
|
354
|
+
const response = await this.executeWithRetry(prompt);
|
|
355
|
+
return this.parseJsonResponse(response);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUP Compliance Assessor
|
|
3
|
+
* Scans MCP server for Acceptable Use Policy violations
|
|
4
|
+
*
|
|
5
|
+
* Checks:
|
|
6
|
+
* - Tool names and descriptions
|
|
7
|
+
* - README content
|
|
8
|
+
* - Source code (if sourceCodePath provided)
|
|
9
|
+
*
|
|
10
|
+
* Based on Anthropic's 14 AUP categories (A-N)
|
|
11
|
+
*
|
|
12
|
+
* Supports optional Claude Code integration for semantic analysis
|
|
13
|
+
* to reduce false positives (e.g., security tools, disclaimers).
|
|
14
|
+
*/
|
|
15
|
+
import { BaseAssessor } from "./BaseAssessor.js";
|
|
16
|
+
import { AssessmentContext } from "../AssessmentOrchestrator.js";
|
|
17
|
+
import type { AUPComplianceAssessment, AUPViolation } from "../../../lib/assessmentTypes.js";
|
|
18
|
+
import type { ClaudeCodeBridge } from "../lib/claudeCodeBridge.js";
|
|
19
|
+
/**
|
|
20
|
+
* Extended AUP violation with semantic analysis results
|
|
21
|
+
*/
|
|
22
|
+
export interface EnhancedAUPViolation extends AUPViolation {
|
|
23
|
+
semanticAnalysis?: {
|
|
24
|
+
isConfirmedViolation: boolean;
|
|
25
|
+
confidence: number;
|
|
26
|
+
reasoning: string;
|
|
27
|
+
source: "claude-verified" | "pattern-only";
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Extended AUP compliance assessment with semantic analysis
|
|
32
|
+
*/
|
|
33
|
+
export interface EnhancedAUPComplianceAssessment extends AUPComplianceAssessment {
|
|
34
|
+
confirmedViolations: EnhancedAUPViolation[];
|
|
35
|
+
flaggedForReview: EnhancedAUPViolation[];
|
|
36
|
+
semanticAnalysisEnabled: boolean;
|
|
37
|
+
falsePositivesFiltered: number;
|
|
38
|
+
}
|
|
39
|
+
export declare class AUPComplianceAssessor extends BaseAssessor {
|
|
40
|
+
private claudeBridge;
|
|
41
|
+
/**
|
|
42
|
+
* Set the Claude Code bridge for semantic violation analysis
|
|
43
|
+
*/
|
|
44
|
+
setClaudeBridge(bridge: ClaudeCodeBridge | null): void;
|
|
45
|
+
/**
|
|
46
|
+
* Check if Claude semantic analysis is enabled
|
|
47
|
+
*/
|
|
48
|
+
private isSemanticAnalysisEnabled;
|
|
49
|
+
/**
|
|
50
|
+
* Run AUP compliance assessment
|
|
51
|
+
* If Claude semantic analysis is enabled, violations are verified to reduce false positives.
|
|
52
|
+
*/
|
|
53
|
+
assess(context: AssessmentContext): Promise<AUPComplianceAssessment | EnhancedAUPComplianceAssessment>;
|
|
54
|
+
/**
|
|
55
|
+
* Run Claude semantic analysis on flagged violations
|
|
56
|
+
* Separates confirmed violations from likely false positives
|
|
57
|
+
*/
|
|
58
|
+
private runSemanticAnalysis;
|
|
59
|
+
/**
|
|
60
|
+
* Generate explanation for semantic analysis results
|
|
61
|
+
*/
|
|
62
|
+
private generateSemanticExplanation;
|
|
63
|
+
/**
|
|
64
|
+
* Generate recommendations for semantic analysis results
|
|
65
|
+
*/
|
|
66
|
+
private generateSemanticRecommendations;
|
|
67
|
+
/**
|
|
68
|
+
* Scan a tool name for AUP violations
|
|
69
|
+
*/
|
|
70
|
+
private scanToolName;
|
|
71
|
+
/**
|
|
72
|
+
* Scan a tool description for AUP violations
|
|
73
|
+
*/
|
|
74
|
+
private scanToolDescription;
|
|
75
|
+
/**
|
|
76
|
+
* Scan README content for AUP violations
|
|
77
|
+
*/
|
|
78
|
+
private scanReadme;
|
|
79
|
+
/**
|
|
80
|
+
* Scan a source file for AUP violations
|
|
81
|
+
*/
|
|
82
|
+
private scanSourceFile;
|
|
83
|
+
/**
|
|
84
|
+
* Check if a file should be skipped for AUP scanning
|
|
85
|
+
*/
|
|
86
|
+
private shouldSkipFile;
|
|
87
|
+
/**
|
|
88
|
+
* Determine overall status based on violations
|
|
89
|
+
*/
|
|
90
|
+
private determineAUPStatus;
|
|
91
|
+
/**
|
|
92
|
+
* Generate explanation text
|
|
93
|
+
*/
|
|
94
|
+
private generateExplanation;
|
|
95
|
+
/**
|
|
96
|
+
* Generate recommendations
|
|
97
|
+
*/
|
|
98
|
+
private generateRecommendations;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=AUPComplianceAssessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AUPComplianceAssessor.d.ts","sourceRoot":"","sources":["../../../../src/services/assessment/modules/AUPComplianceAssessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EACV,uBAAuB,EACvB,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,gBAAgB,CAAC,EAAE;QACjB,oBAAoB,EAAE,OAAO,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,iBAAiB,GAAG,cAAc,CAAC;KAC5C,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,+BAAgC,SAAQ,uBAAuB;IAC9E,mBAAmB,EAAE,oBAAoB,EAAE,CAAC;IAC5C,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,uBAAuB,EAAE,OAAO,CAAC;IACjC,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED,qBAAa,qBAAsB,SAAQ,YAAY;IAErD,OAAO,CAAC,YAAY,CAAiC;IAErD;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI;IAItD;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAMjC;;;OAGG;IACG,MAAM,CACV,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,uBAAuB,GAAG,+BAA+B,CAAC;IA+HrE;;;OAGG;YACW,mBAAmB;IAyHjC;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAqDnC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAiEvC;;OAEG;IACH,OAAO,CAAC,YAAY;IAgBpB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAmB3B;;OAEG;IACH,OAAO,CAAC,UAAU;IAgBlB;;OAEG;IACH,OAAO,CAAC,cAAc;IA4BtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAetB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA0B1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkD3B;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAkDhC"}
|