@oculum/scanner 1.0.9 → 1.0.11

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 (365) hide show
  1. package/dist/baseline/diff.d.ts +32 -0
  2. package/dist/baseline/diff.d.ts.map +1 -0
  3. package/dist/baseline/diff.js +119 -0
  4. package/dist/baseline/diff.js.map +1 -0
  5. package/dist/baseline/index.d.ts +9 -0
  6. package/dist/baseline/index.d.ts.map +1 -0
  7. package/dist/baseline/index.js +19 -0
  8. package/dist/baseline/index.js.map +1 -0
  9. package/dist/baseline/manager.d.ts +67 -0
  10. package/dist/baseline/manager.d.ts.map +1 -0
  11. package/dist/baseline/manager.js +180 -0
  12. package/dist/baseline/manager.js.map +1 -0
  13. package/dist/baseline/types.d.ts +91 -0
  14. package/dist/baseline/types.d.ts.map +1 -0
  15. package/dist/baseline/types.js +12 -0
  16. package/dist/baseline/types.js.map +1 -0
  17. package/dist/formatters/cli-terminal.d.ts +38 -0
  18. package/dist/formatters/cli-terminal.d.ts.map +1 -1
  19. package/dist/formatters/cli-terminal.js +365 -42
  20. package/dist/formatters/cli-terminal.js.map +1 -1
  21. package/dist/formatters/github-comment.d.ts +1 -1
  22. package/dist/formatters/github-comment.d.ts.map +1 -1
  23. package/dist/formatters/github-comment.js +75 -11
  24. package/dist/formatters/github-comment.js.map +1 -1
  25. package/dist/formatters/index.d.ts +1 -1
  26. package/dist/formatters/index.d.ts.map +1 -1
  27. package/dist/formatters/index.js +4 -1
  28. package/dist/formatters/index.js.map +1 -1
  29. package/dist/index.d.ts +7 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +155 -16
  32. package/dist/index.js.map +1 -1
  33. package/dist/layer1/config-audit.d.ts.map +1 -1
  34. package/dist/layer1/config-audit.js +20 -3
  35. package/dist/layer1/config-audit.js.map +1 -1
  36. package/dist/layer1/config-mcp-audit.d.ts +20 -0
  37. package/dist/layer1/config-mcp-audit.d.ts.map +1 -0
  38. package/dist/layer1/config-mcp-audit.js +239 -0
  39. package/dist/layer1/config-mcp-audit.js.map +1 -0
  40. package/dist/layer1/index.d.ts +1 -0
  41. package/dist/layer1/index.d.ts.map +1 -1
  42. package/dist/layer1/index.js +9 -1
  43. package/dist/layer1/index.js.map +1 -1
  44. package/dist/layer2/ai-agent-tools.d.ts.map +1 -1
  45. package/dist/layer2/ai-agent-tools.js +303 -0
  46. package/dist/layer2/ai-agent-tools.js.map +1 -1
  47. package/dist/layer2/ai-endpoint-protection.d.ts.map +1 -1
  48. package/dist/layer2/ai-endpoint-protection.js +17 -3
  49. package/dist/layer2/ai-endpoint-protection.js.map +1 -1
  50. package/dist/layer2/ai-execution-sinks.d.ts.map +1 -1
  51. package/dist/layer2/ai-execution-sinks.js +462 -12
  52. package/dist/layer2/ai-execution-sinks.js.map +1 -1
  53. package/dist/layer2/ai-fingerprinting.d.ts.map +1 -1
  54. package/dist/layer2/ai-fingerprinting.js +3 -0
  55. package/dist/layer2/ai-fingerprinting.js.map +1 -1
  56. package/dist/layer2/ai-mcp-security.d.ts +17 -0
  57. package/dist/layer2/ai-mcp-security.d.ts.map +1 -0
  58. package/dist/layer2/ai-mcp-security.js +679 -0
  59. package/dist/layer2/ai-mcp-security.js.map +1 -0
  60. package/dist/layer2/ai-package-hallucination.d.ts +19 -0
  61. package/dist/layer2/ai-package-hallucination.d.ts.map +1 -0
  62. package/dist/layer2/ai-package-hallucination.js +696 -0
  63. package/dist/layer2/ai-package-hallucination.js.map +1 -0
  64. package/dist/layer2/ai-prompt-hygiene.d.ts.map +1 -1
  65. package/dist/layer2/ai-prompt-hygiene.js +495 -9
  66. package/dist/layer2/ai-prompt-hygiene.js.map +1 -1
  67. package/dist/layer2/ai-rag-safety.d.ts.map +1 -1
  68. package/dist/layer2/ai-rag-safety.js +372 -1
  69. package/dist/layer2/ai-rag-safety.js.map +1 -1
  70. package/dist/layer2/auth-antipatterns.d.ts.map +1 -1
  71. package/dist/layer2/auth-antipatterns.js +4 -0
  72. package/dist/layer2/auth-antipatterns.js.map +1 -1
  73. package/dist/layer2/byok-patterns.d.ts.map +1 -1
  74. package/dist/layer2/byok-patterns.js +3 -0
  75. package/dist/layer2/byok-patterns.js.map +1 -1
  76. package/dist/layer2/dangerous-functions/child-process.d.ts +16 -0
  77. package/dist/layer2/dangerous-functions/child-process.d.ts.map +1 -0
  78. package/dist/layer2/dangerous-functions/child-process.js +74 -0
  79. package/dist/layer2/dangerous-functions/child-process.js.map +1 -0
  80. package/dist/layer2/dangerous-functions/dom-xss.d.ts +29 -0
  81. package/dist/layer2/dangerous-functions/dom-xss.d.ts.map +1 -0
  82. package/dist/layer2/dangerous-functions/dom-xss.js +179 -0
  83. package/dist/layer2/dangerous-functions/dom-xss.js.map +1 -0
  84. package/dist/layer2/dangerous-functions/index.d.ts +13 -0
  85. package/dist/layer2/dangerous-functions/index.d.ts.map +1 -0
  86. package/dist/layer2/dangerous-functions/index.js +621 -0
  87. package/dist/layer2/dangerous-functions/index.js.map +1 -0
  88. package/dist/layer2/dangerous-functions/json-parse.d.ts +31 -0
  89. package/dist/layer2/dangerous-functions/json-parse.d.ts.map +1 -0
  90. package/dist/layer2/dangerous-functions/json-parse.js +319 -0
  91. package/dist/layer2/dangerous-functions/json-parse.js.map +1 -0
  92. package/dist/layer2/dangerous-functions/math-random.d.ts +61 -0
  93. package/dist/layer2/dangerous-functions/math-random.d.ts.map +1 -0
  94. package/dist/layer2/dangerous-functions/math-random.js +459 -0
  95. package/dist/layer2/dangerous-functions/math-random.js.map +1 -0
  96. package/dist/layer2/dangerous-functions/patterns.d.ts +21 -0
  97. package/dist/layer2/dangerous-functions/patterns.d.ts.map +1 -0
  98. package/dist/layer2/dangerous-functions/patterns.js +161 -0
  99. package/dist/layer2/dangerous-functions/patterns.js.map +1 -0
  100. package/dist/layer2/dangerous-functions/request-validation.d.ts +13 -0
  101. package/dist/layer2/dangerous-functions/request-validation.d.ts.map +1 -0
  102. package/dist/layer2/dangerous-functions/request-validation.js +119 -0
  103. package/dist/layer2/dangerous-functions/request-validation.js.map +1 -0
  104. package/dist/layer2/dangerous-functions/utils/control-flow.d.ts +23 -0
  105. package/dist/layer2/dangerous-functions/utils/control-flow.d.ts.map +1 -0
  106. package/dist/layer2/dangerous-functions/utils/control-flow.js +149 -0
  107. package/dist/layer2/dangerous-functions/utils/control-flow.js.map +1 -0
  108. package/dist/layer2/dangerous-functions/utils/helpers.d.ts +31 -0
  109. package/dist/layer2/dangerous-functions/utils/helpers.d.ts.map +1 -0
  110. package/dist/layer2/dangerous-functions/utils/helpers.js +124 -0
  111. package/dist/layer2/dangerous-functions/utils/helpers.js.map +1 -0
  112. package/dist/layer2/dangerous-functions/utils/index.d.ts +9 -0
  113. package/dist/layer2/dangerous-functions/utils/index.d.ts.map +1 -0
  114. package/dist/layer2/dangerous-functions/utils/index.js +23 -0
  115. package/dist/layer2/dangerous-functions/utils/index.js.map +1 -0
  116. package/dist/layer2/dangerous-functions/utils/schema-validation.d.ts +22 -0
  117. package/dist/layer2/dangerous-functions/utils/schema-validation.d.ts.map +1 -0
  118. package/dist/layer2/dangerous-functions/utils/schema-validation.js +89 -0
  119. package/dist/layer2/dangerous-functions/utils/schema-validation.js.map +1 -0
  120. package/dist/layer2/data-exposure.d.ts.map +1 -1
  121. package/dist/layer2/data-exposure.js +3 -0
  122. package/dist/layer2/data-exposure.js.map +1 -1
  123. package/dist/layer2/framework-checks.d.ts.map +1 -1
  124. package/dist/layer2/framework-checks.js +3 -0
  125. package/dist/layer2/framework-checks.js.map +1 -1
  126. package/dist/layer2/index.d.ts +3 -0
  127. package/dist/layer2/index.d.ts.map +1 -1
  128. package/dist/layer2/index.js +61 -2
  129. package/dist/layer2/index.js.map +1 -1
  130. package/dist/layer2/logic-gates.d.ts.map +1 -1
  131. package/dist/layer2/logic-gates.js +4 -0
  132. package/dist/layer2/logic-gates.js.map +1 -1
  133. package/dist/layer2/model-supply-chain.d.ts +20 -0
  134. package/dist/layer2/model-supply-chain.d.ts.map +1 -0
  135. package/dist/layer2/model-supply-chain.js +376 -0
  136. package/dist/layer2/model-supply-chain.js.map +1 -0
  137. package/dist/layer2/risky-imports.d.ts.map +1 -1
  138. package/dist/layer2/risky-imports.js +4 -0
  139. package/dist/layer2/risky-imports.js.map +1 -1
  140. package/dist/layer2/variables.d.ts.map +1 -1
  141. package/dist/layer2/variables.js +4 -0
  142. package/dist/layer2/variables.js.map +1 -1
  143. package/dist/layer3/anthropic/auto-dismiss.d.ts +24 -0
  144. package/dist/layer3/anthropic/auto-dismiss.d.ts.map +1 -0
  145. package/dist/layer3/anthropic/auto-dismiss.js +188 -0
  146. package/dist/layer3/anthropic/auto-dismiss.js.map +1 -0
  147. package/dist/layer3/anthropic/clients.d.ts +44 -0
  148. package/dist/layer3/anthropic/clients.d.ts.map +1 -0
  149. package/dist/layer3/anthropic/clients.js +81 -0
  150. package/dist/layer3/anthropic/clients.js.map +1 -0
  151. package/dist/layer3/anthropic/index.d.ts +41 -0
  152. package/dist/layer3/anthropic/index.d.ts.map +1 -0
  153. package/dist/layer3/anthropic/index.js +141 -0
  154. package/dist/layer3/anthropic/index.js.map +1 -0
  155. package/dist/layer3/anthropic/prompts/index.d.ts +8 -0
  156. package/dist/layer3/anthropic/prompts/index.d.ts.map +1 -0
  157. package/dist/layer3/anthropic/prompts/index.js +14 -0
  158. package/dist/layer3/anthropic/prompts/index.js.map +1 -0
  159. package/dist/layer3/anthropic/prompts/semantic-analysis.d.ts +15 -0
  160. package/dist/layer3/anthropic/prompts/semantic-analysis.d.ts.map +1 -0
  161. package/dist/layer3/anthropic/prompts/semantic-analysis.js +169 -0
  162. package/dist/layer3/anthropic/prompts/semantic-analysis.js.map +1 -0
  163. package/dist/layer3/anthropic/prompts/validation.d.ts +12 -0
  164. package/dist/layer3/anthropic/prompts/validation.d.ts.map +1 -0
  165. package/dist/layer3/anthropic/prompts/validation.js +421 -0
  166. package/dist/layer3/anthropic/prompts/validation.js.map +1 -0
  167. package/dist/layer3/anthropic/providers/anthropic.d.ts +21 -0
  168. package/dist/layer3/anthropic/providers/anthropic.d.ts.map +1 -0
  169. package/dist/layer3/anthropic/providers/anthropic.js +266 -0
  170. package/dist/layer3/anthropic/providers/anthropic.js.map +1 -0
  171. package/dist/layer3/anthropic/providers/index.d.ts +8 -0
  172. package/dist/layer3/anthropic/providers/index.d.ts.map +1 -0
  173. package/dist/layer3/anthropic/providers/index.js +15 -0
  174. package/dist/layer3/anthropic/providers/index.js.map +1 -0
  175. package/dist/layer3/anthropic/providers/openai.d.ts +18 -0
  176. package/dist/layer3/anthropic/providers/openai.d.ts.map +1 -0
  177. package/dist/layer3/anthropic/providers/openai.js +340 -0
  178. package/dist/layer3/anthropic/providers/openai.js.map +1 -0
  179. package/dist/layer3/anthropic/request-builder.d.ts +20 -0
  180. package/dist/layer3/anthropic/request-builder.d.ts.map +1 -0
  181. package/dist/layer3/anthropic/request-builder.js +134 -0
  182. package/dist/layer3/anthropic/request-builder.js.map +1 -0
  183. package/dist/layer3/anthropic/types.d.ts +88 -0
  184. package/dist/layer3/anthropic/types.d.ts.map +1 -0
  185. package/dist/layer3/anthropic/types.js +38 -0
  186. package/dist/layer3/anthropic/types.js.map +1 -0
  187. package/dist/layer3/anthropic/utils/index.d.ts +9 -0
  188. package/dist/layer3/anthropic/utils/index.d.ts.map +1 -0
  189. package/dist/layer3/anthropic/utils/index.js +24 -0
  190. package/dist/layer3/anthropic/utils/index.js.map +1 -0
  191. package/dist/layer3/anthropic/utils/path-helpers.d.ts +21 -0
  192. package/dist/layer3/anthropic/utils/path-helpers.d.ts.map +1 -0
  193. package/dist/layer3/anthropic/utils/path-helpers.js +69 -0
  194. package/dist/layer3/anthropic/utils/path-helpers.js.map +1 -0
  195. package/dist/layer3/anthropic/utils/response-parser.d.ts +40 -0
  196. package/dist/layer3/anthropic/utils/response-parser.d.ts.map +1 -0
  197. package/dist/layer3/anthropic/utils/response-parser.js +285 -0
  198. package/dist/layer3/anthropic/utils/response-parser.js.map +1 -0
  199. package/dist/layer3/anthropic/utils/retry.d.ts +15 -0
  200. package/dist/layer3/anthropic/utils/retry.d.ts.map +1 -0
  201. package/dist/layer3/anthropic/utils/retry.js +62 -0
  202. package/dist/layer3/anthropic/utils/retry.js.map +1 -0
  203. package/dist/layer3/index.d.ts +1 -0
  204. package/dist/layer3/index.d.ts.map +1 -1
  205. package/dist/layer3/index.js +16 -6
  206. package/dist/layer3/index.js.map +1 -1
  207. package/dist/layer3/osv-check.d.ts +75 -0
  208. package/dist/layer3/osv-check.d.ts.map +1 -0
  209. package/dist/layer3/osv-check.js +308 -0
  210. package/dist/layer3/osv-check.js.map +1 -0
  211. package/dist/rules/framework-fixes.d.ts +48 -0
  212. package/dist/rules/framework-fixes.d.ts.map +1 -0
  213. package/dist/rules/framework-fixes.js +439 -0
  214. package/dist/rules/framework-fixes.js.map +1 -0
  215. package/dist/rules/index.d.ts +8 -0
  216. package/dist/rules/index.d.ts.map +1 -0
  217. package/dist/rules/index.js +18 -0
  218. package/dist/rules/index.js.map +1 -0
  219. package/dist/rules/metadata.d.ts +43 -0
  220. package/dist/rules/metadata.d.ts.map +1 -0
  221. package/dist/rules/metadata.js +734 -0
  222. package/dist/rules/metadata.js.map +1 -0
  223. package/dist/suppression/config-loader.d.ts +74 -0
  224. package/dist/suppression/config-loader.d.ts.map +1 -0
  225. package/dist/suppression/config-loader.js +424 -0
  226. package/dist/suppression/config-loader.js.map +1 -0
  227. package/dist/suppression/hash.d.ts +48 -0
  228. package/dist/suppression/hash.d.ts.map +1 -0
  229. package/dist/suppression/hash.js +88 -0
  230. package/dist/suppression/hash.js.map +1 -0
  231. package/dist/suppression/index.d.ts +11 -0
  232. package/dist/suppression/index.d.ts.map +1 -0
  233. package/dist/suppression/index.js +39 -0
  234. package/dist/suppression/index.js.map +1 -0
  235. package/dist/suppression/inline-parser.d.ts +39 -0
  236. package/dist/suppression/inline-parser.d.ts.map +1 -0
  237. package/dist/suppression/inline-parser.js +218 -0
  238. package/dist/suppression/inline-parser.js.map +1 -0
  239. package/dist/suppression/manager.d.ts +94 -0
  240. package/dist/suppression/manager.d.ts.map +1 -0
  241. package/dist/suppression/manager.js +292 -0
  242. package/dist/suppression/manager.js.map +1 -0
  243. package/dist/suppression/types.d.ts +151 -0
  244. package/dist/suppression/types.d.ts.map +1 -0
  245. package/dist/suppression/types.js +28 -0
  246. package/dist/suppression/types.js.map +1 -0
  247. package/dist/tiers.d.ts +1 -1
  248. package/dist/tiers.d.ts.map +1 -1
  249. package/dist/tiers.js +27 -0
  250. package/dist/tiers.js.map +1 -1
  251. package/dist/types.d.ts +62 -1
  252. package/dist/types.d.ts.map +1 -1
  253. package/dist/types.js.map +1 -1
  254. package/dist/utils/context-helpers.d.ts +4 -0
  255. package/dist/utils/context-helpers.d.ts.map +1 -1
  256. package/dist/utils/context-helpers.js +13 -9
  257. package/dist/utils/context-helpers.js.map +1 -1
  258. package/package.json +4 -2
  259. package/src/__tests__/benchmark/fixtures/layer1/mcp-config-audit.json +31 -0
  260. package/src/__tests__/benchmark/fixtures/layer2/ai-execution-sinks.ts +1489 -82
  261. package/src/__tests__/benchmark/fixtures/layer2/ai-mcp-security.ts +495 -0
  262. package/src/__tests__/benchmark/fixtures/layer2/ai-package-hallucination.ts +255 -0
  263. package/src/__tests__/benchmark/fixtures/layer2/ai-prompt-hygiene.ts +300 -1
  264. package/src/__tests__/benchmark/fixtures/layer2/ai-rag-safety.ts +139 -0
  265. package/src/__tests__/benchmark/fixtures/layer2/byok-patterns.ts +7 -0
  266. package/src/__tests__/benchmark/fixtures/layer2/data-exposure.ts +63 -0
  267. package/src/__tests__/benchmark/fixtures/layer2/excessive-agency.ts +221 -0
  268. package/src/__tests__/benchmark/fixtures/layer2/index.ts +18 -0
  269. package/src/__tests__/benchmark/fixtures/layer2/model-supply-chain.ts +204 -0
  270. package/src/__tests__/benchmark/fixtures/layer2/phase1-enhancements.ts +157 -0
  271. package/src/__tests__/snapshots/__snapshots__/anthropic-validation-refactor.test.ts.snap +758 -0
  272. package/src/__tests__/snapshots/__snapshots__/dangerous-functions-refactor.test.ts.snap +503 -0
  273. package/src/__tests__/snapshots/anthropic-validation-refactor.test.ts +321 -0
  274. package/src/__tests__/snapshots/dangerous-functions-refactor.test.ts +439 -0
  275. package/src/baseline/__tests__/diff.test.ts +261 -0
  276. package/src/baseline/__tests__/manager.test.ts +225 -0
  277. package/src/baseline/diff.ts +135 -0
  278. package/src/baseline/index.ts +29 -0
  279. package/src/baseline/manager.ts +230 -0
  280. package/src/baseline/types.ts +97 -0
  281. package/src/formatters/cli-terminal.ts +444 -41
  282. package/src/formatters/github-comment.ts +79 -11
  283. package/src/formatters/index.ts +4 -0
  284. package/src/index.ts +197 -14
  285. package/src/layer1/config-audit.ts +24 -3
  286. package/src/layer1/config-mcp-audit.ts +276 -0
  287. package/src/layer1/index.ts +16 -6
  288. package/src/layer2/ai-agent-tools.ts +336 -0
  289. package/src/layer2/ai-endpoint-protection.ts +16 -3
  290. package/src/layer2/ai-execution-sinks.ts +516 -12
  291. package/src/layer2/ai-fingerprinting.ts +5 -1
  292. package/src/layer2/ai-mcp-security.ts +730 -0
  293. package/src/layer2/ai-package-hallucination.ts +791 -0
  294. package/src/layer2/ai-prompt-hygiene.ts +547 -9
  295. package/src/layer2/ai-rag-safety.ts +382 -3
  296. package/src/layer2/auth-antipatterns.ts +5 -0
  297. package/src/layer2/byok-patterns.ts +5 -1
  298. package/src/layer2/dangerous-functions/child-process.ts +98 -0
  299. package/src/layer2/dangerous-functions/dom-xss.ts +220 -0
  300. package/src/layer2/dangerous-functions/index.ts +949 -0
  301. package/src/layer2/dangerous-functions/json-parse.ts +385 -0
  302. package/src/layer2/dangerous-functions/math-random.ts +537 -0
  303. package/src/layer2/dangerous-functions/patterns.ts +174 -0
  304. package/src/layer2/dangerous-functions/request-validation.ts +145 -0
  305. package/src/layer2/dangerous-functions/utils/control-flow.ts +162 -0
  306. package/src/layer2/dangerous-functions/utils/helpers.ts +170 -0
  307. package/src/layer2/dangerous-functions/utils/index.ts +25 -0
  308. package/src/layer2/dangerous-functions/utils/schema-validation.ts +91 -0
  309. package/src/layer2/data-exposure.ts +5 -1
  310. package/src/layer2/framework-checks.ts +5 -0
  311. package/src/layer2/index.ts +63 -1
  312. package/src/layer2/logic-gates.ts +5 -0
  313. package/src/layer2/model-supply-chain.ts +456 -0
  314. package/src/layer2/risky-imports.ts +5 -0
  315. package/src/layer2/variables.ts +5 -0
  316. package/src/layer3/__tests__/osv-check.test.ts +384 -0
  317. package/src/layer3/anthropic/auto-dismiss.ts +212 -0
  318. package/src/layer3/anthropic/clients.ts +84 -0
  319. package/src/layer3/anthropic/index.ts +170 -0
  320. package/src/layer3/anthropic/prompts/index.ts +14 -0
  321. package/src/layer3/anthropic/prompts/semantic-analysis.ts +173 -0
  322. package/src/layer3/anthropic/prompts/validation.ts +419 -0
  323. package/src/layer3/anthropic/providers/anthropic.ts +310 -0
  324. package/src/layer3/anthropic/providers/index.ts +8 -0
  325. package/src/layer3/anthropic/providers/openai.ts +384 -0
  326. package/src/layer3/anthropic/request-builder.ts +150 -0
  327. package/src/layer3/anthropic/types.ts +148 -0
  328. package/src/layer3/anthropic/utils/index.ts +26 -0
  329. package/src/layer3/anthropic/utils/path-helpers.ts +68 -0
  330. package/src/layer3/anthropic/utils/response-parser.ts +322 -0
  331. package/src/layer3/anthropic/utils/retry.ts +75 -0
  332. package/src/layer3/index.ts +18 -5
  333. package/src/layer3/osv-check.ts +420 -0
  334. package/src/rules/__tests__/framework-fixes.test.ts +689 -0
  335. package/src/rules/__tests__/metadata.test.ts +218 -0
  336. package/src/rules/framework-fixes.ts +470 -0
  337. package/src/rules/index.ts +21 -0
  338. package/src/rules/metadata.ts +831 -0
  339. package/src/suppression/__tests__/config-loader.test.ts +382 -0
  340. package/src/suppression/__tests__/hash.test.ts +166 -0
  341. package/src/suppression/__tests__/inline-parser.test.ts +212 -0
  342. package/src/suppression/__tests__/manager.test.ts +415 -0
  343. package/src/suppression/config-loader.ts +462 -0
  344. package/src/suppression/hash.ts +95 -0
  345. package/src/suppression/index.ts +51 -0
  346. package/src/suppression/inline-parser.ts +273 -0
  347. package/src/suppression/manager.ts +379 -0
  348. package/src/suppression/types.ts +174 -0
  349. package/src/tiers.ts +36 -0
  350. package/src/types.ts +90 -0
  351. package/src/utils/context-helpers.ts +13 -9
  352. package/dist/layer2/dangerous-functions.d.ts +0 -7
  353. package/dist/layer2/dangerous-functions.d.ts.map +0 -1
  354. package/dist/layer2/dangerous-functions.js +0 -1701
  355. package/dist/layer2/dangerous-functions.js.map +0 -1
  356. package/dist/layer3/anthropic.d.ts +0 -87
  357. package/dist/layer3/anthropic.d.ts.map +0 -1
  358. package/dist/layer3/anthropic.js +0 -1948
  359. package/dist/layer3/anthropic.js.map +0 -1
  360. package/dist/layer3/openai.d.ts +0 -25
  361. package/dist/layer3/openai.d.ts.map +0 -1
  362. package/dist/layer3/openai.js +0 -238
  363. package/dist/layer3/openai.js.map +0 -1
  364. package/src/layer2/dangerous-functions.ts +0 -1940
  365. package/src/layer3/anthropic.ts +0 -2257
