@weave_protocol/mund 0.1.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 (98) hide show
  1. package/dist/analyzers/code-analyzer.d.ts +24 -0
  2. package/dist/analyzers/code-analyzer.d.ts.map +1 -0
  3. package/dist/analyzers/code-analyzer.js +73 -0
  4. package/dist/analyzers/code-analyzer.js.map +1 -0
  5. package/dist/analyzers/exfiltration-detector.d.ts +40 -0
  6. package/dist/analyzers/exfiltration-detector.d.ts.map +1 -0
  7. package/dist/analyzers/exfiltration-detector.js +220 -0
  8. package/dist/analyzers/exfiltration-detector.js.map +1 -0
  9. package/dist/analyzers/index.d.ts +26 -0
  10. package/dist/analyzers/index.d.ts.map +1 -0
  11. package/dist/analyzers/index.js +61 -0
  12. package/dist/analyzers/index.js.map +1 -0
  13. package/dist/analyzers/injection-detector.d.ts +36 -0
  14. package/dist/analyzers/injection-detector.d.ts.map +1 -0
  15. package/dist/analyzers/injection-detector.js +165 -0
  16. package/dist/analyzers/injection-detector.js.map +1 -0
  17. package/dist/analyzers/pii-detector.d.ts +44 -0
  18. package/dist/analyzers/pii-detector.d.ts.map +1 -0
  19. package/dist/analyzers/pii-detector.js +190 -0
  20. package/dist/analyzers/pii-detector.js.map +1 -0
  21. package/dist/analyzers/secret-scanner.d.ts +32 -0
  22. package/dist/analyzers/secret-scanner.d.ts.map +1 -0
  23. package/dist/analyzers/secret-scanner.js +119 -0
  24. package/dist/analyzers/secret-scanner.js.map +1 -0
  25. package/dist/constants.d.ts +18 -0
  26. package/dist/constants.d.ts.map +1 -0
  27. package/dist/constants.js +580 -0
  28. package/dist/constants.js.map +1 -0
  29. package/dist/index.d.ts +9 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +242 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/notifications/email.d.ts +18 -0
  34. package/dist/notifications/email.d.ts.map +1 -0
  35. package/dist/notifications/email.js +192 -0
  36. package/dist/notifications/email.js.map +1 -0
  37. package/dist/notifications/index.d.ts +51 -0
  38. package/dist/notifications/index.d.ts.map +1 -0
  39. package/dist/notifications/index.js +107 -0
  40. package/dist/notifications/index.js.map +1 -0
  41. package/dist/notifications/slack.d.ts +17 -0
  42. package/dist/notifications/slack.d.ts.map +1 -0
  43. package/dist/notifications/slack.js +128 -0
  44. package/dist/notifications/slack.js.map +1 -0
  45. package/dist/notifications/teams.d.ts +17 -0
  46. package/dist/notifications/teams.d.ts.map +1 -0
  47. package/dist/notifications/teams.js +136 -0
  48. package/dist/notifications/teams.js.map +1 -0
  49. package/dist/notifications/webhook.d.ts +15 -0
  50. package/dist/notifications/webhook.d.ts.map +1 -0
  51. package/dist/notifications/webhook.js +67 -0
  52. package/dist/notifications/webhook.js.map +1 -0
  53. package/dist/storage/index.d.ts +11 -0
  54. package/dist/storage/index.d.ts.map +1 -0
  55. package/dist/storage/index.js +26 -0
  56. package/dist/storage/index.js.map +1 -0
  57. package/dist/storage/memory.d.ts +35 -0
  58. package/dist/storage/memory.d.ts.map +1 -0
  59. package/dist/storage/memory.js +144 -0
  60. package/dist/storage/memory.js.map +1 -0
  61. package/dist/tools/configuration.d.ts +8 -0
  62. package/dist/tools/configuration.d.ts.map +1 -0
  63. package/dist/tools/configuration.js +399 -0
  64. package/dist/tools/configuration.js.map +1 -0
  65. package/dist/tools/index.d.ts +15 -0
  66. package/dist/tools/index.d.ts.map +1 -0
  67. package/dist/tools/index.js +16 -0
  68. package/dist/tools/index.js.map +1 -0
  69. package/dist/tools/monitoring.d.ts +10 -0
  70. package/dist/tools/monitoring.d.ts.map +1 -0
  71. package/dist/tools/monitoring.js +476 -0
  72. package/dist/tools/monitoring.js.map +1 -0
  73. package/dist/types.d.ts +207 -0
  74. package/dist/types.d.ts.map +1 -0
  75. package/dist/types.js +6 -0
  76. package/dist/types.js.map +1 -0
  77. package/package.json +62 -0
  78. package/rules/default.yaml +189 -0
  79. package/src/analyzers/code-analyzer.ts +88 -0
  80. package/src/analyzers/exfiltration-detector.ts +257 -0
  81. package/src/analyzers/index.ts +74 -0
  82. package/src/analyzers/injection-detector.ts +191 -0
  83. package/src/analyzers/pii-detector.ts +220 -0
  84. package/src/analyzers/secret-scanner.ts +142 -0
  85. package/src/constants.ts +603 -0
  86. package/src/index.ts +285 -0
  87. package/src/notifications/email.ts +211 -0
  88. package/src/notifications/index.ts +136 -0
  89. package/src/notifications/slack.ts +170 -0
  90. package/src/notifications/teams.ts +200 -0
  91. package/src/notifications/webhook.ts +80 -0
  92. package/src/storage/index.ts +29 -0
  93. package/src/storage/memory.ts +181 -0
  94. package/src/tools/configuration.ts +478 -0
  95. package/src/tools/index.ts +29 -0
  96. package/src/tools/monitoring.ts +559 -0
  97. package/src/types.ts +300 -0
  98. package/tsconfig.json +24 -0
