secure-scan 1.2.2

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 (569) hide show
  1. package/README.md +564 -0
  2. package/dist/ai/aiAnalyzer.d.ts +99 -0
  3. package/dist/ai/aiAnalyzer.d.ts.map +1 -0
  4. package/dist/ai/aiAnalyzer.js +669 -0
  5. package/dist/ai/aiAnalyzer.js.map +1 -0
  6. package/dist/ai/index.d.ts +5 -0
  7. package/dist/ai/index.d.ts.map +1 -0
  8. package/dist/ai/index.js +21 -0
  9. package/dist/ai/index.js.map +1 -0
  10. package/dist/analyzers/base/baseAnalyzer.d.ts +44 -0
  11. package/dist/analyzers/base/baseAnalyzer.d.ts.map +1 -0
  12. package/dist/analyzers/base/baseAnalyzer.js +53 -0
  13. package/dist/analyzers/base/baseAnalyzer.js.map +1 -0
  14. package/dist/analyzers/base/index.d.ts +5 -0
  15. package/dist/analyzers/base/index.d.ts.map +1 -0
  16. package/dist/analyzers/base/index.js +21 -0
  17. package/dist/analyzers/base/index.js.map +1 -0
  18. package/dist/analyzers/c-cpp/cppAnalyzer.d.ts +60 -0
  19. package/dist/analyzers/c-cpp/cppAnalyzer.d.ts.map +1 -0
  20. package/dist/analyzers/c-cpp/cppAnalyzer.js +218 -0
  21. package/dist/analyzers/c-cpp/cppAnalyzer.js.map +1 -0
  22. package/dist/analyzers/c-cpp/index.d.ts +5 -0
  23. package/dist/analyzers/c-cpp/index.d.ts.map +1 -0
  24. package/dist/analyzers/c-cpp/index.js +21 -0
  25. package/dist/analyzers/c-cpp/index.js.map +1 -0
  26. package/dist/analyzers/core/engine/index.d.ts +5 -0
  27. package/dist/analyzers/core/engine/index.d.ts.map +1 -0
  28. package/dist/analyzers/core/engine/index.js +21 -0
  29. package/dist/analyzers/core/engine/index.js.map +1 -0
  30. package/dist/analyzers/core/engine/ruleEngine.d.ts +46 -0
  31. package/dist/analyzers/core/engine/ruleEngine.d.ts.map +1 -0
  32. package/dist/analyzers/core/engine/ruleEngine.js +173 -0
  33. package/dist/analyzers/core/engine/ruleEngine.js.map +1 -0
  34. package/dist/analyzers/core/index.d.ts +8 -0
  35. package/dist/analyzers/core/index.d.ts.map +1 -0
  36. package/dist/analyzers/core/index.js +24 -0
  37. package/dist/analyzers/core/index.js.map +1 -0
  38. package/dist/analyzers/core/scanner/fileScanner.d.ts +31 -0
  39. package/dist/analyzers/core/scanner/fileScanner.d.ts.map +1 -0
  40. package/dist/analyzers/core/scanner/fileScanner.js +199 -0
  41. package/dist/analyzers/core/scanner/fileScanner.js.map +1 -0
  42. package/dist/analyzers/core/scanner/index.d.ts +5 -0
  43. package/dist/analyzers/core/scanner/index.d.ts.map +1 -0
  44. package/dist/analyzers/core/scanner/index.js +21 -0
  45. package/dist/analyzers/core/scanner/index.js.map +1 -0
  46. package/dist/analyzers/core/scoring/index.d.ts +5 -0
  47. package/dist/analyzers/core/scoring/index.d.ts.map +1 -0
  48. package/dist/analyzers/core/scoring/index.js +21 -0
  49. package/dist/analyzers/core/scoring/index.js.map +1 -0
  50. package/dist/analyzers/core/scoring/riskScoring.d.ts +49 -0
  51. package/dist/analyzers/core/scoring/riskScoring.d.ts.map +1 -0
  52. package/dist/analyzers/core/scoring/riskScoring.js +180 -0
  53. package/dist/analyzers/core/scoring/riskScoring.js.map +1 -0
  54. package/dist/analyzers/core/securityScanner.d.ts +47 -0
  55. package/dist/analyzers/core/securityScanner.d.ts.map +1 -0
  56. package/dist/analyzers/core/securityScanner.js +298 -0
  57. package/dist/analyzers/core/securityScanner.js.map +1 -0
  58. package/dist/analyzers/csharp/csharpAnalyzer.d.ts +64 -0
  59. package/dist/analyzers/csharp/csharpAnalyzer.d.ts.map +1 -0
  60. package/dist/analyzers/csharp/csharpAnalyzer.js +232 -0
  61. package/dist/analyzers/csharp/csharpAnalyzer.js.map +1 -0
  62. package/dist/analyzers/csharp/index.d.ts +5 -0
  63. package/dist/analyzers/csharp/index.d.ts.map +1 -0
  64. package/dist/analyzers/csharp/index.js +21 -0
  65. package/dist/analyzers/csharp/index.js.map +1 -0
  66. package/dist/analyzers/iac/iacAnalyzer.d.ts +36 -0
  67. package/dist/analyzers/iac/iacAnalyzer.d.ts.map +1 -0
  68. package/dist/analyzers/iac/iacAnalyzer.js +182 -0
  69. package/dist/analyzers/iac/iacAnalyzer.js.map +1 -0
  70. package/dist/analyzers/iac/index.d.ts +5 -0
  71. package/dist/analyzers/iac/index.d.ts.map +1 -0
  72. package/dist/analyzers/iac/index.js +21 -0
  73. package/dist/analyzers/iac/index.js.map +1 -0
  74. package/dist/analyzers/index.d.ts +30 -0
  75. package/dist/analyzers/index.d.ts.map +1 -0
  76. package/dist/analyzers/index.js +80 -0
  77. package/dist/analyzers/index.js.map +1 -0
  78. package/dist/analyzers/java/index.d.ts +5 -0
  79. package/dist/analyzers/java/index.d.ts.map +1 -0
  80. package/dist/analyzers/java/index.js +21 -0
  81. package/dist/analyzers/java/index.js.map +1 -0
  82. package/dist/analyzers/java/javaAnalyzer.d.ts +64 -0
  83. package/dist/analyzers/java/javaAnalyzer.d.ts.map +1 -0
  84. package/dist/analyzers/java/javaAnalyzer.js +224 -0
  85. package/dist/analyzers/java/javaAnalyzer.js.map +1 -0
  86. package/dist/analyzers/javascript/astUtils.d.ts +170 -0
  87. package/dist/analyzers/javascript/astUtils.d.ts.map +1 -0
  88. package/dist/analyzers/javascript/astUtils.js +700 -0
  89. package/dist/analyzers/javascript/astUtils.js.map +1 -0
  90. package/dist/analyzers/javascript/index.d.ts +18 -0
  91. package/dist/analyzers/javascript/index.d.ts.map +1 -0
  92. package/dist/analyzers/javascript/index.js +50 -0
  93. package/dist/analyzers/javascript/index.js.map +1 -0
  94. package/dist/analyzers/javascript/javascriptAnalyzer.d.ts +111 -0
  95. package/dist/analyzers/javascript/javascriptAnalyzer.d.ts.map +1 -0
  96. package/dist/analyzers/javascript/javascriptAnalyzer.js +860 -0
  97. package/dist/analyzers/javascript/javascriptAnalyzer.js.map +1 -0
  98. package/dist/analyzers/javascript/malwareDetector.d.ts +102 -0
  99. package/dist/analyzers/javascript/malwareDetector.d.ts.map +1 -0
  100. package/dist/analyzers/javascript/malwareDetector.js +616 -0
  101. package/dist/analyzers/javascript/malwareDetector.js.map +1 -0
  102. package/dist/analyzers/javascript/packageJsonAnalyzer.d.ts +87 -0
  103. package/dist/analyzers/javascript/packageJsonAnalyzer.d.ts.map +1 -0
  104. package/dist/analyzers/javascript/packageJsonAnalyzer.js +553 -0
  105. package/dist/analyzers/javascript/packageJsonAnalyzer.js.map +1 -0
  106. package/dist/analyzers/javascript/taintAnalyzer.d.ts +120 -0
  107. package/dist/analyzers/javascript/taintAnalyzer.d.ts.map +1 -0
  108. package/dist/analyzers/javascript/taintAnalyzer.js +526 -0
  109. package/dist/analyzers/javascript/taintAnalyzer.js.map +1 -0
  110. package/dist/analyzers/php/index.d.ts +5 -0
  111. package/dist/analyzers/php/index.d.ts.map +1 -0
  112. package/dist/analyzers/php/index.js +21 -0
  113. package/dist/analyzers/php/index.js.map +1 -0
  114. package/dist/analyzers/php/phpAnalyzer.d.ts +56 -0
  115. package/dist/analyzers/php/phpAnalyzer.d.ts.map +1 -0
  116. package/dist/analyzers/php/phpAnalyzer.js +202 -0
  117. package/dist/analyzers/php/phpAnalyzer.js.map +1 -0
  118. package/dist/analyzers/python/index.d.ts +5 -0
  119. package/dist/analyzers/python/index.d.ts.map +1 -0
  120. package/dist/analyzers/python/index.js +21 -0
  121. package/dist/analyzers/python/index.js.map +1 -0
  122. package/dist/analyzers/python/pythonAnalyzer.d.ts +64 -0
  123. package/dist/analyzers/python/pythonAnalyzer.d.ts.map +1 -0
  124. package/dist/analyzers/python/pythonAnalyzer.js +226 -0
  125. package/dist/analyzers/python/pythonAnalyzer.js.map +1 -0
  126. package/dist/cli/index.d.ts +7 -0
  127. package/dist/cli/index.d.ts.map +1 -0
  128. package/dist/cli/index.js +281 -0
  129. package/dist/cli/index.js.map +1 -0
  130. package/dist/core/engine/index.d.ts +5 -0
  131. package/dist/core/engine/index.d.ts.map +1 -0
  132. package/dist/core/engine/index.js +21 -0
  133. package/dist/core/engine/index.js.map +1 -0
  134. package/dist/core/engine/ruleEngine.d.ts +46 -0
  135. package/dist/core/engine/ruleEngine.d.ts.map +1 -0
  136. package/dist/core/engine/ruleEngine.js +173 -0
  137. package/dist/core/engine/ruleEngine.js.map +1 -0
  138. package/dist/core/index.d.ts +8 -0
  139. package/dist/core/index.d.ts.map +1 -0
  140. package/dist/core/index.js +24 -0
  141. package/dist/core/index.js.map +1 -0
  142. package/dist/core/scanner/fileScanner.d.ts +31 -0
  143. package/dist/core/scanner/fileScanner.d.ts.map +1 -0
  144. package/dist/core/scanner/fileScanner.js +199 -0
  145. package/dist/core/scanner/fileScanner.js.map +1 -0
  146. package/dist/core/scanner/index.d.ts +5 -0
  147. package/dist/core/scanner/index.d.ts.map +1 -0
  148. package/dist/core/scanner/index.js +21 -0
  149. package/dist/core/scanner/index.js.map +1 -0
  150. package/dist/core/scoring/index.d.ts +5 -0
  151. package/dist/core/scoring/index.d.ts.map +1 -0
  152. package/dist/core/scoring/index.js +21 -0
  153. package/dist/core/scoring/index.js.map +1 -0
  154. package/dist/core/scoring/riskScoring.d.ts +49 -0
  155. package/dist/core/scoring/riskScoring.d.ts.map +1 -0
  156. package/dist/core/scoring/riskScoring.js +180 -0
  157. package/dist/core/scoring/riskScoring.js.map +1 -0
  158. package/dist/core/securityScanner.d.ts +47 -0
  159. package/dist/core/securityScanner.d.ts.map +1 -0
  160. package/dist/core/securityScanner.js +298 -0
  161. package/dist/core/securityScanner.js.map +1 -0
  162. package/dist/dependencies/aiDependencyAnalyzer.d.ts +96 -0
  163. package/dist/dependencies/aiDependencyAnalyzer.d.ts.map +1 -0
  164. package/dist/dependencies/aiDependencyAnalyzer.js +435 -0
  165. package/dist/dependencies/aiDependencyAnalyzer.js.map +1 -0
  166. package/dist/dependencies/database/cveDatabase.d.ts +32 -0
  167. package/dist/dependencies/database/cveDatabase.d.ts.map +1 -0
  168. package/dist/dependencies/database/cveDatabase.js +393 -0
  169. package/dist/dependencies/database/cveDatabase.js.map +1 -0
  170. package/dist/dependencies/database/index.d.ts +6 -0
  171. package/dist/dependencies/database/index.d.ts.map +1 -0
  172. package/dist/dependencies/database/index.js +22 -0
  173. package/dist/dependencies/database/index.js.map +1 -0
  174. package/dist/dependencies/database/maliciousPackages.d.ts +43 -0
  175. package/dist/dependencies/database/maliciousPackages.d.ts.map +1 -0
  176. package/dist/dependencies/database/maliciousPackages.js +279 -0
  177. package/dist/dependencies/database/maliciousPackages.js.map +1 -0
  178. package/dist/dependencies/dependencyAnalyzer.d.ts +74 -0
  179. package/dist/dependencies/dependencyAnalyzer.d.ts.map +1 -0
  180. package/dist/dependencies/dependencyAnalyzer.js +349 -0
  181. package/dist/dependencies/dependencyAnalyzer.js.map +1 -0
  182. package/dist/dependencies/detectors/index.d.ts +7 -0
  183. package/dist/dependencies/detectors/index.d.ts.map +1 -0
  184. package/dist/dependencies/detectors/index.js +28 -0
  185. package/dist/dependencies/detectors/index.js.map +1 -0
  186. package/dist/dependencies/detectors/securityStandards.d.ts +15 -0
  187. package/dist/dependencies/detectors/securityStandards.d.ts.map +1 -0
  188. package/dist/dependencies/detectors/securityStandards.js +178 -0
  189. package/dist/dependencies/detectors/securityStandards.js.map +1 -0
  190. package/dist/dependencies/detectors/vulnerabilityDetector.d.ts +53 -0
  191. package/dist/dependencies/detectors/vulnerabilityDetector.d.ts.map +1 -0
  192. package/dist/dependencies/detectors/vulnerabilityDetector.js +289 -0
  193. package/dist/dependencies/detectors/vulnerabilityDetector.js.map +1 -0
  194. package/dist/dependencies/index.d.ts +14 -0
  195. package/dist/dependencies/index.d.ts.map +1 -0
  196. package/dist/dependencies/index.js +43 -0
  197. package/dist/dependencies/index.js.map +1 -0
  198. package/dist/dependencies/installed/index.d.ts +8 -0
  199. package/dist/dependencies/installed/index.d.ts.map +1 -0
  200. package/dist/dependencies/installed/index.js +24 -0
  201. package/dist/dependencies/installed/index.js.map +1 -0
  202. package/dist/dependencies/installed/installedScanner.d.ts +91 -0
  203. package/dist/dependencies/installed/installedScanner.d.ts.map +1 -0
  204. package/dist/dependencies/installed/installedScanner.js +766 -0
  205. package/dist/dependencies/installed/installedScanner.js.map +1 -0
  206. package/dist/dependencies/installed/malwarePatterns.d.ts +32 -0
  207. package/dist/dependencies/installed/malwarePatterns.d.ts.map +1 -0
  208. package/dist/dependencies/installed/malwarePatterns.js +480 -0
  209. package/dist/dependencies/installed/malwarePatterns.js.map +1 -0
  210. package/dist/dependencies/installed/types.d.ts +274 -0
  211. package/dist/dependencies/installed/types.d.ts.map +1 -0
  212. package/dist/dependencies/installed/types.js +7 -0
  213. package/dist/dependencies/installed/types.js.map +1 -0
  214. package/dist/dependencies/parsers/base/baseParser.d.ts +44 -0
  215. package/dist/dependencies/parsers/base/baseParser.d.ts.map +1 -0
  216. package/dist/dependencies/parsers/base/baseParser.js +80 -0
  217. package/dist/dependencies/parsers/base/baseParser.js.map +1 -0
  218. package/dist/dependencies/parsers/base/index.d.ts +6 -0
  219. package/dist/dependencies/parsers/base/index.d.ts.map +1 -0
  220. package/dist/dependencies/parsers/base/index.js +27 -0
  221. package/dist/dependencies/parsers/base/index.js.map +1 -0
  222. package/dist/dependencies/parsers/cpp/cppParser.d.ts +36 -0
  223. package/dist/dependencies/parsers/cpp/cppParser.d.ts.map +1 -0
  224. package/dist/dependencies/parsers/cpp/cppParser.js +196 -0
  225. package/dist/dependencies/parsers/cpp/cppParser.js.map +1 -0
  226. package/dist/dependencies/parsers/cpp/index.d.ts +6 -0
  227. package/dist/dependencies/parsers/cpp/index.d.ts.map +1 -0
  228. package/dist/dependencies/parsers/cpp/index.js +27 -0
  229. package/dist/dependencies/parsers/cpp/index.js.map +1 -0
  230. package/dist/dependencies/parsers/csharp/csharpParser.d.ts +32 -0
  231. package/dist/dependencies/parsers/csharp/csharpParser.d.ts.map +1 -0
  232. package/dist/dependencies/parsers/csharp/csharpParser.js +125 -0
  233. package/dist/dependencies/parsers/csharp/csharpParser.js.map +1 -0
  234. package/dist/dependencies/parsers/csharp/index.d.ts +6 -0
  235. package/dist/dependencies/parsers/csharp/index.d.ts.map +1 -0
  236. package/dist/dependencies/parsers/csharp/index.js +27 -0
  237. package/dist/dependencies/parsers/csharp/index.js.map +1 -0
  238. package/dist/dependencies/parsers/index.d.ts +24 -0
  239. package/dist/dependencies/parsers/index.d.ts.map +1 -0
  240. package/dist/dependencies/parsers/index.js +69 -0
  241. package/dist/dependencies/parsers/index.js.map +1 -0
  242. package/dist/dependencies/parsers/java/index.d.ts +6 -0
  243. package/dist/dependencies/parsers/java/index.d.ts.map +1 -0
  244. package/dist/dependencies/parsers/java/index.js +27 -0
  245. package/dist/dependencies/parsers/java/index.js.map +1 -0
  246. package/dist/dependencies/parsers/java/javaParser.d.ts +32 -0
  247. package/dist/dependencies/parsers/java/javaParser.d.ts.map +1 -0
  248. package/dist/dependencies/parsers/java/javaParser.js +168 -0
  249. package/dist/dependencies/parsers/java/javaParser.js.map +1 -0
  250. package/dist/dependencies/parsers/javascript/index.d.ts +6 -0
  251. package/dist/dependencies/parsers/javascript/index.d.ts.map +1 -0
  252. package/dist/dependencies/parsers/javascript/index.js +27 -0
  253. package/dist/dependencies/parsers/javascript/index.js.map +1 -0
  254. package/dist/dependencies/parsers/javascript/javascriptParser.d.ts +55 -0
  255. package/dist/dependencies/parsers/javascript/javascriptParser.d.ts.map +1 -0
  256. package/dist/dependencies/parsers/javascript/javascriptParser.js +266 -0
  257. package/dist/dependencies/parsers/javascript/javascriptParser.js.map +1 -0
  258. package/dist/dependencies/parsers/php/index.d.ts +6 -0
  259. package/dist/dependencies/parsers/php/index.d.ts.map +1 -0
  260. package/dist/dependencies/parsers/php/index.js +27 -0
  261. package/dist/dependencies/parsers/php/index.js.map +1 -0
  262. package/dist/dependencies/parsers/php/phpParser.d.ts +35 -0
  263. package/dist/dependencies/parsers/php/phpParser.d.ts.map +1 -0
  264. package/dist/dependencies/parsers/php/phpParser.js +162 -0
  265. package/dist/dependencies/parsers/php/phpParser.js.map +1 -0
  266. package/dist/dependencies/parsers/python/index.d.ts +6 -0
  267. package/dist/dependencies/parsers/python/index.d.ts.map +1 -0
  268. package/dist/dependencies/parsers/python/index.js +27 -0
  269. package/dist/dependencies/parsers/python/index.js.map +1 -0
  270. package/dist/dependencies/parsers/python/pythonParser.d.ts +60 -0
  271. package/dist/dependencies/parsers/python/pythonParser.d.ts.map +1 -0
  272. package/dist/dependencies/parsers/python/pythonParser.js +336 -0
  273. package/dist/dependencies/parsers/python/pythonParser.js.map +1 -0
  274. package/dist/dependencies/types.d.ts +280 -0
  275. package/dist/dependencies/types.d.ts.map +1 -0
  276. package/dist/dependencies/types.js +59 -0
  277. package/dist/dependencies/types.js.map +1 -0
  278. package/dist/i18n/index.d.ts +2 -0
  279. package/dist/i18n/index.d.ts.map +1 -0
  280. package/dist/i18n/index.js +18 -0
  281. package/dist/i18n/index.js.map +1 -0
  282. package/dist/i18n/translations.d.ts +55 -0
  283. package/dist/i18n/translations.d.ts.map +1 -0
  284. package/dist/i18n/translations.js +119 -0
  285. package/dist/i18n/translations.js.map +1 -0
  286. package/dist/index.d.ts +14 -0
  287. package/dist/index.d.ts.map +1 -0
  288. package/dist/index.js +36 -0
  289. package/dist/index.js.map +1 -0
  290. package/dist/reports/dependencyReportGenerator.d.ts +20 -0
  291. package/dist/reports/dependencyReportGenerator.d.ts.map +1 -0
  292. package/dist/reports/dependencyReportGenerator.js +690 -0
  293. package/dist/reports/dependencyReportGenerator.js.map +1 -0
  294. package/dist/reports/htmlReportGenerator.d.ts +43 -0
  295. package/dist/reports/htmlReportGenerator.d.ts.map +1 -0
  296. package/dist/reports/htmlReportGenerator.js +793 -0
  297. package/dist/reports/htmlReportGenerator.js.map +1 -0
  298. package/dist/reports/index.d.ts +7 -0
  299. package/dist/reports/index.d.ts.map +1 -0
  300. package/dist/reports/index.js +23 -0
  301. package/dist/reports/index.js.map +1 -0
  302. package/dist/reports/installedDepsReportGenerator.d.ts +14 -0
  303. package/dist/reports/installedDepsReportGenerator.d.ts.map +1 -0
  304. package/dist/reports/installedDepsReportGenerator.js +872 -0
  305. package/dist/reports/installedDepsReportGenerator.js.map +1 -0
  306. package/dist/rules/index.d.ts +31 -0
  307. package/dist/rules/index.d.ts.map +1 -0
  308. package/dist/rules/index.js +95 -0
  309. package/dist/rules/index.js.map +1 -0
  310. package/dist/rules/malware/categories/backdoors.d.ts +12 -0
  311. package/dist/rules/malware/categories/backdoors.d.ts.map +1 -0
  312. package/dist/rules/malware/categories/backdoors.js +163 -0
  313. package/dist/rules/malware/categories/backdoors.js.map +1 -0
  314. package/dist/rules/malware/categories/cryptominers.d.ts +13 -0
  315. package/dist/rules/malware/categories/cryptominers.d.ts.map +1 -0
  316. package/dist/rules/malware/categories/cryptominers.js +415 -0
  317. package/dist/rules/malware/categories/cryptominers.js.map +1 -0
  318. package/dist/rules/malware/categories/exfiltration.d.ts +20 -0
  319. package/dist/rules/malware/categories/exfiltration.d.ts.map +1 -0
  320. package/dist/rules/malware/categories/exfiltration.js +658 -0
  321. package/dist/rules/malware/categories/exfiltration.js.map +1 -0
  322. package/dist/rules/malware/categories/keyloggers.d.ts +19 -0
  323. package/dist/rules/malware/categories/keyloggers.d.ts.map +1 -0
  324. package/dist/rules/malware/categories/keyloggers.js +763 -0
  325. package/dist/rules/malware/categories/keyloggers.js.map +1 -0
  326. package/dist/rules/malware/categories/loaders.d.ts +20 -0
  327. package/dist/rules/malware/categories/loaders.d.ts.map +1 -0
  328. package/dist/rules/malware/categories/loaders.js +702 -0
  329. package/dist/rules/malware/categories/loaders.js.map +1 -0
  330. package/dist/rules/malware/categories/network.d.ts +19 -0
  331. package/dist/rules/malware/categories/network.d.ts.map +1 -0
  332. package/dist/rules/malware/categories/network.js +622 -0
  333. package/dist/rules/malware/categories/network.js.map +1 -0
  334. package/dist/rules/malware/categories/obfuscation.d.ts +22 -0
  335. package/dist/rules/malware/categories/obfuscation.d.ts.map +1 -0
  336. package/dist/rules/malware/categories/obfuscation.js +766 -0
  337. package/dist/rules/malware/categories/obfuscation.js.map +1 -0
  338. package/dist/rules/malware/constants/index.d.ts +281 -0
  339. package/dist/rules/malware/constants/index.d.ts.map +1 -0
  340. package/dist/rules/malware/constants/index.js +327 -0
  341. package/dist/rules/malware/constants/index.js.map +1 -0
  342. package/dist/rules/malware/engine/index.d.ts +178 -0
  343. package/dist/rules/malware/engine/index.d.ts.map +1 -0
  344. package/dist/rules/malware/engine/index.js +552 -0
  345. package/dist/rules/malware/engine/index.js.map +1 -0
  346. package/dist/rules/malware/index.d.ts +205 -0
  347. package/dist/rules/malware/index.d.ts.map +1 -0
  348. package/dist/rules/malware/index.js +837 -0
  349. package/dist/rules/malware/index.js.map +1 -0
  350. package/dist/rules/malware/scoring/index.d.ts +84 -0
  351. package/dist/rules/malware/scoring/index.d.ts.map +1 -0
  352. package/dist/rules/malware/scoring/index.js +441 -0
  353. package/dist/rules/malware/scoring/index.js.map +1 -0
  354. package/dist/rules/malware/types/index.d.ts +616 -0
  355. package/dist/rules/malware/types/index.d.ts.map +1 -0
  356. package/dist/rules/malware/types/index.js +155 -0
  357. package/dist/rules/malware/types/index.js.map +1 -0
  358. package/dist/rules/malware/utils/index.d.ts +117 -0
  359. package/dist/rules/malware/utils/index.d.ts.map +1 -0
  360. package/dist/rules/malware/utils/index.js +514 -0
  361. package/dist/rules/malware/utils/index.js.map +1 -0
  362. package/dist/rules/standards.d.ts +26 -0
  363. package/dist/rules/standards.d.ts.map +1 -0
  364. package/dist/rules/standards.js +352 -0
  365. package/dist/rules/standards.js.map +1 -0
  366. package/dist/rules/vulnerabilities/constants/index.d.ts +835 -0
  367. package/dist/rules/vulnerabilities/constants/index.d.ts.map +1 -0
  368. package/dist/rules/vulnerabilities/constants/index.js +544 -0
  369. package/dist/rules/vulnerabilities/constants/index.js.map +1 -0
  370. package/dist/rules/vulnerabilities/engine/index.d.ts +145 -0
  371. package/dist/rules/vulnerabilities/engine/index.d.ts.map +1 -0
  372. package/dist/rules/vulnerabilities/engine/index.js +581 -0
  373. package/dist/rules/vulnerabilities/engine/index.js.map +1 -0
  374. package/dist/rules/vulnerabilities/index.d.ts +148 -0
  375. package/dist/rules/vulnerabilities/index.d.ts.map +1 -0
  376. package/dist/rules/vulnerabilities/index.js +252 -0
  377. package/dist/rules/vulnerabilities/index.js.map +1 -0
  378. package/dist/rules/vulnerabilities/rules/authentication.d.ts +8 -0
  379. package/dist/rules/vulnerabilities/rules/authentication.d.ts.map +1 -0
  380. package/dist/rules/vulnerabilities/rules/authentication.js +419 -0
  381. package/dist/rules/vulnerabilities/rules/authentication.js.map +1 -0
  382. package/dist/rules/vulnerabilities/rules/commandInjection.d.ts +8 -0
  383. package/dist/rules/vulnerabilities/rules/commandInjection.d.ts.map +1 -0
  384. package/dist/rules/vulnerabilities/rules/commandInjection.js +300 -0
  385. package/dist/rules/vulnerabilities/rules/commandInjection.js.map +1 -0
  386. package/dist/rules/vulnerabilities/rules/csrf.d.ts +8 -0
  387. package/dist/rules/vulnerabilities/rules/csrf.d.ts.map +1 -0
  388. package/dist/rules/vulnerabilities/rules/csrf.js +261 -0
  389. package/dist/rules/vulnerabilities/rules/csrf.js.map +1 -0
  390. package/dist/rules/vulnerabilities/rules/deserialization.d.ts +8 -0
  391. package/dist/rules/vulnerabilities/rules/deserialization.d.ts.map +1 -0
  392. package/dist/rules/vulnerabilities/rules/deserialization.js +336 -0
  393. package/dist/rules/vulnerabilities/rules/deserialization.js.map +1 -0
  394. package/dist/rules/vulnerabilities/rules/fileUpload.d.ts +8 -0
  395. package/dist/rules/vulnerabilities/rules/fileUpload.d.ts.map +1 -0
  396. package/dist/rules/vulnerabilities/rules/fileUpload.js +325 -0
  397. package/dist/rules/vulnerabilities/rules/fileUpload.js.map +1 -0
  398. package/dist/rules/vulnerabilities/rules/hardcodedSecrets.d.ts +8 -0
  399. package/dist/rules/vulnerabilities/rules/hardcodedSecrets.d.ts.map +1 -0
  400. package/dist/rules/vulnerabilities/rules/hardcodedSecrets.js +446 -0
  401. package/dist/rules/vulnerabilities/rules/hardcodedSecrets.js.map +1 -0
  402. package/dist/rules/vulnerabilities/rules/index.d.ts +17 -0
  403. package/dist/rules/vulnerabilities/rules/index.d.ts.map +1 -0
  404. package/dist/rules/vulnerabilities/rules/index.js +47 -0
  405. package/dist/rules/vulnerabilities/rules/index.js.map +1 -0
  406. package/dist/rules/vulnerabilities/rules/pathTraversal.d.ts +8 -0
  407. package/dist/rules/vulnerabilities/rules/pathTraversal.d.ts.map +1 -0
  408. package/dist/rules/vulnerabilities/rules/pathTraversal.js +351 -0
  409. package/dist/rules/vulnerabilities/rules/pathTraversal.js.map +1 -0
  410. package/dist/rules/vulnerabilities/rules/prototypePollution.d.ts +8 -0
  411. package/dist/rules/vulnerabilities/rules/prototypePollution.d.ts.map +1 -0
  412. package/dist/rules/vulnerabilities/rules/prototypePollution.js +272 -0
  413. package/dist/rules/vulnerabilities/rules/prototypePollution.js.map +1 -0
  414. package/dist/rules/vulnerabilities/rules/securityMisconfiguration.d.ts +8 -0
  415. package/dist/rules/vulnerabilities/rules/securityMisconfiguration.d.ts.map +1 -0
  416. package/dist/rules/vulnerabilities/rules/securityMisconfiguration.js +438 -0
  417. package/dist/rules/vulnerabilities/rules/securityMisconfiguration.js.map +1 -0
  418. package/dist/rules/vulnerabilities/rules/sqlInjection.d.ts +12 -0
  419. package/dist/rules/vulnerabilities/rules/sqlInjection.d.ts.map +1 -0
  420. package/dist/rules/vulnerabilities/rules/sqlInjection.js +636 -0
  421. package/dist/rules/vulnerabilities/rules/sqlInjection.js.map +1 -0
  422. package/dist/rules/vulnerabilities/rules/ssrf.d.ts +8 -0
  423. package/dist/rules/vulnerabilities/rules/ssrf.d.ts.map +1 -0
  424. package/dist/rules/vulnerabilities/rules/ssrf.js +401 -0
  425. package/dist/rules/vulnerabilities/rules/ssrf.js.map +1 -0
  426. package/dist/rules/vulnerabilities/rules/xss.d.ts +11 -0
  427. package/dist/rules/vulnerabilities/rules/xss.d.ts.map +1 -0
  428. package/dist/rules/vulnerabilities/rules/xss.js +724 -0
  429. package/dist/rules/vulnerabilities/rules/xss.js.map +1 -0
  430. package/dist/rules/vulnerabilities/scoring/index.d.ts +80 -0
  431. package/dist/rules/vulnerabilities/scoring/index.d.ts.map +1 -0
  432. package/dist/rules/vulnerabilities/scoring/index.js +414 -0
  433. package/dist/rules/vulnerabilities/scoring/index.js.map +1 -0
  434. package/dist/rules/vulnerabilities/types/index.d.ts +830 -0
  435. package/dist/rules/vulnerabilities/types/index.d.ts.map +1 -0
  436. package/dist/rules/vulnerabilities/types/index.js +164 -0
  437. package/dist/rules/vulnerabilities/types/index.js.map +1 -0
  438. package/dist/rules/vulnerabilities/utils/index.d.ts +206 -0
  439. package/dist/rules/vulnerabilities/utils/index.d.ts.map +1 -0
  440. package/dist/rules/vulnerabilities/utils/index.js +615 -0
  441. package/dist/rules/vulnerabilities/utils/index.js.map +1 -0
  442. package/dist/types/index.d.ts +359 -0
  443. package/dist/types/index.d.ts.map +1 -0
  444. package/dist/types/index.js +61 -0
  445. package/dist/types/index.js.map +1 -0
  446. package/dist/utils/index.d.ts +82 -0
  447. package/dist/utils/index.d.ts.map +1 -0
  448. package/dist/utils/index.js +326 -0
  449. package/dist/utils/index.js.map +1 -0
  450. package/dist/utils/logger.d.ts +40 -0
  451. package/dist/utils/logger.d.ts.map +1 -0
  452. package/dist/utils/logger.js +139 -0
  453. package/dist/utils/logger.js.map +1 -0
  454. package/docs/ARCHITECTURE.md +320 -0
  455. package/docs/V1.2.1-IA_Performances.md +116 -0
  456. package/docs/images/WIN_Defender.png +0 -0
  457. package/package.json +68 -0
  458. package/secure-scan.config.json +134 -0
  459. package/secure-scan.sln +29 -0
  460. package/src/ai/aiAnalyzer.ts +714 -0
  461. package/src/ai/index.ts +5 -0
  462. package/src/analyzers/base/baseAnalyzer.ts +66 -0
  463. package/src/analyzers/base/index.ts +5 -0
  464. package/src/analyzers/c-cpp/cppAnalyzer.ts +308 -0
  465. package/src/analyzers/c-cpp/index.ts +5 -0
  466. package/src/analyzers/core/engine/index.ts +5 -0
  467. package/src/analyzers/core/engine/ruleEngine.ts +221 -0
  468. package/src/analyzers/core/index.ts +8 -0
  469. package/src/analyzers/core/scanner/fileScanner.ts +204 -0
  470. package/src/analyzers/core/scanner/index.ts +5 -0
  471. package/src/analyzers/core/scoring/index.ts +5 -0
  472. package/src/analyzers/core/scoring/riskScoring.ts +198 -0
  473. package/src/analyzers/core/securityScanner.ts +321 -0
  474. package/src/analyzers/csharp/csharpAnalyzer.ts +328 -0
  475. package/src/analyzers/csharp/index.ts +5 -0
  476. package/src/analyzers/iac/iacAnalyzer.ts +318 -0
  477. package/src/analyzers/iac/index.ts +5 -0
  478. package/src/analyzers/index.ts +67 -0
  479. package/src/analyzers/java/index.ts +5 -0
  480. package/src/analyzers/java/javaAnalyzer.ts +320 -0
  481. package/src/analyzers/javascript/PROMPT_JS_ANALYZER.md +267 -0
  482. package/src/analyzers/javascript/astUtils.ts +789 -0
  483. package/src/analyzers/javascript/index.ts +50 -0
  484. package/src/analyzers/javascript/javascriptAnalyzer.ts +984 -0
  485. package/src/analyzers/javascript/malwareDetector.ts +697 -0
  486. package/src/analyzers/javascript/packageJsonAnalyzer.ts +626 -0
  487. package/src/analyzers/javascript/taintAnalyzer.ts +630 -0
  488. package/src/analyzers/php/index.ts +5 -0
  489. package/src/analyzers/php/phpAnalyzer.ts +280 -0
  490. package/src/analyzers/python/index.ts +5 -0
  491. package/src/analyzers/python/pythonAnalyzer.ts +319 -0
  492. package/src/cli/index.ts +276 -0
  493. package/src/dependencies/aiDependencyAnalyzer.ts +496 -0
  494. package/src/dependencies/database/cveDatabase.ts +426 -0
  495. package/src/dependencies/database/index.ts +6 -0
  496. package/src/dependencies/database/maliciousPackages.ts +286 -0
  497. package/src/dependencies/dependencyAnalyzer.ts +394 -0
  498. package/src/dependencies/detectors/index.ts +7 -0
  499. package/src/dependencies/detectors/securityStandards.ts +200 -0
  500. package/src/dependencies/detectors/vulnerabilityDetector.ts +343 -0
  501. package/src/dependencies/index.ts +27 -0
  502. package/src/dependencies/installed/index.ts +8 -0
  503. package/src/dependencies/installed/installedScanner.ts +821 -0
  504. package/src/dependencies/installed/malwarePatterns.ts +492 -0
  505. package/src/dependencies/installed/types.ts +287 -0
  506. package/src/dependencies/parsers/base/baseParser.ts +108 -0
  507. package/src/dependencies/parsers/base/index.ts +6 -0
  508. package/src/dependencies/parsers/cpp/cppParser.ts +245 -0
  509. package/src/dependencies/parsers/cpp/index.ts +6 -0
  510. package/src/dependencies/parsers/csharp/csharpParser.ts +151 -0
  511. package/src/dependencies/parsers/csharp/index.ts +6 -0
  512. package/src/dependencies/parsers/index.ts +56 -0
  513. package/src/dependencies/parsers/java/index.ts +6 -0
  514. package/src/dependencies/parsers/java/javaParser.ts +203 -0
  515. package/src/dependencies/parsers/javascript/index.ts +6 -0
  516. package/src/dependencies/parsers/javascript/javascriptParser.ts +362 -0
  517. package/src/dependencies/parsers/php/index.ts +6 -0
  518. package/src/dependencies/parsers/php/phpParser.ts +208 -0
  519. package/src/dependencies/parsers/python/index.ts +6 -0
  520. package/src/dependencies/parsers/python/pythonParser.ts +437 -0
  521. package/src/dependencies/types.ts +330 -0
  522. package/src/i18n/index.ts +1 -0
  523. package/src/i18n/translations.ts +194 -0
  524. package/src/index.ts +16 -0
  525. package/src/reports/dependencyReportGenerator.ts +717 -0
  526. package/src/reports/htmlReportGenerator.ts +781 -0
  527. package/src/reports/index.ts +7 -0
  528. package/src/reports/installedDepsReportGenerator.ts +899 -0
  529. package/src/rules/index.ts +58 -0
  530. package/src/rules/malware/INFO.md +287 -0
  531. package/src/rules/malware/categories/backdoors.ts +174 -0
  532. package/src/rules/malware/categories/cryptominers.ts +434 -0
  533. package/src/rules/malware/categories/exfiltration.ts +677 -0
  534. package/src/rules/malware/categories/keyloggers.ts +780 -0
  535. package/src/rules/malware/categories/loaders.ts +721 -0
  536. package/src/rules/malware/categories/network.ts +639 -0
  537. package/src/rules/malware/categories/obfuscation.ts +788 -0
  538. package/src/rules/malware/constants/index.ts +358 -0
  539. package/src/rules/malware/engine/index.ts +758 -0
  540. package/src/rules/malware/index.ts +928 -0
  541. package/src/rules/malware/scoring/index.ts +549 -0
  542. package/src/rules/malware/types/index.ts +752 -0
  543. package/src/rules/malware/utils/index.ts +643 -0
  544. package/src/rules/standards.ts +372 -0
  545. package/src/rules/vulnerabilities/PROMPT_VULNERABILITIES.md +226 -0
  546. package/src/rules/vulnerabilities/constants/index.ts +625 -0
  547. package/src/rules/vulnerabilities/engine/index.ts +831 -0
  548. package/src/rules/vulnerabilities/index.ts +312 -0
  549. package/src/rules/vulnerabilities/rules/authentication.ts +426 -0
  550. package/src/rules/vulnerabilities/rules/commandInjection.ts +307 -0
  551. package/src/rules/vulnerabilities/rules/csrf.ts +268 -0
  552. package/src/rules/vulnerabilities/rules/deserialization.ts +343 -0
  553. package/src/rules/vulnerabilities/rules/fileUpload.ts +332 -0
  554. package/src/rules/vulnerabilities/rules/hardcodedSecrets.ts +453 -0
  555. package/src/rules/vulnerabilities/rules/index.ts +17 -0
  556. package/src/rules/vulnerabilities/rules/pathTraversal.ts +358 -0
  557. package/src/rules/vulnerabilities/rules/prototypePollution.ts +279 -0
  558. package/src/rules/vulnerabilities/rules/securityMisconfiguration.ts +445 -0
  559. package/src/rules/vulnerabilities/rules/sqlInjection.ts +669 -0
  560. package/src/rules/vulnerabilities/rules/ssrf.ts +408 -0
  561. package/src/rules/vulnerabilities/rules/xss.ts +753 -0
  562. package/src/rules/vulnerabilities/scoring/index.ts +543 -0
  563. package/src/rules/vulnerabilities/types/index.ts +1004 -0
  564. package/src/rules/vulnerabilities/utils/index.ts +709 -0
  565. package/src/types/index.ts +391 -0
  566. package/src/utils/index.ts +306 -0
  567. package/src/utils/logger.ts +150 -0
  568. package/test-installed-scanner.ts +136 -0
  569. package/tsconfig.json +30 -0