@@ -0,0 +1,621 @@
1
+ "use strict";
2
+ /**
3
+ * Layer 2: Dangerous Function Call Analysis
4
+ *
5
+ * Detects usage of dangerous functions that can lead to security vulnerabilities.
6
+ * This module orchestrates detection across multiple specialized modules.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DANGEROUS_FUNCTIONS = void 0;
10
+ exports.detectDangerousFunctions = detectDangerousFunctions;
11
+ const context_helpers_1 = require("../../utils/context-helpers");
12
+ // Pattern definitions
13
+ const patterns_1 = require("./patterns");
14
+ // Child process detection
15
+ const child_process_1 = require("./child-process");
16
+ // DOM/XSS detection
17
+ const dom_xss_1 = require("./dom-xss");
18
+ // JSON.parse detection
19
+ const json_parse_1 = require("./json-parse");
20
+ // Math.random detection
21
+ const math_random_1 = require("./math-random");
22
+ // Request validation detection
23
+ const request_validation_1 = require("./request-validation");
24
+ // Utilities
25
+ const control_flow_1 = require("./utils/control-flow");
26
+ const schema_validation_1 = require("./utils/schema-validation");
27
+ const helpers_1 = require("./utils/helpers");
28
+ // Re-export types and patterns for external use
29
+ var patterns_2 = require("./patterns");
30
+ Object.defineProperty(exports, "DANGEROUS_FUNCTIONS", { enumerable: true, get: function () { return patterns_2.DANGEROUS_FUNCTIONS; } });
31
+ /**
32
+ * Main detection function for dangerous function calls
33
+ */
34
+ function detectDangerousFunctions(content, filePath) {
35
+ const vulnerabilities = [];
36
+ // Skip scanner/fixture files to avoid self-detection
37
+ if ((0, context_helpers_1.isScannerOrFixtureFile)(filePath)) {
38
+ return vulnerabilities;
39
+ }
40
+ const lines = content.split('\n');
41
+ const isTestFile = (0, context_helpers_1.isTestOrMockFile)(filePath);
42
+ lines.forEach((line, index) => {
43
+ // Skip comment lines
44
+ if ((0, context_helpers_1.isComment)(line))
45
+ return;
46
+ for (const funcPattern of patterns_1.DANGEROUS_FUNCTIONS) {
47
+ // Check language filter
48
+ if (!(0, patterns_1.matchesLanguage)(filePath, funcPattern.languages))
49
+ continue;
50
+ const regex = new RegExp(funcPattern.pattern.source, funcPattern.pattern.flags);
51
+ if (regex.test(line)) {
52
+ // Special handling for innerHTML patterns
53
+ if (funcPattern.name === 'innerHTML assignment' ||
54
+ funcPattern.name === 'dangerouslySetInnerHTML') {
55
+ handleInnerHTMLPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities);
56
+ break;
57
+ }
58
+ // Note: JSON.parse is now handled by standalone detectJSONParseSafe() function
59
+ // which provides better source-aware severity classification
60
+ // Special handling for eval and Function constructor
61
+ if (funcPattern.name === 'eval() usage' ||
62
+ funcPattern.name === 'Function constructor') {
63
+ if (handleEvalPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities)) {
64
+ break;
65
+ }
66
+ continue;
67
+ }
68
+ // Special handling for child_process exec - verify it's not RegExp.exec
69
+ if (funcPattern.name === 'child_process exec') {
70
+ if (handleChildProcessPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities)) {
71
+ break;
72
+ }
73
+ continue;
74
+ }
75
+ // Special handling for SQL patterns - check for whitelist validation
76
+ if (funcPattern.name === 'Raw SQL query construction' ||
77
+ funcPattern.name === 'SQL template literal') {
78
+ handleSQLPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities);
79
+ break;
80
+ }
81
+ // Special handling for dynamic file paths - check for path traversal protection
82
+ if (funcPattern.name === 'Dynamic file path' ||
83
+ funcPattern.name === 'Path traversal risk') {
84
+ handleFilePathPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities);
85
+ break;
86
+ }
87
+ // Special handling for Math.random
88
+ if (funcPattern.name === 'Math.random for security') {
89
+ handleMathRandomPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities);
90
+ break;
91
+ }
92
+ // Standard handling for all other patterns
93
+ handleStandardPattern(funcPattern, line, index, filePath, isTestFile, vulnerabilities);
94
+ break; // Only report once per line
95
+ }
96
+ }
97
+ });
98
+ // Additional standalone checks (not in DANGEROUS_FUNCTIONS array)
99
+ // JSON.parse source-aware detection
100
+ (0, json_parse_1.detectJSONParseSafe)(content, filePath, isTestFile, vulnerabilities);
101
+ // request.json() / req.json() schema validation suggestion
102
+ (0, request_validation_1.detectRequestJsonValidation)(content, filePath, isTestFile, vulnerabilities);
103
+ return vulnerabilities;
104
+ }
105
+ /**
106
+ * Handle innerHTML/dangerouslySetInnerHTML patterns
107
+ */
108
+ function handleInnerHTMLPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities) {
109
+ // Check if this is a style element (CSS injection is not XSS)
110
+ if ((0, dom_xss_1.isStyleElementInnerHTML)(line, content, index)) {
111
+ // Style elements with CSS are safe - don't report anything
112
+ // CSS cannot execute JavaScript, so there's no XSS risk
113
+ return;
114
+ }
115
+ // Check if this uses static content only - skip entirely (safe)
116
+ if ((0, dom_xss_1.isStaticHTMLContent)(line, content, index)) {
117
+ return; // Static HTML is safe - no finding needed
118
+ }
119
+ // Check if DOMPurify or similar sanitization is used - skip entirely (safe)
120
+ if ((0, dom_xss_1.hasDOMPurifySanitization)(line, content, index)) {
121
+ return; // Sanitized HTML is safe - no finding needed
122
+ }
123
+ // Check if this is a static bootstrap script (e.g., theme/font loader) - skip entirely (safe)
124
+ if ((0, dom_xss_1.isStaticBootstrapScript)(line, content, index)) {
125
+ return; // Static bootstrap scripts are safe - no finding needed
126
+ }
127
+ // Check if this is in LLM prompt context (not XSS - it's prompt injection)
128
+ if ((0, dom_xss_1.isLLMPromptContext)(line, content, filePath)) {
129
+ vulnerabilities.push({
130
+ id: `dangerous-func-${filePath}-${index + 1}-prompt-injection`,
131
+ filePath,
132
+ lineNumber: index + 1,
133
+ lineContent: line.trim(),
134
+ severity: 'info',
135
+ category: 'ai_pattern',
136
+ title: 'Potential prompt injection risk',
137
+ description: 'User content is being used in an LLM prompt context. This is NOT XSS (the content goes to an AI, not a DOM). However, untrusted content in prompts may lead to prompt injection attacks.',
138
+ suggestedFix: 'Consider input validation, content filtering, or structured prompts to limit prompt injection risk.',
139
+ confidence: 'low',
140
+ layer: 2,
141
+ });
142
+ return;
143
+ }
144
+ // Dynamic content - full severity, needs AI validation
145
+ let severity = funcPattern.severity;
146
+ if (isTestFile) {
147
+ severity = 'low';
148
+ }
149
+ vulnerabilities.push({
150
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
151
+ filePath,
152
+ lineNumber: index + 1,
153
+ lineContent: line.trim(),
154
+ severity,
155
+ category: 'dangerous_function',
156
+ title: funcPattern.name,
157
+ description: funcPattern.description +
158
+ ' This appears to use dynamic content which increases XSS risk.' +
159
+ (isTestFile ? ' (in test file)' : ''),
160
+ suggestedFix: funcPattern.suggestedFix,
161
+ confidence: isTestFile ? 'low' : 'high',
162
+ layer: 2,
163
+ requiresAIValidation: true, // Dynamic HTML needs validation
164
+ });
165
+ }
166
+ /**
167
+ * Handle eval and Function constructor patterns
168
+ * Returns true if a finding was added, false otherwise
169
+ */
170
+ function handleEvalPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities) {
171
+ // Check if "eval" or "Function" appears inside a string literal
172
+ // e.g., const docs = "Don't use eval() in production"
173
+ // This is NOT an actual eval call, just documentation/comments
174
+ const evalInsideStringPattern = /(['"`])(?:[^\\]|\\.)*?\beval\s*\(.*?\1/;
175
+ const functionInsideStringPattern = /(['"`])(?:[^\\]|\\.)*?\bFunction\s*\(.*?\1/;
176
+ if (evalInsideStringPattern.test(line) || functionInsideStringPattern.test(line)) {
177
+ return true; // Skip - this is just a string mentioning eval, not actual eval()
178
+ }
179
+ // Suppress entirely in test files - test files legitimately test eval behavior
180
+ if (isTestFile) {
181
+ return true; // Skip reporting entirely
182
+ }
183
+ // Check if eval is inside a test assertion (expect(), test(), it(), describe())
184
+ const testAssertionPattern = /\b(expect|test|it|describe)\s*\(/;
185
+ if (testAssertionPattern.test(line)) {
186
+ return true; // Skip reporting - this is testing eval behavior
187
+ }
188
+ // Check if inputs are static literals (low risk) - skip entirely
189
+ if ((0, helpers_1.hasOnlyStaticInputs)(line, content, index)) {
190
+ return true; // Static eval is safe enough - no finding needed
191
+ }
192
+ vulnerabilities.push({
193
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
194
+ filePath,
195
+ lineNumber: index + 1,
196
+ lineContent: line.trim(),
197
+ severity: funcPattern.severity,
198
+ category: 'dangerous_function',
199
+ title: funcPattern.name,
200
+ description: funcPattern.description,
201
+ suggestedFix: funcPattern.suggestedFix,
202
+ confidence: 'high',
203
+ layer: 2,
204
+ requiresAIValidation: true, // Code execution patterns need validation
205
+ });
206
+ return true;
207
+ }
208
+ /**
209
+ * Handle child_process exec patterns
210
+ * Returns true if a finding was added, false otherwise
211
+ */
212
+ function handleChildProcessPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities) {
213
+ // First check if this is actually from child_process (not RegExp.exec)
214
+ const isExecMatch = /\bexec\s*\(/.test(line);
215
+ const isOtherMatch = /\b(execSync|spawn|spawnSync|execFile)\s*\(/.test(line);
216
+ if (isExecMatch && !isOtherMatch) {
217
+ // This matched 'exec(' - verify it's from child_process
218
+ if (!(0, child_process_1.isChildProcessExec)(content, line)) {
219
+ // This is RegExp.exec or similar - skip
220
+ return false;
221
+ }
222
+ }
223
+ else if (isOtherMatch) {
224
+ // This matched spawn/execSync/etc - verify child_process import
225
+ if (!(0, child_process_1.isChildProcessSpawn)(content, line)) {
226
+ // No child_process import - skip
227
+ return false;
228
+ }
229
+ }
230
+ // Check if arguments are validated via allowlist
231
+ const lines = content.split('\n');
232
+ const contextStart = Math.max(0, index - 15);
233
+ const contextEnd = Math.min(lines.length, index + 5);
234
+ const context = lines.slice(contextStart, contextEnd).join('\n');
235
+ // Detect allowlist validation patterns before exec/spawn
236
+ const hasArgAllowlist = /allowedArgs\.includes\s*\(/i.test(context) ||
237
+ /if\s*\(\s*!?allowedArgs\.includes/i.test(context) ||
238
+ /if\s*\(\s*!?\w+Args\.includes/i.test(context) ||
239
+ /validArgs\.includes/i.test(context) ||
240
+ // ALLOWED_COMMANDS pattern (common naming convention)
241
+ /ALLOWED_\w+\.includes\s*\(/i.test(context) ||
242
+ /if\s*\(\s*!?ALLOWED_\w+\.includes/i.test(context) ||
243
+ // allowedCommands, validCommands, safeCommands
244
+ /allowed(?:Commands?|Cmds?)\.includes\s*\(/i.test(context) ||
245
+ /valid(?:Commands?|Cmds?)\.includes\s*\(/i.test(context) ||
246
+ /safe(?:Commands?|Cmds?)\.includes\s*\(/i.test(context) ||
247
+ // Generic whitelist/allowlist check
248
+ /(?:whitelist|allowlist)\.includes\s*\(/i.test(context);
249
+ // execFile with hardcoded command is safe (safer than exec)
250
+ const isExecFileWithHardcodedCmd = /execFile\s*\(\s*['"][^'"]+['"]/i.test(line);
251
+ if (hasArgAllowlist || isExecFileWithHardcodedCmd) {
252
+ return true; // Allowlisted or execFile with hardcoded command - safe
253
+ }
254
+ if ((0, helpers_1.hasOnlyStaticInputs)(line, content, index)) {
255
+ return true; // Static command is safe - no finding needed
256
+ }
257
+ // Dynamic command - report with standard severity
258
+ let severity = funcPattern.severity;
259
+ let confidence = 'high';
260
+ if (isTestFile) {
261
+ if (severity === 'critical') {
262
+ severity = 'medium';
263
+ }
264
+ else if (severity === 'high') {
265
+ severity = 'low';
266
+ }
267
+ else {
268
+ severity = 'info';
269
+ }
270
+ confidence = 'low';
271
+ }
272
+ vulnerabilities.push({
273
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
274
+ filePath,
275
+ lineNumber: index + 1,
276
+ lineContent: line.trim(),
277
+ severity,
278
+ category: 'dangerous_function',
279
+ title: funcPattern.name,
280
+ description: funcPattern.description + (isTestFile ? ' (in test file)' : ''),
281
+ suggestedFix: funcPattern.suggestedFix,
282
+ confidence,
283
+ layer: 2,
284
+ });
285
+ return true;
286
+ }
287
+ /**
288
+ * Handle SQL injection patterns
289
+ */
290
+ function handleSQLPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities) {
291
+ // Check for whitelist validation - skip entirely (safe)
292
+ if ((0, schema_validation_1.hasSQLWhitelistValidation)(content, index)) {
293
+ return; // Whitelist validated - safe, no finding needed
294
+ }
295
+ // Check for ORM methods (not raw SQL) - skip entirely (safe)
296
+ // Prisma: prisma.user.findMany({ where: {...} })
297
+ // Sequelize: Model.findAll({ where: {...} })
298
+ // TypeORM: repository.find({ where: {...} })
299
+ const ormMethodPattern = /\.(findMany|findUnique|findFirst|findAll|find|create|update|delete|upsert)\s*\(\s*\{/i;
300
+ if (ormMethodPattern.test(line)) {
301
+ return; // ORM method - safe, no finding needed
302
+ }
303
+ // Check for parameterized queries - skip entirely (safe)
304
+ // e.g., db.query('SELECT * FROM users WHERE id = $1', [userId])
305
+ const parameterizedQueryPattern = /\.\s*(query|execute)\s*\(\s*['"`][^${}]+['"`]\s*,\s*\[/;
306
+ if (parameterizedQueryPattern.test(line)) {
307
+ return; // Parameterized query - safe, no finding needed
308
+ }
309
+ // No whitelist - report with standard severity
310
+ let severity = funcPattern.severity;
311
+ let confidence = 'high';
312
+ if (isTestFile) {
313
+ if (severity === 'critical') {
314
+ severity = 'medium';
315
+ }
316
+ else if (severity === 'high') {
317
+ severity = 'low';
318
+ }
319
+ else {
320
+ severity = 'info';
321
+ }
322
+ confidence = 'low';
323
+ }
324
+ vulnerabilities.push({
325
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
326
+ filePath,
327
+ lineNumber: index + 1,
328
+ lineContent: line.trim(),
329
+ severity,
330
+ category: 'dangerous_function',
331
+ title: funcPattern.name,
332
+ description: funcPattern.description + (isTestFile ? ' (in test file)' : ''),
333
+ suggestedFix: funcPattern.suggestedFix,
334
+ confidence,
335
+ layer: 2,
336
+ });
337
+ }
338
+ /**
339
+ * Handle dynamic file path patterns
340
+ */
341
+ function handleFilePathPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities) {
342
+ // Check file context for CLI/tooling (lower risk)
343
+ const isCLITool = /\/(cli|scripts?|tools?|bin)\//i.test(filePath) ||
344
+ /cli\.(ts|js)$/i.test(filePath);
345
+ // Check for GitHub Action context (workflow-controlled paths)
346
+ const isGitHubAction = /\/(github-action|actions?)\//i.test(filePath) ||
347
+ /action\.(ts|js)$/i.test(filePath);
348
+ // Check for utility/helper file context (called by trusted code)
349
+ const isUtilityFile = /\/(utils?|helpers?|lib|common|shared)\//i.test(filePath) ||
350
+ /(util(s)?|helper(s)?|checksum|hash)\.(ts|js)$/i.test(filePath);
351
+ // Get surrounding context for protection check
352
+ const lines = content.split('\n');
353
+ const contextStart = Math.max(0, index - 10);
354
+ const contextEnd = Math.min(lines.length, index + 10);
355
+ const context = lines.slice(contextStart, contextEnd).join('\n');
356
+ // Check if path comes from directory iteration (fs.readdir, fs.readdirSync)
357
+ // These paths are filesystem-controlled, not user input
358
+ const hasDirectoryIteration = /\b(readdir|readdirSync|opendir|opendirSync)\s*\(/.test(content) &&
359
+ (/for\s*\(\s*(const|let|var)\s+\w+\s+of/.test(context) ||
360
+ /\.forEach\s*\(/.test(context) ||
361
+ /entry\.(name|isFile|isDirectory)/.test(context) ||
362
+ /dirent\.(name|isFile|isDirectory)/.test(context));
363
+ if ((0, helpers_1.hasPathTraversalProtection)(context, line)) {
364
+ vulnerabilities.push({
365
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
366
+ filePath,
367
+ lineNumber: index + 1,
368
+ lineContent: line.trim(),
369
+ severity: 'info',
370
+ category: 'dangerous_function',
371
+ title: funcPattern.name + ' (protected)',
372
+ description: 'Dynamic file path with path traversal protection detected. Verify the protection is complete and covers all attack vectors.',
373
+ suggestedFix: 'Ensure path normalization and base directory checks are applied consistently.',
374
+ confidence: 'low',
375
+ layer: 2,
376
+ });
377
+ return;
378
+ }
379
+ // Directory iteration paths are filesystem-controlled (not user input)
380
+ if (hasDirectoryIteration) {
381
+ // Skip entirely - paths from fs.readdir are not user-controlled
382
+ return;
383
+ }
384
+ // GitHub Action paths are workflow-controlled (not arbitrary user input)
385
+ if (isGitHubAction) {
386
+ vulnerabilities.push({
387
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
388
+ filePath,
389
+ lineNumber: index + 1,
390
+ lineContent: line.trim(),
391
+ severity: 'info',
392
+ category: 'dangerous_function',
393
+ title: funcPattern.name + ' (GitHub Action)',
394
+ description: 'Dynamic file path in GitHub Action. Paths are typically controlled by workflow configuration, not arbitrary user input.',
395
+ suggestedFix: 'Verify paths come from trusted action inputs or environment variables.',
396
+ confidence: 'low',
397
+ layer: 2,
398
+ });
399
+ return;
400
+ }
401
+ // CLI tools with dynamic paths are lower risk (trusted operator)
402
+ if (isCLITool) {
403
+ vulnerabilities.push({
404
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
405
+ filePath,
406
+ lineNumber: index + 1,
407
+ lineContent: line.trim(),
408
+ severity: 'info',
409
+ category: 'dangerous_function',
410
+ title: funcPattern.name + ' (CLI tool)',
411
+ description: 'Dynamic file path in CLI tool. CLI tools typically have trusted operators, but consider adding path validation if user input is involved.',
412
+ suggestedFix: 'Add path validation if accepting paths from untrusted sources.',
413
+ confidence: 'low',
414
+ layer: 2,
415
+ });
416
+ return;
417
+ }
418
+ // Utility/helper files with function parameters are lower risk (called by trusted code)
419
+ // Check if path variable appears to be a function parameter, not from request
420
+ const hasRequestData = /req\.(params|query|body)|request\.(params|query|body)/i.test(context);
421
+ if (isUtilityFile && !hasRequestData) {
422
+ // Skip entirely - utility functions receive paths from trusted callers
423
+ return;
424
+ }
425
+ // Standard handling for unprotected paths
426
+ let severity = funcPattern.severity;
427
+ let confidence = 'high';
428
+ if (isTestFile) {
429
+ if (severity === 'critical') {
430
+ severity = 'medium';
431
+ }
432
+ else if (severity === 'high') {
433
+ severity = 'low';
434
+ }
435
+ else {
436
+ severity = 'info';
437
+ }
438
+ confidence = 'low';
439
+ }
440
+ vulnerabilities.push({
441
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
442
+ filePath,
443
+ lineNumber: index + 1,
444
+ lineContent: line.trim(),
445
+ severity,
446
+ category: 'dangerous_function',
447
+ title: funcPattern.name,
448
+ description: funcPattern.description + (isTestFile ? ' (in test file)' : ''),
449
+ suggestedFix: funcPattern.suggestedFix,
450
+ confidence,
451
+ layer: 2,
452
+ });
453
+ }
454
+ /**
455
+ * Handle Math.random patterns with context-aware severity
456
+ */
457
+ function handleMathRandomPattern(funcPattern, line, content, index, filePath, isTestFile, vulnerabilities) {
458
+ // Skip entirely for certain contexts
459
+ if ((0, math_random_1.shouldSkipMathRandom)(content, filePath, index)) {
460
+ return;
461
+ }
462
+ // Analyze context
463
+ const functionName = (0, control_flow_1.extractFunctionContext)(content, index);
464
+ const functionIntent = (0, math_random_1.classifyFunctionIntent)(functionName);
465
+ const toStringPattern = (0, math_random_1.analyzeToStringPattern)(line);
466
+ const variableName = (0, math_random_1.extractMathRandomVariableName)(line);
467
+ const variableRisk = (0, math_random_1.classifyVariableNameRisk)(variableName);
468
+ const context = (0, math_random_1.analyzeMathRandomContext)(content, filePath, index);
469
+ // Determine severity based on all factors
470
+ let severity;
471
+ let confidence;
472
+ let description;
473
+ let suggestedFix;
474
+ let explanation = '';
475
+ // Variable name indicates security risk - check this FIRST before toString patterns
476
+ // This ensures 'secret', 'token', 'key' etc. are always flagged as high
477
+ if (variableRisk === 'high') {
478
+ severity = 'high';
479
+ confidence = 'high';
480
+ // Update context description to indicate security context
481
+ context.contextDescription = 'security-sensitive variable';
482
+ description = `Math.random() assigned to security-sensitive variable '${variableName}'. Math.random() is NOT cryptographically secure.`;
483
+ suggestedFix =
484
+ 'Use crypto.randomBytes() or crypto.getRandomValues() for security-sensitive values.';
485
+ }
486
+ // Security-sensitive contexts get high severity
487
+ else if (context.inSecurityContext || functionIntent === 'security') {
488
+ severity = 'high';
489
+ confidence = 'high';
490
+ description =
491
+ 'Math.random() is being used in a security-sensitive context. This is NOT cryptographically secure and should be replaced.';
492
+ suggestedFix =
493
+ 'Use crypto.randomBytes() for Node.js or crypto.getRandomValues() for browsers.';
494
+ }
495
+ // Test contexts get info severity
496
+ else if (context.inTestContext) {
497
+ severity = 'info';
498
+ confidence = 'low';
499
+ description =
500
+ 'Math.random() in test context. Acceptable for test data generation.';
501
+ suggestedFix = 'No change needed for test data.';
502
+ }
503
+ // UUID/CAPTCHA generation - legitimate use
504
+ else if (functionIntent === 'uuid' || functionIntent === 'captcha') {
505
+ severity = 'info';
506
+ confidence = 'low';
507
+ description = `Math.random() used for ${functionIntent === 'uuid' ? 'ID generation' : 'CAPTCHA/puzzle'} (not security-sensitive).`;
508
+ suggestedFix =
509
+ 'For truly unique IDs, consider crypto.randomUUID(). For security tokens, use crypto.randomBytes().';
510
+ }
511
+ // Demo/seed data - legitimate use
512
+ else if (functionIntent === 'demo') {
513
+ severity = 'info';
514
+ confidence = 'low';
515
+ description =
516
+ 'Math.random() for demo/seed data generation. Acceptable for non-production data.';
517
+ suggestedFix = 'No change needed for demo/seed data.';
518
+ }
519
+ // Short UI IDs (.toString(36).substring(2,9)) - info
520
+ else if (toStringPattern.intent === 'short-ui-id') {
521
+ severity = 'info';
522
+ confidence = 'low';
523
+ explanation = ` (${toStringPattern.truncationLength || '?'}-char string)`;
524
+ // Override context description for UI IDs
525
+ context.contextDescription = 'UI identifier generation';
526
+ description = `Math.random() generating short UI identifier${explanation}. Acceptable for React keys, temp IDs.`;
527
+ suggestedFix =
528
+ 'For security tokens, use crypto.randomBytes(). For unique IDs, crypto.randomUUID().';
529
+ }
530
+ // Business IDs (.toString(36) with medium truncation) - low
531
+ else if (toStringPattern.intent === 'business-id') {
532
+ severity = 'low';
533
+ confidence = 'low';
534
+ explanation = variableName ? ` (variable: ${variableName})` : '';
535
+ description = `Math.random() generating business identifier${explanation}. Verify this is not used for security purposes.`;
536
+ suggestedFix =
537
+ 'For business IDs, crypto.randomUUID() is preferred. For security tokens, use crypto.randomBytes().';
538
+ }
539
+ // Full token (.toString(36) without truncation) - severity based on variable name
540
+ else if (toStringPattern.intent === 'full-token') {
541
+ // Note: high-risk variable names are already handled above
542
+ if (variableRisk === 'low') {
543
+ severity = 'low';
544
+ confidence = 'low';
545
+ }
546
+ else {
547
+ severity = 'medium';
548
+ confidence = 'medium';
549
+ }
550
+ explanation = variableName ? ` (variable: ${variableName})` : '';
551
+ description = `Math.random() generating full-length random string${explanation}. This pattern is often used for security tokens.`;
552
+ suggestedFix =
553
+ 'Use crypto.randomBytes() for security tokens. Use crypto.randomUUID() for unique IDs.';
554
+ }
555
+ // Business logic context - low
556
+ else if (context.inBusinessLogicContext) {
557
+ severity = 'low';
558
+ confidence = 'low';
559
+ description =
560
+ 'Math.random() in business logic context (backoff, sampling, experiments). Verify this is not for security.';
561
+ suggestedFix =
562
+ 'If used for security, replace with crypto.randomBytes(). Otherwise, usage is acceptable.';
563
+ }
564
+ // Unknown context - medium
565
+ else {
566
+ severity = 'medium';
567
+ confidence = 'medium';
568
+ description =
569
+ 'Math.random() is being used. Verify this is not for security-critical purposes like tokens, session IDs, or cryptographic operations.';
570
+ suggestedFix =
571
+ 'If used for security, replace with crypto.randomBytes(). For unique IDs, use crypto.randomUUID()';
572
+ }
573
+ // Update title with context
574
+ const title = `Math.random() in ${context.contextDescription}${explanation}`;
575
+ vulnerabilities.push({
576
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
577
+ filePath,
578
+ lineNumber: index + 1,
579
+ lineContent: line.trim(),
580
+ severity,
581
+ category: 'dangerous_function',
582
+ title,
583
+ description,
584
+ suggestedFix,
585
+ confidence,
586
+ layer: 2,
587
+ });
588
+ }
589
+ /**
590
+ * Handle standard patterns without special logic
591
+ */
592
+ function handleStandardPattern(funcPattern, line, index, filePath, isTestFile, vulnerabilities) {
593
+ let severity = funcPattern.severity;
594
+ let confidence = 'high';
595
+ if (isTestFile) {
596
+ if (severity === 'critical') {
597
+ severity = 'medium';
598
+ }
599
+ else if (severity === 'high') {
600
+ severity = 'low';
601
+ }
602
+ else {
603
+ severity = 'info';
604
+ }
605
+ confidence = 'low';
606
+ }
607
+ vulnerabilities.push({
608
+ id: `dangerous-func-${filePath}-${index + 1}-${funcPattern.name}`,
609
+ filePath,
610
+ lineNumber: index + 1,
611
+ lineContent: line.trim(),
612
+ severity,
613
+ category: 'dangerous_function',
614
+ title: funcPattern.name,
615
+ description: funcPattern.description + (isTestFile ? ' (in test file)' : ''),
616
+ suggestedFix: funcPattern.suggestedFix,
617
+ confidence,
618
+ layer: 2,
619
+ });
620
+ }
621
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layer2/dangerous-functions/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAyDH,4DA8JC;AApND,iEAKoC;AAEpC,sBAAsB;AACtB,yCAImB;AAEnB,0BAA0B;AAC1B,mDAAyE;AAEzE,oBAAoB;AACpB,uCAMkB;AAElB,uBAAuB;AACvB,6CAAkD;AAElD,wBAAwB;AACxB,+CAQsB;AAEtB,+BAA+B;AAC/B,6DAAkE;AAElE,YAAY;AACZ,uDA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