@trentapps/manager-protocol 1.1.3 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +164 -17
  2. package/dist/analyzers/CSSAnalyzer.d.ts +180 -8
  3. package/dist/analyzers/CSSAnalyzer.d.ts.map +1 -1
  4. package/dist/analyzers/CSSAnalyzer.js +561 -105
  5. package/dist/analyzers/CSSAnalyzer.js.map +1 -1
  6. package/dist/config/dashboard.d.ts +55 -0
  7. package/dist/config/dashboard.d.ts.map +1 -0
  8. package/dist/config/dashboard.js +103 -0
  9. package/dist/config/dashboard.js.map +1 -0
  10. package/dist/config/index.d.ts +7 -0
  11. package/dist/config/index.d.ts.map +1 -0
  12. package/dist/config/index.js +7 -0
  13. package/dist/config/index.js.map +1 -0
  14. package/dist/dashboard/httpDashboard.d.ts +100 -0
  15. package/dist/dashboard/httpDashboard.d.ts.map +1 -0
  16. package/dist/dashboard/httpDashboard.js +1276 -0
  17. package/dist/dashboard/httpDashboard.js.map +1 -0
  18. package/dist/dashboard/index.d.ts +6 -0
  19. package/dist/dashboard/index.d.ts.map +1 -0
  20. package/dist/dashboard/index.js +7 -0
  21. package/dist/dashboard/index.js.map +1 -0
  22. package/dist/engine/AuditLogger.d.ts +370 -2
  23. package/dist/engine/AuditLogger.d.ts.map +1 -1
  24. package/dist/engine/AuditLogger.js +1064 -24
  25. package/dist/engine/AuditLogger.js.map +1 -1
  26. package/dist/engine/GitHubClient.d.ts +183 -0
  27. package/dist/engine/GitHubClient.d.ts.map +1 -0
  28. package/dist/engine/GitHubClient.js +411 -0
  29. package/dist/engine/GitHubClient.js.map +1 -0
  30. package/dist/engine/RateLimiter.d.ts +5 -3
  31. package/dist/engine/RateLimiter.d.ts.map +1 -1
  32. package/dist/engine/RateLimiter.js +49 -72
  33. package/dist/engine/RateLimiter.js.map +1 -1
  34. package/dist/engine/RuleDependencyAnalyzer.d.ts +73 -0
  35. package/dist/engine/RuleDependencyAnalyzer.d.ts.map +1 -0
  36. package/dist/engine/RuleDependencyAnalyzer.js +475 -0
  37. package/dist/engine/RuleDependencyAnalyzer.js.map +1 -0
  38. package/dist/engine/RulesEngine.d.ts +102 -3
  39. package/dist/engine/RulesEngine.d.ts.map +1 -1
  40. package/dist/engine/RulesEngine.js +326 -21
  41. package/dist/engine/RulesEngine.js.map +1 -1
  42. package/dist/engine/TaskManager.d.ts +10 -14
  43. package/dist/engine/TaskManager.d.ts.map +1 -1
  44. package/dist/engine/TaskManager.js +169 -197
  45. package/dist/engine/TaskManager.js.map +1 -1
  46. package/dist/engine/index.d.ts +3 -0
  47. package/dist/engine/index.d.ts.map +1 -1
  48. package/dist/engine/index.js +5 -0
  49. package/dist/engine/index.js.map +1 -1
  50. package/dist/rules/azure.d.ts.map +1 -1
  51. package/dist/rules/azure.js +12 -14
  52. package/dist/rules/azure.js.map +1 -1
  53. package/dist/rules/compliance.d.ts.map +1 -1
  54. package/dist/rules/compliance.js +23 -41
  55. package/dist/rules/compliance.js.map +1 -1
  56. package/dist/rules/condition-optimizer.d.ts +151 -0
  57. package/dist/rules/condition-optimizer.d.ts.map +1 -0
  58. package/dist/rules/condition-optimizer.js +479 -0
  59. package/dist/rules/condition-optimizer.js.map +1 -0
  60. package/dist/rules/css.d.ts.map +1 -1
  61. package/dist/rules/css.js +538 -0
  62. package/dist/rules/css.js.map +1 -1
  63. package/dist/rules/field-standards.d.ts +1172 -0
  64. package/dist/rules/field-standards.d.ts.map +1 -0
  65. package/dist/rules/field-standards.js +908 -0
  66. package/dist/rules/field-standards.js.map +1 -0
  67. package/dist/rules/flask.d.ts.map +1 -1
  68. package/dist/rules/flask.js +18 -31
  69. package/dist/rules/flask.js.map +1 -1
  70. package/dist/rules/index.d.ts +220 -0
  71. package/dist/rules/index.d.ts.map +1 -1
  72. package/dist/rules/index.js +155 -0
  73. package/dist/rules/index.js.map +1 -1
  74. package/dist/rules/ml-ai.d.ts.map +1 -1
  75. package/dist/rules/ml-ai.js +11 -13
  76. package/dist/rules/ml-ai.js.map +1 -1
  77. package/dist/rules/patterns.d.ts +568 -0
  78. package/dist/rules/patterns.d.ts.map +1 -0
  79. package/dist/rules/patterns.js +1359 -0
  80. package/dist/rules/patterns.js.map +1 -0
  81. package/dist/rules/security.d.ts.map +1 -1
  82. package/dist/rules/security.js +580 -19
  83. package/dist/rules/security.js.map +1 -1
  84. package/dist/rules/shared-patterns.d.ts +268 -0
  85. package/dist/rules/shared-patterns.d.ts.map +1 -0
  86. package/dist/rules/shared-patterns.js +556 -0
  87. package/dist/rules/shared-patterns.js.map +1 -0
  88. package/dist/rules/storage.d.ts +8 -2
  89. package/dist/rules/storage.d.ts.map +1 -1
  90. package/dist/rules/storage.js +541 -3
  91. package/dist/rules/storage.js.map +1 -1
  92. package/dist/rules/stripe.d.ts.map +1 -1
  93. package/dist/rules/stripe.js +19 -26
  94. package/dist/rules/stripe.js.map +1 -1
  95. package/dist/rules/websocket.d.ts.map +1 -1
  96. package/dist/rules/websocket.js +32 -40
  97. package/dist/rules/websocket.js.map +1 -1
  98. package/dist/supervisor/AgentSupervisor.d.ts +52 -0
  99. package/dist/supervisor/AgentSupervisor.d.ts.map +1 -1
  100. package/dist/supervisor/AgentSupervisor.js +120 -1
  101. package/dist/supervisor/AgentSupervisor.js.map +1 -1
  102. package/dist/supervisor/ManagedServerRegistry.d.ts +139 -2
  103. package/dist/supervisor/ManagedServerRegistry.d.ts.map +1 -1
  104. package/dist/supervisor/ManagedServerRegistry.js +590 -6
  105. package/dist/supervisor/ManagedServerRegistry.js.map +1 -1
  106. package/dist/supervisor/ProjectTracker.d.ts +2 -1
  107. package/dist/supervisor/ProjectTracker.d.ts.map +1 -1
  108. package/dist/supervisor/ProjectTracker.js +5 -9
  109. package/dist/supervisor/ProjectTracker.js.map +1 -1
  110. package/dist/testing/index.d.ts +11 -0
  111. package/dist/testing/index.d.ts.map +1 -0
  112. package/dist/testing/index.js +12 -0
  113. package/dist/testing/index.js.map +1 -0
  114. package/dist/testing/rule-tester.d.ts +217 -0
  115. package/dist/testing/rule-tester.d.ts.map +1 -0
  116. package/dist/testing/rule-tester.examples.d.ts +57 -0
  117. package/dist/testing/rule-tester.examples.d.ts.map +1 -0
  118. package/dist/testing/rule-tester.examples.js +375 -0
  119. package/dist/testing/rule-tester.examples.js.map +1 -0
  120. package/dist/testing/rule-tester.js +381 -0
  121. package/dist/testing/rule-tester.js.map +1 -0
  122. package/dist/testing/rule-validator.d.ts +141 -0
  123. package/dist/testing/rule-validator.d.ts.map +1 -0
  124. package/dist/testing/rule-validator.js +640 -0
  125. package/dist/testing/rule-validator.js.map +1 -0
  126. package/dist/types/index.d.ts +265 -4
  127. package/dist/types/index.d.ts.map +1 -1
  128. package/dist/types/index.js +57 -2
  129. package/dist/types/index.js.map +1 -1
  130. package/dist/utils/index.d.ts +2 -0
  131. package/dist/utils/index.d.ts.map +1 -1
  132. package/dist/utils/index.js +2 -0
  133. package/dist/utils/index.js.map +1 -1
  134. package/dist/utils/rate-limiting.d.ts +268 -0
  135. package/dist/utils/rate-limiting.d.ts.map +1 -0
  136. package/dist/utils/rate-limiting.js +403 -0
  137. package/dist/utils/rate-limiting.js.map +1 -0
  138. package/dist/utils/shared.d.ts +306 -0
  139. package/dist/utils/shared.d.ts.map +1 -0
  140. package/dist/utils/shared.js +464 -0
  141. package/dist/utils/shared.js.map +1 -0
  142. package/package.json +3 -2
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Built-in security rules for protecting against common vulnerabilities and threats.
5
5
  */
