@bryan-thompson/inspector-assessment-client 1.26.5 → 1.26.6

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 (28) hide show
  1. package/dist/assets/{OAuthCallback-DpdInvWI.js → OAuthCallback-CCWVtjr7.js} +1 -1
  2. package/dist/assets/{OAuthDebugCallback-D1ImpKK5.js → OAuthDebugCallback-DqbXfUi4.js} +1 -1
  3. package/dist/assets/{index-umcoGmYw.js → index-CsDJSSWq.js} +4 -4
  4. package/dist/index.html +1 -1
  5. package/lib/services/assessment/modules/securityTests/ConfidenceScorer.d.ts +57 -0
  6. package/lib/services/assessment/modules/securityTests/ConfidenceScorer.d.ts.map +1 -0
  7. package/lib/services/assessment/modules/securityTests/ConfidenceScorer.js +199 -0
  8. package/lib/services/assessment/modules/securityTests/ErrorClassifier.d.ts +57 -0
  9. package/lib/services/assessment/modules/securityTests/ErrorClassifier.d.ts.map +1 -0
  10. package/lib/services/assessment/modules/securityTests/ErrorClassifier.js +113 -0
  11. package/lib/services/assessment/modules/securityTests/ExecutionArtifactDetector.d.ts +49 -0
  12. package/lib/services/assessment/modules/securityTests/ExecutionArtifactDetector.d.ts.map +1 -0
  13. package/lib/services/assessment/modules/securityTests/ExecutionArtifactDetector.js +74 -0
  14. package/lib/services/assessment/modules/securityTests/MathAnalyzer.d.ts +58 -0
  15. package/lib/services/assessment/modules/securityTests/MathAnalyzer.d.ts.map +1 -0
  16. package/lib/services/assessment/modules/securityTests/MathAnalyzer.js +251 -0
  17. package/lib/services/assessment/modules/securityTests/SafeResponseDetector.d.ts +59 -0
  18. package/lib/services/assessment/modules/securityTests/SafeResponseDetector.d.ts.map +1 -0
  19. package/lib/services/assessment/modules/securityTests/SafeResponseDetector.js +151 -0
  20. package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts +229 -0
  21. package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts.map +1 -0
  22. package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.js +566 -0
  23. package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.d.ts.map +1 -1
  24. package/lib/services/assessment/modules/securityTests/SecurityPayloadGenerator.js +49 -24
  25. package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts +63 -85
  26. package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -1
  27. package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +270 -1171
  28. package/package.json +1 -1
