@bryan-thompson/inspector-assessment 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.
Files changed (50) hide show
  1. package/cli/build/__tests__/assess-full-e2e.test.js +496 -0
  2. package/cli/build/__tests__/flag-parsing.test.js +42 -1
  3. package/cli/build/__tests__/http-transport-integration.test.js +5 -1
  4. package/cli/build/__tests__/testbed-integration.test.js +5 -1
  5. package/cli/build/assess-full.js +3 -1
  6. package/cli/build/lib/cli-parser.js +83 -2
  7. package/cli/package.json +1 -1
  8. package/client/dist/assets/{OAuthCallback-kF1MLuwg.js → OAuthCallback-9Gbb39Ii.js} +1 -1
  9. package/client/dist/assets/{OAuthDebugCallback-Nv-8u0GR.js → OAuthDebugCallback-B76J2MBn.js} +1 -1
  10. package/client/dist/assets/{index-CCiX5wkF.js → index-CHTOR9VI.js} +77 -39
  11. package/client/dist/index.html +1 -1
  12. package/client/lib/lib/assessment/configTypes.d.ts +1 -0
  13. package/client/lib/lib/assessment/configTypes.d.ts.map +1 -1
  14. package/client/lib/lib/assessment/configTypes.js +10 -0
  15. package/client/lib/lib/assessment/extendedTypes.d.ts +74 -0
  16. package/client/lib/lib/assessment/extendedTypes.d.ts.map +1 -1
  17. package/client/lib/lib/assessment/resultTypes.d.ts +3 -1
  18. package/client/lib/lib/assessment/resultTypes.d.ts.map +1 -1
  19. package/client/lib/lib/securityPatterns.d.ts +8 -3
  20. package/client/lib/lib/securityPatterns.d.ts.map +1 -1
  21. package/client/lib/lib/securityPatterns.js +205 -3
  22. package/client/lib/services/assessment/AssessmentOrchestrator.d.ts +1 -0
  23. package/client/lib/services/assessment/AssessmentOrchestrator.d.ts.map +1 -1
  24. package/client/lib/services/assessment/AssessmentOrchestrator.js +31 -1
  25. package/client/lib/services/assessment/modules/ErrorHandlingAssessor.d.ts +25 -0
  26. package/client/lib/services/assessment/modules/ErrorHandlingAssessor.d.ts.map +1 -1
  27. package/client/lib/services/assessment/modules/ErrorHandlingAssessor.js +119 -5
  28. package/client/lib/services/assessment/modules/FileModularizationAssessor.d.ts +87 -0
  29. package/client/lib/services/assessment/modules/FileModularizationAssessor.d.ts.map +1 -0
  30. package/client/lib/services/assessment/modules/FileModularizationAssessor.js +475 -0
  31. package/client/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts +27 -0
  32. package/client/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts.map +1 -1
  33. package/client/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.js +50 -0
  34. package/client/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.d.ts.map +1 -1
  35. package/client/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.js +13 -0
  36. package/client/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts +35 -0
  37. package/client/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -1
  38. package/client/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +66 -0
  39. package/client/lib/services/assessment/modules/temporal/MutationDetector.d.ts +75 -0
  40. package/client/lib/services/assessment/modules/temporal/MutationDetector.d.ts.map +1 -0
  41. package/client/lib/services/assessment/modules/temporal/MutationDetector.js +147 -0
  42. package/client/lib/services/assessment/modules/temporal/VarianceClassifier.d.ts +112 -0
  43. package/client/lib/services/assessment/modules/temporal/VarianceClassifier.d.ts.map +1 -0
  44. package/client/lib/services/assessment/modules/temporal/VarianceClassifier.js +427 -0
  45. package/client/lib/services/assessment/modules/temporal/index.d.ts +10 -0
  46. package/client/lib/services/assessment/modules/temporal/index.d.ts.map +1 -0
  47. package/client/lib/services/assessment/modules/temporal/index.js +9 -0
  48. package/client/package.json +1 -1
  49. package/package.json +1 -1
  50. package/server/package.json +1 -1