6
+ import { createEncryptionRule } from './shared-patterns.js';
6
7
  export const securityRules = [
7
8
  // ============================================================================
8
9
  // DATA PROTECTION RULES
@@ -24,7 +25,9 @@ export const securityRules = [
24
25
  { type: 'log' }
25
26
  ],
26
27
  riskWeight: 45,
27
- tags: ['pii', 'gdpr', 'privacy']
28
+ tags: ['pii', 'gdpr', 'privacy'],
29
+ // Task #37: Rule interdependencies
30
+ relatedRules: ['sec-002', 'sec-003'] // Related to data export and logging rules
28
31
  },
29
32
  {
30
33
  id: 'sec-002',
@@ -42,7 +45,10 @@ export const securityRules = [
42
45
  { type: 'require_approval', message: 'Bulk data export (>1000 records) requires human approval' }
43
46
  ],
44
47
  riskWeight: 35,
45
- tags: ['data-export', 'bulk-operations']
48
+ tags: ['data-export', 'bulk-operations'],
49
+ // Task #37: Rule interdependencies
50
+ dependsOn: ['sec-001'], // Check PII access authorization first
51
+ relatedRules: ['sec-003'] // Related to logging sensitive data
46
52
  },
47
53
  {
48
54
  id: 'sec-003',
@@ -61,7 +67,10 @@ export const securityRules = [
61
67
  { type: 'warn', message: 'Sensitive data should not be logged - ensure data masking is enabled' }
62
68
  ],
63
69
  riskWeight: 25,
64
- tags: ['logging', 'data-masking']
70
+ tags: ['logging', 'data-masking'],
71
+ // Task #37: Rule interdependencies
72
+ dependsOn: ['sec-001'], // PII access check should happen first
73
+ relatedRules: ['sec-002'] // Related to bulk export
65
74
  },