@@ -0,0 +1,566 @@
1
+ /**
2
+ * Security Pattern Library
3
+ * Single source of truth for all regex patterns used in security analysis
4
+ *
5
+ * Extracted from SecurityResponseAnalyzer.ts (Issue #53)
6
+ * Consolidates 16 pattern collections, eliminates duplicates
7
+ */
8
+ // =============================================================================
9
+ // HTTP ERROR PATTERNS (consolidated from 3 duplicate locations)
10
+ // =============================================================================
11
+ /**
12
+ * Patterns to detect HTTP error responses (4xx/5xx)
13
+ * Used by: isHttpErrorResponse(), analyzeComputedMathResult()
14
+ */
15
+ export const HTTP_ERROR_PATTERNS = {
16
+ /** Full pattern: status code + context (e.g., "404 not found") */
17
+ statusWithContext: /\b(4\d{2}|5\d{2})\b.*?(not found|error|bad request|unauthorized|forbidden|internal server|unavailable|timeout|service)/i,
18
+ /** Simple pattern: status code at start (e.g., "404: ...") */
19
+ statusAtStart: /^(4\d{2}|5\d{2})[\s:]/,
20
+ /** Short "not found" responses */
21
+ notFound: /not found/i,
22
+ /** JSON status field pattern */
23
+ jsonStatus: /"status":\s*(4\d{2}|5\d{2})/,
24
+ };
25
+ // =============================================================================
26
+ // MCP VALIDATION ERROR PATTERNS
27
+ // =============================================================================
28
+ /**
29
+ * Patterns for MCP protocol validation errors
30
+ * These indicate proper input rejection (SAFE behavior)
31
+ * Used by: isMCPValidationError()
32
+ */
33
+ export const VALIDATION_ERROR_PATTERNS = [
34
+ /parameter validation failed/i,
35
+ /schema validation (error|failed)/i,
36
+ /invalid (url|email|format|parameter|input|data)/i,
37
+ /must be a valid/i,
38
+ /must have a valid/i,
39
+ /failed to validate/i,
40
+ /validation error/i,
41
+ /does not match (pattern|schema)/i,
42
+ /not a valid (url|email|number|string)/i,
43
+ /expected.*but (got|received)/i,
44
+ /type mismatch/i,
45
+ /\brequired\b.*\bmissing\b/i,
46
+ /cannot.*be.*empty/i,
47
+ /must.*not.*be.*empty/i,
48
+ /empty.*not.*allowed/i,
49
+ /\brequired\b/i,
50
+ /missing.*required/i,
51
+ /field.*required/i,
52
+ ];
53
+ // =============================================================================
54
+ // EXECUTION EVIDENCE PATTERNS
55
+ // =============================================================================
56
+ /**
57
+ * Patterns indicating actual code/command execution
58
+ * Used by: hasExecutionEvidence()
59
+ */
60
+ export const EXECUTION_INDICATORS = [
61
+ /\bexecuted\b/i,
62
+ /\bprocessed\b/i,
63
+ /\bran\b.*command/i,
64
+ /\bcompleted\b/i,
65
+ /\bcomputed\b/i,
66
+ /\bcalculated\b/i,
67
+ /NullPointerException/i,
68
+ /SegmentationFault/i,
69
+ /StackOverflow/i,
70
+ /OutOfMemory/i,
71
+ /syntax error in executed/i,
72
+ /error while executing/i,
73
+ /failed during execution/i,
74
+ /error in query execution/i,
75
+ /runtime error/i,
76
+ /deleted \d+ (rows|files|records)/i,
77
+ /(file|resource) (opened|accessed|modified|deleted)/i,
78
+ /query returned \d+ results/i,
79
+ /modified \d+ records/i,
80
+ /\d+ rows affected/i,
81
+ /command output:/i,
82
+ /execution result:/i,
83
+ ];
84
+ /**
85
+ * Patterns for detecting execution artifacts in response
86
+ * Used by: detectExecutionArtifacts()
87
+ */
88
+ export const EXECUTION_ARTIFACT_PATTERNS = {
89
+ /** Always indicates execution */
90
+ alwaysExecution: [
91
+ /[a-z]+:x:\d+:\d+:/i, // passwd format
92
+ /uid=\d+\([^)]+\)\s+gid=\d+/i, // id command
93
+ /[d-][rwx-]{9}\s+\d+\s+[a-z]+/i, // ls -l format
94
+ /total\s+\d+\s*$/m, // ls total
95
+ /command_executed:\s*[^"\s]/i,
96
+ /stdout:\s*["']?[^"'\s]/i,
97
+ /(execution|output)_log:/i,
98
+ /\/bin\/(bash|sh|zsh|dash)/i,
99
+ /\b(root|administrator)\s*$/im,
100
+ /\/root\//i,
101
+ /PID:\s*\d{3,}/i,
102
+ ],
103
+ /** Context-sensitive - only count if no echoed payload */
104
+ contextSensitive: [/\/etc\/passwd/i, /\/etc\/shadow/i, /file:\/\/\//i],
105
+ };
106
+ // =============================================================================
107
+ // CONNECTION ERROR PATTERNS (consolidated from 2 duplicate locations)
108
+ // =============================================================================
109
+ /**
110
+ * Patterns for connection/server errors
111
+ * Used by: isConnectionError(), isConnectionErrorFromException()
112
+ */
113
+ export const CONNECTION_ERROR_PATTERNS = {
114
+ /** Unambiguous connection errors */
115
+ unambiguous: [
116
+ /MCP error -32001/i,
117
+ /MCP error -32603/i,
118
+ /MCP error -32000/i,
119
+ /MCP error -32700/i,
120
+ /socket hang up/i,
121
+ /ECONNREFUSED/i,
122
+ /ETIMEDOUT/i,
123
+ /network error/i,
124
+ /ERR_CONNECTION/i,
125
+ /fetch failed/i,
126
+ /connection reset/i,
127
+ /error POSTing to endpoint/i,
128
+ /error GETting.*endpoint/i,
129
+ /service unavailable/i,
130
+ /gateway timeout/i,
131
+ /unknown tool:/i,
132
+ /no such tool/i,
133
+ ],
134
+ /** Only apply when response starts with MCP error prefix */
135
+ contextual: [
136
+ /bad request/i,
137
+ /unauthorized/i,
138
+ /forbidden/i,
139
+ /no valid session/i,
140
+ /session.*expired/i,
141
+ /internal server error/i,
142
+ /HTTP [45]\d\d/i,
143
+ ],
144
+ /** MCP error prefix pattern */
145
+ mcpPrefix: /^mcp error -\d+:/i,
146
+ };
147
+ /**
148
+ * Patterns for error classification
149
+ * Used by: classifyError(), classifyErrorFromException()
150
+ */
151
+ export const ERROR_CLASSIFICATION_PATTERNS = {
152
+ connection: /socket|ECONNREFUSED|ETIMEDOUT|network|fetch failed|connection reset/i,
153
+ server: /-32603|-32000|-32700|internal server error|service unavailable|gateway timeout|HTTP 5\d\d|error POSTing.*endpoint|error GETting.*endpoint|bad request|HTTP 400|unauthorized|forbidden|no valid session|session.*expired/i,
154
+ protocol: /-32001/i,
155
+ };
156
+ // =============================================================================
157
+ // REFLECTION PATTERNS (safe response detection)
158
+ // =============================================================================
159
+ /**
160
+ * Status patterns indicating safe response handling
161
+ * Used by: isReflectionResponse()
162
+ */
163
+ export const STATUS_PATTERNS = [
164
+ /\d+\s+total\s+(in\s+)?(memory|storage|items|results)/i,
165
+ /\d+\s+(results|items|records),?\s+\d+\s+total/i,
166
+ /action\s+executed\s+successfully:/i,
167
+ /command\s+executed\s+successfully:/i,
168
+ /"result":\s*"action\s+executed\s+successfully"/i,
169
+ /result.*action\s+executed\s+successfully/i,
170
+ /successfully\s+(executed|completed|processed):/i,
171
+ /successfully\s+(executed|completed|processed)"/i,
172
+ /action\s+received:/i,
173
+ /input\s+received:/i,
174
+ /request\s+received:/i,
175
+ /"safe"\s*:\s*true[^}]{0,500}("message"|"result"|"status"|"response")/i,
176
+ /("message"|"result"|"status"|"response")[^}]{0,500}"safe"\s*:\s*true/i,
177
+ /"vulnerable"\s*:\s*false[^}]{0,500}("safe"|"stored"|"reflected"|"status")/i,
178
+ /("safe"|"stored"|"reflected"|"status")[^}]{0,500}"vulnerable"\s*:\s*false/i,
179
+ /"status"\s*:\s*"acknowledged"[^}]{0,500}("message"|"result"|"safe")/i,
180
+ /("message"|"result"|"safe")[^}]{0,500}"status"\s*:\s*"acknowledged"/i,
181
+ ];
182
+ /**
183
+ * Reflection patterns indicating safe data handling
184
+ * Used by: isReflectionResponse()
185
+ */
186
+ export const REFLECTION_PATTERNS = [
187
+ // Storage patterns
188
+ /stored.*query/i,
189
+ /saved.*input/i,
190
+ /received.*parameter/i,
191
+ /processing.*request/i,
192
+ /storing.*data/i,
193
+ /added.*to.*collection/i,
194
+ // Echo patterns
195
+ /echo:/i,
196
+ /echoing/i,
197
+ /repeating/i,
198
+ /displaying/i,
199
+ /showing.*input/i,
200
+ /message.*echoed/i,
201
+ // Safe data handling
202
+ /safely.*as.*data/i,
203
+ /query.*stored/i,
204
+ /input.*saved/i,
205
+ /parameter.*received/i,
206
+ /command.*stored/i,
207
+ /stored.*command/i,
208
+ /data.*stored/i,
209
+ /stored.*data/i,
210
+ /action.*stored/i,
211
+ /stored.*action/i,
212
+ /text.*stored/i,
213
+ /stored.*text/i,
214
+ /setting.*stored/i,
215
+ /stored.*setting/i,
216
+ /instruction.*stored/i,
217
+ /stored.*instruction/i,
218
+ /url.*stored/i,
219
+ /stored.*url/i,
220
+ /package.*stored/i,
221
+ /stored.*package/i,
222
+ /stored.*safely/i,
223
+ /safely.*stored/i,
224
+ // Non-execution indicators
225
+ /without\s+execut/i,
226
+ /not\s+executed/i,
227
+ /never\s+executed/i,
228
+ /stored.*as.*data/i,
229
+ /treated.*as.*data/i,
230
+ /stored\s+in\s+(collection|database)/i,
231
+ /stored.*successfully/i,
232
+ /saved.*to/i,
233
+ /recorded\s+in/i,
234
+ /added\s+to/i,
235
+ // Processing status
236
+ /logged successfully:/i,
237
+ /queued for processing:/i,
238
+ /saved (for|successfully)/i,
239
+ /stored for (admin review|configuration|processing)/i,
240
+ /processed successfully/i,
241
+ /validated successfully/i,
242
+ /parsed successfully/i,
243
+ /(validation|processing) (passed|completed)/i,
244
+ // Error/rejection patterns (safe)
245
+ /error:.*not (found|in approved list|recognized)/i,
246
+ /error getting info for ['"].*['"]/i,
247
+ /invalid .* format.*stored as text/i,
248
+ /error:.*too (long|short|large)/i,
249
+ // Rate limiting / resource limits
250
+ /payload.?rejected/i,
251
+ /input.?exceeds.?limit/i,
252
+ /resource.?limit.?enforced/i,
253
+ /size.?limit/i,
254
+ /maximum.?length/i,
255
+ /rate.?limit/i,
256
+ /request.?throttled/i,
257
+ /input.?too.?large/i,
258
+ /exceeds.?maximum.?size/i,
259
+ /depth.?limit.?exceeded/i,
260
+ /nesting.?limit/i,
261
+ /complexity.?limit/i,
262
+ // Serialization safety
263
+ /serialization.?not.?supported/i,
264
+ /pickle.?disabled/i,
265
+ /deserialization.?blocked/i,
266
+ /unsafe.?format.?rejected/i,
267
+ /binary.?data.?not.?accepted/i,
268
+ /data.?stored.?safely/i,
269
+ /without.?deserialization/i,
270
+ /no.?pickle/i,
271
+ /stored.?without.?deserializ/i,
272
+ // Reference/sanitization indicators
273
+ /\[ref-[a-f0-9]+\]/i,
274
+ /stored.*\[ref-/i,
275
+ /\[sanitized\]/i,
276
+ /\[redacted\]/i,
277
+ /\[filtered\]/i,
278
+ /\[blocked\]/i,
279
+ /expression.*stored:/i,
280
+ /input.*sanitized/i,
281
+ /content.*replaced/i,
282
+ ];
283
+ // =============================================================================
284
+ // AUTH BYPASS PATTERNS (Issue #75, CVE-2025-52882)
285
+ // =============================================================================
286
+ /**
287
+ * Fail-open authentication patterns (VULNERABLE)
288
+ * Used by: analyzeAuthBypassResponse()
289
+ */
290
+ export const AUTH_FAIL_OPEN_PATTERNS = [
291
+ {
292
+ pattern: /"auth_type"\s*:\s*"fail-open"/i,
293
+ evidence: "auth_type: fail-open (CVE-2025-52882)",
294
+ },
295
+ {
296
+ pattern: /"auth_status"\s*:\s*"bypassed"/i,
297
+ evidence: "auth_status: bypassed",
298
+ },
299
+ {
300
+ pattern: /access.*granted.*despite/i,
301
+ evidence: "access granted despite failure",
302
+ },
303
+ { pattern: /authentication.*skipped/i, evidence: "authentication skipped" },
304
+ { pattern: /fail[\s-]?open/i, evidence: "fail-open pattern detected" },
305
+ { pattern: /bypassed.*auth/i, evidence: "auth bypassed" },
306
+ { pattern: /authentication.*bypassed/i, evidence: "authentication bypassed" },
307
+ {
308
+ pattern: /"vulnerable"\s*:\s*true[^}]*(?:"auth_status"|"auth_type"|"auth_error")|(?:"auth_status"|"auth_type"|"auth_error")[^}]*"vulnerable"\s*:\s*true/i,
309
+ evidence: "vulnerable flag with auth context",
310
+ },
311
+ {
312
+ pattern: /auth.*succeeded.*null/i,
313
+ evidence: "auth succeeded with null token",
314
+ },
315
+ {
316
+ pattern: /granted.*without.*valid/i,
317
+ evidence: "granted without valid token",
318
+ },
319
+ { pattern: /"action_performed"/i, evidence: "action performed indicator" },
320
+ ];
321
+ /**
322
+ * Fail-closed authentication patterns (SAFE)
323
+ * Used by: analyzeAuthBypassResponse()
324
+ */
325
+ export const AUTH_FAIL_CLOSED_PATTERNS = [
326
+ {
327
+ pattern: /"auth_type"\s*:\s*"fail-closed"/i,
328
+ evidence: "auth_type: fail-closed (secure)",
329
+ },
330
+ { pattern: /"auth_status"\s*:\s*"denied"/i, evidence: "auth_status: denied" },
331
+ { pattern: /access.*denied/i, evidence: "access denied" },
332
+ { pattern: /authentication.*failed/i, evidence: "authentication failed" },
333
+ { pattern: /fail[\s-]?closed/i, evidence: "fail-closed pattern detected" },
334
+ { pattern: /"status"\s*:\s*"blocked"/i, evidence: "status: blocked" },
335
+ { pattern: /invalid.*token/i, evidence: "invalid token rejection" },
336
+ { pattern: /token.*required/i, evidence: "token required" },
337
+ { pattern: /unauthorized/i, evidence: "unauthorized response" },
338
+ { pattern: /"denial_reason"/i, evidence: "denial reason provided" },
339
+ ];
340
+ // =============================================================================
341
+ // SEARCH/RETRIEVAL PATTERNS
342
+ // =============================================================================
343
+ /**
344
+ * Patterns indicating search result responses
345
+ * Used by: isSearchResultResponse()
346
+ */
347
+ export const SEARCH_RESULT_PATTERNS = [
348
+ /"results"\s*:\s*\[/i,
349
+ /"type"\s*:\s*"search"/i,
350
+ /"object"\s*:\s*"list"/i,
351
+ /\bhighlight\b/i,
352
+ /search\s+results/i,
353
+ /found\s+\d+\s+(results?|pages?|items?)/i,
354
+ /query\s+(returned|matched)/i,
355
+ /\d+\s+(results?|matches?|hits?)\s+for/i,
356
+ /"has_more"\s*:/i,
357
+ /next_cursor/i,
358
+ ];
359
+ /**
360
+ * Patterns indicating creation/modification responses
361
+ * Used by: isCreationResponse()
362
+ */
363
+ export const CREATION_PATTERNS = [
364
+ /successfully\s+created/i,
365
+ /database\s+created/i,
366
+ /page\s+created/i,
367
+ /resource\s+created/i,
368
+ /\bcreate\s+table\b/i,
369
+ /\binsert\s+into\b/i,
370
+ /"id"\s*:\s*"[a-f0-9-]{36}"/i,
371
+ /"object"\s*:\s*"(page|database)"/i,
372
+ /collection:\/\//i,
373
+ /successfully\s+(added|inserted|updated|modified)/i,
374
+ /resource\s+id:\s*[a-f0-9-]/i,
375
+ /"created_time"/i,
376
+ /"last_edited_time"/i,
377
+ ];
378
+ // =============================================================================
379
+ // INJECTION DETECTION PATTERNS
380
+ // =============================================================================
381
+ /**
382
+ * Patterns for echoed injection payloads
383
+ * Used by: containsEchoedInjectionPayload()
384
+ */
385
+ export const ECHOED_PAYLOAD_PATTERNS = [
386
+ /<!DOCTYPE\s+\w+\s+\[/i,
387
+ /<!ENTITY\s+\w+\s+SYSTEM/i,
388
+ /<!ENTITY\s+%\s*\w+/i,
389
+ /stored.*http:\/\//i,
390
+ /saved.*http:\/\//i,
391
+ /stored.*union\s+select/i,
392
+ /stored.*drop\s+table/i,
393
+ /stored\s+query:\s*[<'"]/i,
394
+ /saved\s+data:\s*[<'"]/i,
395
+ ];
396
+ /**
397
+ * Fallback execution detection patterns
398
+ * Used by: analyzeInjectionResponse()
399
+ */
400
+ export const FALLBACK_EXECUTION_PATTERNS = [
401
+ /executed/i,
402
+ /command.*ran/i,
403
+ /result.*is/i,
404
+ /output.*:/i,
405
+ /returned.*value/i,
406
+ ];
407
+ // =============================================================================
408
+ // VALIDATION/REJECTION PATTERNS
409
+ // =============================================================================
410
+ /**
411
+ * Text-based validation rejection patterns
412
+ * Used by: isValidationRejection()
413
+ */
414
+ export const TEXT_REJECTION_PATTERNS = [
415
+ /validation failed/i,
416
+ /rejected/i,
417
+ /not.*approved/i,
418
+ /not.*in.*list/i,
419
+ /invalid.*input/i,
420
+ /error:.*invalid/i,
421
+ ];
422
+ /**
423
+ * Result field rejection patterns (for JSON responses)
424
+ * Used by: isValidationRejection()
425
+ */
426
+ export const RESULT_REJECTION_PATTERNS = [
427
+ /validation (failed|error)/i,
428
+ /rejected/i,
429
+ /not.*approved/i,
430
+ /not.*in.*list/i,
431
+ /invalid.*input/i,
432
+ /error:.*invalid/i,
433
+ ];
434
+ /**
435
+ * Ambiguous validation pattern strings (for confidence calculation)
436
+ * Used by: isValidationPattern()
437
+ */
438
+ export const AMBIGUOUS_VALIDATION_PATTERNS = [
439
+ "type.*error",
440
+ "invalid.*type",
441
+ "error",
442
+ "invalid",
443
+ "failed",
444
+ "negative.*not.*allowed",
445
+ "must.*be.*positive",
446
+ "invalid.*value",
447
+ "overflow",
448
+ "out.*of.*range",
449
+ ];
450
+ // =============================================================================
451
+ // TOOL CLASSIFICATION PATTERNS
452
+ // =============================================================================
453
+ /**
454
+ * Patterns for identifying structured data tools
455
+ * Used by: isStructuredDataTool()
456
+ */
457
+ export const DATA_TOOL_PATTERNS = [
458
+ /search/i,
459
+ /find/i,
460
+ /lookup/i,
461
+ /query/i,
462
+ /retrieve/i,
463
+ /fetch/i,
464
+ /get/i,
465
+ /list/i,
466
+ /resolve/i,
467
+ /discover/i,
468
+ /browse/i,
469
+ ];
470
+ /**
471
+ * Read-only tool name patterns
472
+ * Used by: analyzeComputedMathResult()
473
+ */
474
+ export const READ_ONLY_TOOL_NAME_PATTERN = /^(get|list|fetch|read|retrieve|show|view)_/i;
475
+ // =============================================================================
476
+ // MATH ANALYSIS PATTERNS
477
+ // =============================================================================
478
+ /**
479
+ * Simple math expression pattern
480
+ * Used by: isComputedMathResult(), analyzeComputedMathResult()
481
+ */
482
+ export const SIMPLE_MATH_PATTERN = /^\s*(\d+)\s*([+\-*/])\s*(\d+)(?:\s*([+\-*/])\s*(\d+))?\s*$/;
483
+ /**
484
+ * Computational language indicators
485
+ * Used by: analyzeComputedMathResult()
486
+ */
487
+ export const COMPUTATIONAL_INDICATORS = [
488
+ /\bthe\s+answer\s+is\b/i,
489
+ /\bresult\s*[=:]\s*\d/i,
490
+ /\bcalculated\s+to\b/i,
491
+ /\bcomputed\s+as\b/i,
492
+ /\bevaluates?\s+to\b/i,
493
+ /\bequals?\s+\d/i,
494
+ /\bsum\s+is\b/i,
495
+ /\bproduct\s+is\b/i,
496
+ ];
497
+ /**
498
+ * Common data field names that often contain numeric values
499
+ * Used by: isCoincidentalNumericInStructuredData()
500
+ */
501
+ export const STRUCTURED_DATA_FIELD_NAMES = [
502
+ "count",
503
+ "total",
504
+ "records",
505
+ "page",
506
+ "limit",
507
+ "offset",
508
+ "id",
509
+ "status",
510
+ "code",
511
+ "version",
512
+ "index",
513
+ "size",
514
+ "employees",
515
+ "items",
516
+ "results",
517
+ "entries",
518
+ "length",
519
+ "pages",
520
+ "rows",
521
+ "columns",
522
+ "width",
523
+ "height",
524
+ "timestamp",
525
+ "duration",
526
+ "amount",
527
+ "price",
528
+ "quantity",
529
+ ];
530
+ // =============================================================================
531
+ // CONFIDENCE CALCULATION PATTERNS
532
+ // =============================================================================
533
+ /**
534
+ * Structured data indicators for confidence calculation
535
+ * Used by: calculateConfidence()
536
+ */
537
+ export const STRUCTURED_DATA_INDICATORS = {
538
+ fieldPatterns: /title:|name:|description:|trust score:|id:|snippets:/i,
539
+ bulletPattern: /^\s*-\s+/m,
540
+ jsonPattern: /"[^"]+"\s*:\s*"[^"]+"/g,
541
+ numericMetadataPattern: /\b(score|count|trust|rating|id|version)\b/i,
542
+ };
543
+ // =============================================================================
544
+ // HELPER FUNCTIONS
545
+ // =============================================================================
546
+ /**
547
+ * Check if any pattern in array matches text
548
+ */
549
+ export function matchesAny(patterns, text) {
550
+ return patterns.some((pattern) => pattern.test(text));
551
+ }
552
+ /**
553
+ * Check if HTTP error pattern matches
554
+ */
555
+ export function isHttpError(text) {
556
+ return (HTTP_ERROR_PATTERNS.statusWithContext.test(text) ||
557
+ HTTP_ERROR_PATTERNS.statusAtStart.test(text) ||
558
+ HTTP_ERROR_PATTERNS.jsonStatus.test(text) ||
559
+ (HTTP_ERROR_PATTERNS.notFound.test(text) && text.length < 100));
560
+ }
561
+ /**
562
+ * Check if response has MCP error prefix
563
+ */
564
+ export function hasMcpErrorPrefix(text) {
565
+ return CONNECTION_ERROR_PATTERNS.mcpPrefix.test(text);
566
+ }
@@ -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;IA+H1B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IASjC;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAQ7C"}
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;IAwJ1B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IASjC;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAQ7C"}
@@ -31,7 +31,55 @@ export class SecurityPayloadGenerator {
31
31
  const params = {};
32
32
  const targetParamTypes = payload.parameterTypes || [];
33
33
  let payloadInjected = false;
34
- // Check for language-specific code execution parameters first
34
+ // PRIORITY 1: Handle auth payloads first (Issue #81)
35
+ // These MUST go to token/auth parameters, not language-detected params
36
+ if (!payloadInjected && payload.payloadType === "auth") {
37
+ const authParams = [
38
+ "token",
39
+ "auth_token",
40
+ "authorization",
41
+ "api_key",
42
+ "access_token",
43
+ ];
44
+ for (const [key, prop] of Object.entries(schema.properties)) {
45
+ const propSchema = prop;
46
+ if (propSchema.type === "string") {
47
+ for (const authParam of authParams) {
48
+ if (key.toLowerCase().includes(authParam.toLowerCase())) {
49
+ params[key] = payload.payload;
50
+ payloadInjected = true;
51
+ break;
52
+ }
53
+ }
54
+ if (payloadInjected)
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ // PRIORITY 2: Handle auth_failure payloads (Issue #79)
60
+ // These MUST go to simulate_failure parameters
61
+ if (!payloadInjected && payload.payloadType === "auth_failure") {
62
+ const authFailureParams = [
63
+ "simulate_failure",
64
+ "failure_mode",
65
+ "failure_type",
66
+ ];
67
+ for (const [key, prop] of Object.entries(schema.properties)) {
68
+ const propSchema = prop;
69
+ if (propSchema.type === "string") {
70
+ for (const failParam of authFailureParams) {
71
+ if (key.toLowerCase().includes(failParam.toLowerCase())) {
72
+ params[key] = payload.payload;
73
+ payloadInjected = true;
74
+ break;
75
+ }
76
+ }
77
+ if (payloadInjected)
78
+ break;
79
+ }
80
+ }
81
+ }
82
+ // PRIORITY 3: Check for language-specific code execution parameters
35
83
  for (const [key, prop] of Object.entries(schema.properties)) {
36
84
  const propSchema = prop;
37
85
  if (propSchema.type !== "string")
@@ -71,29 +119,6 @@ export class SecurityPayloadGenerator {
71
119
  }
72
120
  }
73
121
  }
74
- // Special handling for auth_failure payloads (Issue #79)
75
- // These target simulate_failure parameters to test fail-open behavior
76
- if (!payloadInjected && payload.payloadType === "auth_failure") {
77
- const authFailureParams = [
78
- "simulate_failure",
79
- "failure_mode",
80
- "failure_type",
81
- ];
82
- for (const [key, prop] of Object.entries(schema.properties)) {
83
- const propSchema = prop;
84
- if (propSchema.type === "string") {
85
- for (const failParam of authFailureParams) {
86
- if (key.toLowerCase().includes(failParam.toLowerCase())) {
87
- params[key] = payload.payload;
88
- payloadInjected = true;
89
- break;
90
- }
91
- }
92
- if (payloadInjected)
93
- break;
94
- }
95
- }
96
- }
97
122
  // Fall back to generic payload - inject into first string parameter
98
123
  if (!payloadInjected) {
99
124
  for (const [key, prop] of Object.entries(schema.properties)) {