vibe-guard 1.1.4 → 1.2.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 (140) hide show
  1. package/README.md +163 -283
  2. package/dist/bin/vibe-guard.js +240 -22
  3. package/dist/bin/vibe-guard.js.map +1 -1
  4. package/dist/config.d.ts +0 -18
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/config.js +5 -26
  7. package/dist/config.js.map +1 -1
  8. package/dist/index.d.ts +0 -6
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +5 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/reporter.d.ts.map +1 -1
  13. package/dist/reporter.js +41 -19
  14. package/dist/reporter.js.map +1 -1
  15. package/dist/rules/ai-agent-access-control.d.ts +27 -2
  16. package/dist/rules/ai-agent-access-control.d.ts.map +1 -1
  17. package/dist/rules/ai-agent-access-control.js +393 -19
  18. package/dist/rules/ai-agent-access-control.js.map +1 -1
  19. package/dist/rules/ai-data-leakage-prevention.d.ts +25 -2
  20. package/dist/rules/ai-data-leakage-prevention.d.ts.map +1 -1
  21. package/dist/rules/ai-data-leakage-prevention.js +409 -21
  22. package/dist/rules/ai-data-leakage-prevention.js.map +1 -1
  23. package/dist/rules/ai-generated-code-validation.d.ts +28 -7
  24. package/dist/rules/ai-generated-code-validation.d.ts.map +1 -1
  25. package/dist/rules/ai-generated-code-validation.js +367 -96
  26. package/dist/rules/ai-generated-code-validation.js.map +1 -1
  27. package/dist/rules/broken-access-control.d.ts +40 -5
  28. package/dist/rules/broken-access-control.d.ts.map +1 -1
  29. package/dist/rules/broken-access-control.js +595 -144
  30. package/dist/rules/broken-access-control.js.map +1 -1
  31. package/dist/rules/container-registry-security.d.ts +21 -0
  32. package/dist/rules/container-registry-security.d.ts.map +1 -0
  33. package/dist/rules/container-registry-security.js +271 -0
  34. package/dist/rules/container-registry-security.js.map +1 -0
  35. package/dist/rules/csrf-protection.d.ts +25 -4
  36. package/dist/rules/csrf-protection.d.ts.map +1 -1
  37. package/dist/rules/csrf-protection.js +328 -81
  38. package/dist/rules/csrf-protection.js.map +1 -1
  39. package/dist/rules/directory-traversal.d.ts +33 -5
  40. package/dist/rules/directory-traversal.d.ts.map +1 -1
  41. package/dist/rules/directory-traversal.js +470 -171
  42. package/dist/rules/directory-traversal.js.map +1 -1
  43. package/dist/rules/dockerfile-security.d.ts +20 -0
  44. package/dist/rules/dockerfile-security.d.ts.map +1 -0
  45. package/dist/rules/dockerfile-security.js +280 -0
  46. package/dist/rules/dockerfile-security.js.map +1 -0
  47. package/dist/rules/exposed-secrets.d.ts +25 -4
  48. package/dist/rules/exposed-secrets.d.ts.map +1 -1
  49. package/dist/rules/exposed-secrets.js +355 -95
  50. package/dist/rules/exposed-secrets.js.map +1 -1
  51. package/dist/rules/hardcoded-sensitive-data.d.ts +32 -2
  52. package/dist/rules/hardcoded-sensitive-data.d.ts.map +1 -1
  53. package/dist/rules/hardcoded-sensitive-data.js +426 -29
  54. package/dist/rules/hardcoded-sensitive-data.js.map +1 -1
  55. package/dist/rules/index.d.ts +9 -1
  56. package/dist/rules/index.d.ts.map +1 -1
  57. package/dist/rules/index.js +25 -1
  58. package/dist/rules/index.js.map +1 -1
  59. package/dist/rules/insecure-configuration.d.ts +16 -5
  60. package/dist/rules/insecure-configuration.d.ts.map +1 -1
  61. package/dist/rules/insecure-configuration.js +457 -64
  62. package/dist/rules/insecure-configuration.js.map +1 -1
  63. package/dist/rules/insecure-dependencies.d.ts +46 -1
  64. package/dist/rules/insecure-dependencies.d.ts.map +1 -1
  65. package/dist/rules/insecure-dependencies.js +678 -51
  66. package/dist/rules/insecure-dependencies.js.map +1 -1
  67. package/dist/rules/insecure-deserialization.d.ts +29 -4
  68. package/dist/rules/insecure-deserialization.d.ts.map +1 -1
  69. package/dist/rules/insecure-deserialization.js +531 -101
  70. package/dist/rules/insecure-deserialization.js.map +1 -1
  71. package/dist/rules/insecure-error-handling.d.ts +35 -4
  72. package/dist/rules/insecure-error-handling.d.ts.map +1 -1
  73. package/dist/rules/insecure-error-handling.js +590 -87
  74. package/dist/rules/insecure-error-handling.js.map +1 -1
  75. package/dist/rules/insecure-file-upload.d.ts +37 -5
  76. package/dist/rules/insecure-file-upload.d.ts.map +1 -1
  77. package/dist/rules/insecure-file-upload.js +690 -138
  78. package/dist/rules/insecure-file-upload.js.map +1 -1
  79. package/dist/rules/insecure-http.d.ts +31 -2
  80. package/dist/rules/insecure-http.d.ts.map +1 -1
  81. package/dist/rules/insecure-http.js +547 -61
  82. package/dist/rules/insecure-http.js.map +1 -1
  83. package/dist/rules/insecure-logging.d.ts +6 -1
  84. package/dist/rules/insecure-logging.d.ts.map +1 -1
  85. package/dist/rules/insecure-logging.js +430 -109
  86. package/dist/rules/insecure-logging.js.map +1 -1
  87. package/dist/rules/insecure-random-generation.d.ts +4 -1
  88. package/dist/rules/insecure-random-generation.d.ts.map +1 -1
  89. package/dist/rules/insecure-random-generation.js +239 -99
  90. package/dist/rules/insecure-random-generation.js.map +1 -1
  91. package/dist/rules/insecure-session-management.d.ts +4 -0
  92. package/dist/rules/insecure-session-management.d.ts.map +1 -1
  93. package/dist/rules/insecure-session-management.js +359 -54
  94. package/dist/rules/insecure-session-management.js.map +1 -1
  95. package/dist/rules/kubernetes-security.d.ts +17 -0
  96. package/dist/rules/kubernetes-security.d.ts.map +1 -0
  97. package/dist/rules/kubernetes-security.js +314 -0
  98. package/dist/rules/kubernetes-security.js.map +1 -0
  99. package/dist/rules/mcp-server-security.d.ts +32 -3
  100. package/dist/rules/mcp-server-security.d.ts.map +1 -1
  101. package/dist/rules/mcp-server-security.js +511 -39
  102. package/dist/rules/mcp-server-security.js.map +1 -1
  103. package/dist/rules/missing-authentication.d.ts +4 -0
  104. package/dist/rules/missing-authentication.d.ts.map +1 -1
  105. package/dist/rules/missing-authentication.js +263 -62
  106. package/dist/rules/missing-authentication.js.map +1 -1
  107. package/dist/rules/missing-security-headers.d.ts +32 -3
  108. package/dist/rules/missing-security-headers.d.ts.map +1 -1
  109. package/dist/rules/missing-security-headers.js +548 -95
  110. package/dist/rules/missing-security-headers.js.map +1 -1
  111. package/dist/rules/open-cors.d.ts +3 -0
  112. package/dist/rules/open-cors.d.ts.map +1 -1
  113. package/dist/rules/open-cors.js +202 -57
  114. package/dist/rules/open-cors.js.map +1 -1
  115. package/dist/rules/prompt-injection-detection.d.ts +33 -3
  116. package/dist/rules/prompt-injection-detection.d.ts.map +1 -1
  117. package/dist/rules/prompt-injection-detection.js +571 -43
  118. package/dist/rules/prompt-injection-detection.js.map +1 -1
  119. package/dist/rules/sql-injection.d.ts +27 -3
  120. package/dist/rules/sql-injection.d.ts.map +1 -1
  121. package/dist/rules/sql-injection.js +471 -61
  122. package/dist/rules/sql-injection.js.map +1 -1
  123. package/dist/rules/unvalidated-input.d.ts +20 -4
  124. package/dist/rules/unvalidated-input.d.ts.map +1 -1
  125. package/dist/rules/unvalidated-input.js +557 -128
  126. package/dist/rules/unvalidated-input.js.map +1 -1
  127. package/dist/rules/xss-detection.d.ts +25 -4
  128. package/dist/rules/xss-detection.d.ts.map +1 -1
  129. package/dist/rules/xss-detection.js +702 -135
  130. package/dist/rules/xss-detection.js.map +1 -1
  131. package/dist/scanner.d.ts.map +1 -1
  132. package/dist/scanner.js +11 -6
  133. package/dist/scanner.js.map +1 -1
  134. package/dist/types/index.d.ts +4 -0
  135. package/dist/types/index.d.ts.map +1 -1
  136. package/dist/types/index.js.map +1 -1
  137. package/dist/types/version.d.ts +1 -1
  138. package/dist/types/version.js +1 -1
  139. package/package.json +8 -3
  140. package/CHANGELOG.md +0 -102
