@triedotdev/mcp 1.0.168 → 1.0.170

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 (149) hide show
  1. package/README.md +54 -500
  2. package/dist/chunk-2YXOBNKW.js +619 -0
  3. package/dist/chunk-2YXOBNKW.js.map +1 -0
  4. package/dist/chunk-QR64Y5TI.js +363 -0
  5. package/dist/chunk-QR64Y5TI.js.map +1 -0
  6. package/dist/cli/main.d.ts +0 -15
  7. package/dist/cli/main.js +356 -3100
  8. package/dist/cli/main.js.map +1 -1
  9. package/dist/index.js +2 -36
  10. package/dist/index.js.map +1 -1
  11. package/dist/server/mcp-server.js +2 -36
  12. package/package.json +8 -31
  13. package/dist/autonomy-config-FSERX3O3.js +0 -30
  14. package/dist/autonomy-config-FSERX3O3.js.map +0 -1
  15. package/dist/chat-store-JNGNTDSN.js +0 -15
  16. package/dist/chat-store-JNGNTDSN.js.map +0 -1
  17. package/dist/chunk-2HF65EHQ.js +0 -311
  18. package/dist/chunk-2HF65EHQ.js.map +0 -1
  19. package/dist/chunk-43X6JBEM.js +0 -36
  20. package/dist/chunk-43X6JBEM.js.map +0 -1
  21. package/dist/chunk-4MXH2ZPT.js +0 -1827
  22. package/dist/chunk-4MXH2ZPT.js.map +0 -1
  23. package/dist/chunk-575YT2SD.js +0 -737
  24. package/dist/chunk-575YT2SD.js.map +0 -1
  25. package/dist/chunk-5BRRRTN6.js +0 -354
  26. package/dist/chunk-5BRRRTN6.js.map +0 -1
  27. package/dist/chunk-6NLHFIYA.js +0 -344
  28. package/dist/chunk-6NLHFIYA.js.map +0 -1
  29. package/dist/chunk-7WITSO22.js +0 -824
  30. package/dist/chunk-7WITSO22.js.map +0 -1
  31. package/dist/chunk-DGUM43GV.js +0 -11
  32. package/dist/chunk-DGUM43GV.js.map +0 -1
  33. package/dist/chunk-EFWVF6TI.js +0 -267
  34. package/dist/chunk-EFWVF6TI.js.map +0 -1
  35. package/dist/chunk-F6WFNUAY.js +0 -216
  36. package/dist/chunk-F6WFNUAY.js.map +0 -1
  37. package/dist/chunk-FQ45QP5A.js +0 -361
  38. package/dist/chunk-FQ45QP5A.js.map +0 -1
  39. package/dist/chunk-G2TGF6TR.js +0 -573
  40. package/dist/chunk-G2TGF6TR.js.map +0 -1
  41. package/dist/chunk-GTKYBOXL.js +0 -700
  42. package/dist/chunk-GTKYBOXL.js.map +0 -1
  43. package/dist/chunk-HVCDY3AK.js +0 -850
  44. package/dist/chunk-HVCDY3AK.js.map +0 -1
  45. package/dist/chunk-JVMBCWKS.js +0 -348
  46. package/dist/chunk-JVMBCWKS.js.map +0 -1
  47. package/dist/chunk-KDHN2ZQE.js +0 -313
  48. package/dist/chunk-KDHN2ZQE.js.map +0 -1
  49. package/dist/chunk-LQIMKE3P.js +0 -12524
  50. package/dist/chunk-LQIMKE3P.js.map +0 -1
  51. package/dist/chunk-ME2OERF5.js +0 -345
  52. package/dist/chunk-ME2OERF5.js.map +0 -1
  53. package/dist/chunk-MRHKX5M5.js +0 -662
  54. package/dist/chunk-MRHKX5M5.js.map +0 -1
  55. package/dist/chunk-OBQ74FOU.js +0 -27
  56. package/dist/chunk-OBQ74FOU.js.map +0 -1
  57. package/dist/chunk-OMR4YCBS.js +0 -987
  58. package/dist/chunk-OMR4YCBS.js.map +0 -1
  59. package/dist/chunk-Q5EKA5YA.js +0 -254
  60. package/dist/chunk-Q5EKA5YA.js.map +0 -1
  61. package/dist/chunk-Q63FFI6D.js +0 -132
  62. package/dist/chunk-Q63FFI6D.js.map +0 -1
  63. package/dist/chunk-SY6KQG44.js +0 -983
  64. package/dist/chunk-SY6KQG44.js.map +0 -1
  65. package/dist/chunk-T63OHG4Q.js +0 -440
  66. package/dist/chunk-T63OHG4Q.js.map +0 -1
  67. package/dist/chunk-TN5WEKWI.js +0 -173
  68. package/dist/chunk-TN5WEKWI.js.map +0 -1
  69. package/dist/chunk-VUL52BQL.js +0 -402
  70. package/dist/chunk-VUL52BQL.js.map +0 -1
  71. package/dist/chunk-VVITXIHN.js +0 -189
  72. package/dist/chunk-VVITXIHN.js.map +0 -1
  73. package/dist/chunk-WCN7S3EI.js +0 -14
  74. package/dist/chunk-WCN7S3EI.js.map +0 -1
  75. package/dist/chunk-XE6KQRKZ.js +0 -816
  76. package/dist/chunk-XE6KQRKZ.js.map +0 -1
  77. package/dist/chunk-XPZZFPBZ.js +0 -491
  78. package/dist/chunk-XPZZFPBZ.js.map +0 -1
  79. package/dist/chunk-XTFWT2XM.js +0 -727
  80. package/dist/chunk-XTFWT2XM.js.map +0 -1
  81. package/dist/chunk-YDHUCDHM.js +0 -4011
  82. package/dist/chunk-YDHUCDHM.js.map +0 -1
  83. package/dist/chunk-YZ6Y2H3P.js +0 -1289
  84. package/dist/chunk-YZ6Y2H3P.js.map +0 -1
  85. package/dist/chunk-ZJF5FTBX.js +0 -1396
  86. package/dist/chunk-ZJF5FTBX.js.map +0 -1
  87. package/dist/chunk-ZV2K6M7T.js +0 -74
  88. package/dist/chunk-ZV2K6M7T.js.map +0 -1
  89. package/dist/cli/create-agent.d.ts +0 -1
  90. package/dist/cli/create-agent.js +0 -1050
  91. package/dist/cli/create-agent.js.map +0 -1
  92. package/dist/cli/yolo-daemon.d.ts +0 -1
  93. package/dist/cli/yolo-daemon.js +0 -423
  94. package/dist/cli/yolo-daemon.js.map +0 -1
  95. package/dist/client-NJPZE5JT.js +0 -28
  96. package/dist/client-NJPZE5JT.js.map +0 -1
  97. package/dist/codebase-index-VAPF32XX.js +0 -12
  98. package/dist/codebase-index-VAPF32XX.js.map +0 -1
  99. package/dist/fast-analyzer-XXYMOXRK.js +0 -216
  100. package/dist/fast-analyzer-XXYMOXRK.js.map +0 -1
  101. package/dist/git-EO5SRFMN.js +0 -28
  102. package/dist/git-EO5SRFMN.js.map +0 -1
  103. package/dist/github-ingester-ZOKK6GRS.js +0 -11
  104. package/dist/github-ingester-ZOKK6GRS.js.map +0 -1
  105. package/dist/goal-manager-YOB7VWK7.js +0 -25
  106. package/dist/goal-manager-YOB7VWK7.js.map +0 -1
  107. package/dist/goal-validator-ULKIBDPX.js +0 -24
  108. package/dist/goal-validator-ULKIBDPX.js.map +0 -1
  109. package/dist/graph-B3NA4S7I.js +0 -10
  110. package/dist/graph-B3NA4S7I.js.map +0 -1
  111. package/dist/hypothesis-7BFFT5JY.js +0 -23
  112. package/dist/hypothesis-7BFFT5JY.js.map +0 -1
  113. package/dist/incident-index-EFNUSGWL.js +0 -11
  114. package/dist/incident-index-EFNUSGWL.js.map +0 -1
  115. package/dist/insight-store-EC4PLSAW.js +0 -22
  116. package/dist/insight-store-EC4PLSAW.js.map +0 -1
  117. package/dist/issue-store-ZIRP23EP.js +0 -36
  118. package/dist/issue-store-ZIRP23EP.js.map +0 -1
  119. package/dist/ledger-TWZTGDFA.js +0 -58
  120. package/dist/ledger-TWZTGDFA.js.map +0 -1
  121. package/dist/linear-ingester-XXPAZZRW.js +0 -11
  122. package/dist/linear-ingester-XXPAZZRW.js.map +0 -1
  123. package/dist/output-manager-RVJ37XKA.js +0 -13
  124. package/dist/output-manager-RVJ37XKA.js.map +0 -1
  125. package/dist/parse-goal-violation-SACGFG3C.js +0 -8
  126. package/dist/parse-goal-violation-SACGFG3C.js.map +0 -1
  127. package/dist/pattern-discovery-F7LU5K6E.js +0 -8
  128. package/dist/pattern-discovery-F7LU5K6E.js.map +0 -1
  129. package/dist/progress-SRQ2V3BP.js +0 -18
  130. package/dist/progress-SRQ2V3BP.js.map +0 -1
  131. package/dist/project-state-AHPA77SM.js +0 -28
  132. package/dist/project-state-AHPA77SM.js.map +0 -1
  133. package/dist/sync-M2FSWPBC.js +0 -12
  134. package/dist/sync-M2FSWPBC.js.map +0 -1
  135. package/dist/terminal-spawn-5YXDMUCF.js +0 -157
  136. package/dist/terminal-spawn-5YXDMUCF.js.map +0 -1
  137. package/dist/tiered-storage-Z3YCR465.js +0 -12
  138. package/dist/tiered-storage-Z3YCR465.js.map +0 -1
  139. package/dist/trie-agent-3YDPEGHJ.js +0 -28
  140. package/dist/trie-agent-3YDPEGHJ.js.map +0 -1
  141. package/dist/ui/chat.html +0 -1014
  142. package/dist/ui/goals.html +0 -967
  143. package/dist/ui/hypotheses.html +0 -1011
  144. package/dist/ui/ledger.html +0 -954
  145. package/dist/ui/nudges.html +0 -995
  146. package/dist/vibe-code-signatures-F6URTBW3.js +0 -16
  147. package/dist/vibe-code-signatures-F6URTBW3.js.map +0 -1
  148. package/dist/vulnerability-signatures-T7SKHORW.js +0 -18
  149. package/dist/vulnerability-signatures-T7SKHORW.js.map +0 -1