66
75
  // ============================================================================
67
76
  // AUTHENTICATION & AUTHORIZATION RULES
@@ -82,7 +91,9 @@ export const securityRules = [
82
91
  { type: 'deny', message: 'External API calls require authentication token' }
83
92
  ],
84
93
  riskWeight: 50,
85
- tags: ['authentication', 'api']
94
+ tags: ['authentication', 'api'],
95
+ // Task #37: Rule interdependencies
96
+ relatedRules: ['sec-011', 'sec-012', 'sec-031'] // Related auth and API rules
86
97
  },
87
98
  {
88
99
  id: 'sec-011',
@@ -102,7 +113,10 @@ export const securityRules = [
102
113
  { type: 'notify', message: 'Security alert: Privilege escalation attempt detected' }
103
114
  ],
104
115
  riskWeight: 60,
105
- tags: ['privilege-escalation', 'authorization']
116
+ tags: ['privilege-escalation', 'authorization'],
117
+ // Task #37: Rule interdependencies
118
+ dependsOn: ['sec-010'], // Check authentication before authorization
119
+ relatedRules: ['sec-012'] // Related session security
106
120
  },
107
121
  {
108
122
  id: 'sec-012',
@@ -120,7 +134,10 @@ export const securityRules = [
120
134
  { type: 'notify', message: 'Security alert: Possible session hijacking detected' }
121
135
  ],
122
136
  riskWeight: 55,
123
- tags: ['session-security', 'anomaly-detection']
137
+ tags: ['session-security', 'anomaly-detection'],
138
+ // Task #37: Rule interdependencies
139
+ dependsOn: ['sec-010'], // Check authentication first
140
+ relatedRules: ['sec-011'] // Related to privilege escalation
124
141
  },
125
142
  // ============================================================================
126
143
  // CODE EXECUTION RULES
@@ -183,24 +200,21 @@ export const securityRules = [
183
200
  riskWeight: 35,
184
201
  tags: ['network', 'whitelist']
185
202
  },
186
- {
203
+ // HTTPS for External APIs - uses shared encryption pattern
204
+ createEncryptionRule({
187
205
  id: 'sec-031',
188
206
  name: 'Enforce HTTPS for External APIs',
189
207
  description: 'Requires HTTPS for all external API communications',
190
- type: 'security',
191
- enabled: true,
208
+ encryptionType: 'transport',
209
+ scope: {
210
+ category: 'external_api'
211
+ },
212
+ actionType: 'deny',
213
+ message: 'External API calls must use HTTPS',
192
214
  priority: 930,
193
- conditions: [
194
- { field: 'actionCategory', operator: 'equals', value: 'external_api' },
195
- { field: 'protocol', operator: 'not_equals', value: 'https' }
196
- ],
197
- conditionLogic: 'all',
198
- actions: [
199
- { type: 'deny', message: 'External API calls must use HTTPS' }
200
- ],
201
215
  riskWeight: 40,
202
- tags: ['https', 'encryption', 'api']
203
- },
216
+ tags: ['https', 'api']
217
+ }),
204
218
  // ============================================================================
205
219
  // FILE SYSTEM SECURITY RULES
206
220
  // ============================================================================
@@ -281,6 +295,553 @@ export const securityRules = [
281
295
  ],
282
296
  riskWeight: 80,
283
297
  tags: ['command-injection', 'owasp']