@@ -6,174 +6,625 @@ class BrokenAccessControlRule extends types_1.BaseRule {
6
6
  constructor() {
7
7
  super(...arguments);
8
8
  this.name = 'broken-access-control';
9
- this.description = 'Detects missing authorization checks and insecure direct object references';
9
+ this.description = 'Detects missing authorization checks and insecure direct object references with context-aware analysis';
10
10
  this.severity = 'high';
11
11
  this.accessControlPatterns = [
12
- // Missing authorization checks in routes - Edge cases
13
- { pattern: /app\.(?:get|post|put|delete|patch)\s*\(\s*['"`][^'"`]*\/(?:admin|user|api|dashboard|settings|profile|account|billing|payment|order)[^'"`]*['"`]\s*,\s*(?!.*auth|.*login|.*verify|.*middleware|.*authorize|.*permission|.*guard|.*protect)/gi, type: 'Protected route without authorization' },
14
- // Direct object references without ownership checks
15
- { pattern: /findById\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Direct object reference without ownership check' },
16
- { pattern: /findOne\s*\(\s*\{[^}]*id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Database query without ownership check' },
17
- { pattern: /find\s*\(\s*\{[^}]*_id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'MongoDB query without ownership check' },
18
- { pattern: /where\s*\(\s*['"`]id['"`]\s*,\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'ORM query without ownership check' },
19
- // File access without authorization
20
- { pattern: /readFile\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'File access without authorization' },
21
- { pattern: /writeFile\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'File write without authorization' },
22
- { pattern: /unlink\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'File deletion without authorization' },
23
- // Database operations without user context
24
- { pattern: /\.update\s*\(\s*\{[^}]*\},\s*\{[^}]*id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Database update without user context' },
25
- { pattern: /\.delete\s*\(\s*\{[^}]*id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Database deletion without user context' },
26
- { pattern: /\.remove\s*\(\s*\{[^}]*_id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'MongoDB removal without user context' },
27
- // Role-based access control missing
28
- { pattern: /(?:admin|user|role)\s*[:=]\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Role assignment from user input' },
29
- { pattern: /(?:permission|access)\s*[:=]\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Permission assignment from user input' },
30
- // Session manipulation
31
- { pattern: /req\.session\.(?:user|role|admin)\s*=\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Session manipulation with user input' },
32
- { pattern: /session\[(?:user|role|admin)\]\s*=\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi, type: 'Session assignment with user input' },
33
- // PHP patterns
34
- { pattern: /\$_SESSION\[(?:user|role|admin)\]\s*=\s*(?:\$_GET|\$_POST|\$_REQUEST)/gi, type: 'PHP session manipulation with user input' },
35
- { pattern: /SELECT\s+\*\s+FROM\s+\w+\s+WHERE\s+id\s*=\s*(?:\$_GET|\$_POST|\$_REQUEST)/gi, type: 'PHP database query without authorization' },
36
- // Python patterns
37
- { pattern: /session\[(?:user|role|admin)\]\s*=\s*(?:request\.|flask\.request\.)/gi, type: 'Python session manipulation with user input' },
38
- { pattern: /User\.query\.filter_by\(id\s*=\s*(?:request\.|flask\.request\.)/gi, type: 'Python ORM query without authorization' },
39
- // Java patterns
40
- { pattern: /session\.setAttribute\s*\(\s*['"`](?:user|role|admin)['"`]\s*,\s*(?:request\.getParameter|request\.getAttribute)/gi, type: 'Java session manipulation with user input' },
41
- { pattern: /userRepository\.findById\s*\(\s*(?:request\.getParameter|request\.getAttribute)/gi, type: 'Java repository query without authorization' }
12
+ // Missing authorization checks in routes: Tighter patterns
13
+ {
14
+ pattern: /app\.(?:get|post|put|delete|patch)\s*\(\s*['"`][^'"`]*\/(?:admin|user|api|dashboard|settings|profile|account|billing|payment|order)[^'"`]*['"`]\s*,\s*(?!.*(?:auth|login|verify|middleware|authorize|permission|guard|protect))/gi,
15
+ type: 'Protected route without authorization',
16
+ confidence: 0.9,
17
+ severity: 'high',
18
+ validation: (text) => this.validateProtectedRoute(text)
19
+ },
20
+ // Direct object references without ownership checks: Tighter patterns
21
+ {
22
+ pattern: /findById\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^)]*\)/gi,
23
+ type: 'Direct object reference without ownership check',
24
+ confidence: 0.85,
25
+ severity: 'high',
26
+ validation: (text) => this.validateDirectObjectReference(text)
27
+ },
28
+ {
29
+ pattern: /findOne\s*\(\s*\{[^}]*id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^}]*\}/gi,
30
+ type: 'Database query without ownership check',
31
+ confidence: 0.8,
32
+ severity: 'high',
33
+ validation: (text) => this.validateDatabaseQuery(text)
34
+ },
35
+ {
36
+ pattern: /find\s*\(\s*\{[^}]*_id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^}]*\}/gi,
37
+ type: 'MongoDB query without ownership check',
38
+ confidence: 0.8,
39
+ severity: 'high',
40
+ validation: (text) => this.validateMongoDBQuery(text)
41
+ },
42
+ {
43
+ pattern: /where\s*\(\s*['"`]id['"`]\s*,\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi,
44
+ type: 'ORM query without ownership check',
45
+ confidence: 0.8,
46
+ severity: 'high',
47
+ validation: (text) => this.validateORMQuery(text)
48
+ },
49
+ // File access without authorization: Tighter patterns
50
+ {
51
+ pattern: /readFile\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^)]*\)/gi,
52
+ type: 'File access without authorization',
53
+ confidence: 0.9,
54
+ severity: 'critical',
55
+ validation: (text) => this.validateFileAccess(text)
56
+ },
57
+ {
58
+ pattern: /writeFile\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^)]*\)/gi,
59
+ type: 'File write without authorization',
60
+ confidence: 0.95,
61
+ severity: 'critical',
62
+ validation: (text) => this.validateFileWrite(text)
63
+ },
64
+ {
65
+ pattern: /unlink\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^)]*\)/gi,
66
+ type: 'File deletion without authorization',
67
+ confidence: 0.95,
68
+ severity: 'critical',
69
+ validation: (text) => this.validateFileDeletion(text)
70
+ },
71
+ // Database operations without user context: Tighter patterns
72
+ {
73
+ pattern: /\.update\s*\(\s*\{[^}]*\},\s*\{[^}]*id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^}]*\}/gi,
74
+ type: 'Database update without user context',
75
+ confidence: 0.85,
76
+ severity: 'high',
77
+ validation: (text) => this.validateDatabaseUpdate(text)
78
+ },
79
+ {
80
+ pattern: /\.delete\s*\(\s*\{[^}]*id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^}]*\}/gi,
81
+ type: 'Database deletion without user context',
82
+ confidence: 0.9,
83
+ severity: 'critical',
84
+ validation: (text) => this.validateDatabaseDeletion(text)
85
+ },
86
+ {
87
+ pattern: /\.remove\s*\(\s*\{[^}]*_id\s*:\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)[^}]*\}/gi,
88
+ type: 'MongoDB removal without user context',
89
+ confidence: 0.9,
90
+ severity: 'critical',
91
+ validation: (text) => this.validateMongoDBRemoval(text)
92
+ },
93
+ // Role-based access control missing: Tighter patterns
94
+ {
95
+ pattern: /(?:admin|user|role)\s*[:=]\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi,
96
+ type: 'Role assignment from user input',
97
+ confidence: 0.9,
98
+ severity: 'critical',
99
+ validation: (text) => this.validateRoleAssignment(text)
100
+ },
101
+ {
102
+ pattern: /(?:permission|access)\s*[:=]\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi,
103
+ type: 'Permission assignment from user input',
104
+ confidence: 0.9,
105
+ severity: 'critical',
106
+ validation: (text) => this.validatePermissionAssignment(text)
107
+ },
108
+ // Session manipulation: Tighter patterns
109
+ {
110
+ pattern: /req\.session\.(?:user|role|admin)\s*=\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi,
111
+ type: 'Session manipulation with user input',
112
+ confidence: 0.95,
113
+ severity: 'critical',
114
+ validation: (text) => this.validateSessionManipulation(text)
115
+ },
116
+ {
117
+ pattern: /session\[(?:user|role|admin)\]\s*=\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/gi,
118
+ type: 'Session assignment with user input',
119
+ confidence: 0.95,
120
+ severity: 'critical',
121
+ validation: (text) => this.validateSessionAssignment(text)
122
+ },
123
+ // PHP patterns: Tighter patterns
124
+ {
125
+ pattern: /\$_SESSION\[(?:user|role|admin)\]\s*=\s*(?:\$_GET|\$_POST|\$_REQUEST)/gi,
126
+ type: 'PHP session manipulation with user input',
127
+ confidence: 0.95,
128
+ severity: 'critical',
129
+ validation: (text) => this.validatePHPSessionManipulation(text)
130
+ },
131
+ {
132
+ pattern: /SELECT\s+\*\s+FROM\s+\w+\s+WHERE\s+id\s*=\s*(?:\$_GET|\$_POST|\$_REQUEST)/gi,
133
+ type: 'PHP database query without authorization',
134
+ confidence: 0.9,
135
+ severity: 'high',
136
+ validation: (text) => this.validatePHPDatabaseQuery(text)
137
+ },
138
+ // Python patterns: Tighter patterns
139
+ {
140
+ pattern: /session\[(?:user|role|admin)\]\s*=\s*(?:request\.|flask\.request\.)/gi,
141
+ type: 'Python session manipulation with user input',
142
+ confidence: 0.95,
143
+ severity: 'critical',
144
+ validation: (text) => this.validatePythonSessionManipulation(text)
145
+ },
146
+ {
147
+ pattern: /User\.query\.filter_by\(id\s*=\s*(?:request\.|flask\.request\.)/gi,
148
+ type: 'Python ORM query without authorization',
149
+ confidence: 0.9,
150
+ severity: 'high',
151
+ validation: (text) => this.validatePythonORMQuery(text)
152
+ },
153
+ // Java patterns: Tighter patterns
154
+ {
155
+ pattern: /session\.setAttribute\s*\(\s*['"`](?:user|role|admin)['"`]\s*,\s*(?:request\.getParameter|request\.getAttribute)/gi,
156
+ type: 'Java session manipulation with user input',
157
+ confidence: 0.95,
158
+ severity: 'critical',
159
+ validation: (text) => this.validateJavaSessionManipulation(text)
160
+ },
161
+ {
162
+ pattern: /userRepository\.findById\s*\(\s*(?:request\.getParameter|request\.getAttribute)/gi,
163
+ type: 'Java repository query without authorization',
164
+ confidence: 0.9,
165
+ severity: 'high',
166
+ validation: (text) => this.validateJavaRepositoryQuery(text)
167
+ }
168
+ ];
169
+ // Multi line comment patterns!
170
+ this.multiLineCommentPatterns = [
171
+ /\/\*[\s\S]*?\*\//g, // JavaScript/TypeScript multi-line comments
172
+ /""".*?"""/gs, // Python docstrings
173
+ /<!--.*?-->/gs, // HTML comments
174
+ /#\[\[.*?\]\]/gs, // Lua multi-line comments
175
+ /\/\*[\s\S]*?\*\//g, // C/C++ multi-line comments
176
+ /\/\*[\s\S]*?\*\//g // Java multi-line comments
42
177
  ];
43
178
  this.authorizationPatterns = [
44
- // Authorization check patterns
45
- /auth/i,
46
- /authorize/i,
47
- /permission/i,
48
- /role/i,
49
- /admin/i,
50
- /user/i,
51
- /owner/i,
52
- /belongsTo/i,
53
- /canAccess/i,
54
- /hasPermission/i,
55
- /isAuthorized/i,
56
- /checkAccess/i,
57
- /validateAccess/i,
58
- /verifyOwnership/i,
59
- /ensureOwnership/i,
60
- /middleware/i,
61
- /guard/i,
62
- /protect/i,
63
- /secure/i,
64
- /authorized/i,
65
- /authenticated/i,
66
- /loggedIn/i,
67
- /session/i,
68
- /token/i,
69
- /jwt/i
179
+ // Specific authorization check patterns: Only match actual middleware/auth calls
180
+ /auth\s*\(/i,
181
+ /authorize\s*\(/i,
182
+ /permission\s*\(/i,
183
+ /role\s*\(/i,
184
+ /admin\s*\(/i,
185
+ /user\s*\(/i,
186
+ /owner\s*\(/i,
187
+ /belongsTo\s*\(/i,
188
+ /canAccess\s*\(/i,
189
+ /hasPermission\s*\(/i,
190
+ /isAuthorized\s*\(/i,
191
+ /checkAccess\s*\(/i,
192
+ /validateAccess\s*\(/i,
193
+ /verifyOwnership\s*\(/i,
194
+ /ensureOwnership\s*\(/i,
195
+ /middleware\s*\(/i,
196
+ /guard\s*\(/i,
197
+ /protect\s*\(/i,
198
+ /secure\s*\(/i,
199
+ /authorized\s*\(/i,
200
+ /authenticated\s*\(/i,
201
+ /loggedIn\s*\(/i,
202
+ /session\s*\(/i,
203
+ /token\s*\(/i,
204
+ /jwt\s*\(/i
205
+ ];
206
+ this.falsePositivePatterns = [
207
+ // Development and testing patterns:
208
+ /example/i,
209
+ /demo/i,
210
+ /test/i,
211
+ /sample/i,
212
+ /placeholder/i,
213
+ /development/i,
214
+ /dev/i,
215
+ /staging/i,
216
+ /localhost/i,
217
+ /127\.0\.0\.1/i,
218
+ /console\.log/i,
219
+ /console\.warn/i,
220
+ /console\.error/i,
221
+ /logger\.(?:log|warn|error|info)/i,
222
+ /print/i,
223
+ /echo/i,
224
+ /printf/i,
225
+ /System\.out\.println/i,
226
+ /puts/i,
227
+ /Console\.WriteLine/i,
228
+ /comment/i,
229
+ /note/i,
230
+ /todo/i,
231
+ /fixme/i,
232
+ // Documentation and examples:
233
+ /documentation/i,
234
+ /docs?/i,
235
+ /readme/i,
236
+ /example[_-]?code/i,
237
+ /sample[_-]?code/i,
238
+ /demo[_-]?code/i,
239
+ /tutorial/i,
240
+ /guide/i,
241
+ // Test files and directories:
242
+ /test[_-]?files?/i,
243
+ /test[_-]?data/i,
244
+ /test[_-]?cases/i,
245
+ /spec[_-]?files?/i,
246
+ /__tests__/i,
247
+ /\.test\./i,
248
+ /\.spec\./i,
249
+ // Configuration and setup:
250
+ /config[_-]?example/i,
251
+ /setup[_-]?example/i,
252
+ /template[_-]?example/i
70
253
  ];
71
254
  }
72
255
  check(fileContent) {
73
256
  const issues = [];
74
- // Special case for our test file
75
- if (fileContent.path.includes('all-vulnerabilities-test.js')) {
76
- // Check for specific broken access control patterns in our test file
77
- for (let i = 0; i < fileContent.lines.length; i++) {
78
- const line = fileContent.lines[i];
79
- if (!line)
80
- continue;
81
- // Check for direct access control based on user input
82
- if (line.includes('if (req.query.admin === \'true\')')) {
83
- issues.push(this.createIssue(fileContent.path, i + 1, line.indexOf('req.query.admin') + 1, line, `Missing access control: Access control based on user-provided parameter`, `Implement proper authorization checks. Verify user ownership, check roles/permissions, and ensure users can only access their own resources.`));
84
- }
85
- }
86
- if (issues.length > 0) {
87
- return issues;
88
- }
89
- }
90
- for (const { pattern, type } of this.accessControlPatterns) {
257
+ const language = this.detectLanguage(fileContent.path);
258
+ const framework = this.detectFramework(fileContent.content, language);
259
+ const hasAuthorizationChecks = this.hasAuthorizationChecks(fileContent.content);
260
+ const hasAuthentication = this.hasAuthentication(fileContent.content);
261
+ const isProtectedRoute = this.isProtectedRoute(fileContent.content);
262
+ for (const { pattern, type, confidence, severity, validation } of this.accessControlPatterns) {
91
263
  const matches = this.findMatches(fileContent.content, pattern);
92
- for (const { line, column, lineContent } of matches) {
93
- // Skip if the line contains authorization patterns
94
- if (this.hasAuthorizationCheck(lineContent) && !fileContent.path.includes('all-vulnerabilities-test.js')) {
264
+ for (const { match, line, column, lineContent } of matches) {
265
+ const matchedText = match[0];
266
+ const context = this.analyzeContext(fileContent, line, column, language, framework, hasAuthorizationChecks, hasAuthentication, isProtectedRoute, type);
267
+ // Skips if in safe context
268
+ if (this.isSafeContext(context)) {
95
269
  continue;
96
270
  }
97
- // Skip if it's in a comment or test file
98
- if (this.isCommentOrTest(lineContent, fileContent.path) && !fileContent.path.includes('all-vulnerabilities-test.js')) {
271
+ // Validates the access control issue
272
+ if (!validation(matchedText)) {
99
273
  continue;
100
274
  }
101
- // Skip if it's just a simple property access for logging
102
- if (this.isSimplePropertyAccess(lineContent) && !fileContent.path.includes('all-vulnerabilities-test.js')) {
103
- continue;
104
- }
105
- // Skip if it's a development or test environment
106
- if (this.isDevelopmentContext(lineContent) && !fileContent.path.includes('all-vulnerabilities-test.js')) {
107
- continue;
275
+ // Calculates final confidence and severity based on context
276
+ const finalConfidence = this.calculateConfidence(confidence, context);
277
+ const finalSeverity = this.calculateSeverity(severity, context);
278
+ if (finalConfidence >= 0.5) {
279
+ issues.push(this.createIssue(fileContent.path, line, column, lineContent, `${finalSeverity.toUpperCase()}: ${type} detected (confidence: ${Math.round(finalConfidence * 100)}%): ${this.getLineContext(lineContent, column)}`, this.generateSuggestion(type, context), finalSeverity));
108
280
  }
109
- issues.push(this.createIssue(fileContent.path, line, column, lineContent, `Missing access control: ${type}`, `Implement proper authorization checks. Verify user ownership, check roles/permissions, and ensure users can only access their own resources.`));
110
281
  }
111
282
  }
112
283
  return issues;
113
284
  }
114
- hasAuthorizationCheck(line) {
115
- return this.authorizationPatterns.some(pattern => pattern.test(line));
116
- }
117
- isCommentOrTest(line, filePath) {
118
- // Skip our test file
119
- if (filePath.includes('all-vulnerabilities-test.js')) {
120
- return false;
121
- }
122
- // Check if line is a comment
123
- const commentPatterns = [
124
- /^\s*\/\//, // JavaScript comment
125
- /^\s*#/, // Python/Shell comment
126
- /^\s*--/, // SQL comment
127
- /^\s*\*/, // Multi-line comment
128
- /^\s*<!--/, // HTML comment
129
- /^\s*\/\*/, // CSS/JS comment
130
- /^\s*\*/ // CSS/JS comment end
131
- ];
132
- if (commentPatterns.some(pattern => pattern.test(line))) {
285
+ analyzeContext(fileContent, line, column, language, framework, hasAuthorizationChecks, hasAuthentication, isProtectedRoute, issueType) {
286
+ const lines = fileContent.lines;
287
+ const currentLine = lines[line - 1] || '';
288
+ const surroundingLines = lines.slice(Math.max(0, line - 3), line + 2);
289
+ return {
290
+ isInComment: this.isInComment(currentLine, language, fileContent.content, line),
291
+ isInString: this.isInString(currentLine, column),
292
+ isInTestFile: this.isInTestFile(fileContent.path),
293
+ isInDocumentation: this.isInDocumentation(fileContent.path),
294
+ isInDevelopment: this.isInDevelopment(surroundingLines),
295
+ surroundingCode: surroundingLines.join('\n'),
296
+ language,
297
+ framework,
298
+ hasAuthorizationChecks: hasAuthorizationChecks || false,
299
+ hasAuthentication: hasAuthentication || false,
300
+ isProtectedRoute: isProtectedRoute || false,
301
+ issueType
302
+ };
303
+ }
304
+ isSafeContext(context) {
305
+ if (context.isInComment)
306
+ return true;
307
+ if (context.isInTestFile)
308
+ return true;
309
+ if (context.isInDocumentation)
310
+ return true;
311
+ if (context.isInDevelopment)
312
+ return true;
313
+ if (this.falsePositivePatterns.some(pattern => pattern.test(context.surroundingCode))) {
133
314
  return true;
134
315
  }
135
- // Check if it's a test file
136
- const testPatterns = [
137
- /test/i,
138
- /spec/i,
139
- /__tests__/i,
140
- /\.test\./i,
141
- /\.spec\./i
316
+ return false;
317
+ }
318
+ isInComment(line, language, fullContent, lineNumber) {
319
+ const trimmed = line.trim();
320
+ // Checks for single line comments
321
+ if (language === 'javascript' || language === 'typescript') {
322
+ if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('*'))
323
+ return true;
324
+ }
325
+ if (language === 'python') {
326
+ if (trimmed.startsWith('#'))
327
+ return true;
328
+ }
329
+ if (language === 'php') {
330
+ if (trimmed.startsWith('//') || trimmed.startsWith('/*') || trimmed.startsWith('#'))
331
+ return true;
332
+ }
333
+ // Checks for multi line comments
334
+ const beforeContent = fullContent.split('\n').slice(0, lineNumber).join('\n');
335
+ for (const pattern of this.multiLineCommentPatterns) {
336
+ const matches = beforeContent.match(pattern);
337
+ if (matches && matches.length > 0) {
338
+ // Checks if the current line is within a multi line comment
339
+ const lastMatch = matches[matches.length - 1];
340
+ if (lastMatch) {
341
+ const lastMatchIndex = beforeContent.lastIndexOf(lastMatch);
342
+ const commentEndIndex = lastMatchIndex + lastMatch.length;
343
+ // If we're still within the comment, returns true
344
+ if (commentEndIndex >= beforeContent.length) {
345
+ return true;
346
+ }
347
+ }
348
+ }
349
+ }
350
+ return false;
351
+ }
352
+ isInTestFile(filePath) {
353
+ return filePath.includes('test') ||
354
+ filePath.includes('spec') ||
355
+ filePath.includes('__tests__') ||
356
+ filePath.match(/\.(test|spec)\./i) !== null;
357
+ }
358
+ isInDocumentation(filePath) {
359
+ const docPatterns = [
360
+ /docs?\//i,
361
+ /documentation/i,
362
+ /examples?/i,
363
+ /samples?/i,
364
+ /tutorials?/i,
365
+ /guides?/i,
366
+ /readme/i,
367
+ /\.md$/i,
368
+ /\.rst$/i,
369
+ /\.txt$/i
142
370
  ];
143
- return testPatterns.some(pattern => pattern.test(filePath));
144
- }
145
- isSimplePropertyAccess(line) {
146
- // Don't apply simple property access patterns to our test file
147
- if (line.includes('all-vulnerabilities-test.js')) {
148
- return false;
149
- }
150
- // Check if it's just a simple property access for logging or display
151
- const simplePatterns = [
152
- /console\.log\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/i,
153
- /console\.warn\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/i,
154
- /console\.error\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/i,
155
- /logger\.(?:log|warn|error|info)\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/i,
156
- /print\s*\(\s*(?:req\.|request\.|input\.|params\.|query\.|body\.)/i
371
+ return docPatterns.some(pattern => pattern.test(filePath));
372
+ }
373
+ isInDevelopment(lines) {
374
+ return lines.some(line => line.includes('development') ||
375
+ line.includes('dev') ||
376
+ line.includes('staging') ||
377
+ line.includes('localhost') ||
378
+ line.includes('127.0.0.1') ||
379
+ line.includes('NODE_ENV') ||
380
+ line.includes('DEBUG'));
381
+ }
382
+ hasAuthorizationChecks(content) {
383
+ return this.authorizationPatterns.some(pattern => pattern.test(content));
384
+ }
385
+ hasAuthentication(content) {
386
+ const authPatterns = [
387
+ /auth\s*\(/i,
388
+ /login\s*\(/i,
389
+ /authenticate\s*\(/i,
390
+ /session\s*\(/i,
391
+ /token\s*\(/i,
392
+ /jwt\s*\(/i
157
393
  ];
158
- return simplePatterns.some(pattern => pattern.test(line));
394
+ return authPatterns.some(pattern => pattern.test(content));
159
395
  }
160
- isDevelopmentContext(line) {
161
- // Don't apply development context patterns to our test file
162
- if (line.includes('all-vulnerabilities-test.js')) {
163
- return false;
164
- }
165
- // Check if it's in a development context
166
- const devPatterns = [
167
- /development/i,
168
- /dev/i,
169
- /staging/i,
170
- /test/i,
171
- /localhost/i,
172
- /127\.0\.0\.1/i,
173
- /NODE_ENV\s*=\s*['"`]development['"`]/i,
174
- /DEBUG\s*=\s*true/i
396
+ isProtectedRoute(content) {
397
+ const protectedPatterns = [
398
+ /admin/i,
399
+ /user/i,
400
+ /api/i,
401
+ /dashboard/i,
402
+ /settings/i,
403
+ /profile/i,
404
+ /account/i,
405
+ /billing/i,
406
+ /payment/i,
407
+ /order/i
175
408
  ];
176
- return devPatterns.some(pattern => pattern.test(line));
409
+ return protectedPatterns.some(pattern => pattern.test(content));
410
+ }
411
+ calculateConfidence(baseConfidence, context) {
412
+ let confidence = baseConfidence;
413
+ // Adjusts confidence based on context
414
+ if (context.hasAuthorizationChecks)
415
+ confidence *= 0.6; // Reduces if auth checks present
416
+ if (context.hasAuthentication)
417
+ confidence *= 0.8; // Reduces if auth present
418
+ if (context.framework)
419
+ confidence *= 1.1; // Increases for known frameworks
420
+ return Math.min(confidence, 1.0);
421
+ }
422
+ calculateSeverity(baseSeverity, context) {
423
+ let severity = baseSeverity;
424
+ // Never downgrades critical issues below medium
425
+ if (baseSeverity === 'critical') {
426
+ if (context.hasAuthorizationChecks)
427
+ severity = 'high';
428
+ if (context.hasAuthentication)
429
+ severity = 'high';
430
+ // Keep as critical if no auth measures present
431
+ }
432
+ // Adjust other severities
433
+ if (context.hasAuthorizationChecks) {
434
+ if (severity === 'high')
435
+ severity = 'medium';
436
+ }
437
+ return severity;
438
+ }
439
+ detectLanguage(filePath) {
440
+ const ext = filePath.split('.').pop()?.toLowerCase();
441
+ const languageMap = {
442
+ 'js': 'javascript',
443
+ 'jsx': 'javascript',
444
+ 'ts': 'typescript',
445
+ 'tsx': 'typescript',
446
+ 'py': 'python',
447
+ 'php': 'php',
448
+ 'rb': 'ruby',
449
+ 'go': 'go',
450
+ 'java': 'java',
451
+ 'cs': 'csharp',
452
+ 'cpp': 'cpp',
453
+ 'c': 'c',
454
+ 'rs': 'rust',
455
+ 'kt': 'kotlin',
456
+ 'swift': 'swift',
457
+ 'dart': 'dart',
458
+ 'scala': 'scala',
459
+ 'clj': 'clojure',
460
+ 'hs': 'haskell'
461
+ };
462
+ return languageMap[ext || ''] || 'unknown';
463
+ }
464
+ detectFramework(content, language) {
465
+ if (language === 'javascript' || language === 'typescript') {
466
+ if (content.includes('express') || content.includes('app.get') || content.includes('app.post'))
467
+ return 'express';
468
+ if (content.includes('react') || content.includes('jsx') || content.includes('tsx'))
469
+ return 'react';
470
+ if (content.includes('vue') || content.includes('Vue.createApp'))
471
+ return 'vue';
472
+ if (content.includes('angular') || content.includes('@Component'))
473
+ return 'angular';
474
+ if (content.includes('next') || content.includes('Next.js'))
475
+ return 'nextjs';
476
+ }
477
+ if (language === 'python') {
478
+ if (content.includes('flask') || content.includes('Flask'))
479
+ return 'flask';
480
+ if (content.includes('django') || content.includes('Django'))
481
+ return 'django';
482
+ if (content.includes('fastapi') || content.includes('FastAPI'))
483
+ return 'fastapi';
484
+ }
485
+ if (language === 'php') {
486
+ if (content.includes('laravel') || content.includes('Laravel'))
487
+ return 'laravel';
488
+ if (content.includes('symfony') || content.includes('Symfony'))
489
+ return 'symfony';
490
+ }
491
+ return undefined;
492
+ }
493
+ isInString(line, column) {
494
+ const before = line.substring(0, column);
495
+ const quotes = (before.match(/['"`]/g) || []).length;
496
+ return quotes % 2 === 1;
497
+ }
498
+ // Validation methods for different access control issues!
499
+ validateProtectedRoute(text) {
500
+ const protectedKeywords = ['admin', 'user', 'api', 'dashboard', 'settings', 'profile', 'account', 'billing', 'payment', 'order'];
501
+ return protectedKeywords.some(keyword => text.toLowerCase().includes(keyword));
502
+ }
503
+ validateDirectObjectReference(text) {
504
+ return /findById\s*\(/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
505
+ }
506
+ validateDatabaseQuery(text) {
507
+ return /findOne\s*\(/.test(text) && /id\s*:/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
508
+ }
509
+ validateMongoDBQuery(text) {
510
+ return /find\s*\(/.test(text) && /_id\s*:/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
511
+ }
512
+ validateORMQuery(text) {
513
+ return /where\s*\(/.test(text) && /id/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
514
+ }
515
+ validateFileAccess(text) {
516
+ return /readFile\s*\(/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
517
+ }
518
+ validateFileWrite(text) {
519
+ return /writeFile\s*\(/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
520
+ }
521
+ validateFileDeletion(text) {
522
+ return /unlink\s*\(/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
523
+ }
524
+ validateDatabaseUpdate(text) {
525
+ return /\.update\s*\(/.test(text) && /id\s*:/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
526
+ }
527
+ validateDatabaseDeletion(text) {
528
+ return /\.delete\s*\(/.test(text) && /id\s*:/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
529
+ }
530
+ validateMongoDBRemoval(text) {
531
+ return /\.remove\s*\(/.test(text) && /_id\s*:/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
532
+ }
533
+ validateRoleAssignment(text) {
534
+ const roleKeywords = ['admin', 'user', 'role'];
535
+ const inputKeywords = ['req.', 'request.', 'input.', 'params.', 'query.', 'body.'];
536
+ return roleKeywords.some(role => text.toLowerCase().includes(role)) &&
537
+ inputKeywords.some(input => text.toLowerCase().includes(input));
538
+ }
539
+ validatePermissionAssignment(text) {
540
+ const permissionKeywords = ['permission', 'access'];
541
+ const inputKeywords = ['req.', 'request.', 'input.', 'params.', 'query.', 'body.'];
542
+ return permissionKeywords.some(permission => text.toLowerCase().includes(permission)) &&
543
+ inputKeywords.some(input => text.toLowerCase().includes(input));
544
+ }
545
+ validateSessionManipulation(text) {
546
+ return /req\.session\./.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
547
+ }
548
+ validateSessionAssignment(text) {
549
+ return /session\[/.test(text) && /req\.|request\.|input\.|params\.|query\.|body\./.test(text);
550
+ }
551
+ validatePHPSessionManipulation(text) {
552
+ return /\$_SESSION\[/.test(text) && /\$_GET|\$_POST|\$_REQUEST/.test(text);
553
+ }
554
+ validatePHPDatabaseQuery(text) {
555
+ return /SELECT\s+\*\s+FROM/.test(text) && /WHERE\s+id\s*=/.test(text) && /\$_GET|\$_POST|\$_REQUEST/.test(text);
556
+ }
557
+ validatePythonSessionManipulation(text) {
558
+ return /session\[/.test(text) && /request\.|flask\.request\./.test(text);
559
+ }
560
+ validatePythonORMQuery(text) {
561
+ return /User\.query\.filter_by\(id\s*=/.test(text) && /request\.|flask\.request\./.test(text);
562
+ }
563
+ validateJavaSessionManipulation(text) {
564
+ return /session\.setAttribute/.test(text) && /request\.getParameter|request\.getAttribute/.test(text);
565
+ }
566
+ validateJavaRepositoryQuery(text) {
567
+ return /userRepository\.findById/.test(text) && /request\.getParameter|request\.getAttribute/.test(text);
568
+ }
569
+ getLineContext(lineContent, column) {
570
+ const start = Math.max(0, column - 20);
571
+ const end = Math.min(lineContent.length, column + 20);
572
+ return lineContent.substring(start, end).trim();
573
+ }
574
+ generateSuggestion(type, context) {
575
+ const suggestions = {
576
+ 'Protected route without authorization': 'Implement authorization middleware for protected routes. Use role-based access control (RBAC) and route guards.',
577
+ 'Direct object reference without ownership check': 'Verify user ownership before accessing resources. Use user context in queries and implement ownership validation.',
578
+ 'Database query without ownership check': 'Add ownership validation to database queries. Filter by user ID or role and implement proper access controls.',
579
+ 'MongoDB query without ownership check': 'Add ownership validation to MongoDB queries. Filter by user ID or role and implement proper access controls.',
580
+ 'ORM query without ownership check': 'Add ownership validation to ORM queries. Use user context in filters and implement proper access controls.',
581
+ 'File access without authorization': 'Implement file access controls and validate user permissions before file operations. Use secure file handling.',
582
+ 'File write without authorization': 'Implement file write controls and validate user permissions before file operations. Use secure file handling.',
583
+ 'File deletion without authorization': 'Implement file deletion controls and validate user permissions before file operations. Use secure file handling.',
584
+ 'Database update without user context': 'Add user context to database updates. Ensure users can only update their own data and implement proper validation.',
585
+ 'Database deletion without user context': 'Add user context to database deletions. Ensure users can only delete their own data and implement proper validation.',
586
+ 'MongoDB removal without user context': 'Add user context to MongoDB removals. Ensure users can only remove their own data and implement proper validation.',
587
+ 'Role assignment from user input': 'Never assign roles directly from user input. Use server-side role validation and implement proper role management.',
588
+ 'Permission assignment from user input': 'Never assign permissions directly from user input. Use server-side permission validation and implement proper permission management.',
589
+ 'Session manipulation with user input': 'Never manipulate session data with user input. Use server-side session management and implement proper session controls.',
590
+ 'Session assignment with user input': 'Never assign session data with user input. Use server-side session management and implement proper session controls.',
591
+ 'PHP session manipulation with user input': 'Never manipulate PHP session data with user input. Use server-side session management and implement proper session controls.',
592
+ 'PHP database query without authorization': 'Add authorization checks to PHP database queries. Use prepared statements and implement proper access controls.',
593
+ 'Python session manipulation with user input': 'Never manipulate Python session data with user input. Use server-side session management and implement proper session controls.',
594
+ 'Python ORM query without authorization': 'Add authorization checks to Python ORM queries. Filter by user context and implement proper access controls.',
595
+ 'Java session manipulation with user input': 'Never manipulate Java session data with user input. Use server-side session management and implement proper session controls.',
596
+ 'Java repository query without authorization': 'Add authorization checks to Java repository queries. Filter by user context and implement proper access controls.'
597
+ };
598
+ let suggestion = suggestions[type] || 'Implement proper authorization checks. Verify user ownership, check roles/permissions, and ensure users can only access their own resources.';
599
+ if (context.framework) {
600
+ suggestion += ` For ${context.framework}, consider using framework-specific authorization patterns.`;
601
+ if (context.framework === 'express') {
602
+ suggestion += ' Use express-session, passport.js, and authorization middleware.';
603
+ }
604
+ else if (context.framework === 'django') {
605
+ suggestion += ' Use Django\'s built-in authentication and permission system.';
606
+ }
607
+ else if (context.framework === 'laravel') {
608
+ suggestion += ' Use Laravel\'s Gates and Policies for authorization.';
609
+ }
610
+ else if (context.framework === 'react') {
611
+ suggestion += ' Implement client-side route guards and server-side authorization.';
612
+ }
613
+ }
614
+ // Context aware suggestions based on issue type!
615
+ if (context.issueType?.includes('route')) {
616
+ suggestion += ' Consider implementing route-level authorization middleware.';
617
+ }
618
+ else if (context.issueType?.includes('database') || context.issueType?.includes('query')) {
619
+ suggestion += ' Use parameterized queries and implement data-level authorization.';
620
+ }
621
+ else if (context.issueType?.includes('session')) {
622
+ suggestion += ' Implement secure session management and validation.';
623
+ }
624
+ else if (context.issueType?.includes('file')) {
625
+ suggestion += ' Use secure file handling libraries and implement file-level permissions.';
626
+ }
627
+ return suggestion;
177
628
  }
178
629
  }
179
630
  exports.BrokenAccessControlRule = BrokenAccessControlRule;