@@ -0,0 +1,860 @@
1
+ "use strict";
2
+ /**
3
+ * JavaScript/TypeScript Security Analyzer v2.0
4
+ * Advanced SAST analyzer with AST-based detection, taint analysis, and malware detection
5
+ *
6
+ * Features:
7
+ * - AST-based vulnerability detection (Babel Parser)
8
+ * - Taint analysis (source-to-sink tracking)
9
+ * - Malware detection (cryptominers, stealers, backdoors, etc.)
10
+ * - Package.json security analysis
11
+ * - OWASP/CWE compliance
12
+ *
13
+ * @version 2.0.0
14
+ * @author Secure-Scan Team
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.JavaScriptAnalyzer = void 0;
18
+ const base_1 = require("../base");
19
+ const types_1 = require("../../types");
20
+ const utils_1 = require("../../utils");
21
+ const standards_1 = require("../../rules/standards");
22
+ const logger_1 = require("../../utils/logger");
23
+ // Import specialized modules
24
+ const taintAnalyzer_1 = require("./taintAnalyzer");
25
+ const astUtils_1 = require("./astUtils");
26
+ const malwareDetector_1 = require("./malwareDetector");
27
+ const packageJsonAnalyzer_1 = require("./packageJsonAnalyzer");
28
+ /**
29
+ * Default analyzer options
30
+ */
31
+ const DEFAULT_OPTIONS = {
32
+ enableAST: true,
33
+ enableTaintAnalysis: true,
34
+ enableMalwareDetection: true,
35
+ enablePackageAnalysis: true,
36
+ maxFileSize: 5 * 1024 * 1024, // 5MB
37
+ fileTimeout: 30000, // 30 seconds
38
+ minConfidence: 50
39
+ };
40
+ /**
41
+ * Vulnerability patterns database (regex fallback)
42
+ */
43
+ const VULNERABILITY_PATTERNS = [
44
+ // === CODE EXECUTION ===
45
+ {
46
+ id: 'JS-EXEC-001',
47
+ name: 'eval() Usage',
48
+ pattern: /\beval\s*\(\s*(?!['"`])/g,
49
+ severity: types_1.Severity.CRITICAL,
50
+ threatType: types_1.ThreatType.COMMAND_INJECTION,
51
+ category: types_1.FindingCategory.VULNERABILITY,
52
+ description: 'Use of eval() with dynamic content can lead to code injection.',
53
+ remediation: 'Avoid eval(). Use JSON.parse() for JSON data or safer alternatives.',
54
+ confidence: 85,
55
+ tags: ['injection', 'rce', 'owasp-a03']
56
+ },
57
+ {
58
+ id: 'JS-EXEC-002',
59
+ name: 'Function Constructor',
60
+ pattern: /\bnew\s+Function\s*\(/g,
61
+ severity: types_1.Severity.CRITICAL,
62
+ threatType: types_1.ThreatType.COMMAND_INJECTION,
63
+ category: types_1.FindingCategory.VULNERABILITY,
64
+ description: 'new Function() is equivalent to eval() and can execute arbitrary code.',
65
+ remediation: 'Use predefined functions instead of dynamically creating them.',
66
+ confidence: 85,
67
+ tags: ['injection', 'rce', 'owasp-a03']
68
+ },
69
+ {
70
+ id: 'JS-EXEC-003',
71
+ name: 'setTimeout/setInterval with String',
72
+ pattern: /\bset(?:Timeout|Interval)\s*\(\s*['"`][^'"`]+['"`]/g,
73
+ severity: types_1.Severity.HIGH,
74
+ threatType: types_1.ThreatType.COMMAND_INJECTION,
75
+ category: types_1.FindingCategory.VULNERABILITY,
76
+ description: 'setTimeout/setInterval with string argument acts like eval().',
77
+ remediation: 'Pass a function reference instead of a string.',
78
+ confidence: 80,
79
+ tags: ['injection', 'owasp-a03']
80
+ },
81
+ // === COMMAND INJECTION ===
82
+ {
83
+ id: 'JS-CMD-001',
84
+ name: 'child_process exec()',
85
+ pattern: /(?:child_process\.)?exec\s*\(\s*(?!['"`])/g,
86
+ severity: types_1.Severity.CRITICAL,
87
+ threatType: types_1.ThreatType.COMMAND_INJECTION,
88
+ category: types_1.FindingCategory.VULNERABILITY,
89
+ description: 'exec() with dynamic command string is vulnerable to command injection.',
90
+ remediation: 'Use execFile() with argument array instead of exec().',
91
+ confidence: 80,
92
+ tags: ['injection', 'rce', 'owasp-a03']
93
+ },
94
+ {
95
+ id: 'JS-CMD-002',
96
+ name: 'spawn with shell: true',
97
+ pattern: /spawn\s*\([^)]*shell\s*:\s*true/g,
98
+ severity: types_1.Severity.HIGH,
99
+ threatType: types_1.ThreatType.COMMAND_INJECTION,
100
+ category: types_1.FindingCategory.VULNERABILITY,
101
+ description: 'spawn() with shell option is vulnerable to command injection.',
102
+ remediation: 'Remove shell: true and pass arguments as an array.',
103
+ confidence: 85,
104
+ tags: ['injection', 'rce', 'owasp-a03']
105
+ },
106
+ // === XSS VULNERABILITIES ===
107
+ {
108
+ id: 'JS-XSS-001',
109
+ name: 'innerHTML Assignment',
110
+ pattern: /\.innerHTML\s*=\s*(?!['"`]<)/g,
111
+ severity: types_1.Severity.HIGH,
112
+ threatType: types_1.ThreatType.XSS,
113
+ category: types_1.FindingCategory.VULNERABILITY,
114
+ description: 'Direct innerHTML assignment with dynamic content enables XSS.',
115
+ remediation: 'Use textContent for text, or sanitize with DOMPurify.',
116
+ confidence: 75,
117
+ tags: ['xss', 'dom', 'owasp-a03']
118
+ },
119
+ {
120
+ id: 'JS-XSS-002',
121
+ name: 'document.write()',
122
+ pattern: /document\.write(?:ln)?\s*\(/g,
123
+ severity: types_1.Severity.HIGH,
124
+ threatType: types_1.ThreatType.XSS,
125
+ category: types_1.FindingCategory.VULNERABILITY,
126
+ description: 'document.write() with dynamic content is vulnerable to XSS.',
127
+ remediation: 'Use DOM manipulation methods like createElement() and textContent.',
128
+ confidence: 80,
129
+ tags: ['xss', 'dom', 'owasp-a03']
130
+ },
131
+ {
132
+ id: 'JS-XSS-003',
133
+ name: 'insertAdjacentHTML()',
134
+ pattern: /\.insertAdjacentHTML\s*\(/g,
135
+ severity: types_1.Severity.HIGH,
136
+ threatType: types_1.ThreatType.XSS,
137
+ category: types_1.FindingCategory.VULNERABILITY,
138
+ description: 'insertAdjacentHTML() with unsanitized content enables XSS.',
139
+ remediation: 'Sanitize HTML content with DOMPurify before insertion.',
140
+ confidence: 75,
141
+ tags: ['xss', 'dom', 'owasp-a03']
142
+ },
143
+ {
144
+ id: 'JS-XSS-004',
145
+ name: 'jQuery .html()',
146
+ pattern: /\$\([^)]+\)\.html\s*\(\s*(?!['"`]<)/g,
147
+ severity: types_1.Severity.HIGH,
148
+ threatType: types_1.ThreatType.XSS,
149
+ category: types_1.FindingCategory.VULNERABILITY,
150
+ description: 'jQuery .html() with dynamic content is vulnerable to XSS.',
151
+ remediation: 'Use .text() for text content or sanitize before .html().',
152
+ confidence: 70,
153
+ tags: ['xss', 'jquery', 'owasp-a03']
154
+ },
155
+ // === PROTOTYPE POLLUTION ===
156
+ {
157
+ id: 'JS-PP-001',
158
+ name: '__proto__ Access',
159
+ pattern: /\[['"`]?__proto__['"`]?\]|\.__proto__\b/g,
160
+ severity: types_1.Severity.HIGH,
161
+ threatType: types_1.ThreatType.DANGEROUS_FUNCTION,
162
+ category: types_1.FindingCategory.VULNERABILITY,
163
+ description: 'Direct __proto__ access can lead to prototype pollution.',
164
+ remediation: 'Use Object.create(null) for safe objects or validate keys.',
165
+ confidence: 85,
166
+ tags: ['prototype-pollution', 'owasp-a03']
167
+ },
168
+ {
169
+ id: 'JS-PP-002',
170
+ name: 'Object.prototype Modification',
171
+ pattern: /Object\.prototype\s*\.\s*\w+\s*=/g,
172
+ severity: types_1.Severity.HIGH,
173
+ threatType: types_1.ThreatType.DANGEROUS_FUNCTION,
174
+ category: types_1.FindingCategory.VULNERABILITY,
175
+ description: 'Modifying Object.prototype affects all objects.',
176
+ remediation: 'Avoid modifying built-in prototypes.',
177
+ confidence: 90,
178
+ tags: ['prototype-pollution', 'owasp-a03']
179
+ },
180
+ {
181
+ id: 'JS-PP-003',
182
+ name: 'constructor.prototype Access',
183
+ pattern: /constructor\s*\.\s*prototype/g,
184
+ severity: types_1.Severity.MEDIUM,
185
+ threatType: types_1.ThreatType.DANGEROUS_FUNCTION,
186
+ category: types_1.FindingCategory.VULNERABILITY,
187
+ description: 'Accessing constructor.prototype may indicate prototype pollution.',
188
+ remediation: 'Validate and sanitize any dynamic property access.',
189
+ confidence: 70,
190
+ tags: ['prototype-pollution', 'owasp-a03']
191
+ },
192
+ // === INSECURE RANDOMNESS ===
193
+ {
194
+ id: 'JS-RAND-001',
195
+ name: 'Math.random() for Security',
196
+ pattern: /(?:token|secret|key|password|salt|nonce|iv)\s*[=:]\s*[^;{]*Math\.random/gi,
197
+ severity: types_1.Severity.HIGH,
198
+ threatType: types_1.ThreatType.WEAK_RANDOM,
199
+ category: types_1.FindingCategory.VULNERABILITY,
200
+ description: 'Math.random() is not cryptographically secure.',
201
+ remediation: 'Use crypto.randomBytes() or crypto.getRandomValues().',
202
+ confidence: 80,
203
+ tags: ['crypto', 'random', 'owasp-a02']
204
+ },
205
+ // === HARDCODED CREDENTIALS ===
206
+ {
207
+ id: 'JS-CRED-001',
208
+ name: 'Hardcoded Password',
209
+ pattern: /(?:password|passwd|pwd)\s*[=:]\s*['"`][^'"`]{6,}['"`]/gi,
210
+ severity: types_1.Severity.HIGH,
211
+ threatType: types_1.ThreatType.HARDCODED_CREDENTIALS,
212
+ category: types_1.FindingCategory.VULNERABILITY,
213
+ description: 'Hardcoded password detected in source code.',
214
+ remediation: 'Use environment variables or a secrets manager.',
215
+ confidence: 75,
216
+ tags: ['credentials', 'secrets', 'owasp-a07']
217
+ },
218
+ {
219
+ id: 'JS-CRED-002',
220
+ name: 'Hardcoded API Key',
221
+ pattern: /(?:api[_-]?key|apikey)\s*[=:]\s*['"`][a-zA-Z0-9_-]{20,}['"`]/gi,
222
+ severity: types_1.Severity.HIGH,
223
+ threatType: types_1.ThreatType.HARDCODED_CREDENTIALS,
224
+ category: types_1.FindingCategory.VULNERABILITY,
225
+ description: 'Hardcoded API key detected in source code.',
226
+ remediation: 'Use environment variables or a secrets manager.',
227
+ confidence: 80,
228
+ tags: ['credentials', 'secrets', 'owasp-a07']
229
+ },
230
+ {
231
+ id: 'JS-CRED-003',
232
+ name: 'Hardcoded Secret/Token',
233
+ pattern: /(?:secret|token|auth)\s*[=:]\s*['"`][a-zA-Z0-9_-]{20,}['"`]/gi,
234
+ severity: types_1.Severity.HIGH,
235
+ threatType: types_1.ThreatType.HARDCODED_CREDENTIALS,
236
+ category: types_1.FindingCategory.VULNERABILITY,
237
+ description: 'Hardcoded secret or token detected in source code.',
238
+ remediation: 'Use environment variables or a secrets manager.',
239
+ confidence: 75,
240
+ tags: ['credentials', 'secrets', 'owasp-a07']
241
+ },
242
+ // === INSECURE CRYPTO ===
243
+ {
244
+ id: 'JS-CRYPTO-001',
245
+ name: 'MD5 Usage',
246
+ pattern: /(?:createHash|crypto)\s*\(\s*['"`]md5['"`]\s*\)/gi,
247
+ severity: types_1.Severity.MEDIUM,
248
+ threatType: types_1.ThreatType.INSECURE_CRYPTO,
249
+ category: types_1.FindingCategory.VULNERABILITY,
250
+ description: 'MD5 is cryptographically broken and should not be used.',
251
+ remediation: 'Use SHA-256 or stronger for hashing.',
252
+ confidence: 90,
253
+ tags: ['crypto', 'hash', 'owasp-a02']
254
+ },
255
+ {
256
+ id: 'JS-CRYPTO-002',
257
+ name: 'SHA1 Usage',
258
+ pattern: /(?:createHash|crypto)\s*\(\s*['"`]sha1['"`]\s*\)/gi,
259
+ severity: types_1.Severity.MEDIUM,
260
+ threatType: types_1.ThreatType.INSECURE_CRYPTO,
261
+ category: types_1.FindingCategory.VULNERABILITY,
262
+ description: 'SHA-1 is deprecated for cryptographic use.',
263
+ remediation: 'Use SHA-256 or stronger for hashing.',
264
+ confidence: 85,
265
+ tags: ['crypto', 'hash', 'owasp-a02']
266
+ },
267
+ {
268
+ id: 'JS-CRYPTO-003',
269
+ name: 'DES/3DES Usage',
270
+ pattern: /(?:createCipher|createDecipher)\s*\(\s*['"`](?:des|3des|des-ede3)['"`]/gi,
271
+ severity: types_1.Severity.HIGH,
272
+ threatType: types_1.ThreatType.INSECURE_CRYPTO,
273
+ category: types_1.FindingCategory.VULNERABILITY,
274
+ description: 'DES and 3DES are deprecated encryption algorithms.',
275
+ remediation: 'Use AES-256-GCM for encryption.',
276
+ confidence: 90,
277
+ tags: ['crypto', 'encryption', 'owasp-a02']
278
+ },
279
+ // === PATH TRAVERSAL ===
280
+ {
281
+ id: 'JS-PATH-001',
282
+ name: 'Path Traversal in File Read',
283
+ pattern: /(?:readFile|readFileSync|createReadStream)\s*\([^)]*(?:req\.(?:body|query|params)|process\.argv)/gi,
284
+ severity: types_1.Severity.HIGH,
285
+ threatType: types_1.ThreatType.PATH_TRAVERSAL,
286
+ category: types_1.FindingCategory.VULNERABILITY,
287
+ description: 'File read with user-controlled path enables path traversal.',
288
+ remediation: 'Validate paths with path.resolve() and check against base directory.',
289
+ confidence: 80,
290
+ tags: ['path-traversal', 'file', 'owasp-a01']
291
+ },
292
+ // === SQL INJECTION ===
293
+ {
294
+ id: 'JS-SQL-001',
295
+ name: 'SQL Query Concatenation',
296
+ pattern: /\.query\s*\(\s*['"`](?:SELECT|INSERT|UPDATE|DELETE)[^'"]*\+/gi,
297
+ severity: types_1.Severity.CRITICAL,
298
+ threatType: types_1.ThreatType.SQL_INJECTION,
299
+ category: types_1.FindingCategory.VULNERABILITY,
300
+ description: 'SQL query with string concatenation is vulnerable to injection.',
301
+ remediation: 'Use parameterized queries or prepared statements.',
302
+ confidence: 85,
303
+ tags: ['sqli', 'injection', 'owasp-a03']
304
+ },
305
+ {
306
+ id: 'JS-SQL-002',
307
+ name: 'SQL Template Literal',
308
+ pattern: /\.query\s*\(\s*`(?:SELECT|INSERT|UPDATE|DELETE)[^`]*\$\{/gi,
309
+ severity: types_1.Severity.CRITICAL,
310
+ threatType: types_1.ThreatType.SQL_INJECTION,
311
+ category: types_1.FindingCategory.VULNERABILITY,
312
+ description: 'SQL query with template literal interpolation is vulnerable.',
313
+ remediation: 'Use parameterized queries or prepared statements.',
314
+ confidence: 85,
315
+ tags: ['sqli', 'injection', 'owasp-a03']
316
+ },
317
+ // === SSRF ===
318
+ {
319
+ id: 'JS-SSRF-001',
320
+ name: 'SSRF in fetch()',
321
+ pattern: /fetch\s*\(\s*(?:req\.(?:body|query|params)|`[^`]*\$\{)/gi,
322
+ severity: types_1.Severity.HIGH,
323
+ threatType: types_1.ThreatType.SECURITY_MISCONFIGURATION,
324
+ category: types_1.FindingCategory.VULNERABILITY,
325
+ description: 'fetch() with user-controlled URL enables SSRF attacks.',
326
+ remediation: 'Validate and whitelist URLs before making requests.',
327
+ confidence: 75,
328
+ tags: ['ssrf', 'owasp-a10']
329
+ },
330
+ // === INSECURE CONFIGURATION ===
331
+ {
332
+ id: 'JS-CONFIG-001',
333
+ name: 'CORS Wildcard',
334
+ pattern: /(?:cors|Access-Control-Allow-Origin)\s*[=:]\s*['"*]/gi,
335
+ severity: types_1.Severity.MEDIUM,
336
+ threatType: types_1.ThreatType.SECURITY_MISCONFIGURATION,
337
+ category: types_1.FindingCategory.VULNERABILITY,
338
+ description: 'CORS with wildcard origin allows any domain to access the API.',
339
+ remediation: 'Specify allowed origins explicitly.',
340
+ confidence: 80,
341
+ tags: ['cors', 'config', 'owasp-a05']
342
+ },
343
+ {
344
+ id: 'JS-CONFIG-002',
345
+ name: 'Disabled CSRF Protection',
346
+ pattern: /csrf\s*:\s*false|csrfProtection\s*=\s*false/gi,
347
+ severity: types_1.Severity.HIGH,
348
+ threatType: types_1.ThreatType.CSRF,
349
+ category: types_1.FindingCategory.VULNERABILITY,
350
+ description: 'CSRF protection is explicitly disabled.',
351
+ remediation: 'Enable CSRF protection for state-changing operations.',
352
+ confidence: 90,
353
+ tags: ['csrf', 'config', 'owasp-a05']
354
+ },
355
+ {
356
+ id: 'JS-CONFIG-003',
357
+ name: 'Insecure Cookie Settings',
358
+ pattern: /(?:secure|httpOnly)\s*:\s*false/gi,
359
+ severity: types_1.Severity.MEDIUM,
360
+ threatType: types_1.ThreatType.SECURITY_MISCONFIGURATION,
361
+ category: types_1.FindingCategory.VULNERABILITY,
362
+ description: 'Cookie security flags are explicitly disabled.',
363
+ remediation: 'Set secure: true and httpOnly: true for session cookies.',
364
+ confidence: 85,
365
+ tags: ['cookie', 'config', 'owasp-a05']
366
+ },
367
+ // === POSTMESSAGE VULNERABILITIES ===
368
+ {
369
+ id: 'JS-PM-001',
370
+ name: 'postMessage Wildcard Origin',
371
+ pattern: /postMessage\s*\([^)]+,\s*['"]\*['"]\s*\)/g,
372
+ severity: types_1.Severity.MEDIUM,
373
+ threatType: types_1.ThreatType.SECURITY_MISCONFIGURATION,
374
+ category: types_1.FindingCategory.VULNERABILITY,
375
+ description: 'postMessage with "*" origin can leak data to any origin.',
376
+ remediation: 'Specify the target origin explicitly.',
377
+ confidence: 90,
378
+ tags: ['postmessage', 'origin', 'owasp-a05']
379
+ },
380
+ {
381
+ id: 'JS-PM-002',
382
+ name: 'Missing Origin Check',
383
+ pattern: /addEventListener\s*\(\s*['"`]message['"`][^}]*(?:eval|innerHTML|document\.write)/g,
384
+ severity: types_1.Severity.HIGH,
385
+ threatType: types_1.ThreatType.XSS,
386
+ category: types_1.FindingCategory.VULNERABILITY,
387
+ description: 'Message event handler without origin check enables XSS.',
388
+ remediation: 'Always validate event.origin before processing messages.',
389
+ confidence: 75,
390
+ tags: ['postmessage', 'xss', 'owasp-a03']
391
+ },
392
+ // === DANGEROUS PATTERNS ===
393
+ {
394
+ id: 'JS-DANGER-001',
395
+ name: 'debugger Statement',
396
+ pattern: /\bdebugger\s*;/g,
397
+ severity: types_1.Severity.LOW,
398
+ threatType: types_1.ThreatType.SECURITY_MISCONFIGURATION,
399
+ category: types_1.FindingCategory.CODE_SMELL,
400
+ description: 'debugger statement should be removed in production.',
401
+ remediation: 'Remove debugger statements before deployment.',
402
+ confidence: 100,
403
+ tags: ['debug', 'cleanup']
404
+ },
405
+ {
406
+ id: 'JS-DANGER-002',
407
+ name: 'console.log in Production',
408
+ pattern: /console\.(?:log|debug|trace)\s*\([^)]*(?:password|secret|token|key)/gi,
409
+ severity: types_1.Severity.MEDIUM,
410
+ threatType: types_1.ThreatType.INFORMATION_DISCLOSURE,
411
+ category: types_1.FindingCategory.VULNERABILITY,
412
+ description: 'Logging sensitive data may expose credentials.',
413
+ remediation: 'Remove or redact sensitive data from logs.',
414
+ confidence: 70,
415
+ tags: ['logging', 'secrets', 'owasp-a09']
416
+ }
417
+ ];
418
+ /**
419
+ * JavaScript/TypeScript Analyzer Class v2.0
420
+ */
421
+ class JavaScriptAnalyzer extends base_1.BaseAnalyzer {
422
+ name = 'JavaScript Analyzer';
423
+ languages = ['javascript', 'typescript'];
424
+ version = '2.0.0';
425
+ // Specialized analyzers
426
+ taintAnalyzer;
427
+ astUtils;
428
+ malwareDetector;
429
+ packageJsonAnalyzer;
430
+ // Configuration
431
+ options;
432
+ constructor(options = {}) {
433
+ super();
434
+ this.options = { ...DEFAULT_OPTIONS, ...options };
435
+ // Initialize specialized analyzers
436
+ this.taintAnalyzer = new taintAnalyzer_1.TaintAnalyzer();
437
+ this.astUtils = new astUtils_1.ASTUtils();
438
+ this.malwareDetector = new malwareDetector_1.MalwareDetector();
439
+ this.packageJsonAnalyzer = new packageJsonAnalyzer_1.PackageJsonAnalyzer();
440
+ }
441
+ /**
442
+ * Initialize the analyzer
443
+ */
444
+ async initialize() {
445
+ await super.initialize();
446
+ logger_1.logger.debug('JavaScript Analyzer v2.0 initialized with AST, Taint, and Malware detection');
447
+ }
448
+ /**
449
+ * Main analysis entry point
450
+ */
451
+ async analyze(file, rules) {
452
+ const findings = [];
453
+ const startTime = Date.now();
454
+ try {
455
+ // Skip files that are too large
456
+ if (file.size > this.options.maxFileSize) {
457
+ logger_1.logger.warn(`Skipping ${file.relativePath}: file too large (${file.size} bytes)`);
458
+ return findings;
459
+ }
460
+ // Filter rules for JS/TS
461
+ const jsRules = rules.filter(r => r.languages.includes('javascript') || r.languages.includes('typescript'));
462
+ // Run rule engine (inherited from BaseAnalyzer)
463
+ const ruleFindings = await this.ruleEngine.analyzeFile(file, jsRules);
464
+ findings.push(...ruleFindings);
465
+ // Special handling for package.json
466
+ if (file.relativePath.endsWith('package.json')) {
467
+ const pkgFindings = await this.analyzePackageJson(file);
468
+ findings.push(...pkgFindings);
469
+ return this.filterByConfidence(findings);
470
+ }
471
+ // Run parallel analysis for code files
472
+ const analysisPromises = [];
473
+ // 1. Pattern-based vulnerability detection (fast, always run)
474
+ analysisPromises.push(this.runPatternAnalysis(file));
475
+ // 2. AST-based analysis (accurate, optional)
476
+ if (this.options.enableAST) {
477
+ analysisPromises.push(this.runASTAnalysis(file));
478
+ }
479
+ // 3. Taint analysis (complex, optional)
480
+ if (this.options.enableTaintAnalysis) {
481
+ analysisPromises.push(this.runTaintAnalysis(file));
482
+ }
483
+ // 4. Malware detection (comprehensive, optional)
484
+ if (this.options.enableMalwareDetection) {
485
+ analysisPromises.push(this.runMalwareAnalysis(file));
486
+ }
487
+ // 5. Obfuscation detection
488
+ analysisPromises.push(this.checkObfuscation(file));
489
+ // Wait for all analyses with timeout
490
+ const results = await Promise.race([
491
+ Promise.all(analysisPromises),
492
+ this.timeout(this.options.fileTimeout)
493
+ ]);
494
+ // Flatten results
495
+ for (const result of results) {
496
+ findings.push(...result);
497
+ }
498
+ // Deduplicate findings
499
+ const deduped = this.deduplicateFindings(findings);
500
+ // Filter by confidence
501
+ const filtered = this.filterByConfidence(deduped);
502
+ const elapsed = Date.now() - startTime;
503
+ logger_1.logger.debug(`Analyzed ${file.relativePath} in ${elapsed}ms, found ${filtered.length} issues`);
504
+ return filtered;
505
+ }
506
+ catch (error) {
507
+ logger_1.logger.error(`Error analyzing ${file.relativePath}:`, error);
508
+ return findings;
509
+ }
510
+ }
511
+ /**
512
+ * Run pattern-based vulnerability detection
513
+ */
514
+ async runPatternAnalysis(file) {
515
+ const findings = [];
516
+ for (const vuln of VULNERABILITY_PATTERNS) {
517
+ // Reset regex state
518
+ vuln.pattern.lastIndex = 0;
519
+ let match;
520
+ while ((match = vuln.pattern.exec(file.content)) !== null) {
521
+ // Find line number
522
+ const beforeMatch = file.content.substring(0, match.index);
523
+ const lineNum = beforeMatch.split('\n').length;
524
+ const context = (0, utils_1.extractCodeContext)(file.content, lineNum, 2);
525
+ findings.push({
526
+ id: (0, utils_1.generateId)(),
527
+ title: vuln.name,
528
+ description: vuln.description,
529
+ severity: vuln.severity,
530
+ threatType: vuln.threatType,
531
+ category: vuln.category,
532
+ location: {
533
+ file: file.relativePath,
534
+ startLine: lineNum,
535
+ endLine: lineNum
536
+ },
537
+ snippet: {
538
+ code: context.code,
539
+ contextBefore: context.contextBefore,
540
+ contextAfter: context.contextAfter
541
+ },
542
+ standards: (0, standards_1.getStandardsForThreat)(vuln.threatType),
543
+ remediation: vuln.remediation,
544
+ confidence: vuln.confidence,
545
+ analyzer: this.name,
546
+ timestamp: new Date(),
547
+ tags: vuln.tags
548
+ });
549
+ }
550
+ }
551
+ return findings;
552
+ }
553
+ /**
554
+ * Run AST-based analysis
555
+ */
556
+ async runASTAnalysis(file) {
557
+ const findings = [];
558
+ try {
559
+ // Parse the file
560
+ const ast = this.astUtils.safeParse(file.content, file.relativePath);
561
+ if (!ast) {
562
+ logger_1.logger.debug(`Could not parse ${file.relativePath} for AST analysis`);
563
+ return findings;
564
+ }
565
+ // Find dangerous calls
566
+ const dangerousCalls = this.astUtils.findDangerousCalls(file.relativePath);
567
+ for (const call of dangerousCalls) {
568
+ findings.push(this.dangerousCallToFinding(call, file));
569
+ }
570
+ // Find hardcoded secrets
571
+ const secrets = this.astUtils.findHardcodedSecrets();
572
+ for (const secret of secrets) {
573
+ findings.push(this.dangerousCallToFinding(secret, file));
574
+ }
575
+ // Find dangerous regex patterns
576
+ const regexIssues = this.astUtils.findDangerousRegex();
577
+ for (const regex of regexIssues) {
578
+ findings.push(this.dangerousCallToFinding(regex, file));
579
+ }
580
+ }
581
+ catch (error) {
582
+ logger_1.logger.debug(`AST analysis failed for ${file.relativePath}:`, error);
583
+ }
584
+ return findings;
585
+ }
586
+ /**
587
+ * Run taint analysis
588
+ */
589
+ async runTaintAnalysis(file) {
590
+ const findings = [];
591
+ try {
592
+ const flows = this.taintAnalyzer.analyze(file.content, file.relativePath);
593
+ for (const flow of flows) {
594
+ findings.push(this.taintFlowToFinding(flow, file));
595
+ }
596
+ }
597
+ catch (error) {
598
+ logger_1.logger.debug(`Taint analysis failed for ${file.relativePath}:`, error);
599
+ }
600
+ return findings;
601
+ }
602
+ /**
603
+ * Run malware detection
604
+ */
605
+ async runMalwareAnalysis(file) {
606
+ const findings = [];
607
+ try {
608
+ const matches = this.malwareDetector.scan(file.content, file.relativePath);
609
+ for (const match of matches) {
610
+ findings.push(this.malwareMatchToFinding(match, file));
611
+ }
612
+ }
613
+ catch (error) {
614
+ logger_1.logger.debug(`Malware analysis failed for ${file.relativePath}:`, error);
615
+ }
616
+ return findings;
617
+ }
618
+ /**
619
+ * Analyze package.json for security issues
620
+ */
621
+ async analyzePackageJson(file) {
622
+ const findings = [];
623
+ if (!this.options.enablePackageAnalysis) {
624
+ return findings;
625
+ }
626
+ try {
627
+ const pkgFindings = this.packageJsonAnalyzer.analyze(file.content, file.relativePath);
628
+ for (const finding of pkgFindings) {
629
+ findings.push(this.packageFindingToFinding(finding, file));
630
+ }
631
+ }
632
+ catch (error) {
633
+ logger_1.logger.debug(`Package.json analysis failed for ${file.relativePath}:`, error);
634
+ }
635
+ return findings;
636
+ }
637
+ /**
638
+ * Check for obfuscated code
639
+ */
640
+ async checkObfuscation(file) {
641
+ const findings = [];
642
+ if ((0, utils_1.looksObfuscated)(file.content)) {
643
+ const entropy = (0, utils_1.calculateEntropy)(file.content);
644
+ findings.push({
645
+ id: (0, utils_1.generateId)(),
646
+ title: 'Heavily Obfuscated Code',
647
+ description: `This file contains heavily obfuscated code (entropy: ${entropy.toFixed(2)}). This is unusual for legitimate code and may hide malicious functionality.`,
648
+ severity: types_1.Severity.HIGH,
649
+ threatType: types_1.ThreatType.OBFUSCATED_CODE,
650
+ category: types_1.FindingCategory.MALWARE,
651
+ location: {
652
+ file: file.relativePath,
653
+ startLine: 1,
654
+ endLine: Math.min(10, file.lineCount)
655
+ },
656
+ snippet: {
657
+ code: file.content.substring(0, 200) + '...'
658
+ },
659
+ standards: (0, standards_1.getStandardsForThreat)(types_1.ThreatType.OBFUSCATED_CODE),
660
+ remediation: 'Deobfuscate and review the code. If this is a third-party library, verify its source and integrity.',
661
+ confidence: 75,
662
+ analyzer: this.name,
663
+ timestamp: new Date(),
664
+ tags: ['obfuscation', 'suspicious']
665
+ });
666
+ }
667
+ return findings;
668
+ }
669
+ /**
670
+ * Convert DangerousCall to Finding
671
+ */
672
+ dangerousCallToFinding(call, file) {
673
+ const threatTypeMap = {
674
+ [astUtils_1.DangerousPatternType.CODE_EXECUTION]: types_1.ThreatType.COMMAND_INJECTION,
675
+ [astUtils_1.DangerousPatternType.COMMAND_INJECTION]: types_1.ThreatType.COMMAND_INJECTION,
676
+ [astUtils_1.DangerousPatternType.PROTOTYPE_POLLUTION]: types_1.ThreatType.DANGEROUS_FUNCTION,
677
+ [astUtils_1.DangerousPatternType.XSS_SINK]: types_1.ThreatType.XSS,
678
+ [astUtils_1.DangerousPatternType.DYNAMIC_REQUIRE]: types_1.ThreatType.DANGEROUS_FUNCTION,
679
+ [astUtils_1.DangerousPatternType.INSECURE_RANDOM]: types_1.ThreatType.WEAK_RANDOM,
680
+ [astUtils_1.DangerousPatternType.HARDCODED_SECRET]: types_1.ThreatType.HARDCODED_CREDENTIALS,
681
+ [astUtils_1.DangerousPatternType.DANGEROUS_REGEX]: types_1.ThreatType.DANGEROUS_FUNCTION,
682
+ [astUtils_1.DangerousPatternType.UNSAFE_ASSIGNMENT]: types_1.ThreatType.DANGEROUS_FUNCTION,
683
+ [astUtils_1.DangerousPatternType.NETWORK_REQUEST]: types_1.ThreatType.SUSPICIOUS_NETWORK,
684
+ [astUtils_1.DangerousPatternType.FILE_OPERATION]: types_1.ThreatType.PATH_TRAVERSAL,
685
+ [astUtils_1.DangerousPatternType.CRYPTO_WEAKNESS]: types_1.ThreatType.INSECURE_CRYPTO
686
+ };
687
+ const severityMap = {
688
+ [astUtils_1.DangerousPatternType.CODE_EXECUTION]: types_1.Severity.CRITICAL,
689
+ [astUtils_1.DangerousPatternType.COMMAND_INJECTION]: types_1.Severity.CRITICAL,
690
+ [astUtils_1.DangerousPatternType.PROTOTYPE_POLLUTION]: types_1.Severity.HIGH,
691
+ [astUtils_1.DangerousPatternType.XSS_SINK]: types_1.Severity.HIGH,
692
+ [astUtils_1.DangerousPatternType.DYNAMIC_REQUIRE]: types_1.Severity.MEDIUM,
693
+ [astUtils_1.DangerousPatternType.INSECURE_RANDOM]: types_1.Severity.MEDIUM,
694
+ [astUtils_1.DangerousPatternType.HARDCODED_SECRET]: types_1.Severity.HIGH,
695
+ [astUtils_1.DangerousPatternType.DANGEROUS_REGEX]: types_1.Severity.MEDIUM,
696
+ [astUtils_1.DangerousPatternType.UNSAFE_ASSIGNMENT]: types_1.Severity.MEDIUM,
697
+ [astUtils_1.DangerousPatternType.NETWORK_REQUEST]: types_1.Severity.MEDIUM,
698
+ [astUtils_1.DangerousPatternType.FILE_OPERATION]: types_1.Severity.MEDIUM,
699
+ [astUtils_1.DangerousPatternType.CRYPTO_WEAKNESS]: types_1.Severity.MEDIUM
700
+ };
701
+ const context = (0, utils_1.extractCodeContext)(file.content, call.location.startLine, 2);
702
+ return {
703
+ id: (0, utils_1.generateId)(),
704
+ title: `AST: ${call.name}`,
705
+ description: call.context || `Dangerous ${call.patternType.replace(/_/g, ' ')} detected via AST analysis`,
706
+ severity: severityMap[call.patternType] || types_1.Severity.MEDIUM,
707
+ threatType: threatTypeMap[call.patternType] || types_1.ThreatType.DANGEROUS_FUNCTION,
708
+ category: types_1.FindingCategory.VULNERABILITY,
709
+ location: {
710
+ file: file.relativePath,
711
+ startLine: call.location.startLine,
712
+ endLine: call.location.endLine,
713
+ startColumn: call.location.startColumn,
714
+ endColumn: call.location.endColumn
715
+ },
716
+ snippet: {
717
+ code: call.code,
718
+ contextBefore: context.contextBefore,
719
+ contextAfter: context.contextAfter
720
+ },
721
+ standards: (0, standards_1.getStandardsForThreat)(threatTypeMap[call.patternType] || types_1.ThreatType.DANGEROUS_FUNCTION),
722
+ remediation: 'Review and fix the identified security issue.',
723
+ confidence: 85,
724
+ analyzer: `${this.name} (AST)`,
725
+ timestamp: new Date(),
726
+ tags: ['ast', call.patternType]
727
+ };
728
+ }
729
+ /**
730
+ * Convert TaintFlow to Finding
731
+ */
732
+ taintFlowToFinding(flow, file) {
733
+ const sourceDesc = taintAnalyzer_1.TaintAnalyzer.getSourceDescription(flow.source.type);
734
+ const sinkInfo = taintAnalyzer_1.TaintAnalyzer.getSinkInfo(flow.sink.type);
735
+ const context = (0, utils_1.extractCodeContext)(file.content, flow.sink.line, 2);
736
+ // Build detailed description with flow path
737
+ let description = `Tainted data from ${sourceDesc} flows to ${flow.sink.type} sink.`;
738
+ if (flow.propagation.length > 0) {
739
+ description += ` The data passes through ${flow.propagation.length} intermediate assignments.`;
740
+ }
741
+ return {
742
+ id: (0, utils_1.generateId)(),
743
+ title: `Taint Flow: ${flow.source.type} → ${flow.sink.type}`,
744
+ description,
745
+ severity: flow.sink.severity,
746
+ threatType: flow.sink.threatType,
747
+ category: types_1.FindingCategory.VULNERABILITY,
748
+ location: {
749
+ file: file.relativePath,
750
+ startLine: flow.sink.line,
751
+ endLine: flow.sink.line
752
+ },
753
+ snippet: {
754
+ code: flow.sink.code,
755
+ contextBefore: context.contextBefore,
756
+ contextAfter: context.contextAfter
757
+ },
758
+ standards: (0, standards_1.getStandardsForThreat)(flow.sink.threatType),
759
+ remediation: sinkInfo?.remediation || 'Validate and sanitize all user input before use.',
760
+ confidence: flow.confidence,
761
+ analyzer: `${this.name} (Taint)`,
762
+ timestamp: new Date(),
763
+ tags: ['taint-analysis', flow.source.type, flow.sink.type]
764
+ };
765
+ }
766
+ /**
767
+ * Convert MalwareMatch to Finding
768
+ */
769
+ malwareMatchToFinding(match, file) {
770
+ const context = (0, utils_1.extractCodeContext)(file.content, match.line, 2);
771
+ return {
772
+ id: (0, utils_1.generateId)(),
773
+ title: `Malware: ${match.name}`,
774
+ description: match.description,
775
+ severity: match.severity,
776
+ threatType: malwareDetector_1.MalwareDetector.getThreatType(match.type),
777
+ category: types_1.FindingCategory.MALWARE,
778
+ location: {
779
+ file: file.relativePath,
780
+ startLine: match.line,
781
+ endLine: match.line
782
+ },
783
+ snippet: {
784
+ code: match.code,
785
+ contextBefore: context.contextBefore,
786
+ contextAfter: context.contextAfter
787
+ },
788
+ standards: (0, standards_1.getStandardsForThreat)(malwareDetector_1.MalwareDetector.getThreatType(match.type)),
789
+ remediation: match.remediation,
790
+ confidence: match.confidence,
791
+ analyzer: `${this.name} (Malware)`,
792
+ timestamp: new Date(),
793
+ tags: ['malware', match.type, ...(match.mitreAttack || [])]
794
+ };
795
+ }
796
+ /**
797
+ * Convert PackageJsonFinding to Finding
798
+ */
799
+ packageFindingToFinding(pkgFinding, file) {
800
+ return {
801
+ id: (0, utils_1.generateId)(),
802
+ title: pkgFinding.name,
803
+ description: pkgFinding.description,
804
+ severity: pkgFinding.severity,
805
+ threatType: pkgFinding.threatType,
806
+ category: pkgFinding.category,
807
+ location: {
808
+ file: file.relativePath,
809
+ startLine: 1,
810
+ endLine: 1
811
+ },
812
+ snippet: {
813
+ code: `"${pkgFinding.field}": "${pkgFinding.value.substring(0, 100)}"`
814
+ },
815
+ standards: (0, standards_1.getStandardsForThreat)(pkgFinding.threatType),
816
+ remediation: pkgFinding.remediation,
817
+ confidence: pkgFinding.confidence,
818
+ analyzer: `${this.name} (Package)`,
819
+ timestamp: new Date(),
820
+ tags: ['package-json', pkgFinding.type]
821
+ };
822
+ }
823
+ /**
824
+ * Deduplicate findings based on location and type
825
+ */
826
+ deduplicateFindings(findings) {
827
+ const seen = new Map();
828
+ for (const finding of findings) {
829
+ const key = `${finding.location.file}:${finding.location.startLine}:${finding.threatType}`;
830
+ if (!seen.has(key)) {
831
+ seen.set(key, finding);
832
+ }
833
+ else {
834
+ // Keep the one with higher confidence
835
+ const existing = seen.get(key);
836
+ if (finding.confidence > existing.confidence) {
837
+ seen.set(key, finding);
838
+ }
839
+ }
840
+ }
841
+ return Array.from(seen.values());
842
+ }
843
+ /**
844
+ * Filter findings by minimum confidence
845
+ */
846
+ filterByConfidence(findings) {
847
+ return findings.filter(f => f.confidence >= this.options.minConfidence);
848
+ }
849
+ /**
850
+ * Create a timeout promise
851
+ */
852
+ timeout(ms) {
853
+ return new Promise((_, reject) => {
854
+ setTimeout(() => reject(new Error('Analysis timeout')), ms);
855
+ });
856
+ }
857
+ }
858
+ exports.JavaScriptAnalyzer = JavaScriptAnalyzer;
859
+ exports.default = JavaScriptAnalyzer;
860
+ //# sourceMappingURL=javascriptAnalyzer.js.map