@@ -1,983 +0,0 @@
1
- import {
2
- AhoCorasick
3
- } from "./chunk-6NLHFIYA.js";
4
- import {
5
- isInteractiveMode
6
- } from "./chunk-KDHN2ZQE.js";
7
-
8
- // src/trie/vulnerability-signatures.ts
9
- var ALWAYS_EXCLUDED_FILES = [
10
- /vulnerability-signatures\.[jt]s$/,
11
- // CRITICAL: Never scan ourselves!
12
- /vibe-code-signatures\.[jt]s$/,
13
- // Never scan signature files
14
- /legal\.[jt]s$/,
15
- // Legal skill contains detection patterns
16
- /security-scanner\.[jt]s$/,
17
- // Security scanner contains patterns
18
- /agent-smith\.[jt]s$/,
19
- // Agent Smith contains patterns
20
- /security\.[jt]s$/,
21
- // Security skill
22
- /privacy\.[jt]s$/,
23
- // Privacy skill
24
- /soc2\.[jt]s$/,
25
- // SOC2 skill
26
- /skills[\/\\]built-in[\/\\]/,
27
- // Never scan Trie's own skill implementations
28
- /skills[\/\\].*\.[jt]s$/,
29
- // Never scan any skills directory
30
- /trie-agents?[\/\\]src[\/\\]/,
31
- // Never scan Trie's source when installed as dependency
32
- /trie-agents?[\/\\]dist[\/\\]/,
33
- // Never scan Trie's dist when installed
34
- /package-lock\.json$/,
35
- // Lock files
36
- /yarn\.lock$/,
37
- /pnpm-lock\.yaml$/,
38
- /node_modules[\/\\]/,
39
- // Dependencies
40
- /\.d\.ts$/,
41
- // Type definitions
42
- /\.min\.[jt]s$/,
43
- // Minified files
44
- /dist[\/\\]/,
45
- // Build output
46
- /build[\/\\]/
47
- ];
48
- var EXCLUDED_FILE_PATTERNS = [
49
- /\.test\.[jt]sx?$/,
50
- // Test files
51
- /\.spec\.[jt]sx?$/,
52
- // Spec files
53
- /__tests__\//,
54
- // Test directories
55
- /\/test\//,
56
- // test/ directory
57
- /\/tests\//,
58
- // tests/ directory
59
- /\.stories\.[jt]sx?$/,
60
- // Storybook files
61
- /\.config\.[jt]s$/,
62
- // Config files
63
- /example/i,
64
- // Example files
65
- /demo/i,
66
- // Demo files
67
- /fixture/i,
68
- // Test fixtures
69
- /mock/i
70
- // Mock files
71
- ];
72
- function shouldAlwaysExcludeFile(filePath) {
73
- const normalizedPath = filePath.replace(/\\/g, "/");
74
- if (ALWAYS_EXCLUDED_FILES.some((pattern) => pattern.test(normalizedPath))) {
75
- return true;
76
- }
77
- if (normalizedPath.includes("trie") && normalizedPath.includes("/src/")) {
78
- return true;
79
- }
80
- const fileName = normalizedPath.split("/").pop() || "";
81
- const TRIE_SCANNER_FILES = [
82
- "vulnerability-signatures.ts",
83
- "vulnerability-signatures.js",
84
- "vibe-code-signatures.ts",
85
- "vibe-code-signatures.js",
86
- "legal.ts",
87
- "legal.js",
88
- "security-scanner.ts",
89
- "security-scanner.js",
90
- "agent-smith.ts",
91
- "agent-smith.js",
92
- "security.ts",
93
- "security.js",
94
- "privacy.ts",
95
- "privacy.js",
96
- "soc2.ts",
97
- "soc2.js"
98
- ];
99
- if (TRIE_SCANNER_FILES.includes(fileName)) {
100
- if (normalizedPath.includes("/skills/") || normalizedPath.includes("/trie/")) {
101
- return true;
102
- }
103
- }
104
- return false;
105
- }
106
- function shouldExcludeFile(filePath, patternCategory) {
107
- if (shouldAlwaysExcludeFile(filePath)) {
108
- return true;
109
- }
110
- if (patternCategory === "secrets" || patternCategory === "exposed-secrets") {
111
- return false;
112
- }
113
- return EXCLUDED_FILE_PATTERNS.some((pattern) => pattern.test(filePath));
114
- }
115
- var SQL_CONTEXT_KEYWORDS = [
116
- "SELECT",
117
- "INSERT",
118
- "UPDATE",
119
- "DELETE",
120
- "FROM",
121
- "WHERE",
122
- "JOIN",
123
- "query",
124
- "execute",
125
- "sql",
126
- "prisma",
127
- "knex",
128
- "sequelize",
129
- "createQueryBuilder",
130
- "rawQuery",
131
- ".raw("
132
- ];
133
- function isInSQLContext(line, surroundingLines) {
134
- const allContent = [line, ...surroundingLines].join(" ").toLowerCase();
135
- return SQL_CONTEXT_KEYWORDS.some(
136
- (keyword) => allContent.includes(keyword.toLowerCase())
137
- );
138
- }
139
- var VULNERABILITY_PATTERNS = [
140
- // ============================================
141
- // CRITICAL: Injection vulnerabilities
142
- // ============================================
143
- {
144
- pattern: "eval(",
145
- metadata: {
146
- type: "vulnerability",
147
- severity: "critical",
148
- category: "injection",
149
- description: "eval() can execute arbitrary code - potential RCE",
150
- cwe: "CWE-95",
151
- fix: "Use safer alternatives like JSON.parse() or a sandboxed interpreter"
152
- }
153
- },
154
- {
155
- pattern: "new Function(",
156
- metadata: {
157
- type: "vulnerability",
158
- severity: "critical",
159
- category: "injection",
160
- description: "new Function() can execute arbitrary code",
161
- cwe: "CWE-95",
162
- fix: "Avoid dynamic function creation from user input"
163
- }
164
- },
165
- {
166
- pattern: "exec(",
167
- metadata: {
168
- type: "vulnerability",
169
- severity: "critical",
170
- category: "injection",
171
- description: "Command execution - potential command injection",
172
- cwe: "CWE-78",
173
- fix: "Use parameterized commands and validate/sanitize all inputs"
174
- }
175
- },
176
- {
177
- pattern: "execSync(",
178
- metadata: {
179
- type: "vulnerability",
180
- severity: "critical",
181
- category: "injection",
182
- description: "Synchronous command execution - potential injection",
183
- cwe: "CWE-78",
184
- fix: "Use spawn with argument arrays instead of shell strings"
185
- }
186
- },
187
- {
188
- pattern: "spawn(",
189
- metadata: {
190
- type: "vulnerability",
191
- severity: "serious",
192
- category: "injection",
193
- description: "Process spawn - verify inputs are sanitized",
194
- cwe: "CWE-78",
195
- fix: "Use shell: false and pass arguments as array"
196
- }
197
- },
198
- {
199
- pattern: "child_process",
200
- metadata: {
201
- type: "vulnerability",
202
- severity: "serious",
203
- category: "injection",
204
- description: "Child process module - review for command injection",
205
- cwe: "CWE-78",
206
- fix: "Validate all inputs passed to child processes"
207
- }
208
- },
209
- // ============================================
210
- // CRITICAL: SQL Injection patterns
211
- // NOTE: ${} is NOT flagged here - we check SQL context in isFalsePositive
212
- // ============================================
213
- {
214
- pattern: "SELECT * FROM",
215
- metadata: {
216
- type: "vulnerability",
217
- severity: "moderate",
218
- category: "sql-injection",
219
- description: "Raw SQL query detected - verify parameterization",
220
- cwe: "CWE-89",
221
- fix: "Use ORM or parameterized queries"
222
- }
223
- },
224
- {
225
- pattern: "INSERT INTO",
226
- metadata: {
227
- type: "vulnerability",
228
- severity: "moderate",
229
- category: "sql-injection",
230
- description: "Raw SQL INSERT - verify parameterization",
231
- cwe: "CWE-89",
232
- fix: "Use parameterized queries"
233
- }
234
- },
235
- {
236
- pattern: "DELETE FROM",
237
- metadata: {
238
- type: "vulnerability",
239
- severity: "moderate",
240
- category: "sql-injection",
241
- description: "Raw SQL DELETE - verify parameterization",
242
- cwe: "CWE-89",
243
- fix: "Use parameterized queries"
244
- }
245
- },
246
- {
247
- pattern: ".raw(`",
248
- metadata: {
249
- type: "vulnerability",
250
- severity: "serious",
251
- category: "sql-injection",
252
- description: "Raw query with template literal - high injection risk",
253
- cwe: "CWE-89",
254
- fix: "Avoid raw queries with interpolation or use proper escaping"
255
- }
256
- },
257
- {
258
- pattern: ".raw('",
259
- metadata: {
260
- type: "vulnerability",
261
- severity: "moderate",
262
- category: "sql-injection",
263
- description: "Raw query method - verify for injection risk",
264
- cwe: "CWE-89",
265
- fix: "Use parameterized queries instead of raw SQL"
266
- }
267
- },
268
- {
269
- pattern: '.raw("',
270
- metadata: {
271
- type: "vulnerability",
272
- severity: "moderate",
273
- category: "sql-injection",
274
- description: "Raw query method - verify for injection risk",
275
- cwe: "CWE-89",
276
- fix: "Use parameterized queries instead of raw SQL"
277
- }
278
- },
279
- {
280
- pattern: "`SELECT",
281
- metadata: {
282
- type: "vulnerability",
283
- severity: "serious",
284
- category: "sql-injection",
285
- description: "SQL in template literal - check for injection",
286
- cwe: "CWE-89",
287
- fix: "Use parameterized queries with placeholders"
288
- }
289
- },
290
- {
291
- pattern: "`INSERT",
292
- metadata: {
293
- type: "vulnerability",
294
- severity: "serious",
295
- category: "sql-injection",
296
- description: "SQL INSERT in template literal - check for injection",
297
- cwe: "CWE-89",
298
- fix: "Use parameterized queries with placeholders"
299
- }
300
- },
301
- {
302
- pattern: "`UPDATE",
303
- metadata: {
304
- type: "vulnerability",
305
- severity: "serious",
306
- category: "sql-injection",
307
- description: "SQL UPDATE in template literal - check for injection",
308
- cwe: "CWE-89",
309
- fix: "Use parameterized queries with placeholders"
310
- }
311
- },
312
- {
313
- pattern: "`DELETE",
314
- metadata: {
315
- type: "vulnerability",
316
- severity: "serious",
317
- category: "sql-injection",
318
- description: "SQL DELETE in template literal - check for injection",
319
- cwe: "CWE-89",
320
- fix: "Use parameterized queries with placeholders"
321
- }
322
- },
323
- // ============================================
324
- // CRITICAL: XSS vulnerabilities
325
- // ============================================
326
- {
327
- pattern: "innerHTML",
328
- metadata: {
329
- type: "vulnerability",
330
- severity: "serious",
331
- category: "xss",
332
- description: "innerHTML can inject malicious scripts",
333
- cwe: "CWE-79",
334
- fix: "Use textContent or sanitize HTML with DOMPurify"
335
- }
336
- },
337
- {
338
- pattern: "outerHTML",
339
- metadata: {
340
- type: "vulnerability",
341
- severity: "serious",
342
- category: "xss",
343
- description: "outerHTML can inject malicious scripts",
344
- cwe: "CWE-79",
345
- fix: "Avoid outerHTML with user input"
346
- }
347
- },
348
- {
349
- pattern: "document.write",
350
- metadata: {
351
- type: "vulnerability",
352
- severity: "serious",
353
- category: "xss",
354
- description: "document.write can inject malicious content",
355
- cwe: "CWE-79",
356
- fix: "Use DOM methods like createElement instead"
357
- }
358
- },
359
- {
360
- pattern: "dangerouslySetInnerHTML",
361
- metadata: {
362
- type: "vulnerability",
363
- severity: "serious",
364
- category: "xss",
365
- description: "React dangerouslySetInnerHTML - XSS risk",
366
- cwe: "CWE-79",
367
- fix: "Sanitize with DOMPurify before using"
368
- }
369
- },
370
- {
371
- pattern: "v-html",
372
- metadata: {
373
- type: "vulnerability",
374
- severity: "serious",
375
- category: "xss",
376
- description: "Vue v-html directive - XSS risk",
377
- cwe: "CWE-79",
378
- fix: "Sanitize content or use v-text"
379
- }
380
- },
381
- {
382
- pattern: "[innerHTML]",
383
- metadata: {
384
- type: "vulnerability",
385
- severity: "serious",
386
- category: "xss",
387
- description: "Angular innerHTML binding - XSS risk",
388
- cwe: "CWE-79",
389
- fix: "Use Angular DomSanitizer"
390
- }
391
- },
392
- // ============================================
393
- // CRITICAL: Hardcoded secrets
394
- // More specific patterns to reduce false positives
395
- // ============================================
396
- {
397
- pattern: "password = '",
398
- metadata: {
399
- type: "vulnerability",
400
- severity: "critical",
401
- category: "secrets",
402
- description: "Hardcoded password in string",
403
- cwe: "CWE-798",
404
- fix: "Use environment variables or secret management"
405
- }
406
- },
407
- {
408
- pattern: 'password = "',
409
- metadata: {
410
- type: "vulnerability",
411
- severity: "critical",
412
- category: "secrets",
413
- description: "Hardcoded password in string",
414
- cwe: "CWE-798",
415
- fix: "Use environment variables or secret management"
416
- }
417
- },
418
- {
419
- pattern: "password: '",
420
- metadata: {
421
- type: "vulnerability",
422
- severity: "critical",
423
- category: "secrets",
424
- description: "Hardcoded password in config",
425
- cwe: "CWE-798",
426
- fix: "Use environment variables or secret management"
427
- }
428
- },
429
- {
430
- pattern: 'password: "',
431
- metadata: {
432
- type: "vulnerability",
433
- severity: "critical",
434
- category: "secrets",
435
- description: "Hardcoded password in config",
436
- cwe: "CWE-798",
437
- fix: "Use environment variables or secret management"
438
- }
439
- },
440
- {
441
- pattern: "api_key = '",
442
- metadata: {
443
- type: "vulnerability",
444
- severity: "critical",
445
- category: "secrets",
446
- description: "Hardcoded API key",
447
- cwe: "CWE-798",
448
- fix: "Use environment variables"
449
- }
450
- },
451
- {
452
- pattern: 'api_key = "',
453
- metadata: {
454
- type: "vulnerability",
455
- severity: "critical",
456
- category: "secrets",
457
- description: "Hardcoded API key",
458
- cwe: "CWE-798",
459
- fix: "Use environment variables"
460
- }
461
- },
462
- {
463
- pattern: "apiKey: '",
464
- metadata: {
465
- type: "vulnerability",
466
- severity: "critical",
467
- category: "secrets",
468
- description: "Hardcoded API key in config",
469
- cwe: "CWE-798",
470
- fix: "Use environment variables"
471
- }
472
- },
473
- {
474
- pattern: 'apiKey: "',
475
- metadata: {
476
- type: "vulnerability",
477
- severity: "critical",
478
- category: "secrets",
479
- description: "Hardcoded API key in config",
480
- cwe: "CWE-798",
481
- fix: "Use environment variables"
482
- }
483
- },
484
- {
485
- pattern: "secret = '",
486
- metadata: {
487
- type: "vulnerability",
488
- severity: "critical",
489
- category: "secrets",
490
- description: "Hardcoded secret",
491
- cwe: "CWE-798",
492
- fix: "Use environment variables or secret management"
493
- }
494
- },
495
- {
496
- pattern: 'secret = "',
497
- metadata: {
498
- type: "vulnerability",
499
- severity: "critical",
500
- category: "secrets",
501
- description: "Hardcoded secret",
502
- cwe: "CWE-798",
503
- fix: "Use environment variables or secret management"
504
- }
505
- },
506
- {
507
- pattern: "AWS_SECRET_ACCESS_KEY=",
508
- metadata: {
509
- type: "vulnerability",
510
- severity: "critical",
511
- category: "secrets",
512
- description: "AWS secret key assignment",
513
- cwe: "CWE-798",
514
- fix: "Use IAM roles or AWS Secrets Manager"
515
- }
516
- },
517
- {
518
- pattern: "'Bearer ",
519
- metadata: {
520
- type: "vulnerability",
521
- severity: "serious",
522
- category: "secrets",
523
- description: "Hardcoded bearer token in string",
524
- cwe: "CWE-798",
525
- fix: "Use environment variables for tokens"
526
- }
527
- },
528
- {
529
- pattern: '"Bearer ',
530
- metadata: {
531
- type: "vulnerability",
532
- severity: "serious",
533
- category: "secrets",
534
- description: "Hardcoded bearer token in string",
535
- cwe: "CWE-798",
536
- fix: "Use environment variables for tokens"
537
- }
538
- },
539
- // ============================================
540
- // SERIOUS: Authentication issues
541
- // ============================================
542
- {
543
- pattern: "password ==",
544
- metadata: {
545
- type: "vulnerability",
546
- severity: "critical",
547
- category: "auth",
548
- description: "Plain text password comparison",
549
- cwe: "CWE-256",
550
- fix: "Use bcrypt.compare() or similar secure comparison"
551
- }
552
- },
553
- {
554
- pattern: "password ===",
555
- metadata: {
556
- type: "vulnerability",
557
- severity: "critical",
558
- category: "auth",
559
- description: "Plain text password comparison",
560
- cwe: "CWE-256",
561
- fix: "Use bcrypt.compare() or similar secure comparison"
562
- }
563
- },
564
- {
565
- pattern: "MD5(",
566
- metadata: {
567
- type: "vulnerability",
568
- severity: "serious",
569
- category: "crypto",
570
- description: "MD5 is cryptographically broken",
571
- cwe: "CWE-328",
572
- fix: "Use SHA-256 or bcrypt for passwords"
573
- }
574
- },
575
- {
576
- pattern: "md5(",
577
- metadata: {
578
- type: "vulnerability",
579
- severity: "serious",
580
- category: "crypto",
581
- description: "MD5 is cryptographically broken",
582
- cwe: "CWE-328",
583
- fix: "Use SHA-256 or bcrypt for passwords"
584
- }
585
- },
586
- {
587
- pattern: "SHA1(",
588
- metadata: {
589
- type: "vulnerability",
590
- severity: "moderate",
591
- category: "crypto",
592
- description: "SHA1 is deprecated for security use",
593
- cwe: "CWE-328",
594
- fix: "Use SHA-256 or stronger"
595
- }
596
- },
597
- {
598
- pattern: "sha1(",
599
- metadata: {
600
- type: "vulnerability",
601
- severity: "moderate",
602
- category: "crypto",
603
- description: "SHA1 is deprecated for security use",
604
- cwe: "CWE-328",
605
- fix: "Use SHA-256 or stronger"
606
- }
607
- },
608
- {
609
- pattern: "Math.random()",
610
- metadata: {
611
- type: "vulnerability",
612
- severity: "serious",
613
- category: "crypto",
614
- description: "Math.random() is not cryptographically secure",
615
- cwe: "CWE-338",
616
- fix: "Use crypto.randomBytes() or crypto.getRandomValues()"
617
- }
618
- },
619
- // ============================================
620
- // SERIOUS: Insecure configurations
621
- // ============================================
622
- {
623
- pattern: "cors: true",
624
- metadata: {
625
- type: "vulnerability",
626
- severity: "moderate",
627
- category: "config",
628
- description: "CORS enabled - verify origin restrictions",
629
- cwe: "CWE-942",
630
- fix: "Specify allowed origins explicitly"
631
- }
632
- },
633
- {
634
- pattern: "origin: '*'",
635
- metadata: {
636
- type: "vulnerability",
637
- severity: "serious",
638
- category: "config",
639
- description: "CORS allows all origins",
640
- cwe: "CWE-942",
641
- fix: "Restrict to specific trusted origins"
642
- }
643
- },
644
- {
645
- pattern: 'origin: "*"',
646
- metadata: {
647
- type: "vulnerability",
648
- severity: "serious",
649
- category: "config",
650
- description: "CORS allows all origins",
651
- cwe: "CWE-942",
652
- fix: "Restrict to specific trusted origins"
653
- }
654
- },
655
- {
656
- pattern: "secure: false",
657
- metadata: {
658
- type: "vulnerability",
659
- severity: "serious",
660
- category: "config",
661
- description: "Insecure cookie/connection setting",
662
- cwe: "CWE-614",
663
- fix: "Set secure: true in production"
664
- }
665
- },
666
- {
667
- pattern: "httpOnly: false",
668
- metadata: {
669
- type: "vulnerability",
670
- severity: "serious",
671
- category: "config",
672
- description: "Cookie accessible to JavaScript",
673
- cwe: "CWE-1004",
674
- fix: "Set httpOnly: true to prevent XSS cookie theft"
675
- }
676
- },
677
- {
678
- pattern: "rejectUnauthorized: false",
679
- metadata: {
680
- type: "vulnerability",
681
- severity: "critical",
682
- category: "config",
683
- description: "TLS certificate validation disabled",
684
- cwe: "CWE-295",
685
- fix: "Enable certificate validation in production"
686
- }
687
- },
688
- {
689
- pattern: "NODE_TLS_REJECT_UNAUTHORIZED",
690
- metadata: {
691
- type: "vulnerability",
692
- severity: "critical",
693
- category: "config",
694
- description: "TLS validation may be disabled",
695
- cwe: "CWE-295",
696
- fix: "Never disable TLS validation in production"
697
- }
698
- },
699
- // ============================================
700
- // MODERATE: Common bugs and issues
701
- // ============================================
702
- {
703
- pattern: ".forEach(async",
704
- metadata: {
705
- type: "vulnerability",
706
- severity: "serious",
707
- category: "async",
708
- description: "async forEach does not await - unexpected behavior",
709
- cwe: "CWE-703",
710
- fix: "Use for...of loop or Promise.all(arr.map())"
711
- }
712
- },
713
- {
714
- pattern: "JSON.parse(",
715
- metadata: {
716
- type: "vulnerability",
717
- severity: "moderate",
718
- category: "error-handling",
719
- description: "JSON.parse can throw - needs try/catch",
720
- cwe: "CWE-755",
721
- fix: "Wrap in try/catch block"
722
- }
723
- },
724
- {
725
- pattern: "atob(",
726
- metadata: {
727
- type: "vulnerability",
728
- severity: "low",
729
- category: "encoding",
730
- description: "atob can throw on invalid input",
731
- cwe: "CWE-755",
732
- fix: "Wrap in try/catch and validate input"
733
- }
734
- },
735
- // ============================================
736
- // Privacy & Compliance patterns
737
- // ============================================
738
- {
739
- pattern: "console.log(",
740
- metadata: {
741
- type: "vulnerability",
742
- severity: "low",
743
- category: "logging",
744
- description: "Console logging - may leak sensitive data",
745
- cwe: "CWE-532",
746
- fix: "Remove or replace with proper logging in production"
747
- }
748
- },
749
- {
750
- pattern: "localStorage.setItem",
751
- metadata: {
752
- type: "vulnerability",
753
- severity: "moderate",
754
- category: "storage",
755
- description: "localStorage is accessible to XSS attacks",
756
- cwe: "CWE-922",
757
- fix: "Avoid storing sensitive data in localStorage"
758
- }
759
- },
760
- {
761
- pattern: "sessionStorage.setItem",
762
- metadata: {
763
- type: "vulnerability",
764
- severity: "moderate",
765
- category: "storage",
766
- description: "sessionStorage is accessible to XSS attacks",
767
- cwe: "CWE-922",
768
- fix: "Avoid storing sensitive data in sessionStorage"
769
- }
770
- }
771
- ];
772
- var vulnerabilityTrie = null;
773
- function getVulnerabilityTrie() {
774
- if (!vulnerabilityTrie) {
775
- vulnerabilityTrie = new AhoCorasick();
776
- for (const { pattern, metadata } of VULNERABILITY_PATTERNS) {
777
- vulnerabilityTrie.addPattern(pattern, metadata, metadata);
778
- }
779
- vulnerabilityTrie.build();
780
- if (!isInteractiveMode()) {
781
- console.error(` Loaded ${VULNERABILITY_PATTERNS.length} vulnerability signatures into trie`);
782
- }
783
- }
784
- return vulnerabilityTrie;
785
- }
786
- function scanForVulnerabilities(code, filePath) {
787
- if (shouldAlwaysExcludeFile(filePath)) {
788
- return [];
789
- }
790
- const trie = getVulnerabilityTrie();
791
- const rawMatches = trie.search(code);
792
- const lines = code.split("\n");
793
- const matches = [];
794
- const seen = /* @__PURE__ */ new Set();
795
- for (const match of rawMatches) {
796
- const key = `${match.line}:${match.pattern}`;
797
- if (seen.has(key)) continue;
798
- seen.add(key);
799
- const meta = match.metadata;
800
- if (shouldExcludeFile(filePath, meta.category || "")) continue;
801
- if (isFalsePositive(code, match, filePath, lines)) continue;
802
- const vulnMatch = {
803
- pattern: match.pattern,
804
- line: match.line,
805
- column: match.column,
806
- severity: meta.severity,
807
- category: meta.category || "unknown",
808
- description: meta.description || "",
809
- fix: meta.fix || ""
810
- };
811
- if (meta.cwe !== void 0) {
812
- vulnMatch.cwe = meta.cwe;
813
- }
814
- matches.push(vulnMatch);
815
- }
816
- return matches;
817
- }
818
- function getSurroundingLines(lines, lineNum, range = 3) {
819
- const start = Math.max(0, lineNum - range - 1);
820
- const end = Math.min(lines.length, lineNum + range);
821
- return lines.slice(start, end);
822
- }
823
- function isFalsePositive(_code, match, filePath, lines) {
824
- const line = lines[match.line - 1] || "";
825
- const trimmedLine = line.trim();
826
- const pattern = match.pattern;
827
- const category = match.metadata?.category || "";
828
- if (filePath.includes("signature") || filePath.includes("patterns") || filePath.includes("rules")) {
829
- if (/pattern\s*[:=]/.test(line)) {
830
- return true;
831
- }
832
- }
833
- if (/^\s*(pattern|regex|rule|signature)\s*[:=]/.test(trimmedLine)) {
834
- return true;
835
- }
836
- if (isTestFile(filePath)) {
837
- if (category === "secrets") {
838
- if (/test|mock|fake|dummy|example|fixture|sample|placeholder/i.test(line)) {
839
- return true;
840
- }
841
- if (/'[a-z_]*password[a-z_0-9]*'|"[a-z_]*password[a-z_0-9]*"|'[a-z_]*secret[a-z_0-9]*'|"[a-z_]*secret[a-z_0-9]*"/i.test(line)) {
842
- return true;
843
- }
844
- if (/sk-[a-z0-9]{10,20}"|'sk-[a-z0-9]{10,20}'|api[_-]?key.*['"][a-z0-9_-]{5,30}['"]/i.test(line)) {
845
- return true;
846
- }
847
- }
848
- return true;
849
- }
850
- if (trimmedLine.startsWith("//") || trimmedLine.startsWith("*") || trimmedLine.startsWith("/*") || trimmedLine.startsWith("#") || trimmedLine.startsWith("<!--")) {
851
- return true;
852
- }
853
- if (/^\s*\*\s/.test(line) || /@(param|returns|example|description|see|link)/i.test(line)) {
854
- return true;
855
- }
856
- if (/^\s*(description|fix|message|help|hint|reason|why)\s*[:=]/.test(trimmedLine)) {
857
- return true;
858
- }
859
- if (/^\s*(interface|type|export\s+interface|export\s+type)\s/.test(line)) {
860
- return true;
861
- }
862
- if (/:\s*(string|number|boolean|any|unknown|null|undefined|void)\s*(;|,|\)|$)/.test(line)) {
863
- return true;
864
- }
865
- if (/^\s*\w+\s*\??\s*:\s*(string|number|boolean|any)/.test(trimmedLine)) {
866
- return true;
867
- }
868
- if (/process\.env|import\.meta\.env|getenv|os\.environ|Deno\.env|\.env\.|config\.\w+|settings\.\w+/.test(line)) {
869
- return true;
870
- }
871
- if (filePath.endsWith("package-lock.json") || filePath.endsWith("yarn.lock") || filePath.endsWith("pnpm-lock.yaml") || filePath.includes("node_modules/")) {
872
- return true;
873
- }
874
- if (/^\s*(severity|category|type|level|priority|cwe|owasp)\s*:\s*['"]/.test(trimmedLine)) {
875
- return true;
876
- }
877
- if (category === "sql-injection") {
878
- const surroundingLines = getSurroundingLines(lines, match.line);
879
- if (!isInSQLContext(line, surroundingLines)) {
880
- return true;
881
- }
882
- }
883
- if (category === "secrets" || category === "auth") {
884
- if (/\(\s*[^)]*\w+\s*:\s*(string|any)/.test(line)) {
885
- return true;
886
- }
887
- if (/\{\s*\w*password\w*\s*(,|\}|:)/.test(line) && !/'|"|`/.test(line.split(/password/i)[1] || "")) {
888
- return true;
889
- }
890
- if (/=\s*(process\.env|config\.|options\.|settings\.|env\.)/.test(line)) {
891
- return true;
892
- }
893
- if (/password\s*[=:](?!\s*['"`])/.test(line)) {
894
- return true;
895
- }
896
- if (/password\s*=\s*\w+(\.|$)/.test(line) && !/'|"|`/.test(line)) {
897
- return true;
898
- }
899
- if (/error|message|log|warn|info|debug|throw|new Error/i.test(line)) {
900
- return true;
901
- }
902
- if (/regex|RegExp|\/.*password.*\//i.test(line)) {
903
- return true;
904
- }
905
- }
906
- if (category === "logging") {
907
- if (pattern === "console.error(" || pattern === "console.warn(") {
908
- return true;
909
- }
910
- if (/catch|error|err\b/.test(line)) {
911
- return true;
912
- }
913
- }
914
- if (category === "config") {
915
- if (/secure:\s*true/.test(line) || /httpOnly:\s*true/.test(line)) {
916
- return true;
917
- }
918
- if (/NODE_ENV|process\.env|production|development/.test(line)) {
919
- return true;
920
- }
921
- if (/if\s*\(|ternary|\?.*:/.test(line)) {
922
- return true;
923
- }
924
- }
925
- if (category === "crypto") {
926
- if (/checksum|hash.*file|etag|cache.*key|fingerprint|integrity|content.*hash/i.test(line)) {
927
- return true;
928
- }
929
- if (pattern === "Math.random()") {
930
- if (!/token|secret|password|key|auth|session|csrf|nonce/i.test(line)) {
931
- return true;
932
- }
933
- }
934
- }
935
- if (category === "async") {
936
- if (/\/\/.*intentional|\/\/.*fire.?and.?forget|\/\/.*parallel/i.test(line)) {
937
- return true;
938
- }
939
- }
940
- if (/password.*length|validate.*password|check.*password|verify.*password|is.*valid/i.test(line)) {
941
- return true;
942
- }
943
- if (/bcrypt|argon|scrypt|pbkdf|compare.*hash|hash.*compare|verify.*hash/i.test(line)) {
944
- return true;
945
- }
946
- if (/z\.|yup\.|joi\.|schema|validation|validator/i.test(line)) {
947
- return true;
948
- }
949
- if (/^\s*(import|require|from)\s/.test(trimmedLine)) {
950
- return true;
951
- }
952
- if (/example|demo|sample|tutorial|readme/i.test(filePath)) {
953
- return true;
954
- }
955
- return false;
956
- }
957
- function isTestFile(filePath) {
958
- return /\.(test|spec)\.[jt]sx?$/.test(filePath) || /__tests__\//.test(filePath) || /test\//.test(filePath) || /tests\//.test(filePath) || /\.stories\.[jt]sx?$/.test(filePath);
959
- }
960
- function getVulnerabilityStats() {
961
- const byCategory = {};
962
- const bySeverity = {};
963
- for (const { metadata } of VULNERABILITY_PATTERNS) {
964
- const cat = metadata.category || "unknown";
965
- const sev = metadata.severity || "unknown";
966
- byCategory[cat] = (byCategory[cat] || 0) + 1;
967
- bySeverity[sev] = (bySeverity[sev] || 0) + 1;
968
- }
969
- return {
970
- total: VULNERABILITY_PATTERNS.length,
971
- byCategory,
972
- bySeverity
973
- };
974
- }
975
-
976
- export {
977
- shouldAlwaysExcludeFile,
978
- shouldExcludeFile,
979
- getVulnerabilityTrie,
980
- scanForVulnerabilities,
981
- getVulnerabilityStats
982
- };
983
- //# sourceMappingURL=chunk-SY6KQG44.js.map