@bryan-thompson/inspector-assessment-client 1.25.1 → 1.25.5
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-CkzX_H4T.js → OAuthCallback-Dl4GYls3.js} +1 -1
- package/dist/assets/{OAuthDebugCallback-jZEkm74B.js → OAuthDebugCallback-BdJ38Z-r.js} +1 -1
- package/dist/assets/{index-Df9Sx1jt.css → index-cHhcEXbr.css} +4 -0
- package/dist/assets/{index-BVx1dGJT.js → index-pfUiTdQb.js} +4 -4
- package/dist/index.html +2 -2
- package/lib/lib/assessment/configTypes.d.ts +3 -0
- package/lib/lib/assessment/configTypes.d.ts.map +1 -1
- package/lib/lib/assessment/configTypes.js +11 -6
- package/lib/lib/assessment/coreTypes.d.ts +65 -0
- package/lib/lib/assessment/coreTypes.d.ts.map +1 -1
- package/lib/lib/assessment/extendedTypes.d.ts +127 -0
- package/lib/lib/assessment/extendedTypes.d.ts.map +1 -1
- package/lib/lib/assessment/resultTypes.d.ts +45 -0
- package/lib/lib/assessment/resultTypes.d.ts.map +1 -1
- package/lib/services/assessment/AssessmentOrchestrator.d.ts +4 -12
- package/lib/services/assessment/AssessmentOrchestrator.d.ts.map +1 -1
- package/lib/services/assessment/AssessmentOrchestrator.js +49 -238
- package/lib/services/assessment/TestDataGenerator.d.ts +9 -1
- package/lib/services/assessment/TestDataGenerator.d.ts.map +1 -1
- package/lib/services/assessment/TestDataGenerator.js +32 -6
- package/lib/services/assessment/TestScenarioEngine.d.ts +9 -1
- package/lib/services/assessment/TestScenarioEngine.d.ts.map +1 -1
- package/lib/services/assessment/TestScenarioEngine.js +17 -14
- package/lib/services/assessment/ToolClassifier.d.ts +154 -27
- package/lib/services/assessment/ToolClassifier.d.ts.map +1 -1
- package/lib/services/assessment/ToolClassifier.js +171 -318
- package/lib/services/assessment/config/annotationPatterns.d.ts +3 -1
- package/lib/services/assessment/config/annotationPatterns.d.ts.map +1 -1
- package/lib/services/assessment/config/annotationPatterns.js +5 -2
- package/lib/services/assessment/config/architecturePatterns.d.ts +101 -0
- package/lib/services/assessment/config/architecturePatterns.d.ts.map +1 -0
- package/lib/services/assessment/config/architecturePatterns.js +248 -0
- package/lib/services/assessment/config/performanceConfig.d.ts +122 -0
- package/lib/services/assessment/config/performanceConfig.d.ts.map +1 -0
- package/lib/services/assessment/config/performanceConfig.js +154 -0
- package/lib/services/assessment/config/sanitizationPatterns.d.ts +63 -0
- package/lib/services/assessment/config/sanitizationPatterns.d.ts.map +1 -0
- package/lib/services/assessment/config/sanitizationPatterns.js +223 -0
- package/lib/services/assessment/lib/claudeCodeBridge.d.ts +3 -1
- package/lib/services/assessment/lib/claudeCodeBridge.d.ts.map +1 -1
- package/lib/services/assessment/lib/claudeCodeBridge.js +5 -3
- package/lib/services/assessment/lib/concurrencyLimit.d.ts +6 -2
- package/lib/services/assessment/lib/concurrencyLimit.d.ts.map +1 -1
- package/lib/services/assessment/lib/concurrencyLimit.js +13 -6
- package/lib/services/assessment/lib/errors.d.ts +90 -0
- package/lib/services/assessment/lib/errors.d.ts.map +1 -0
- package/lib/services/assessment/lib/errors.js +136 -0
- package/lib/services/assessment/lib/timeoutUtils.d.ts +69 -0
- package/lib/services/assessment/lib/timeoutUtils.d.ts.map +1 -0
- package/lib/services/assessment/lib/timeoutUtils.js +103 -0
- package/lib/services/assessment/modules/BaseAssessor.d.ts +43 -8
- package/lib/services/assessment/modules/BaseAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/BaseAssessor.js +103 -34
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.d.ts +38 -1
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.js +185 -19
- package/lib/services/assessment/modules/DocumentationAssessor.d.ts +5 -0
- package/lib/services/assessment/modules/DocumentationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/DocumentationAssessor.js +11 -0
- package/lib/services/assessment/modules/ErrorHandlingAssessor.js +1 -1
- package/lib/services/assessment/modules/FunctionalityAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/FunctionalityAssessor.js +6 -3
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.d.ts +3 -0
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/MCPSpecComplianceAssessor.js +14 -2
- package/lib/services/assessment/modules/ManifestValidationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ManifestValidationAssessor.js +7 -2
- package/lib/services/assessment/modules/PromptAssessor.d.ts +1 -0
- package/lib/services/assessment/modules/PromptAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/PromptAssessor.js +26 -16
- package/lib/services/assessment/modules/ProtocolComplianceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ProtocolComplianceAssessor.js +6 -2
- package/lib/services/assessment/modules/ProtocolConformanceAssessor.d.ts +5 -0
- package/lib/services/assessment/modules/ProtocolConformanceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ProtocolConformanceAssessor.js +15 -0
- package/lib/services/assessment/modules/ResourceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ResourceAssessor.js +8 -2
- package/lib/services/assessment/modules/SecurityAssessor.d.ts +3 -171
- package/lib/services/assessment/modules/SecurityAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/SecurityAssessor.js +25 -1480
- package/lib/services/assessment/modules/ToolAnnotationAssessor.d.ts +27 -28
- package/lib/services/assessment/modules/ToolAnnotationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ToolAnnotationAssessor.js +340 -863
- package/lib/services/assessment/modules/UsabilityAssessor.d.ts +5 -0
- package/lib/services/assessment/modules/UsabilityAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/UsabilityAssessor.js +11 -0
- package/lib/services/assessment/modules/annotations/AnnotationDeceptionDetector.d.ts +57 -0
- package/lib/services/assessment/modules/annotations/AnnotationDeceptionDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/AnnotationDeceptionDetector.js +176 -0
- package/lib/services/assessment/modules/annotations/ArchitectureDetector.d.ts +67 -0
- package/lib/services/assessment/modules/annotations/ArchitectureDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/ArchitectureDetector.js +239 -0
- package/lib/services/assessment/modules/annotations/BehaviorInference.d.ts +46 -0
- package/lib/services/assessment/modules/annotations/BehaviorInference.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/BehaviorInference.js +394 -0
- package/lib/services/assessment/modules/annotations/DescriptionAnalyzer.d.ts +64 -0
- package/lib/services/assessment/modules/annotations/DescriptionAnalyzer.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/DescriptionAnalyzer.js +304 -0
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.d.ts +43 -0
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/DescriptionPoisoningDetector.js +276 -0
- package/lib/services/assessment/modules/annotations/SchemaAnalyzer.d.ts +122 -0
- package/lib/services/assessment/modules/annotations/SchemaAnalyzer.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/SchemaAnalyzer.js +388 -0
- package/lib/services/assessment/modules/annotations/index.d.ts +13 -0
- package/lib/services/assessment/modules/annotations/index.d.ts.map +1 -0
- package/lib/services/assessment/modules/annotations/index.js +15 -0
- package/lib/services/assessment/modules/index.d.ts +10 -0
- package/lib/services/assessment/modules/index.d.ts.map +1 -1
- package/lib/services/assessment/modules/index.js +13 -0
- package/lib/services/assessment/modules/securityTests/SanitizationDetector.d.ts +125 -0
- package/lib/services/assessment/modules/securityTests/SanitizationDetector.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SanitizationDetector.js +345 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.d.ts +33 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.js +128 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.d.ts +67 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.js +372 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts +178 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +1207 -0
- package/lib/services/assessment/modules/securityTests/index.d.ts +8 -0
- package/lib/services/assessment/modules/securityTests/index.d.ts.map +1 -0
- package/lib/services/assessment/modules/securityTests/index.js +7 -0
- package/lib/services/assessment/orchestratorHelpers.d.ts +83 -0
- package/lib/services/assessment/orchestratorHelpers.d.ts.map +1 -0
- package/lib/services/assessment/orchestratorHelpers.js +212 -0
- package/lib/services/assessment/tool-classifier-patterns.d.ts +85 -0
- package/lib/services/assessment/tool-classifier-patterns.d.ts.map +1 -0
- package/lib/services/assessment/tool-classifier-patterns.js +365 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Assessment Module
|
|
3
|
+
* Exports all security-related components
|
|
4
|
+
*/
|
|
5
|
+
export { SecurityResponseAnalyzer, type ConfidenceResult, type AnalysisResult, type ErrorClassification, } from "./SecurityResponseAnalyzer.js";
|
|
6
|
+
export { SecurityPayloadTester, type TestProgressCallback, type PayloadTestConfig, type TestLogger, } from "./SecurityPayloadTester.js";
|
|
7
|
+
export { SecurityPayloadGenerator } from "./SecurityPayloadGenerator.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,GACzB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,UAAU,GAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Assessment Module
|
|
3
|
+
* Exports all security-related components
|
|
4
|
+
*/
|
|
5
|
+
export { SecurityResponseAnalyzer, } from "./SecurityResponseAnalyzer.js";
|
|
6
|
+
export { SecurityPayloadTester, } from "./SecurityPayloadTester.js";
|
|
7
|
+
export { SecurityPayloadGenerator } from "./SecurityPayloadGenerator.js";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assessment Orchestrator Helpers
|
|
3
|
+
*
|
|
4
|
+
* Pure functions extracted from AssessmentOrchestrator for testability.
|
|
5
|
+
* These functions handle:
|
|
6
|
+
* - AUP violation enrichment for JSONL events
|
|
7
|
+
* - Module progress/started event emission
|
|
8
|
+
* - Overall status determination
|
|
9
|
+
* - Summary and recommendations generation
|
|
10
|
+
*/
|
|
11
|
+
import { MCPDirectoryAssessment, AssessmentStatus } from "../../lib/assessmentTypes.js";
|
|
12
|
+
export declare const moduleStartTimes: Map<string, number>;
|
|
13
|
+
/**
|
|
14
|
+
* Emit module_started event and track start time for duration calculation.
|
|
15
|
+
* Emits JSONL to stderr with version field for consistent event structure.
|
|
16
|
+
*/
|
|
17
|
+
export declare function emitModuleStartedEvent(moduleName: string, estimatedTests: number, toolCount: number): void;
|
|
18
|
+
/**
|
|
19
|
+
* Emit module_complete event with score and duration.
|
|
20
|
+
* Uses shared score calculator for consistent scoring logic.
|
|
21
|
+
* For AUP module, includes enriched violation data for Claude analysis.
|
|
22
|
+
*/
|
|
23
|
+
export declare function emitModuleProgress(moduleName: string, status: string, result: unknown, testsRun?: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Build AUP enrichment data from an AUP compliance assessment result.
|
|
26
|
+
* Samples violations prioritizing by severity (CRITICAL > HIGH > MEDIUM).
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildAUPEnrichment(aupResult: {
|
|
29
|
+
violations?: Array<{
|
|
30
|
+
severity: string;
|
|
31
|
+
category: string;
|
|
32
|
+
categoryName?: string;
|
|
33
|
+
matchedText?: string;
|
|
34
|
+
location?: string;
|
|
35
|
+
confidence?: string;
|
|
36
|
+
}>;
|
|
37
|
+
scannedLocations?: {
|
|
38
|
+
toolNames: boolean;
|
|
39
|
+
toolDescriptions: boolean;
|
|
40
|
+
readme: boolean;
|
|
41
|
+
sourceCode: boolean;
|
|
42
|
+
};
|
|
43
|
+
highRiskDomains?: string[];
|
|
44
|
+
}, maxSamples?: number): {
|
|
45
|
+
violationsSample: Array<{
|
|
46
|
+
category: string;
|
|
47
|
+
categoryName: string;
|
|
48
|
+
severity: string;
|
|
49
|
+
matchedText: string;
|
|
50
|
+
location: string;
|
|
51
|
+
confidence: string;
|
|
52
|
+
}>;
|
|
53
|
+
samplingNote: string;
|
|
54
|
+
violationMetrics: {
|
|
55
|
+
total: number;
|
|
56
|
+
critical: number;
|
|
57
|
+
high: number;
|
|
58
|
+
medium: number;
|
|
59
|
+
byCategory: Record<string, number>;
|
|
60
|
+
};
|
|
61
|
+
scannedLocations: {
|
|
62
|
+
toolNames: boolean;
|
|
63
|
+
toolDescriptions: boolean;
|
|
64
|
+
readme: boolean;
|
|
65
|
+
sourceCode: boolean;
|
|
66
|
+
};
|
|
67
|
+
highRiskDomains: string[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Determine overall status from assessment results.
|
|
71
|
+
* Priority: FAIL > NEED_MORE_INFO > PASS
|
|
72
|
+
*/
|
|
73
|
+
export declare function determineOverallStatus(results: Partial<MCPDirectoryAssessment>): AssessmentStatus;
|
|
74
|
+
/**
|
|
75
|
+
* Generate summary text from assessment results.
|
|
76
|
+
*/
|
|
77
|
+
export declare function generateSummary(results: Partial<MCPDirectoryAssessment>): string;
|
|
78
|
+
/**
|
|
79
|
+
* Generate recommendations from assessment results.
|
|
80
|
+
* Aggregates, deduplicates, and limits to 10 recommendations.
|
|
81
|
+
*/
|
|
82
|
+
export declare function generateRecommendations(results: Partial<MCPDirectoryAssessment>): string[];
|
|
83
|
+
//# sourceMappingURL=orchestratorHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestratorHelpers.d.ts","sourceRoot":"","sources":["../../../src/services/assessment/orchestratorHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAU/B,eAAO,MAAM,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAa,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,GAChB,IAAI,CAcN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,QAAQ,GAAE,MAAU,GACnB,IAAI,CAiCN;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE;IACT,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,gBAAgB,CAAC,EAAE;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,EACD,UAAU,GAAE,MAAW,GACtB;IACD,gBAAgB,EAAE,KAAK,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACpC,CAAC;IACF,gBAAgB,EAAE;QAChB,SAAS,EAAE,OAAO,CAAC;QACnB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAkEA;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACvC,gBAAgB,CAsBlB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACvC,MAAM,CA8ER;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,CAAC,sBAAsB,CAAC,GACvC,MAAM,EAAE,CAiBV"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assessment Orchestrator Helpers
|
|
3
|
+
*
|
|
4
|
+
* Pure functions extracted from AssessmentOrchestrator for testability.
|
|
5
|
+
* These functions handle:
|
|
6
|
+
* - AUP violation enrichment for JSONL events
|
|
7
|
+
* - Module progress/started event emission
|
|
8
|
+
* - Overall status determination
|
|
9
|
+
* - Summary and recommendations generation
|
|
10
|
+
*/
|
|
11
|
+
// Import score calculation helpers from shared module
|
|
12
|
+
import { calculateModuleScore, normalizeModuleKey, INSPECTOR_VERSION, } from "../../lib/moduleScoring.js";
|
|
13
|
+
// Track module start times for duration calculation
|
|
14
|
+
export const moduleStartTimes = new Map();
|
|
15
|
+
/**
|
|
16
|
+
* Emit module_started event and track start time for duration calculation.
|
|
17
|
+
* Emits JSONL to stderr with version field for consistent event structure.
|
|
18
|
+
*/
|
|
19
|
+
export function emitModuleStartedEvent(moduleName, estimatedTests, toolCount) {
|
|
20
|
+
const moduleKey = normalizeModuleKey(moduleName);
|
|
21
|
+
moduleStartTimes.set(moduleKey, Date.now());
|
|
22
|
+
// Emit JSONL to stderr with version field
|
|
23
|
+
console.error(JSON.stringify({
|
|
24
|
+
event: "module_started",
|
|
25
|
+
module: moduleKey,
|
|
26
|
+
estimatedTests,
|
|
27
|
+
toolCount,
|
|
28
|
+
version: INSPECTOR_VERSION,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Emit module_complete event with score and duration.
|
|
33
|
+
* Uses shared score calculator for consistent scoring logic.
|
|
34
|
+
* For AUP module, includes enriched violation data for Claude analysis.
|
|
35
|
+
*/
|
|
36
|
+
export function emitModuleProgress(moduleName, status, result, testsRun = 0) {
|
|
37
|
+
// Calculate score using shared helper
|
|
38
|
+
const score = calculateModuleScore(result);
|
|
39
|
+
// Don't emit events for skipped modules (null score means module wasn't run)
|
|
40
|
+
if (score === null)
|
|
41
|
+
return;
|
|
42
|
+
const moduleKey = normalizeModuleKey(moduleName);
|
|
43
|
+
// Calculate duration from module start time
|
|
44
|
+
const startTime = moduleStartTimes.get(moduleKey);
|
|
45
|
+
const duration = startTime ? Date.now() - startTime : 0;
|
|
46
|
+
moduleStartTimes.delete(moduleKey);
|
|
47
|
+
// Build base event
|
|
48
|
+
const event = {
|
|
49
|
+
event: "module_complete",
|
|
50
|
+
module: moduleKey,
|
|
51
|
+
status,
|
|
52
|
+
score,
|
|
53
|
+
testsRun,
|
|
54
|
+
duration,
|
|
55
|
+
version: INSPECTOR_VERSION,
|
|
56
|
+
};
|
|
57
|
+
// Add AUP enrichment when module is AUP
|
|
58
|
+
if (moduleKey === "aup" && result) {
|
|
59
|
+
const aupEnrichment = buildAUPEnrichment(result);
|
|
60
|
+
Object.assign(event, aupEnrichment);
|
|
61
|
+
}
|
|
62
|
+
// Emit JSONL to stderr with version field
|
|
63
|
+
console.error(JSON.stringify(event));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Build AUP enrichment data from an AUP compliance assessment result.
|
|
67
|
+
* Samples violations prioritizing by severity (CRITICAL > HIGH > MEDIUM).
|
|
68
|
+
*/
|
|
69
|
+
export function buildAUPEnrichment(aupResult, maxSamples = 10) {
|
|
70
|
+
const violations = aupResult.violations || [];
|
|
71
|
+
// Calculate metrics
|
|
72
|
+
const metrics = {
|
|
73
|
+
total: violations.length,
|
|
74
|
+
critical: violations.filter((v) => v.severity === "CRITICAL").length,
|
|
75
|
+
high: violations.filter((v) => v.severity === "HIGH").length,
|
|
76
|
+
medium: violations.filter((v) => v.severity === "MEDIUM").length,
|
|
77
|
+
byCategory: {},
|
|
78
|
+
};
|
|
79
|
+
// Count by category
|
|
80
|
+
for (const v of violations) {
|
|
81
|
+
metrics.byCategory[v.category] = (metrics.byCategory[v.category] || 0) + 1;
|
|
82
|
+
}
|
|
83
|
+
// Sample violations prioritizing by severity
|
|
84
|
+
const sampled = [];
|
|
85
|
+
const severityOrder = ["CRITICAL", "HIGH", "MEDIUM"];
|
|
86
|
+
for (const severity of severityOrder) {
|
|
87
|
+
if (sampled.length >= maxSamples)
|
|
88
|
+
break;
|
|
89
|
+
const bySeverity = violations.filter((v) => v.severity === severity);
|
|
90
|
+
for (const v of bySeverity) {
|
|
91
|
+
if (sampled.length >= maxSamples)
|
|
92
|
+
break;
|
|
93
|
+
sampled.push({
|
|
94
|
+
category: v.category,
|
|
95
|
+
categoryName: v.categoryName || "",
|
|
96
|
+
severity: v.severity,
|
|
97
|
+
matchedText: v.matchedText || "",
|
|
98
|
+
location: v.location || "",
|
|
99
|
+
confidence: v.confidence || "",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Build sampling note
|
|
104
|
+
let samplingNote = "";
|
|
105
|
+
if (violations.length === 0) {
|
|
106
|
+
samplingNote = "No violations detected.";
|
|
107
|
+
}
|
|
108
|
+
else if (violations.length <= maxSamples) {
|
|
109
|
+
samplingNote = `All ${violations.length} violation(s) included.`;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
samplingNote = `Sampled ${sampled.length} of ${violations.length} violations, prioritized by severity (CRITICAL > HIGH > MEDIUM).`;
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
violationsSample: sampled,
|
|
116
|
+
samplingNote,
|
|
117
|
+
violationMetrics: metrics,
|
|
118
|
+
scannedLocations: aupResult.scannedLocations || {
|
|
119
|
+
toolNames: false,
|
|
120
|
+
toolDescriptions: false,
|
|
121
|
+
readme: false,
|
|
122
|
+
sourceCode: false,
|
|
123
|
+
},
|
|
124
|
+
highRiskDomains: (aupResult.highRiskDomains || []).slice(0, 10),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Determine overall status from assessment results.
|
|
129
|
+
* Priority: FAIL > NEED_MORE_INFO > PASS
|
|
130
|
+
*/
|
|
131
|
+
export function determineOverallStatus(results) {
|
|
132
|
+
const statuses = [];
|
|
133
|
+
// Collect all statuses from assessment results
|
|
134
|
+
Object.values(results).forEach((assessment) => {
|
|
135
|
+
if (assessment &&
|
|
136
|
+
typeof assessment === "object" &&
|
|
137
|
+
"status" in assessment) {
|
|
138
|
+
statuses.push(assessment.status);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
// If any critical category fails, overall fails
|
|
142
|
+
if (statuses.includes("FAIL"))
|
|
143
|
+
return "FAIL";
|
|
144
|
+
// If any category needs more info, overall needs more info
|
|
145
|
+
if (statuses.includes("NEED_MORE_INFO"))
|
|
146
|
+
return "NEED_MORE_INFO";
|
|
147
|
+
// All must pass for overall pass
|
|
148
|
+
return "PASS";
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Generate summary text from assessment results.
|
|
152
|
+
*/
|
|
153
|
+
export function generateSummary(results) {
|
|
154
|
+
const parts = [];
|
|
155
|
+
const totalCategories = Object.keys(results).length;
|
|
156
|
+
const passedCategories = Object.values(results).filter((r) => r && typeof r === "object" && "status" in r && r.status === "PASS").length;
|
|
157
|
+
parts.push(`Assessment complete: ${passedCategories}/${totalCategories} categories passed.`);
|
|
158
|
+
// Add key findings - use type assertions for optional properties
|
|
159
|
+
const security = results.security;
|
|
160
|
+
if (security?.vulnerabilities?.length) {
|
|
161
|
+
parts.push(`Found ${security.vulnerabilities.length} security vulnerabilities.`);
|
|
162
|
+
}
|
|
163
|
+
const functionality = results.functionality;
|
|
164
|
+
if (functionality?.brokenTools?.length) {
|
|
165
|
+
parts.push(`${functionality.brokenTools.length} tools are not functioning correctly.`);
|
|
166
|
+
}
|
|
167
|
+
// New assessor findings
|
|
168
|
+
const aupCompliance = results.aupCompliance;
|
|
169
|
+
if (aupCompliance?.violations?.length) {
|
|
170
|
+
const criticalCount = aupCompliance.violations.filter((v) => v.severity === "CRITICAL").length;
|
|
171
|
+
if (criticalCount > 0) {
|
|
172
|
+
parts.push(`CRITICAL: ${criticalCount} AUP violation(s) detected.`);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
parts.push(`${aupCompliance.violations.length} AUP item(s) flagged for review.`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const toolAnnotations = results.toolAnnotations;
|
|
179
|
+
if (toolAnnotations?.missingAnnotationsCount) {
|
|
180
|
+
parts.push(`${toolAnnotations.missingAnnotationsCount} tools missing annotations.`);
|
|
181
|
+
}
|
|
182
|
+
const prohibitedLibraries = results.prohibitedLibraries;
|
|
183
|
+
if (prohibitedLibraries?.matches?.length) {
|
|
184
|
+
const blockingCount = prohibitedLibraries.matches.filter((m) => m.severity === "BLOCKING").length;
|
|
185
|
+
if (blockingCount > 0) {
|
|
186
|
+
parts.push(`BLOCKING: ${blockingCount} prohibited library/libraries detected.`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const portability = results.portability;
|
|
190
|
+
if (portability?.usesBundleRoot) {
|
|
191
|
+
parts.push("Uses ${BUNDLE_ROOT} anti-pattern.");
|
|
192
|
+
}
|
|
193
|
+
return parts.join(" ");
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Generate recommendations from assessment results.
|
|
197
|
+
* Aggregates, deduplicates, and limits to 10 recommendations.
|
|
198
|
+
*/
|
|
199
|
+
export function generateRecommendations(results) {
|
|
200
|
+
const recommendations = [];
|
|
201
|
+
// Aggregate recommendations from all assessments
|
|
202
|
+
Object.values(results).forEach((assessment) => {
|
|
203
|
+
if (assessment &&
|
|
204
|
+
typeof assessment === "object" &&
|
|
205
|
+
"recommendations" in assessment &&
|
|
206
|
+
Array.isArray(assessment.recommendations)) {
|
|
207
|
+
recommendations.push(...assessment.recommendations);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
// De-duplicate and prioritize
|
|
211
|
+
return [...new Set(recommendations)].slice(0, 10);
|
|
212
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Classifier Pattern Configuration
|
|
3
|
+
*
|
|
4
|
+
* Pre-compiled regex patterns for MCP tool classification.
|
|
5
|
+
* Extracting patterns to this file provides:
|
|
6
|
+
* - Single source of truth for patterns, confidence values, and risk levels
|
|
7
|
+
* - Pre-compiled patterns (created once at module load, not per classify() call)
|
|
8
|
+
* - Easier maintenance without modifying core classification logic
|
|
9
|
+
*
|
|
10
|
+
* @see ToolClassifier.ts for classification logic
|
|
11
|
+
* @see ToolClassifier.test.ts for pattern behavior validation
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Security risk categories for MCP tools.
|
|
15
|
+
*
|
|
16
|
+
* Categories are organized by risk level:
|
|
17
|
+
* - **HIGH**: Tools that may execute code or access sensitive data
|
|
18
|
+
* - **MEDIUM**: Tools with potential bypass or supply chain risks
|
|
19
|
+
* - **LOW**: Safe tools for data retrieval and manipulation
|
|
20
|
+
*/
|
|
21
|
+
export declare enum ToolCategory {
|
|
22
|
+
CALCULATOR = "calculator",
|
|
23
|
+
SYSTEM_EXEC = "system_exec",
|
|
24
|
+
CODE_EXECUTOR = "code_executor",
|
|
25
|
+
DATA_ACCESS = "data_access",
|
|
26
|
+
TOOL_OVERRIDE = "tool_override",
|
|
27
|
+
CONFIG_MODIFIER = "config_modifier",
|
|
28
|
+
URL_FETCHER = "fetcher",
|
|
29
|
+
UNICODE_PROCESSOR = "unicode",
|
|
30
|
+
JSON_PARSER = "parser",
|
|
31
|
+
PACKAGE_INSTALLER = "installer",
|
|
32
|
+
RUG_PULL = "rug_pull",
|
|
33
|
+
SAFE_STORAGE = "safe_storage",
|
|
34
|
+
API_WRAPPER = "api_wrapper",
|
|
35
|
+
SEARCH_RETRIEVAL = "search_retrieval",
|
|
36
|
+
CRUD_CREATION = "crud_creation",
|
|
37
|
+
READ_ONLY_INFO = "read_only_info",
|
|
38
|
+
DATA_FETCHER = "data_fetcher",
|
|
39
|
+
GENERIC = "generic"
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Risk level for security categorization
|
|
43
|
+
*/
|
|
44
|
+
export type RiskLevel = "HIGH" | "MEDIUM" | "LOW";
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for a single tool category
|
|
47
|
+
*/
|
|
48
|
+
export interface CategoryConfig {
|
|
49
|
+
/** Pre-compiled regex patterns for this category */
|
|
50
|
+
readonly patterns: readonly RegExp[];
|
|
51
|
+
/** Confidence score (0-100) when this category matches */
|
|
52
|
+
readonly confidence: number;
|
|
53
|
+
/** Human-readable reasoning for classification */
|
|
54
|
+
readonly reasoning: string;
|
|
55
|
+
/** Risk level for security prioritization */
|
|
56
|
+
readonly risk: RiskLevel;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Complete pattern configuration for all tool categories.
|
|
60
|
+
* Patterns are pre-compiled as static constants for performance.
|
|
61
|
+
*
|
|
62
|
+
* ## Pattern Types
|
|
63
|
+
*
|
|
64
|
+
* 1. **Substring patterns** (`/keyword/i`): Match anywhere in text
|
|
65
|
+
* - Used for HIGH-risk keywords that warrant scrutiny even when embedded
|
|
66
|
+
*
|
|
67
|
+
* 2. **Word boundary patterns** (`/\bword\b/i`): Match isolated words only
|
|
68
|
+
* - Used for common words to prevent false positives
|
|
69
|
+
* - Note: `\b` treats hyphens as boundaries but underscores as word chars
|
|
70
|
+
*/
|
|
71
|
+
export declare const CATEGORY_PATTERNS: Readonly<Record<Exclude<ToolCategory, ToolCategory.GENERIC>, CategoryConfig>>;
|
|
72
|
+
/**
|
|
73
|
+
* Default configuration for GENERIC category (no pattern match)
|
|
74
|
+
*/
|
|
75
|
+
export declare const GENERIC_CONFIG: Readonly<{
|
|
76
|
+
confidence: number;
|
|
77
|
+
reasoning: string;
|
|
78
|
+
risk: RiskLevel;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Order in which categories are checked during classification.
|
|
82
|
+
* This order determines priority when a tool matches multiple categories.
|
|
83
|
+
*/
|
|
84
|
+
export declare const CATEGORY_CHECK_ORDER: readonly Exclude<ToolCategory, ToolCategory.GENERIC>[];
|
|
85
|
+
//# sourceMappingURL=tool-classifier-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-classifier-patterns.d.ts","sourceRoot":"","sources":["../../../src/services/assessment/tool-classifier-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AACH,oBAAY,YAAY;IAEtB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;IACnC,WAAW,YAAY;IAGvB,iBAAiB,YAAY;IAC7B,WAAW,WAAW;IACtB,iBAAiB,cAAc;IAC/B,QAAQ,aAAa;IAGrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,gBAAgB,qBAAqB;IACrC,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAG7B,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CACtC,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,CA0S3D,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,CAAC;CACjB,CAIS,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,OAAO,CACjD,YAAY,EACZ,YAAY,CAAC,OAAO,CACrB,EAqBS,CAAC"}
|