@@ -0,0 +1,603 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Constants and default configurations
4
+ */
5
+
6
+ // import { Severity, ActionType, DetectorType } from './types.js';
7
+ import type { DetectionRule, MundConfig } from './types.js';
8
+
9
+ // ============================================================================
10
+ // Default Configuration
11
+ // ============================================================================
12
+
13
+ export const DEFAULT_CONFIG: MundConfig = {
14
+ port: 3000,
15
+ host: '127.0.0.1',
16
+ transport: 'stdio',
17
+ log_level: 'info',
18
+ storage_type: 'memory',
19
+ block_mode: false,
20
+ notifications: {}
21
+ };
22
+
23
+ // ============================================================================
24
+ // Character Limits
25
+ // ============================================================================
26
+
27
+ export const MAX_CONTENT_LENGTH = 1_000_000; // 1MB
28
+ export const MAX_SNIPPET_LENGTH = 200;
29
+ export const MAX_EVENTS_PER_QUERY = 1000;
30
+ export const DEFAULT_EVENTS_LIMIT = 50;
31
+
32
+ // ============================================================================
33
+ // Secret Detection Patterns
34
+ // ============================================================================
35
+
36
+ export const SECRET_PATTERNS: DetectionRule[] = [
37
+ {
38
+ id: 'aws_access_key_id',
39
+ name: 'AWS Access Key ID',
40
+ description: 'Amazon Web Services access key identifier',
41
+ type: 'secret',
42
+ pattern: '(?<![A-Z0-9])AKIA[0-9A-Z]{16}(?![A-Z0-9])',
43
+ severity: 'critical',
44
+ action: 'alert',
45
+ enabled: true
46
+ },
47
+ {
48
+ id: 'aws_secret_access_key',
49
+ name: 'AWS Secret Access Key',
50
+ description: 'Amazon Web Services secret access key',
51
+ type: 'secret',
52
+ pattern: '(?i)aws[_\\-\\s]*secret[_\\-\\s]*access[_\\-\\s]*key[\\s]*[=:]+[\\s]*["\']?[A-Za-z0-9/+=]{40}["\']?',
53
+ severity: 'critical',
54
+ action: 'alert',
55
+ enabled: true
56
+ },
57
+ {
58
+ id: 'github_token',
59
+ name: 'GitHub Token',
60
+ description: 'GitHub personal access token or OAuth token',
61
+ type: 'secret',
62
+ pattern: 'gh[pousr]_[A-Za-z0-9_]{36,}',
63
+ severity: 'critical',
64
+ action: 'alert',
65
+ enabled: true
66
+ },
67
+ {
68
+ id: 'github_fine_grained_token',
69
+ name: 'GitHub Fine-Grained Token',
70
+ description: 'GitHub fine-grained personal access token',
71
+ type: 'secret',
72
+ pattern: 'github_pat_[A-Za-z0-9_]{22,}',
73
+ severity: 'critical',
74
+ action: 'alert',
75
+ enabled: true
76
+ },
77
+ {
78
+ id: 'openai_api_key',
79
+ name: 'OpenAI API Key',
80
+ description: 'OpenAI API key',
81
+ type: 'secret',
82
+ pattern: 'sk-[A-Za-z0-9]{20}T3BlbkFJ[A-Za-z0-9]{20}',
83
+ severity: 'critical',
84
+ action: 'alert',
85
+ enabled: true
86
+ },
87
+ {
88
+ id: 'openai_api_key_v2',
89
+ name: 'OpenAI API Key (New Format)',
90
+ description: 'OpenAI API key in newer format',
91
+ type: 'secret',
92
+ pattern: 'sk-proj-[A-Za-z0-9_-]{48,}',
93
+ severity: 'critical',
94
+ action: 'alert',
95
+ enabled: true
96
+ },
97
+ {
98
+ id: 'anthropic_api_key',
99
+ name: 'Anthropic API Key',
100
+ description: 'Anthropic Claude API key',
101
+ type: 'secret',
102
+ pattern: 'sk-ant-[A-Za-z0-9_-]{90,}',
103
+ severity: 'critical',
104
+ action: 'alert',
105
+ enabled: true
106
+ },
107
+ {
108
+ id: 'google_api_key',
109
+ name: 'Google API Key',
110
+ description: 'Google Cloud API key',
111
+ type: 'secret',
112
+ pattern: 'AIza[0-9A-Za-z_-]{35}',
113
+ severity: 'high',
114
+ action: 'alert',
115
+ enabled: true
116
+ },
117
+ {
118
+ id: 'google_oauth_client_secret',
119
+ name: 'Google OAuth Client Secret',
120
+ description: 'Google OAuth 2.0 client secret',
121
+ type: 'secret',
122
+ pattern: '(?i)client[_-]?secret[\\s]*[=:]+[\\s]*["\']?GOCSPX-[A-Za-z0-9_-]{28}["\']?',
123
+ severity: 'critical',
124
+ action: 'alert',
125
+ enabled: true
126
+ },
127
+ {
128
+ id: 'gemini_api_key',
129
+ name: 'Gemini API Key',
130
+ description: 'Google Gemini API key for AI services',
131
+ type: 'secret',
132
+ pattern: '(?i)(GEMINI_API_KEY|GOOGLE_API_KEY)[\\s]*[=:]+[\\s]*["\']?AIza[0-9A-Za-z_-]{35}["\']?',
133
+ severity: 'critical',
134
+ action: 'alert',
135
+ enabled: true
136
+ },
137
+ {
138
+ id: 'google_cloud_service_account',
139
+ name: 'Google Cloud Service Account Key',
140
+ description: 'Google Cloud service account JSON key file content',
141
+ type: 'secret',
142
+ pattern: '"type"\\s*:\\s*"service_account"[\\s\\S]*"private_key"\\s*:\\s*"-----BEGIN',
143
+ severity: 'critical',
144
+ action: 'alert',
145
+ enabled: true
146
+ },
147
+ {
148
+ id: 'google_oauth_refresh_token',
149
+ name: 'Google OAuth Refresh Token',
150
+ description: 'Google OAuth refresh token',
151
+ type: 'secret',
152
+ pattern: '1//[0-9A-Za-z_-]{40,}',
153
+ severity: 'high',
154
+ action: 'alert',
155
+ enabled: true
156
+ },
157
+ {
158
+ id: 'firebase_api_key',
159
+ name: 'Firebase API Key',
160
+ description: 'Firebase/Google Cloud API key',
161
+ type: 'secret',
162
+ pattern: 'AIza[0-9A-Za-z_-]{35}',
163
+ severity: 'high',
164
+ action: 'alert',
165
+ enabled: true
166
+ },
167
+ {
168
+ id: 'gcp_project_credentials',
169
+ name: 'GCP Application Credentials Path',
170
+ description: 'Google Application Default Credentials file path',
171
+ type: 'secret',
172
+ pattern: '(?i)GOOGLE_APPLICATION_CREDENTIALS[\\s]*[=:]+[\\s]*["\']?[^"\'\\s]+\\.json["\']?',
173
+ severity: 'medium',
174
+ action: 'alert',
175
+ enabled: true
176
+ },
177
+ {
178
+ id: 'slack_token',
179
+ name: 'Slack Token',
180
+ description: 'Slack bot, user, or workspace token',
181
+ type: 'secret',
182
+ pattern: 'xox[baprs]-[0-9]{10,13}-[0-9]{10,13}[a-zA-Z0-9-]*',
183
+ severity: 'critical',
184
+ action: 'alert',
185
+ enabled: true
186
+ },
187
+ {
188
+ id: 'slack_webhook',
189
+ name: 'Slack Webhook URL',
190
+ description: 'Slack incoming webhook URL',
191
+ type: 'secret',
192
+ pattern: 'https://hooks\\.slack\\.com/services/T[A-Z0-9]+/B[A-Z0-9]+/[A-Za-z0-9]+',
193
+ severity: 'high',
194
+ action: 'alert',
195
+ enabled: true
196
+ },
197
+ {
198
+ id: 'stripe_api_key',
199
+ name: 'Stripe API Key',
200
+ description: 'Stripe publishable or secret API key',
201
+ type: 'secret',
202
+ pattern: '[sr]k_(live|test)_[A-Za-z0-9]{24,}',
203
+ severity: 'critical',
204
+ action: 'alert',
205
+ enabled: true
206
+ },
207
+ {
208
+ id: 'private_key_block',
209
+ name: 'Private Key',
210
+ description: 'RSA, EC, DSA, or OpenSSH private key',
211
+ type: 'secret',
212
+ pattern: '-----BEGIN (RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY( BLOCK)?-----',
213
+ severity: 'critical',
214
+ action: 'alert',
215
+ enabled: true
216
+ },
217
+ {
218
+ id: 'jwt_token',
219
+ name: 'JWT Token',
220
+ description: 'JSON Web Token',
221
+ type: 'secret',
222
+ pattern: 'eyJ[A-Za-z0-9_-]*\\.eyJ[A-Za-z0-9_-]*\\.[A-Za-z0-9_-]*',
223
+ severity: 'high',
224
+ action: 'alert',
225
+ enabled: true
226
+ },
227
+ {
228
+ id: 'basic_auth_header',
229
+ name: 'Basic Auth Header',
230
+ description: 'HTTP Basic Authentication header',
231
+ type: 'secret',
232
+ pattern: '(?i)authorization[\\s]*:[\\s]*basic[\\s]+[A-Za-z0-9+/=]{20,}',
233
+ severity: 'high',
234
+ action: 'alert',
235
+ enabled: true
236
+ },
237
+ {
238
+ id: 'bearer_token',
239
+ name: 'Bearer Token',
240
+ description: 'HTTP Bearer authentication token',
241
+ type: 'secret',
242
+ pattern: '(?i)authorization[\\s]*:[\\s]*bearer[\\s]+[A-Za-z0-9_.-]{20,}',
243
+ severity: 'high',
244
+ action: 'alert',
245
+ enabled: true
246
+ },
247
+ {
248
+ id: 'database_url',
249
+ name: 'Database Connection URL',
250
+ description: 'Database connection string with credentials',
251
+ type: 'secret',
252
+ pattern: '(?i)(postgres|mysql|mongodb|redis|amqp)://[^:]+:[^@]+@[^/]+',
253
+ severity: 'critical',
254
+ action: 'alert',
255
+ enabled: true
256
+ },
257
+ {
258
+ id: 'generic_api_key',
259
+ name: 'Generic API Key',
260
+ description: 'Generic API key pattern',
261
+ type: 'secret',
262
+ pattern: '(?i)(api[_-]?key|apikey|api[_-]?secret)[\\s]*[=:]+[\\s]*["\']?[A-Za-z0-9_-]{20,}["\']?',
263
+ severity: 'medium',
264
+ action: 'alert',
265
+ enabled: true
266
+ },
267
+ {
268
+ id: 'generic_password',
269
+ name: 'Generic Password',
270
+ description: 'Password assignment in code or config',
271
+ type: 'secret',
272
+ pattern: '(?i)(password|passwd|pwd)[\\s]*[=:]+[\\s]*["\'][^"\']{8,}["\']',
273
+ severity: 'high',
274
+ action: 'alert',
275
+ enabled: true
276
+ },
277
+ {
278
+ id: 'npm_token',
279
+ name: 'NPM Token',
280
+ description: 'NPM authentication token',
281
+ type: 'secret',
282
+ pattern: '(?i)//registry\\.npmjs\\.org/:_authToken=[A-Za-z0-9_-]+',
283
+ severity: 'critical',
284
+ action: 'alert',
285
+ enabled: true
286
+ },
287
+ {
288
+ id: 'pypi_token',
289
+ name: 'PyPI Token',
290
+ description: 'Python Package Index API token',
291
+ type: 'secret',
292
+ pattern: 'pypi-[A-Za-z0-9_-]{50,}',
293
+ severity: 'critical',
294
+ action: 'alert',
295
+ enabled: true
296
+ },
297
+ {
298
+ id: 'docker_auth',
299
+ name: 'Docker Auth Config',
300
+ description: 'Docker registry authentication',
301
+ type: 'secret',
302
+ pattern: '(?i)"auth"[\\s]*:[\\s]*"[A-Za-z0-9+/=]{20,}"',
303
+ severity: 'high',
304
+ action: 'alert',
305
+ enabled: true
306
+ },
307
+ {
308
+ id: 'azure_storage_key',
309
+ name: 'Azure Storage Account Key',
310
+ description: 'Microsoft Azure storage account key',
311
+ type: 'secret',
312
+ pattern: '(?i)AccountKey=[A-Za-z0-9+/=]{88}',
313
+ severity: 'critical',
314
+ action: 'alert',
315
+ enabled: true
316
+ },
317
+ {
318
+ id: 'sendgrid_api_key',
319
+ name: 'SendGrid API Key',
320
+ description: 'SendGrid email API key',
321
+ type: 'secret',
322
+ pattern: 'SG\\.[A-Za-z0-9_-]{22}\\.[A-Za-z0-9_-]{43}',
323
+ severity: 'high',
324
+ action: 'alert',
325
+ enabled: true
326
+ },
327
+ {
328
+ id: 'twilio_api_key',
329
+ name: 'Twilio API Key',
330
+ description: 'Twilio API key or auth token',
331
+ type: 'secret',
332
+ pattern: 'SK[a-f0-9]{32}',
333
+ severity: 'high',
334
+ action: 'alert',
335
+ enabled: true
336
+ },
337
+ {
338
+ id: 'mailchimp_api_key',
339
+ name: 'Mailchimp API Key',
340
+ description: 'Mailchimp API key',
341
+ type: 'secret',
342
+ pattern: '[a-f0-9]{32}-us[0-9]{1,2}',
343
+ severity: 'medium',
344
+ action: 'alert',
345
+ enabled: true
346
+ }
347
+ ];
348
+
349
+ // ============================================================================
350
+ // PII Detection Patterns
351
+ // ============================================================================
352
+
353
+ export const PII_PATTERNS: DetectionRule[] = [
354
+ {
355
+ id: 'ssn_us',
356
+ name: 'US Social Security Number',
357
+ description: 'US Social Security Number (XXX-XX-XXXX format)',
358
+ type: 'pii',
359
+ pattern: '(?<!\\d)\\d{3}-\\d{2}-\\d{4}(?!\\d)',
360
+ severity: 'high',
361
+ action: 'alert',
362
+ enabled: true
363
+ },
364
+ {
365
+ id: 'credit_card',
366
+ name: 'Credit Card Number',
367
+ description: 'Credit card number (major providers)',
368
+ type: 'pii',
369
+ pattern: '(?<!\\d)(4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})(?!\\d)',
370
+ severity: 'high',
371
+ action: 'alert',
372
+ enabled: true
373
+ },
374
+ {
375
+ id: 'email_address',
376
+ name: 'Email Address',
377
+ description: 'Email address pattern',
378
+ type: 'pii',
379
+ pattern: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}',
380
+ severity: 'low',
381
+ action: 'log',
382
+ enabled: true
383
+ },
384
+ {
385
+ id: 'phone_number_us',
386
+ name: 'US Phone Number',
387
+ description: 'US phone number in various formats',
388
+ type: 'pii',
389
+ pattern: '(?<!\\d)(\\+?1[-.]?)?\\(?[0-9]{3}\\)?[-.]?[0-9]{3}[-.]?[0-9]{4}(?!\\d)',
390
+ severity: 'low',
391
+ action: 'log',
392
+ enabled: true
393
+ },
394
+ {
395
+ id: 'ip_address',
396
+ name: 'IP Address',
397
+ description: 'IPv4 address',
398
+ type: 'pii',
399
+ pattern: '(?<!\\d)(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?!\\d)',
400
+ severity: 'info',
401
+ action: 'log',
402
+ enabled: false
403
+ }
404
+ ];
405
+
406
+ // ============================================================================
407
+ // Code Pattern Detection (Dangerous Operations)
408
+ // ============================================================================
409
+
410
+ export const CODE_PATTERNS: DetectionRule[] = [
411
+ {
412
+ id: 'shell_injection',
413
+ name: 'Potential Shell Injection',
414
+ description: 'Code that may be vulnerable to shell injection',
415
+ type: 'code_pattern',
416
+ pattern: '(?i)(child_process\\.exec|os\\.system|subprocess\\.call|eval\\(|exec\\().*\\$|.*\\{.*\\}',
417
+ severity: 'medium',
418
+ action: 'alert',
419
+ enabled: true
420
+ },
421
+ {
422
+ id: 'sql_injection_pattern',
423
+ name: 'Potential SQL Injection',
424
+ description: 'String concatenation in SQL queries',
425
+ type: 'code_pattern',
426
+ pattern: '(?i)(SELECT|INSERT|UPDATE|DELETE|DROP).*\\+.*\\$|f".*SELECT.*\\{|f".*INSERT.*\\{',
427
+ severity: 'medium',
428
+ action: 'alert',
429
+ enabled: true
430
+ },
431
+ {
432
+ id: 'dangerous_chmod',
433
+ name: 'Dangerous chmod',
434
+ description: 'chmod with overly permissive permissions',
435
+ type: 'code_pattern',
436
+ pattern: 'chmod\\s+([0-7]*7[0-7]{2}|777|\\+x)',
437
+ severity: 'medium',
438
+ action: 'alert',
439
+ enabled: true
440
+ },
441
+ {
442
+ id: 'rm_rf',
443
+ name: 'Recursive Force Delete',
444
+ description: 'Potentially dangerous rm -rf command',
445
+ type: 'code_pattern',
446
+ pattern: 'rm\\s+-[rf]{1,2}\\s+(/|\\$|~|\\.\\.|\\*)',
447
+ severity: 'high',
448
+ action: 'alert',
449
+ enabled: true
450
+ },
451
+ {
452
+ id: 'curl_bash',
453
+ name: 'Curl to Bash',
454
+ description: 'Piping curl output to bash (dangerous)',
455
+ type: 'code_pattern',
456
+ pattern: 'curl\\s+.*\\|\\s*(ba)?sh',
457
+ severity: 'high',
458
+ action: 'alert',
459
+ enabled: true
460
+ },
461
+ {
462
+ id: 'base64_decode_exec',
463
+ name: 'Base64 Decode Execute',
464
+ description: 'Decoding and executing base64 content',
465
+ type: 'code_pattern',
466
+ pattern: '(?i)(base64\\s+-d|atob|Buffer\\.from.*base64).*\\|.*(sh|eval|exec)',
467
+ severity: 'high',
468
+ action: 'alert',
469
+ enabled: true
470
+ },
471
+ {
472
+ id: 'disable_ssl_verify',
473
+ name: 'SSL Verification Disabled',
474
+ description: 'Code that disables SSL certificate verification',
475
+ type: 'code_pattern',
476
+ pattern: '(?i)(verify\\s*=\\s*False|rejectUnauthorized\\s*:\\s*false|CURLOPT_SSL_VERIFYPEER\\s*,\\s*0|InsecureSkipVerify\\s*:\\s*true)',
477
+ severity: 'medium',
478
+ action: 'alert',
479
+ enabled: true
480
+ }
481
+ ];
482
+
483
+ // ============================================================================
484
+ // Injection Detection Patterns
485
+ // ============================================================================
486
+
487
+ export const INJECTION_PATTERNS: DetectionRule[] = [
488
+ {
489
+ id: 'prompt_injection_ignore',
490
+ name: 'Prompt Injection - Ignore Instructions',
491
+ description: 'Attempts to make AI ignore previous instructions',
492
+ type: 'injection',
493
+ pattern: '(?i)(ignore\\s+(all\\s+)?(previous|prior|above)\\s+(instructions?|prompts?|context)|disregard\\s+(everything|all)\\s+(above|before))',
494
+ severity: 'high',
495
+ action: 'alert',
496
+ enabled: true
497
+ },
498
+ {
499
+ id: 'prompt_injection_jailbreak',
500
+ name: 'Prompt Injection - Jailbreak Attempt',
501
+ description: 'Common jailbreak patterns',
502
+ type: 'injection',
503
+ pattern: '(?i)(DAN\\s+mode|do\\s+anything\\s+now|pretend\\s+you\\s+(are|have)\\s+no\\s+(restrictions|limits)|act\\s+as\\s+(if|an?)\\s+(unrestricted|unfiltered))',
504
+ severity: 'high',
505
+ action: 'alert',
506
+ enabled: true
507
+ },
508
+ {
509
+ id: 'prompt_injection_system',
510
+ name: 'Prompt Injection - System Prompt Extraction',
511
+ description: 'Attempts to extract system prompts',
512
+ type: 'injection',
513
+ pattern: '(?i)(show\\s+(me\\s+)?(your|the)\\s+(system\\s+)?prompt|what\\s+(are|is)\\s+your\\s+(instructions?|rules?)|reveal\\s+(your\\s+)?(system|hidden)\\s+(prompt|instructions?))',
514
+ severity: 'medium',
515
+ action: 'alert',
516
+ enabled: true
517
+ },
518
+ {
519
+ id: 'prompt_injection_roleplay',
520
+ name: 'Prompt Injection - Malicious Roleplay',
521
+ description: 'Roleplay instructions that may bypass safety',
522
+ type: 'injection',
523
+ pattern: '(?i)(you\\s+are\\s+now\\s+(evil|malicious|unrestricted)|roleplay\\s+as\\s+(a\\s+)?(hacker|criminal)|pretend\\s+(to\\s+be|you\\s+are)\\s+(a\\s+)?(virus|malware))',
524
+ severity: 'medium',
525
+ action: 'alert',
526
+ enabled: true
527
+ }
528
+ ];
529
+
530
+ // ============================================================================
531
+ // Exfiltration Detection Patterns
532
+ // ============================================================================
533
+
534
+ export const EXFILTRATION_PATTERNS: DetectionRule[] = [
535
+ {
536
+ id: 'suspicious_url_post',
537
+ name: 'Suspicious Data POST',
538
+ description: 'POST requests to suspicious or unknown domains',
539
+ type: 'exfiltration',
540
+ pattern: '(?i)(fetch|axios|request|http\\.post|requests\\.post|curl\\s+-X\\s+POST).*\\b(ngrok|webhook\\.site|requestbin|pipedream|beeceptor|mockbin|postb\\.in)\\b',
541
+ severity: 'high',
542
+ action: 'alert',
543
+ enabled: true
544
+ },
545
+ {
546
+ id: 'dns_exfiltration',
547
+ name: 'DNS Exfiltration Pattern',
548
+ description: 'Potential DNS-based data exfiltration',
549
+ type: 'exfiltration',
550
+ pattern: '(?i)(nslookup|dig|host)\\s+[A-Za-z0-9+/=]{20,}\\.',
551
+ severity: 'high',
552
+ action: 'alert',
553
+ enabled: true
554
+ },
555
+ {
556
+ id: 'data_encoding_suspicious',
557
+ name: 'Suspicious Data Encoding',
558
+ description: 'Base64 or hex encoding of potentially sensitive data',
559
+ type: 'exfiltration',
560
+ pattern: '(?i)(btoa|Buffer\\.from|base64\\.b64encode).*\\b(password|secret|key|token|credential)\\b',
561
+ severity: 'medium',
562
+ action: 'alert',
563
+ enabled: true
564
+ }
565
+ ];
566
+
567
+ // ============================================================================
568
+ // Dangerous URL Patterns
569
+ // ============================================================================
570
+
571
+ export const DANGEROUS_URL_PATTERNS = [
572
+ // Data exfiltration services
573
+ /webhook\.site/i,
574
+ /requestbin\.(com|net)/i,
575
+ /pipedream\.net/i,
576
+ /beeceptor\.com/i,
577
+ /mockbin\.org/i,
578
+ /postb\.in/i,
579
+ /hookbin\.com/i,
580
+
581
+ // Temporary file sharing
582
+ /file\.io/i,
583
+ /transfer\.sh/i,
584
+ /0x0\.st/i,
585
+
586
+ // Known malicious TLDs
587
+ /\.(tk|ml|ga|cf|gq)$/i,
588
+
589
+ // IP addresses (usually suspicious)
590
+ /^https?:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/,
591
+ ];
592
+
593
+ // ============================================================================
594
+ // All Default Rules Combined
595
+ // ============================================================================
596
+
597
+ export const DEFAULT_RULES: DetectionRule[] = [
598
+ ...SECRET_PATTERNS,
599
+ ...PII_PATTERNS,
600
+ ...CODE_PATTERNS,
601
+ ...INJECTION_PATTERNS,
602
+ ...EXFILTRATION_PATTERNS
603
+ ];