@@ -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,41 @@ 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
+ * @note This method must be called separately from analyzeResponse().
143
+ * It is not part of the standard vulnerability detection flow because
144
+ * secret leakage detection requires examining ALL responses, not just
145
+ * those matching attack payloads. Callers should invoke this method
146
+ * independently when auditing tool responses for credential exposure.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * const analyzer = new SecurityResponseAnalyzer();
151
+ * const response = await client.callTool("get_status", { verbose: true });
152
+ *
153
+ * // Standard vulnerability check
154
+ * const vulnResult = analyzer.analyzeResponse(response, payload);
155
+ *
156
+ * // Additional secret leakage check (separate concern)
157
+ * const leakResult = analyzer.checkSecretLeakage(response);
158
+ * if (leakResult.detected) {
159
+ * console.warn(`Secret leaked: ${leakResult.evidence}`);
160
+ * }
161
+ * ```
162
+ */
163
+ checkSecretLeakage(response: CompatibilityCallToolResult): {
164
+ detected: boolean;
165
+ evidence?: string;
166
+ };
132
167
  /**
133
168
  * Check if response indicates connection/server failure
134
169
  */
@@ -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;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,eAAe,EAAE,cAAc,GAAG,aAAa,GAAG,SAAS,CAAC;IAC5D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,sBAAsB,GACtB,iBAAiB,GACjB,SAAS,GACT,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,kBAAkB,GAClB,iBAAiB,GACjB,2BAA2B,GAC3B,gBAAgB,GAChB,qBAAqB,GACrB,iBAAiB,CAAC;A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E,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,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;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,OAAO,CAAC;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AAM,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"}
@@ -321,6 +321,72 @@ export class SecurityResponseAnalyzer {
321
321
  },
322
322
  };
323
323
  }
324
+ /**
325
+ * Check for secret leakage in response (Issue #103, Challenge #9)
326
+ * Scans for credential patterns regardless of payload type.
327
+ *
328
+ * This method detects when tools inadvertently expose:
329
+ * - API keys (AWS, OpenAI, GitHub, GitLab, Slack)
330
+ * - Database connection strings with credentials
331
+ * - Environment variable values
332
+ * - Partial key previews
333
+ *
334
+ * @note This method must be called separately from analyzeResponse().
335
+ * It is not part of the standard vulnerability detection flow because
336
+ * secret leakage detection requires examining ALL responses, not just
337
+ * those matching attack payloads. Callers should invoke this method
338
+ * independently when auditing tool responses for credential exposure.
339
+ *
340
+ * @example
341
+ * ```typescript
342
+ * const analyzer = new SecurityResponseAnalyzer();
343
+ * const response = await client.callTool("get_status", { verbose: true });
344
+ *
345
+ * // Standard vulnerability check
346
+ * const vulnResult = analyzer.analyzeResponse(response, payload);
347
+ *
348
+ * // Additional secret leakage check (separate concern)
349
+ * const leakResult = analyzer.checkSecretLeakage(response);
350
+ * if (leakResult.detected) {
351
+ * console.warn(`Secret leaked: ${leakResult.evidence}`);
352
+ * }
353
+ * ```
354
+ */
355
+ checkSecretLeakage(response) {
356
+ const responseText = this.extractResponseContent(response);
357
+ const patterns = [
358
+ { regex: /AKIA[A-Z0-9]{16}/, name: "AWS Access Key" },
359
+ { regex: /sk-[a-zA-Z0-9]{20,}/, name: "OpenAI API Key" },
360
+ { regex: /ghp_[a-zA-Z0-9]{36}/, name: "GitHub PAT" },
361
+ { regex: /glpat-[a-zA-Z0-9]{20}/, name: "GitLab PAT" },
362
+ { regex: /xox[baprs]-[a-zA-Z0-9-]+/, name: "Slack Token" },
363
+ {
364
+ regex: /(postgresql|mysql|mongodb|redis|mssql):\/\/[^:]+:[^@]+@/i,
365
+ name: "Connection String with Credentials",
366
+ },
367
+ {
368
+ regex: /(api[_-]?key|secret|password|credential)[^\s]*[:=]\s*["']?[a-zA-Z0-9_-]{10,}/i,
369
+ name: "Credential Assignment",
370
+ },
371
+ {
372
+ regex: /(SECRET_TOKEN|DATABASE_URL|API_KEY|PRIVATE_KEY|DB_PASSWORD)[^\s]*[:=]/i,
373
+ name: "Environment Variable Leakage",
374
+ },
375
+ {
376
+ regex: /api_key_preview|key_fragment|partial_key/i,
377
+ name: "Partial Key Exposure",
378
+ },
379
+ ];
380
+ for (const { regex, name } of patterns) {
381
+ if (regex.test(responseText)) {
382
+ return {
383
+ detected: true,
384
+ evidence: `${name} pattern found in response`,
385
+ };
386
+ }
387
+ }
388
+ return { detected: false };
389
+ }
324
390
  /**
325
391
  * Check if response indicates connection/server failure
326
392
  */
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Mutation Detector Module
3
+ * Detects definition mutations and content changes for rug pull detection.
4
+ *
5
+ * Extracted from TemporalAssessor as part of Issue #106 refactoring.
6
+ * DVMCP Challenge 4: Tool descriptions that mutate after N calls to inject malicious instructions.
7
+ */
8
+ /**
9
+ * Tracks tool definition snapshots across invocations to detect rug pull mutations.
10
+ */
11
+ export interface DefinitionSnapshot {
12
+ invocation: number;
13
+ description: string | undefined;
14
+ inputSchema: unknown;
15
+ timestamp: number;
16
+ }
17
+ /**
18
+ * Result of definition mutation detection.
19
+ */
20
+ export interface DefinitionMutation {
21
+ detectedAt: number;
22
+ baselineDescription?: string;
23
+ mutatedDescription?: string;
24
+ baselineSchema?: unknown;
25
+ mutatedSchema?: unknown;
26
+ }
27
+ /**
28
+ * Result of content change detection.
29
+ */
30
+ export interface ContentChangeResult {
31
+ detected: boolean;
32
+ reason: string | null;
33
+ }
34
+ /**
35
+ * Detects definition mutations and semantic content changes in tool responses.
36
+ * Used to identify "rug pull" attacks where tools change behavior after N invocations.
37
+ */
38
+ export declare class MutationDetector {
39
+ /**
40
+ * Detect mutations in tool definition across invocation snapshots.
41
+ * DVMCP Challenge 4: Tool descriptions that mutate after N calls.
42
+ */
43
+ detectDefinitionMutation(snapshots: DefinitionSnapshot[]): DefinitionMutation | null;
44
+ /**
45
+ * Secondary detection for stateful tools that pass schema comparison.
46
+ * Catches rug pulls that change content semantically while keeping schema intact.
47
+ *
48
+ * Examples detected:
49
+ * - Weather data -> "Rate limit exceeded, upgrade to premium"
50
+ * - Stock prices -> "Subscribe for $9.99/month to continue"
51
+ * - Search results -> "Error: Service unavailable"
52
+ */
53
+ detectStatefulContentChange(baseline: unknown, current: unknown): ContentChangeResult;
54
+ /**
55
+ * Extract text content from a response for semantic analysis.
56
+ */
57
+ private extractTextContent;
58
+ /**
59
+ * Check for error-related keywords that indicate service degradation.
60
+ */
61
+ private hasErrorKeywords;
62
+ /**
63
+ * Check for promotional/monetization keywords that indicate a monetization rug pull.
64
+ * Enhanced to catch CH4-style rug pulls with limited-time offers, referral codes, etc.
65
+ *
66
+ * Combined into single regex for O(text_length) performance instead of O(18 * text_length).
67
+ */
68
+ private hasPromotionalKeywords;
69
+ /**
70
+ * Check for suspicious URL/link injection that wasn't present initially.
71
+ * Rug pulls often inject links to external malicious or monetization pages.
72
+ */
73
+ private hasSuspiciousLinks;
74
+ }
75
+ //# sourceMappingURL=MutationDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MutationDetector.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/temporal/MutationDetector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B;;;OAGG;IACH,wBAAwB,CACtB,SAAS,EAAE,kBAAkB,EAAE,GAC9B,kBAAkB,GAAG,IAAI;IAgC5B;;;;;;;;OAQG;IACH,2BAA2B,CACzB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,OAAO,GACf,mBAAmB;IAgDtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAU9B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CAe3B"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Mutation Detector Module
3
+ * Detects definition mutations and content changes for rug pull detection.
4
+ *
5
+ * Extracted from TemporalAssessor as part of Issue #106 refactoring.
6
+ * DVMCP Challenge 4: Tool descriptions that mutate after N calls to inject malicious instructions.
7
+ */
8
+ /**
9
+ * Detects definition mutations and semantic content changes in tool responses.
10
+ * Used to identify "rug pull" attacks where tools change behavior after N invocations.
11
+ */
12
+ export class MutationDetector {
13
+ /**
14
+ * Detect mutations in tool definition across invocation snapshots.
15
+ * DVMCP Challenge 4: Tool descriptions that mutate after N calls.
16
+ */
17
+ detectDefinitionMutation(snapshots) {
18
+ if (snapshots.length < 2)
19
+ return null;
20
+ const baseline = snapshots[0];
21
+ for (let i = 1; i < snapshots.length; i++) {
22
+ const current = snapshots[i];
23
+ // Check if description changed
24
+ const descriptionChanged = baseline.description !== current.description;
25
+ // Check if schema changed (deep comparison)
26
+ const schemaChanged = JSON.stringify(baseline.inputSchema) !==
27
+ JSON.stringify(current.inputSchema);
28
+ if (descriptionChanged || schemaChanged) {
29
+ return {
30
+ detectedAt: current.invocation,
31
+ baselineDescription: baseline.description,
32
+ mutatedDescription: descriptionChanged
33
+ ? current.description
34
+ : undefined,
35
+ baselineSchema: schemaChanged ? baseline.inputSchema : undefined,
36
+ mutatedSchema: schemaChanged ? current.inputSchema : undefined,
37
+ };
38
+ }
39
+ }
40
+ return null;
41
+ }
42
+ /**
43
+ * Secondary detection for stateful tools that pass schema comparison.
44
+ * Catches rug pulls that change content semantically while keeping schema intact.
45
+ *
46
+ * Examples detected:
47
+ * - Weather data -> "Rate limit exceeded, upgrade to premium"
48
+ * - Stock prices -> "Subscribe for $9.99/month to continue"
49
+ * - Search results -> "Error: Service unavailable"
50
+ */
51
+ detectStatefulContentChange(baseline, current) {
52
+ // Convert to strings for content analysis
53
+ const baselineText = this.extractTextContent(baseline);
54
+ const currentText = this.extractTextContent(current);
55
+ // Skip if both are empty or identical
56
+ if (!baselineText && !currentText)
57
+ return { detected: false, reason: null };
58
+ if (baselineText === currentText)
59
+ return { detected: false, reason: null };
60
+ // Check 1: Error keywords appearing in later responses (not present in baseline)
61
+ if (this.hasErrorKeywords(currentText) &&
62
+ !this.hasErrorKeywords(baselineText)) {
63
+ return { detected: true, reason: "error_keywords_appeared" };
64
+ }
65
+ // Check 2: Promotional/payment keywords (rug pull monetization pattern)
66
+ if (this.hasPromotionalKeywords(currentText) &&
67
+ !this.hasPromotionalKeywords(baselineText)) {
68
+ return { detected: true, reason: "promotional_keywords_appeared" };
69
+ }
70
+ // Check 3: Suspicious links injected (URLs not present in baseline)
71
+ if (this.hasSuspiciousLinks(currentText) &&
72
+ !this.hasSuspiciousLinks(baselineText)) {
73
+ return { detected: true, reason: "suspicious_links_injected" };
74
+ }
75
+ // Check 4: Significant length DECREASE only (response becoming much shorter)
76
+ // This catches cases where helpful responses shrink to terse error messages
77
+ // We don't flag length increase because stateful tools legitimately accumulate data
78
+ if (baselineText.length > 20) {
79
+ // Only check if baseline has meaningful content
80
+ const lengthRatio = currentText.length / baselineText.length;
81
+ if (lengthRatio < 0.3) {
82
+ // Response shrunk to <30% of original
83
+ return { detected: true, reason: "significant_length_decrease" };
84
+ }
85
+ }
86
+ return { detected: false, reason: null };
87
+ }
88
+ /**
89
+ * Extract text content from a response for semantic analysis.
90
+ */
91
+ extractTextContent(obj) {
92
+ if (typeof obj === "string")
93
+ return obj;
94
+ if (typeof obj !== "object" || !obj)
95
+ return "";
96
+ return JSON.stringify(obj);
97
+ }
98
+ /**
99
+ * Check for error-related keywords that indicate service degradation.
100
+ */
101
+ hasErrorKeywords(text) {
102
+ const patterns = [
103
+ /\berror\b/i,
104
+ /\bfail(ed|ure)?\b/i,
105
+ /\bunavailable\b/i,
106
+ /\brate\s*limit/i,
107
+ /\bdenied\b/i,
108
+ /\bexpired\b/i,
109
+ /\btimeout\b/i,
110
+ /\bblocked\b/i,
111
+ ];
112
+ return patterns.some((p) => p.test(text));
113
+ }
114
+ /**
115
+ * Check for promotional/monetization keywords that indicate a monetization rug pull.
116
+ * Enhanced to catch CH4-style rug pulls with limited-time offers, referral codes, etc.
117
+ *
118
+ * Combined into single regex for O(text_length) performance instead of O(18 * text_length).
119
+ */
120
+ hasPromotionalKeywords(text) {
121
+ // Single combined regex with alternation - matches all 18 original patterns
122
+ // Word-boundary patterns: upgrade, premium, discount, exclusive, subscription variants,
123
+ // multi-word phrases (pro plan, buy now, limited time/offer, free trial, etc.)
124
+ // Non-word patterns: price ($X.XX), percentage (N% off/discount)
125
+ const PROMO_PATTERN = /\b(?:upgrade|premium|discount|exclusive|subscri(?:be|ption)|pro\s*plan|buy\s*now|limited\s*(?:time|offer)|free\s*trial|special\s*offer|referral\s*code|promo\s*code|act\s*now|don't\s*miss|for\s*a\s*fee|pay(?:ment)?\s*(?:required|needed|now))\b|\$\d+(?:\.\d{2})?|\b\d+%\s*(?:off|discount)\b/i;
126
+ return PROMO_PATTERN.test(text);
127
+ }
128
+ /**
129
+ * Check for suspicious URL/link injection that wasn't present initially.
130
+ * Rug pulls often inject links to external malicious or monetization pages.
131
+ */
132
+ hasSuspiciousLinks(text) {
133
+ const patterns = [
134
+ // HTTP(S) URLs
135
+ /https?:\/\/[^\s]+/i,
136
+ // Markdown links
137
+ /\[.{0,50}?\]\(.{0,200}?\)/,
138
+ // URL shorteners
139
+ /\b(bit\.ly|tinyurl|t\.co|goo\.gl|ow\.ly|buff\.ly)\b/i,
140
+ // Click-bait action patterns
141
+ /\bclick\s*(here|now|this)\b/i,
142
+ /\bvisit\s*our\s*(website|site|page)\b/i,
143
+ /\b(sign\s*up|register)\s*(here|now|at)\b/i,
144
+ ];
145
+ return patterns.some((p) => p.test(text));
146
+ }
147
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Variance Classifier Module
3
+ * Classifies response variance to distinguish legitimate behavior from rug pulls.
4
+ *
5
+ * Extracted from TemporalAssessor as part of Issue #106 refactoring.
6
+ */
7
+ import { VarianceClassification } from "../../../../lib/assessmentTypes.js";
8
+ import { Tool } from "@modelcontextprotocol/sdk/types.js";
9
+ import { MutationDetector } from "./MutationDetector.js";
10
+ /**
11
+ * Classifies response variance and categorizes tools by their expected behavior patterns.
12
+ * Used to reduce false positives in temporal assessment by understanding legitimate variance.
13
+ */
14
+ export declare class VarianceClassifier {
15
+ private mutationDetector;
16
+ private readonly DESTRUCTIVE_PATTERNS;
17
+ /**
18
+ * Tool name patterns that are expected to have state-dependent responses.
19
+ * These tools legitimately return different results based on data state,
20
+ * which is NOT a rug pull vulnerability.
21
+ *
22
+ * Includes both:
23
+ * - READ operations: search, list, query return more results after data stored
24
+ * - ACCUMULATION operations: add, append, store return accumulated state (counts, IDs)
25
+ *
26
+ * NOTE: Does NOT include patterns already in DESTRUCTIVE_PATTERNS (create, write,
27
+ * insert, etc.) - those need strict comparison to detect real rug pulls.
28
+ *
29
+ * Uses word-boundary matching to prevent false matches.
30
+ * "add_observations" matches "add" but "address_validator" does not.
31
+ */
32
+ private readonly STATEFUL_TOOL_PATTERNS;
33
+ /**
34
+ * Issue #69: Patterns for resource-creating operations that legitimately return
35
+ * different IDs/resources each invocation.
36
+ *
37
+ * These tools CREATE new resources, so they should use schema comparison + variance
38
+ * classification rather than exact comparison. Unlike STATEFUL_TOOL_PATTERNS, these
39
+ * may overlap with DESTRUCTIVE_PATTERNS (e.g., "create", "insert") but should still
40
+ * use intelligent variance classification to avoid false positives.
41
+ *
42
+ * Examples:
43
+ * - create_billing_product -> new product_id each time (LEGITIMATE variance)
44
+ * - generate_report -> new report_id each time (LEGITIMATE variance)
45
+ * - insert_record -> new record_id each time (LEGITIMATE variance)
46
+ */
47
+ private readonly RESOURCE_CREATING_PATTERNS;
48
+ constructor(mutationDetector?: MutationDetector);
49
+ /**
50
+ * Normalize response for comparison by removing naturally varying data.
51
+ * Prevents false positives from timestamps, UUIDs, request IDs, counters, etc.
52
+ * Handles both direct JSON and nested JSON strings (e.g., content[].text).
53
+ */
54
+ normalizeResponse(response: unknown): string;
55
+ /**
56
+ * Detect if a tool may have side effects based on naming patterns.
57
+ */
58
+ isDestructiveTool(tool: Tool): boolean;
59
+ /**
60
+ * Check if a tool is expected to have state-dependent behavior.
61
+ * Stateful tools (search, list, add, store, etc.) legitimately return different
62
+ * results as underlying data changes - this is NOT a rug pull.
63
+ *
64
+ * Uses word-boundary matching to prevent false positives:
65
+ * - "add_observations" matches "add"
66
+ * - "address_validator" does NOT match "add"
67
+ */
68
+ isStatefulTool(tool: Tool): boolean;
69
+ /**
70
+ * Issue #69: Check if a tool creates new resources that legitimately vary per invocation.
71
+ * Resource-creating tools return different IDs, creation timestamps, etc.
72
+ * for each new resource - this is expected behavior, NOT a rug pull.
73
+ *
74
+ * Unlike isStatefulTool(), this DOES include patterns that overlap with DESTRUCTIVE_PATTERNS
75
+ * because resource-creating tools need intelligent variance classification, not exact comparison.
76
+ *
77
+ * Uses word-boundary matching like isStatefulTool() to prevent false matches.
78
+ * - "create_billing_product" matches "create"
79
+ * - "recreate_view" does NOT match "create" (must be at word boundary)
80
+ */
81
+ isResourceCreatingTool(tool: Tool): boolean;
82
+ /**
83
+ * Issue #69: Classify variance between two responses to reduce false positives.
84
+ * Returns LEGITIMATE for expected variance (IDs, timestamps), SUSPICIOUS for
85
+ * schema changes, and BEHAVIORAL for semantic changes (promotional keywords, errors).
86
+ */
87
+ classifyVariance(_tool: Tool, baseline: unknown, current: unknown): VarianceClassification;
88
+ /**
89
+ * Issue #69: Check if a field name represents legitimate variance.
90
+ * Fields containing IDs, timestamps, tokens, etc. are expected to vary.
91
+ */
92
+ isLegitimateFieldVariance(field: string): boolean;
93
+ /**
94
+ * Issue #69: Find which fields differ between two responses.
95
+ * Returns field paths that have different values.
96
+ */
97
+ findVariedFields(obj1: unknown, obj2: unknown, prefix?: string): string[];
98
+ /**
99
+ * Compare response schemas (field names) rather than full content.
100
+ * Stateful tools may have different values but should have consistent fields.
101
+ *
102
+ * For stateful tools, allows schema growth (empty arrays -> populated arrays)
103
+ * but flags when baseline fields disappear (suspicious behavior).
104
+ */
105
+ compareSchemas(response1: unknown, response2: unknown): boolean;
106
+ /**
107
+ * Extract all field names from an object recursively.
108
+ * Handles arrays by sampling multiple elements to detect heterogeneous schemas.
109
+ */
110
+ extractFieldNames(obj: unknown, prefix?: string): string[];
111
+ }
112
+ //# sourceMappingURL=VarianceClassifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VarianceClassifier.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/temporal/VarianceClassifier.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,gBAAgB,CAAmB;IAG3C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAoBnC;IAEF;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAqBrC;IAEF;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAYzC;gBAEU,gBAAgB,CAAC,EAAE,gBAAgB;IAI/C;;;;OAIG;IACH,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM;IAiF5C;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAKtC;;;;;;;;OAQG;IACH,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAenC;;;;;;;;;;;OAWG;IACH,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO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