298
+ },
299
+ // ============================================================================
300
+ // OWASP TOP 10 - PATH TRAVERSAL (A01:2021 - Broken Access Control)
301
+ // ============================================================================
302
+ {
303
+ id: 'sec-060',
304
+ name: 'Path Traversal Prevention',
305
+ description: 'Detects and blocks path traversal attacks (directory traversal)',
306
+ type: 'security',
307
+ enabled: true,
308
+ priority: 1000,
309
+ conditions: [
310
+ { field: 'actionCategory', operator: 'equals', value: 'file_system' },
311
+ { field: 'filePath', operator: 'matches_regex', value: '(\\.\\./|\\.\\.\\\\|%2e%2e%2f|%2e%2e/|\\.\\.%2f|%2e%2e%5c)' }
312
+ ],
313
+ conditionLogic: 'all',
314
+ actions: [
315
+ { type: 'deny', message: 'Path traversal attack detected - action blocked' },
316
+ { type: 'notify', message: 'Security alert: Path traversal attempt detected' }
317
+ ],
318
+ riskWeight: 85,
319
+ tags: ['path-traversal', 'owasp', 'a01-broken-access-control']
320
+ },
321
+ {
322
+ id: 'sec-061',
323
+ name: 'Null Byte Injection Prevention',
324
+ description: 'Blocks null byte injection in file paths',
325
+ type: 'security',
326
+ enabled: true,
327
+ priority: 995,
328
+ conditions: [
329
+ { field: 'actionCategory', operator: 'equals', value: 'file_system' },
330
+ { field: 'filePath', operator: 'matches_regex', value: '(%00|\\x00|\\0)' }
331
+ ],
332
+ conditionLogic: 'all',
333
+ actions: [
334
+ { type: 'deny', message: 'Null byte injection detected in file path' },
335
+ { type: 'notify', message: 'Security alert: Null byte injection attempt detected' }
336
+ ],
337
+ riskWeight: 80,
338
+ tags: ['null-byte', 'owasp', 'file-system']
339
+ },
340
+ // ============================================================================
341
+ // OWASP TOP 10 - SSRF (A10:2021 - Server-Side Request Forgery)
342
+ // ============================================================================
343
+ {
344
+ id: 'sec-070',
345
+ name: 'SSRF Prevention - Internal Network',
346
+ description: 'Blocks server-side requests to internal network addresses',
347
+ type: 'security',
348
+ enabled: true,
349
+ priority: 990,
350
+ conditions: [
351
+ { field: 'actionCategory', operator: 'equals', value: 'network' },
352
+ { field: 'targetUrl', operator: 'matches_regex', value: '(localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|10\\.|172\\.(1[6-9]|2[0-9]|3[01])\\.|192\\.168\\.|\\[::1\\]|\\[::\\])' }
353
+ ],
354
+ conditionLogic: 'all',
355
+ actions: [
356
+ { type: 'deny', message: 'SSRF attempt blocked - internal network address detected' },
357
+ { type: 'notify', message: 'Security alert: SSRF attempt to internal network' }
358
+ ],
359
+ riskWeight: 75,
360
+ tags: ['ssrf', 'owasp', 'a10-ssrf', 'network']
361
+ },
362
+ {
363
+ id: 'sec-071',
364
+ name: 'SSRF Prevention - Cloud Metadata',
365
+ description: 'Blocks server-side requests to cloud metadata endpoints',
366
+ type: 'security',
367
+ enabled: true,
368
+ priority: 995,
369
+ conditions: [
370
+ { field: 'actionCategory', operator: 'equals', value: 'network' },
371
+ { field: 'targetUrl', operator: 'matches_regex', value: '(169\\.254\\.169\\.254|metadata\\.google|metadata\\.azure)' }
372
+ ],
373
+ conditionLogic: 'all',
374
+ actions: [
375
+ { type: 'deny', message: 'SSRF attempt blocked - cloud metadata endpoint detected' },
376
+ { type: 'notify', message: 'Security alert: SSRF attempt to cloud metadata' }
377
+ ],
378
+ riskWeight: 90,
379
+ tags: ['ssrf', 'owasp', 'a10-ssrf', 'cloud-metadata']
380
+ },
381
+ {
382
+ id: 'sec-072',
383
+ name: 'SSRF Prevention - File Protocol',
384
+ description: 'Blocks server-side requests using file:// protocol',
385
+ type: 'security',
386
+ enabled: true,
387
+ priority: 990,
388
+ conditions: [
389
+ { field: 'actionCategory', operator: 'equals', value: 'network' },
390
+ { field: 'targetUrl', operator: 'matches_regex', value: '^(file|gopher|dict|ldap|tftp)://' }
391
+ ],
392
+ conditionLogic: 'all',
393
+ actions: [
394
+ { type: 'deny', message: 'SSRF attempt blocked - dangerous protocol detected' },
395
+ { type: 'notify', message: 'Security alert: SSRF attempt with dangerous protocol' }
396
+ ],
397
+ riskWeight: 85,
398
+ tags: ['ssrf', 'owasp', 'a10-ssrf', 'protocol']
399
+ },
400
+ // ============================================================================
401
+ // OWASP TOP 10 - INSECURE DESERIALIZATION (A08:2021 - Software and Data Integrity Failures)
402
+ // ============================================================================
403
+ {
404
+ id: 'sec-080',
405
+ name: 'Insecure Deserialization Prevention - Java',
406
+ description: 'Detects Java deserialization attacks',
407
+ type: 'security',
408
+ enabled: true,
409
+ priority: 985,
410
+ conditions: [
411
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
412
+ { field: 'payload', operator: 'matches_regex', value: '(rO0AB|ac ed 00 05|java\\.lang\\.(Runtime|ProcessBuilder)|ysoserial)' }
413
+ ],
414
+ conditionLogic: 'all',
415
+ actions: [
416
+ { type: 'deny', message: 'Java deserialization attack detected - action blocked' },
417
+ { type: 'notify', message: 'Security alert: Java deserialization attack attempt' }
418
+ ],
419
+ riskWeight: 90,
420
+ tags: ['deserialization', 'owasp', 'a08-integrity', 'java']
421
+ },
422
+ {
423
+ id: 'sec-081',
424
+ name: 'Insecure Deserialization Prevention - PHP',
425
+ description: 'Detects PHP object injection attacks',
426
+ type: 'security',
427
+ enabled: true,
428
+ priority: 985,
429
+ conditions: [
430
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
431
+ { field: 'payload', operator: 'matches_regex', value: '(O:\\d+:"|a:\\d+:\\{|s:\\d+:|__wakeup|__destruct|__toString)' }
432
+ ],
433
+ conditionLogic: 'all',
434
+ actions: [
435
+ { type: 'deny', message: 'PHP object injection detected - action blocked' },
436
+ { type: 'notify', message: 'Security alert: PHP object injection attempt' }
437
+ ],
438
+ riskWeight: 85,
439
+ tags: ['deserialization', 'owasp', 'a08-integrity', 'php']
440
+ },
441
+ {
442
+ id: 'sec-082',
443
+ name: 'Insecure Deserialization Prevention - Python Pickle',
444
+ description: 'Detects Python pickle deserialization attacks',
445
+ type: 'security',
446
+ enabled: true,
447
+ priority: 985,
448
+ conditions: [
449
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
450
+ { field: 'payload', operator: 'matches_regex', value: '(cos\\nsystem|posix\\nsystem|__reduce__|\\x80\\x04)' }
451
+ ],
452
+ conditionLogic: 'all',
453
+ actions: [
454
+ { type: 'deny', message: 'Python deserialization attack detected - action blocked' },
455
+ { type: 'notify', message: 'Security alert: Python deserialization attempt' }
456
+ ],
457
+ riskWeight: 85,
458
+ tags: ['deserialization', 'owasp', 'a08-integrity', 'python']
459
+ },
460
+ {
461
+ id: 'sec-083',
462
+ name: 'Insecure Deserialization Prevention - .NET',
463
+ description: 'Detects .NET deserialization attacks',
464
+ type: 'security',
465
+ enabled: true,
466
+ priority: 985,
467
+ conditions: [
468
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
469
+ { field: 'payload', operator: 'matches_regex', value: '(BinaryFormatter|ObjectStateFormatter|SoapFormatter|NetDataContractSerializer|LosFormatter)' }
470
+ ],
471
+ conditionLogic: 'all',
472
+ actions: [
473
+ { type: 'deny', message: '.NET deserialization attack detected - action blocked' },
474
+ { type: 'notify', message: 'Security alert: .NET deserialization attack attempt' }
475
+ ],
476
+ riskWeight: 85,
477
+ tags: ['deserialization', 'owasp', 'a08-integrity', 'dotnet']
478
+ },
479
+ // ============================================================================
480
+ // OWASP TOP 10 - XXE (A05:2021 - Security Misconfiguration)
481
+ // ============================================================================
482
+ {
483
+ id: 'sec-090',
484
+ name: 'XXE Prevention - External Entity',
485
+ description: 'Detects XML External Entity injection attacks',
486
+ type: 'security',
487
+ enabled: true,
488
+ priority: 995,
489
+ conditions: [
490
+ { field: 'actionCategory', operator: 'in', value: ['data_access', 'data_modification'] },
491
+ { field: 'payload', operator: 'matches_regex', value: '(<!ENTITY|<!DOCTYPE.*\\[|SYSTEM\\s+["\']|PUBLIC\\s+["\'])' }
492
+ ],
493
+ conditionLogic: 'all',
494
+ actions: [
495
+ { type: 'deny', message: 'XXE attack detected - external entity declaration blocked' },
496
+ { type: 'notify', message: 'Security alert: XXE injection attempt detected' }
497
+ ],
498
+ riskWeight: 85,
499
+ tags: ['xxe', 'owasp', 'a05-misconfiguration', 'xml']
500
+ },
501
+ {
502
+ id: 'sec-091',
503
+ name: 'XXE Prevention - Parameter Entity',
504
+ description: 'Detects XXE parameter entity attacks',
505
+ type: 'security',
506
+ enabled: true,
507
+ priority: 990,
508
+ conditions: [
509
+ { field: 'actionCategory', operator: 'in', value: ['data_access', 'data_modification'] },
510
+ { field: 'payload', operator: 'matches_regex', value: '(%[a-zA-Z0-9]+;|<!ENTITY\\s+%\\s+)' }
511
+ ],
512
+ conditionLogic: 'all',
513
+ actions: [
514
+ { type: 'deny', message: 'XXE parameter entity attack detected - action blocked' },
515
+ { type: 'notify', message: 'Security alert: XXE parameter entity attempt' }
516
+ ],
517
+ riskWeight: 80,
518
+ tags: ['xxe', 'owasp', 'a05-misconfiguration', 'xml']
519
+ },
520
+ // ============================================================================
521
+ // OWASP TOP 10 - OPEN REDIRECTS (A01:2021 - Broken Access Control)
522
+ // ============================================================================
523
+ {
524
+ id: 'sec-100',
525
+ name: 'Open Redirect Prevention',
526
+ description: 'Detects and blocks open redirect vulnerabilities',
527
+ type: 'security',
528
+ enabled: true,
529
+ priority: 920,
530
+ conditions: [
531
+ { field: 'actionCategory', operator: 'equals', value: 'network' },
532
+ { field: 'redirectUrl', operator: 'matches_regex', value: '^(https?://|//|\\\\\\\\)(?!localhost|127\\.0\\.0\\.1)' },
533
+ { field: 'redirectValidated', operator: 'not_equals', value: true }
534
+ ],
535
+ conditionLogic: 'all',
536
+ actions: [
537
+ { type: 'deny', message: 'Open redirect detected - external redirect not allowed' },
538
+ { type: 'notify', message: 'Security alert: Open redirect attempt detected' }
539
+ ],
540
+ riskWeight: 60,
541
+ tags: ['open-redirect', 'owasp', 'a01-broken-access-control']
542
+ },
543
+ {
544
+ id: 'sec-101',
545
+ name: 'Open Redirect Prevention - JavaScript Protocol',
546
+ description: 'Blocks javascript: protocol in redirects',
547
+ type: 'security',
548
+ enabled: true,
549
+ priority: 950,
550
+ conditions: [
551
+ { field: 'actionCategory', operator: 'equals', value: 'network' },
552
+ { field: 'redirectUrl', operator: 'matches_regex', value: '(javascript:|data:|vbscript:)' }
553
+ ],
554
+ conditionLogic: 'all',
555
+ actions: [
556
+ { type: 'deny', message: 'Dangerous protocol in redirect URL blocked' },
557
+ { type: 'notify', message: 'Security alert: JavaScript protocol redirect attempt' }
558
+ ],
559
+ riskWeight: 75,
560
+ tags: ['open-redirect', 'owasp', 'xss', 'a01-broken-access-control']
561
+ },
562
+ // ============================================================================
563
+ // OWASP TOP 10 - MASS ASSIGNMENT (A01:2021 - Broken Access Control)
564
+ // ============================================================================
565
+ {
566
+ id: 'sec-110',
567
+ name: 'Mass Assignment Prevention - Admin Fields',
568
+ description: 'Blocks mass assignment of admin/privileged fields',
569
+ type: 'security',
570
+ enabled: true,
571
+ priority: 960,
572
+ conditions: [
573
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
574
+ { field: 'assignedFields', operator: 'contains', value: 'isAdmin' }
575
+ ],
576
+ conditionLogic: 'all',
577
+ actions: [
578
+ { type: 'deny', message: 'Mass assignment blocked - cannot assign admin fields directly' },
579
+ { type: 'notify', message: 'Security alert: Mass assignment attempt on admin field' }
580
+ ],
581
+ riskWeight: 70,
582
+ tags: ['mass-assignment', 'owasp', 'a01-broken-access-control']
583
+ },
584
+ {
585
+ id: 'sec-111',
586
+ name: 'Mass Assignment Prevention - Role Fields',
587
+ description: 'Blocks mass assignment of role/permission fields',
588
+ type: 'security',
589
+ enabled: true,
590
+ priority: 955,
591
+ conditions: [
592
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
593
+ { field: 'assignedFields', operator: 'matches_regex', value: '(role|permission|privilege|access_level|is_superuser|is_staff)' }
594
+ ],
595
+ conditionLogic: 'all',
596
+ actions: [
597
+ { type: 'deny', message: 'Mass assignment blocked - cannot assign role/permission fields directly' },
598
+ { type: 'notify', message: 'Security alert: Mass assignment attempt on role field' }
599
+ ],
600
+ riskWeight: 70,
601
+ tags: ['mass-assignment', 'owasp', 'a01-broken-access-control']
602
+ },
603
+ {
604
+ id: 'sec-112',
605
+ name: 'Mass Assignment Prevention - Sensitive Fields',
606
+ description: 'Blocks mass assignment of password and sensitive fields',
607
+ type: 'security',
608
+ enabled: true,
609
+ priority: 965,
610
+ conditions: [
611
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
612
+ { field: 'assignedFields', operator: 'matches_regex', value: '(password|password_hash|secret|api_key|token|credit_card|ssn|account_number)' }
613
+ ],
614
+ conditionLogic: 'all',
615
+ actions: [
616
+ { type: 'deny', message: 'Mass assignment blocked - cannot assign sensitive fields directly' },
617
+ { type: 'notify', message: 'Security alert: Mass assignment attempt on sensitive field' }
618
+ ],
619
+ riskWeight: 80,
620
+ tags: ['mass-assignment', 'owasp', 'a01-broken-access-control', 'pii']
621
+ },
622
+ // ============================================================================
623
+ // OWASP TOP 10 - BROKEN ACCESS CONTROL (A01:2021)
624
+ // ============================================================================
625
+ {
626
+ id: 'sec-120',
627
+ name: 'IDOR Prevention - Direct Object Reference',
628
+ description: 'Detects insecure direct object reference patterns',
629
+ type: 'security',
630
+ enabled: true,
631
+ priority: 940,
632
+ conditions: [
633
+ { field: 'actionCategory', operator: 'equals', value: 'data_access' },
634
+ { field: 'objectId', operator: 'exists', value: null },
635
+ { field: 'ownershipVerified', operator: 'not_equals', value: true }
636
+ ],
637
+ conditionLogic: 'all',
638
+ actions: [
639
+ { type: 'require_approval', message: 'Direct object access requires ownership verification' },
640
+ { type: 'warn', message: 'IDOR risk: Ensure object ownership is verified' }
641
+ ],
642
+ riskWeight: 55,
643
+ tags: ['idor', 'owasp', 'a01-broken-access-control']
644
+ },
645
+ {
646
+ id: 'sec-121',
647
+ name: 'Horizontal Privilege Escalation Prevention',
648
+ description: 'Blocks access to resources owned by other users',
649
+ type: 'security',
650
+ enabled: true,
651
+ priority: 970,
652
+ conditions: [
653
+ { field: 'actionCategory', operator: 'in', value: ['data_access', 'data_modification'] },
654
+ { field: 'resourceOwnerId', operator: 'not_equals', value: '@userId' },
655
+ { field: 'userRole', operator: 'not_in', value: ['admin', 'superuser'] }
656
+ ],
657
+ conditionLogic: 'all',
658
+ actions: [
659
+ { type: 'deny', message: 'Access denied - resource belongs to another user' },
660
+ { type: 'notify', message: 'Security alert: Horizontal privilege escalation attempt' }
661
+ ],
662
+ riskWeight: 65,
663
+ tags: ['privilege-escalation', 'owasp', 'a01-broken-access-control']
664
+ },
665
+ {
666
+ id: 'sec-122',
667
+ name: 'Force Browsing Prevention',
668
+ description: 'Blocks access to unauthorized admin/system endpoints',
669
+ type: 'security',
670
+ enabled: true,
671
+ priority: 950,
672
+ conditions: [
673
+ { field: 'actionCategory', operator: 'equals', value: 'network' },
674
+ { field: 'targetUrl', operator: 'matches_regex', value: '(/admin|/management|/console|/debug|/actuator|/swagger|/api-docs)' },
675
+ { field: 'userRole', operator: 'not_in', value: ['admin', 'developer'] }
676
+ ],
677
+ conditionLogic: 'all',
678
+ actions: [
679
+ { type: 'deny', message: 'Access to admin endpoints denied - insufficient privileges' },
680
+ { type: 'notify', message: 'Security alert: Unauthorized admin endpoint access attempt' }
681
+ ],
682
+ riskWeight: 60,
683
+ tags: ['force-browsing', 'owasp', 'a01-broken-access-control']
684
+ },
685
+ // ============================================================================
686
+ // OWASP TOP 10 - CRYPTOGRAPHIC FAILURES (A02:2021)
687
+ // ============================================================================
688
+ {
689
+ id: 'sec-130',
690
+ name: 'Weak Cryptography Detection - MD5/SHA1',
691
+ description: 'Detects use of weak cryptographic algorithms',
692
+ type: 'security',
693
+ enabled: true,
694
+ priority: 900,
695
+ conditions: [
696
+ { field: 'actionCategory', operator: 'in', value: ['data_access', 'data_modification', 'authentication'] },
697
+ { field: 'algorithm', operator: 'in', value: ['md5', 'sha1', 'des', '3des', 'rc4', 'rc2'] }
698
+ ],
699
+ conditionLogic: 'all',
700
+ actions: [
701
+ { type: 'warn', message: 'Weak cryptographic algorithm detected - use SHA-256 or stronger' },
702
+ { type: 'log' }
703
+ ],
704
+ riskWeight: 45,
705
+ tags: ['cryptography', 'owasp', 'a02-crypto-failures']
706
+ },
707
+ {
708
+ id: 'sec-131',
709
+ name: 'Hardcoded Secrets Detection',
710
+ description: 'Detects hardcoded secrets, passwords, and API keys',
711
+ type: 'security',
712
+ enabled: true,
713
+ priority: 980,
714
+ conditions: [
715
+ { field: 'actionCategory', operator: 'equals', value: 'code_execution' },
716
+ { field: 'code', operator: 'matches_regex', value: '(password\\s*=\\s*["\'][^"\']+["\']|api[_-]?key\\s*=\\s*["\'][^"\']+["\']|secret\\s*=\\s*["\'][^"\']+["\']|-----BEGIN (RSA |DSA |EC )?PRIVATE KEY-----)' }
717
+ ],
718
+ conditionLogic: 'all',
719
+ actions: [
720
+ { type: 'deny', message: 'Hardcoded secret detected - use environment variables or secret management' },
721
+ { type: 'notify', message: 'Security alert: Hardcoded secret detected in code' }
722
+ ],
723
+ riskWeight: 75,
724
+ tags: ['secrets', 'owasp', 'a02-crypto-failures']
725
+ },
726
+ {
727
+ id: 'sec-132',
728
+ name: 'Insufficient Key Length Detection',
729
+ description: 'Detects cryptographic keys that are too short',
730
+ type: 'security',
731
+ enabled: true,
732
+ priority: 890,
733
+ conditions: [
734
+ { field: 'actionCategory', operator: 'in', value: ['authentication', 'data_modification'] },
735
+ { field: 'keyLength', operator: 'less_than', value: 2048 },
736
+ { field: 'algorithm', operator: 'in', value: ['rsa', 'dsa'] }
737
+ ],
738
+ conditionLogic: 'all',
739
+ actions: [
740
+ { type: 'warn', message: 'Cryptographic key length too short - use at least 2048 bits for RSA/DSA' },
741
+ { type: 'log' }
742
+ ],
743
+ riskWeight: 40,
744
+ tags: ['cryptography', 'owasp', 'a02-crypto-failures']
745
+ },
746
+ {
747
+ id: 'sec-133',
748
+ name: 'Insecure Random Number Generation',
749
+ description: 'Detects use of weak random number generators for security purposes',
750
+ type: 'security',
751
+ enabled: true,
752
+ priority: 910,
753
+ conditions: [
754
+ { field: 'actionCategory', operator: 'in', value: ['authentication', 'code_execution'] },
755
+ { field: 'randomGenerator', operator: 'in', value: ['Math.random', 'random.random', 'rand', 'srand'] },
756
+ { field: 'securityContext', operator: 'equals', value: true }
757
+ ],
758
+ conditionLogic: 'all',
759
+ actions: [
760
+ { type: 'warn', message: 'Weak random number generator used in security context - use cryptographically secure RNG' },
761
+ { type: 'log' }
762
+ ],
763
+ riskWeight: 50,
764
+ tags: ['cryptography', 'owasp', 'a02-crypto-failures']
765
+ },
766
+ {
767
+ id: 'sec-134',
768
+ name: 'Unencrypted Sensitive Data Storage',
769
+ description: 'Detects storage of sensitive data without encryption',
770
+ type: 'security',
771
+ enabled: true,
772
+ priority: 920,
773
+ conditions: [
774
+ { field: 'actionCategory', operator: 'equals', value: 'data_modification' },
775
+ { field: 'dataClassification', operator: 'in', value: ['confidential', 'restricted'] },
776
+ { field: 'encrypted', operator: 'not_equals', value: true }
777
+ ],
778
+ conditionLogic: 'all',
779
+ actions: [
780
+ { type: 'require_approval', message: 'Storing sensitive data without encryption requires approval' },
781
+ { type: 'warn', message: 'Sensitive data should be encrypted at rest' }
782
+ ],
783
+ riskWeight: 55,
784
+ tags: ['encryption', 'owasp', 'a02-crypto-failures', 'data-protection']
785
+ },
786
+ // ============================================================================
787
+ // OWASP TOP 10 - XSS (A03:2021 - Injection)
788
+ // ============================================================================
789
+ {
790
+ id: 'sec-140',
791
+ name: 'XSS Prevention - Script Tags',
792
+ description: 'Detects script tag injection attempts',
793
+ type: 'security',
794
+ enabled: true,
795
+ priority: 990,
796
+ conditions: [
797
+ { field: 'actionCategory', operator: 'in', value: ['data_modification', 'user_communication'] },
798
+ { field: 'payload', operator: 'matches_regex', value: '(<script|<\\/script|javascript:|on\\w+\\s*=)' }
799
+ ],
800
+ conditionLogic: 'all',
801
+ actions: [
802
+ { type: 'deny', message: 'XSS attack detected - script injection blocked' },
803
+ { type: 'notify', message: 'Security alert: XSS injection attempt detected' }
804
+ ],
805
+ riskWeight: 80,
806
+ tags: ['xss', 'owasp', 'a03-injection']
807
+ },
808
+ {
809
+ id: 'sec-141',
810
+ name: 'XSS Prevention - Event Handlers',
811
+ description: 'Detects event handler injection attempts',
812
+ type: 'security',
813
+ enabled: true,
814
+ priority: 985,
815
+ conditions: [
816
+ { field: 'actionCategory', operator: 'in', value: ['data_modification', 'user_communication'] },
817
+ { field: 'payload', operator: 'matches_regex', value: '(onerror|onload|onclick|onmouseover|onfocus|onblur|onchange|onsubmit)\\s*=' }
818
+ ],
819
+ conditionLogic: 'all',
820
+ actions: [
821
+ { type: 'deny', message: 'XSS attack detected - event handler injection blocked' },
822
+ { type: 'notify', message: 'Security alert: XSS event handler injection attempt' }
823
+ ],
824
+ riskWeight: 75,
825
+ tags: ['xss', 'owasp', 'a03-injection']
826
+ },
827
+ {
828
+ id: 'sec-142',
829
+ name: 'XSS Prevention - Data URI',
830
+ description: 'Detects data URI XSS injection attempts',
831
+ type: 'security',
832
+ enabled: true,
833
+ priority: 980,
834
+ conditions: [
835
+ { field: 'actionCategory', operator: 'in', value: ['data_modification', 'user_communication'] },
836
+ { field: 'payload', operator: 'matches_regex', value: 'data:\\s*(text\\/html|application\\/javascript|text\\/javascript)' }
837
+ ],
838
+ conditionLogic: 'all',
839
+ actions: [
840
+ { type: 'deny', message: 'XSS attack detected - data URI injection blocked' },
841
+ { type: 'notify', message: 'Security alert: XSS data URI injection attempt' }
842
+ ],
843
+ riskWeight: 70,
844
+ tags: ['xss', 'owasp', 'a03-injection']
284
845
  }
285
846
  ];
286
847
  export default securityRules;