erosolar-cli 2.1.249 → 2.1.252

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 (467) hide show
  1. package/agents/general.rules.json +10 -133
  2. package/agents/general.rules.json.bak +278 -0
  3. package/agents/general.rules.json.bak2 +306 -0
  4. package/dist/bin/erosolar.js +9 -5
  5. package/dist/bin/erosolar.js.map +1 -1
  6. package/dist/capabilities/bidirectionalAuditCapability.d.ts +26 -0
  7. package/dist/capabilities/bidirectionalAuditCapability.d.ts.map +1 -0
  8. package/dist/capabilities/bidirectionalAuditCapability.js +44 -0
  9. package/dist/capabilities/bidirectionalAuditCapability.js.map +1 -0
  10. package/dist/capabilities/globCapability.d.ts +3 -6
  11. package/dist/capabilities/globCapability.d.ts.map +1 -1
  12. package/dist/capabilities/globCapability.js +6 -10
  13. package/dist/capabilities/globCapability.js.map +1 -1
  14. package/dist/capabilities/index.d.ts +1 -18
  15. package/dist/capabilities/index.d.ts.map +1 -1
  16. package/dist/capabilities/index.js +1 -18
  17. package/dist/capabilities/index.js.map +1 -1
  18. package/dist/capabilities/orchestrationCapability.d.ts +2 -0
  19. package/dist/capabilities/orchestrationCapability.d.ts.map +1 -1
  20. package/dist/capabilities/orchestrationCapability.js +980 -2
  21. package/dist/capabilities/orchestrationCapability.js.map +1 -1
  22. package/dist/capabilities/searchCapability.d.ts +8 -2
  23. package/dist/capabilities/searchCapability.d.ts.map +1 -1
  24. package/dist/capabilities/searchCapability.js +11 -6
  25. package/dist/capabilities/searchCapability.js.map +1 -1
  26. package/dist/contracts/tools.schema.json +9 -133
  27. package/dist/core/aiErrorFixer.d.ts +1 -14
  28. package/dist/core/aiErrorFixer.d.ts.map +1 -1
  29. package/dist/core/aiErrorFixer.js +51 -239
  30. package/dist/core/aiErrorFixer.js.map +1 -1
  31. package/dist/core/alphaZeroEngine.d.ts +16 -256
  32. package/dist/core/alphaZeroEngine.d.ts.map +1 -1
  33. package/dist/core/alphaZeroEngine.js +22 -513
  34. package/dist/core/alphaZeroEngine.js.map +1 -1
  35. package/dist/core/completeAttackOrchestrator.d.ts +102 -0
  36. package/dist/core/completeAttackOrchestrator.d.ts.map +1 -0
  37. package/dist/core/completeAttackOrchestrator.js +293 -0
  38. package/dist/core/completeAttackOrchestrator.js.map +1 -0
  39. package/dist/core/defensiveSecurityToolkit.d.ts +373 -0
  40. package/dist/core/defensiveSecurityToolkit.d.ts.map +1 -0
  41. package/dist/core/defensiveSecurityToolkit.js +1304 -0
  42. package/dist/core/defensiveSecurityToolkit.js.map +1 -0
  43. package/dist/core/errors/errorTypes.d.ts +30 -57
  44. package/dist/core/errors/errorTypes.d.ts.map +1 -1
  45. package/dist/core/errors/errorTypes.js +51 -228
  46. package/dist/core/errors/errorTypes.js.map +1 -1
  47. package/dist/core/errors/safetyValidator.d.ts +19 -3
  48. package/dist/core/errors/safetyValidator.d.ts.map +1 -1
  49. package/dist/core/errors/safetyValidator.js +33 -71
  50. package/dist/core/errors/safetyValidator.js.map +1 -1
  51. package/dist/core/failureRecovery.d.ts +4 -100
  52. package/dist/core/failureRecovery.d.ts.map +1 -1
  53. package/dist/core/failureRecovery.js +16 -440
  54. package/dist/core/failureRecovery.js.map +1 -1
  55. package/dist/core/intelligentTargetResearcher.d.ts +142 -0
  56. package/dist/core/intelligentTargetResearcher.d.ts.map +1 -0
  57. package/dist/core/intelligentTargetResearcher.js +367 -0
  58. package/dist/core/intelligentTargetResearcher.js.map +1 -0
  59. package/dist/core/intelligentTestFlows.d.ts +26 -107
  60. package/dist/core/intelligentTestFlows.d.ts.map +1 -1
  61. package/dist/core/intelligentTestFlows.js +15 -659
  62. package/dist/core/intelligentTestFlows.js.map +1 -1
  63. package/dist/core/learningPersistence.d.ts +45 -132
  64. package/dist/core/learningPersistence.d.ts.map +1 -1
  65. package/dist/core/learningPersistence.js +32 -463
  66. package/dist/core/learningPersistence.js.map +1 -1
  67. package/dist/core/metricsTracker.d.ts +22 -139
  68. package/dist/core/metricsTracker.d.ts.map +1 -1
  69. package/dist/core/metricsTracker.js +51 -241
  70. package/dist/core/metricsTracker.js.map +1 -1
  71. package/dist/core/performanceMonitor.d.ts +15 -109
  72. package/dist/core/performanceMonitor.d.ts.map +1 -1
  73. package/dist/core/performanceMonitor.js +27 -184
  74. package/dist/core/performanceMonitor.js.map +1 -1
  75. package/dist/core/resultVerification.d.ts +6 -100
  76. package/dist/core/resultVerification.d.ts.map +1 -1
  77. package/dist/core/resultVerification.js +31 -400
  78. package/dist/core/resultVerification.js.map +1 -1
  79. package/dist/core/selfEvolution.d.ts +32 -126
  80. package/dist/core/selfEvolution.d.ts.map +1 -1
  81. package/dist/core/selfEvolution.js +24 -967
  82. package/dist/core/selfEvolution.js.map +1 -1
  83. package/dist/core/selfImprovement.d.ts +50 -109
  84. package/dist/core/selfImprovement.d.ts.map +1 -1
  85. package/dist/core/selfImprovement.js +14 -689
  86. package/dist/core/selfImprovement.js.map +1 -1
  87. package/dist/core/sourceCodeManager.d.ts +89 -0
  88. package/dist/core/sourceCodeManager.d.ts.map +1 -0
  89. package/dist/core/sourceCodeManager.js +332 -0
  90. package/dist/core/sourceCodeManager.js.map +1 -0
  91. package/dist/core/unifiedOrchestrator.d.ts +88 -0
  92. package/dist/core/unifiedOrchestrator.d.ts.map +1 -0
  93. package/dist/core/unifiedOrchestrator.js +284 -0
  94. package/dist/core/unifiedOrchestrator.js.map +1 -0
  95. package/dist/core/userDefenseOrchestrator.d.ts +202 -0
  96. package/dist/core/userDefenseOrchestrator.d.ts.map +1 -0
  97. package/dist/core/userDefenseOrchestrator.js +1006 -0
  98. package/dist/core/userDefenseOrchestrator.js.map +1 -0
  99. package/dist/plugins/index.d.ts +1 -1
  100. package/dist/plugins/index.d.ts.map +1 -1
  101. package/dist/plugins/index.js +36 -26
  102. package/dist/plugins/index.js.map +1 -1
  103. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.d.ts +8 -0
  104. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.d.ts.map +1 -0
  105. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.js +17 -0
  106. package/dist/plugins/tools/bidirectionalAudit/bidirectionalAuditPlugin.js.map +1 -0
  107. package/dist/plugins/tools/nodeDefaults.d.ts +14 -0
  108. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  109. package/dist/plugins/tools/nodeDefaults.js +17 -54
  110. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  111. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts +9 -0
  112. package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts.map +1 -0
  113. package/dist/plugins/tools/orchestration/orchestrationPlugin.js +18 -0
  114. package/dist/plugins/tools/orchestration/orchestrationPlugin.js.map +1 -0
  115. package/dist/shell/interactiveShell.d.ts +97 -2
  116. package/dist/shell/interactiveShell.d.ts.map +1 -1
  117. package/dist/shell/interactiveShell.js +1001 -6
  118. package/dist/shell/interactiveShell.js.map +1 -1
  119. package/dist/tools/appleExposureTools.d.ts +108 -0
  120. package/dist/tools/appleExposureTools.d.ts.map +1 -0
  121. package/dist/tools/appleExposureTools.js +850 -0
  122. package/dist/tools/appleExposureTools.js.map +1 -0
  123. package/dist/tools/bidirectionalAuditTools.d.ts +104 -0
  124. package/dist/tools/bidirectionalAuditTools.d.ts.map +1 -0
  125. package/dist/tools/bidirectionalAuditTools.js +1280 -0
  126. package/dist/tools/bidirectionalAuditTools.js.map +1 -0
  127. package/dist/tools/defensiveSecurityTools.d.ts +152 -0
  128. package/dist/tools/defensiveSecurityTools.d.ts.map +1 -0
  129. package/dist/tools/defensiveSecurityTools.js +576 -0
  130. package/dist/tools/defensiveSecurityTools.js.map +1 -0
  131. package/dist/tools/forwardAttackChainTracer.d.ts +73 -0
  132. package/dist/tools/forwardAttackChainTracer.d.ts.map +1 -0
  133. package/dist/tools/forwardAttackChainTracer.js +604 -0
  134. package/dist/tools/forwardAttackChainTracer.js.map +1 -0
  135. package/dist/tools/localExplore.d.ts +12 -199
  136. package/dist/tools/localExplore.d.ts.map +1 -1
  137. package/dist/tools/localExplore.js +18 -1352
  138. package/dist/tools/localExplore.js.map +1 -1
  139. package/dist/tools/offensiveTransparencyTools.d.ts +188 -0
  140. package/dist/tools/offensiveTransparencyTools.d.ts.map +1 -0
  141. package/dist/tools/offensiveTransparencyTools.js +890 -0
  142. package/dist/tools/offensiveTransparencyTools.js.map +1 -0
  143. package/dist/tools/planningTools.d.ts +8 -17
  144. package/dist/tools/planningTools.d.ts.map +1 -1
  145. package/dist/tools/planningTools.js +31 -141
  146. package/dist/tools/planningTools.js.map +1 -1
  147. package/dist/tools/searchTools.d.ts +9 -0
  148. package/dist/tools/searchTools.d.ts.map +1 -1
  149. package/dist/tools/searchTools.js +305 -189
  150. package/dist/tools/searchTools.js.map +1 -1
  151. package/dist/tools/skillTools.d.ts +7 -5
  152. package/dist/tools/skillTools.d.ts.map +1 -1
  153. package/dist/tools/skillTools.js +13 -155
  154. package/dist/tools/skillTools.js.map +1 -1
  155. package/dist/tools/threatIntelligenceTools.d.ts +128 -0
  156. package/dist/tools/threatIntelligenceTools.d.ts.map +1 -0
  157. package/dist/tools/threatIntelligenceTools.js +712 -0
  158. package/dist/tools/threatIntelligenceTools.js.map +1 -0
  159. package/dist/ui/PromptController.d.ts +4 -0
  160. package/dist/ui/PromptController.d.ts.map +1 -1
  161. package/dist/ui/PromptController.js +32 -11
  162. package/dist/ui/PromptController.js.map +1 -1
  163. package/dist/ui/UnifiedUIRenderer.d.ts +20 -0
  164. package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
  165. package/dist/ui/UnifiedUIRenderer.js +235 -28
  166. package/dist/ui/UnifiedUIRenderer.js.map +1 -1
  167. package/dist/ui/animatedStatus.d.ts +2 -0
  168. package/dist/ui/animatedStatus.d.ts.map +1 -1
  169. package/dist/ui/animatedStatus.js +36 -2
  170. package/dist/ui/animatedStatus.js.map +1 -1
  171. package/dist/ui/orchestration/StatusOrchestrator.d.ts +10 -0
  172. package/dist/ui/orchestration/StatusOrchestrator.d.ts.map +1 -1
  173. package/dist/ui/orchestration/StatusOrchestrator.js +36 -4
  174. package/dist/ui/orchestration/StatusOrchestrator.js.map +1 -1
  175. package/package.json +1 -1
  176. package/dist/capabilities/advancedTestGenerationCapability.d.ts +0 -17
  177. package/dist/capabilities/advancedTestGenerationCapability.d.ts.map +0 -1
  178. package/dist/capabilities/advancedTestGenerationCapability.js +0 -28
  179. package/dist/capabilities/advancedTestGenerationCapability.js.map +0 -1
  180. package/dist/capabilities/browserAutomationCapability.d.ts +0 -37
  181. package/dist/capabilities/browserAutomationCapability.d.ts.map +0 -1
  182. package/dist/capabilities/browserAutomationCapability.js +0 -49
  183. package/dist/capabilities/browserAutomationCapability.js.map +0 -1
  184. package/dist/capabilities/buildCapability.d.ts +0 -24
  185. package/dist/capabilities/buildCapability.d.ts.map +0 -1
  186. package/dist/capabilities/buildCapability.js +0 -25
  187. package/dist/capabilities/buildCapability.js.map +0 -1
  188. package/dist/capabilities/cloudCapability.d.ts +0 -13
  189. package/dist/capabilities/cloudCapability.d.ts.map +0 -1
  190. package/dist/capabilities/cloudCapability.js +0 -38
  191. package/dist/capabilities/cloudCapability.js.map +0 -1
  192. package/dist/capabilities/codeAnalysisCapability.d.ts +0 -13
  193. package/dist/capabilities/codeAnalysisCapability.d.ts.map +0 -1
  194. package/dist/capabilities/codeAnalysisCapability.js +0 -24
  195. package/dist/capabilities/codeAnalysisCapability.js.map +0 -1
  196. package/dist/capabilities/codeQualityCapability.d.ts +0 -13
  197. package/dist/capabilities/codeQualityCapability.d.ts.map +0 -1
  198. package/dist/capabilities/codeQualityCapability.js +0 -25
  199. package/dist/capabilities/codeQualityCapability.js.map +0 -1
  200. package/dist/capabilities/dependencySecurityCapability.d.ts +0 -13
  201. package/dist/capabilities/dependencySecurityCapability.d.ts.map +0 -1
  202. package/dist/capabilities/dependencySecurityCapability.js +0 -24
  203. package/dist/capabilities/dependencySecurityCapability.js.map +0 -1
  204. package/dist/capabilities/devCapability.d.ts +0 -13
  205. package/dist/capabilities/devCapability.d.ts.map +0 -1
  206. package/dist/capabilities/devCapability.js +0 -24
  207. package/dist/capabilities/devCapability.js.map +0 -1
  208. package/dist/capabilities/emailCapability.d.ts +0 -12
  209. package/dist/capabilities/emailCapability.d.ts.map +0 -1
  210. package/dist/capabilities/emailCapability.js +0 -22
  211. package/dist/capabilities/emailCapability.js.map +0 -1
  212. package/dist/capabilities/enhancedAnalysisCapability.d.ts +0 -13
  213. package/dist/capabilities/enhancedAnalysisCapability.d.ts.map +0 -1
  214. package/dist/capabilities/enhancedAnalysisCapability.js +0 -20
  215. package/dist/capabilities/enhancedAnalysisCapability.js.map +0 -1
  216. package/dist/capabilities/enhancedCodeIntelligenceCapability.d.ts +0 -17
  217. package/dist/capabilities/enhancedCodeIntelligenceCapability.d.ts.map +0 -1
  218. package/dist/capabilities/enhancedCodeIntelligenceCapability.js +0 -28
  219. package/dist/capabilities/enhancedCodeIntelligenceCapability.js.map +0 -1
  220. package/dist/capabilities/enhancedDevWorkflowCapability.d.ts +0 -17
  221. package/dist/capabilities/enhancedDevWorkflowCapability.d.ts.map +0 -1
  222. package/dist/capabilities/enhancedDevWorkflowCapability.js +0 -28
  223. package/dist/capabilities/enhancedDevWorkflowCapability.js.map +0 -1
  224. package/dist/capabilities/frontendTestingCapability.d.ts +0 -13
  225. package/dist/capabilities/frontendTestingCapability.d.ts.map +0 -1
  226. package/dist/capabilities/frontendTestingCapability.js +0 -28
  227. package/dist/capabilities/frontendTestingCapability.js.map +0 -1
  228. package/dist/capabilities/interactionCapability.d.ts +0 -12
  229. package/dist/capabilities/interactionCapability.d.ts.map +0 -1
  230. package/dist/capabilities/interactionCapability.js +0 -22
  231. package/dist/capabilities/interactionCapability.js.map +0 -1
  232. package/dist/capabilities/learnCapability.d.ts +0 -22
  233. package/dist/capabilities/learnCapability.d.ts.map +0 -1
  234. package/dist/capabilities/learnCapability.js +0 -37
  235. package/dist/capabilities/learnCapability.js.map +0 -1
  236. package/dist/capabilities/notebookCapability.d.ts +0 -17
  237. package/dist/capabilities/notebookCapability.d.ts.map +0 -1
  238. package/dist/capabilities/notebookCapability.js +0 -27
  239. package/dist/capabilities/notebookCapability.js.map +0 -1
  240. package/dist/capabilities/planningCapability.d.ts +0 -16
  241. package/dist/capabilities/planningCapability.d.ts.map +0 -1
  242. package/dist/capabilities/planningCapability.js +0 -26
  243. package/dist/capabilities/planningCapability.js.map +0 -1
  244. package/dist/capabilities/refactoringCapability.d.ts +0 -13
  245. package/dist/capabilities/refactoringCapability.d.ts.map +0 -1
  246. package/dist/capabilities/refactoringCapability.js +0 -25
  247. package/dist/capabilities/refactoringCapability.js.map +0 -1
  248. package/dist/capabilities/repoChecksCapability.d.ts +0 -10
  249. package/dist/capabilities/repoChecksCapability.d.ts.map +0 -1
  250. package/dist/capabilities/repoChecksCapability.js +0 -24
  251. package/dist/capabilities/repoChecksCapability.js.map +0 -1
  252. package/dist/capabilities/taskManagementCapability.d.ts +0 -12
  253. package/dist/capabilities/taskManagementCapability.d.ts.map +0 -1
  254. package/dist/capabilities/taskManagementCapability.js +0 -22
  255. package/dist/capabilities/taskManagementCapability.js.map +0 -1
  256. package/dist/capabilities/testingCapability.d.ts +0 -13
  257. package/dist/capabilities/testingCapability.d.ts.map +0 -1
  258. package/dist/capabilities/testingCapability.js +0 -25
  259. package/dist/capabilities/testingCapability.js.map +0 -1
  260. package/dist/capabilities/validationCapability.d.ts +0 -13
  261. package/dist/capabilities/validationCapability.d.ts.map +0 -1
  262. package/dist/capabilities/validationCapability.js +0 -24
  263. package/dist/capabilities/validationCapability.js.map +0 -1
  264. package/dist/capabilities/webCapability.d.ts +0 -12
  265. package/dist/capabilities/webCapability.d.ts.map +0 -1
  266. package/dist/capabilities/webCapability.js +0 -22
  267. package/dist/capabilities/webCapability.js.map +0 -1
  268. package/dist/core/deepBugAnalyzer.d.ts +0 -128
  269. package/dist/core/deepBugAnalyzer.d.ts.map +0 -1
  270. package/dist/core/deepBugAnalyzer.js +0 -406
  271. package/dist/core/deepBugAnalyzer.js.map +0 -1
  272. package/dist/core/hypothesisEngine.d.ts +0 -113
  273. package/dist/core/hypothesisEngine.d.ts.map +0 -1
  274. package/dist/core/hypothesisEngine.js +0 -264
  275. package/dist/core/hypothesisEngine.js.map +0 -1
  276. package/dist/core/productTestHarness.d.ts +0 -113
  277. package/dist/core/productTestHarness.d.ts.map +0 -1
  278. package/dist/core/productTestHarness.js +0 -351
  279. package/dist/core/productTestHarness.js.map +0 -1
  280. package/dist/core/validationRunner.d.ts +0 -106
  281. package/dist/core/validationRunner.d.ts.map +0 -1
  282. package/dist/core/validationRunner.js +0 -892
  283. package/dist/core/validationRunner.js.map +0 -1
  284. package/dist/plugins/tools/browser/browserAutomationPlugin.d.ts +0 -14
  285. package/dist/plugins/tools/browser/browserAutomationPlugin.d.ts.map +0 -1
  286. package/dist/plugins/tools/browser/browserAutomationPlugin.js +0 -26
  287. package/dist/plugins/tools/browser/browserAutomationPlugin.js.map +0 -1
  288. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts +0 -3
  289. package/dist/plugins/tools/checks/localRepoChecksPlugin.d.ts.map +0 -1
  290. package/dist/plugins/tools/checks/localRepoChecksPlugin.js +0 -14
  291. package/dist/plugins/tools/checks/localRepoChecksPlugin.js.map +0 -1
  292. package/dist/plugins/tools/cloud/cloudPlugin.d.ts +0 -3
  293. package/dist/plugins/tools/cloud/cloudPlugin.d.ts.map +0 -1
  294. package/dist/plugins/tools/cloud/cloudPlugin.js +0 -14
  295. package/dist/plugins/tools/cloud/cloudPlugin.js.map +0 -1
  296. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts +0 -3
  297. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.d.ts.map +0 -1
  298. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +0 -14
  299. package/dist/plugins/tools/codeAnalysis/codeAnalysisPlugin.js.map +0 -1
  300. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts +0 -3
  301. package/dist/plugins/tools/codeQuality/codeQualityPlugin.d.ts.map +0 -1
  302. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js +0 -14
  303. package/dist/plugins/tools/codeQuality/codeQualityPlugin.js.map +0 -1
  304. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts +0 -3
  305. package/dist/plugins/tools/dependency/dependencyPlugin.d.ts.map +0 -1
  306. package/dist/plugins/tools/dependency/dependencyPlugin.js +0 -12
  307. package/dist/plugins/tools/dependency/dependencyPlugin.js.map +0 -1
  308. package/dist/plugins/tools/development/devPlugin.d.ts +0 -3
  309. package/dist/plugins/tools/development/devPlugin.d.ts.map +0 -1
  310. package/dist/plugins/tools/development/devPlugin.js +0 -14
  311. package/dist/plugins/tools/development/devPlugin.js.map +0 -1
  312. package/dist/plugins/tools/email/emailPlugin.d.ts +0 -3
  313. package/dist/plugins/tools/email/emailPlugin.d.ts.map +0 -1
  314. package/dist/plugins/tools/email/emailPlugin.js +0 -12
  315. package/dist/plugins/tools/email/emailPlugin.js.map +0 -1
  316. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts +0 -3
  317. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.d.ts.map +0 -1
  318. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js +0 -14
  319. package/dist/plugins/tools/enhancedAnalysis/enhancedAnalysisPlugin.js.map +0 -1
  320. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts +0 -3
  321. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.d.ts.map +0 -1
  322. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js +0 -12
  323. package/dist/plugins/tools/enhancedCodeIntelligence/enhancedCodeIntelligencePlugin.js.map +0 -1
  324. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts +0 -3
  325. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.d.ts.map +0 -1
  326. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js +0 -12
  327. package/dist/plugins/tools/enhancedDevWorkflow/enhancedDevWorkflowPlugin.js.map +0 -1
  328. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.d.ts +0 -3
  329. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.d.ts.map +0 -1
  330. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.js +0 -14
  331. package/dist/plugins/tools/frontendTesting/frontendTestingPlugin.js.map +0 -1
  332. package/dist/plugins/tools/interaction/interactionPlugin.d.ts +0 -3
  333. package/dist/plugins/tools/interaction/interactionPlugin.d.ts.map +0 -1
  334. package/dist/plugins/tools/interaction/interactionPlugin.js +0 -12
  335. package/dist/plugins/tools/interaction/interactionPlugin.js.map +0 -1
  336. package/dist/plugins/tools/learn/learnPlugin.d.ts +0 -3
  337. package/dist/plugins/tools/learn/learnPlugin.d.ts.map +0 -1
  338. package/dist/plugins/tools/learn/learnPlugin.js +0 -14
  339. package/dist/plugins/tools/learn/learnPlugin.js.map +0 -1
  340. package/dist/plugins/tools/notebook/notebookPlugin.d.ts +0 -9
  341. package/dist/plugins/tools/notebook/notebookPlugin.d.ts.map +0 -1
  342. package/dist/plugins/tools/notebook/notebookPlugin.js +0 -15
  343. package/dist/plugins/tools/notebook/notebookPlugin.js.map +0 -1
  344. package/dist/plugins/tools/planning/planningPlugin.d.ts +0 -9
  345. package/dist/plugins/tools/planning/planningPlugin.d.ts.map +0 -1
  346. package/dist/plugins/tools/planning/planningPlugin.js +0 -15
  347. package/dist/plugins/tools/planning/planningPlugin.js.map +0 -1
  348. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts +0 -3
  349. package/dist/plugins/tools/refactoring/refactoringPlugin.d.ts.map +0 -1
  350. package/dist/plugins/tools/refactoring/refactoringPlugin.js +0 -12
  351. package/dist/plugins/tools/refactoring/refactoringPlugin.js.map +0 -1
  352. package/dist/plugins/tools/taskManagement/taskManagementPlugin.d.ts +0 -3
  353. package/dist/plugins/tools/taskManagement/taskManagementPlugin.d.ts.map +0 -1
  354. package/dist/plugins/tools/taskManagement/taskManagementPlugin.js +0 -12
  355. package/dist/plugins/tools/taskManagement/taskManagementPlugin.js.map +0 -1
  356. package/dist/plugins/tools/testing/testingPlugin.d.ts +0 -3
  357. package/dist/plugins/tools/testing/testingPlugin.d.ts.map +0 -1
  358. package/dist/plugins/tools/testing/testingPlugin.js +0 -12
  359. package/dist/plugins/tools/testing/testingPlugin.js.map +0 -1
  360. package/dist/plugins/tools/validation/validationPlugin.d.ts +0 -3
  361. package/dist/plugins/tools/validation/validationPlugin.d.ts.map +0 -1
  362. package/dist/plugins/tools/validation/validationPlugin.js +0 -14
  363. package/dist/plugins/tools/validation/validationPlugin.js.map +0 -1
  364. package/dist/plugins/tools/web/webPlugin.d.ts +0 -3
  365. package/dist/plugins/tools/web/webPlugin.d.ts.map +0 -1
  366. package/dist/plugins/tools/web/webPlugin.js +0 -12
  367. package/dist/plugins/tools/web/webPlugin.js.map +0 -1
  368. package/dist/tools/advancedTestGenerationTools.d.ts +0 -21
  369. package/dist/tools/advancedTestGenerationTools.d.ts.map +0 -1
  370. package/dist/tools/advancedTestGenerationTools.js +0 -304
  371. package/dist/tools/advancedTestGenerationTools.js.map +0 -1
  372. package/dist/tools/browserAutomationTools.d.ts +0 -23
  373. package/dist/tools/browserAutomationTools.d.ts.map +0 -1
  374. package/dist/tools/browserAutomationTools.js +0 -916
  375. package/dist/tools/browserAutomationTools.js.map +0 -1
  376. package/dist/tools/buildTools.d.ts +0 -9
  377. package/dist/tools/buildTools.d.ts.map +0 -1
  378. package/dist/tools/buildTools.js +0 -346
  379. package/dist/tools/buildTools.js.map +0 -1
  380. package/dist/tools/cloudTools.d.ts +0 -49
  381. package/dist/tools/cloudTools.d.ts.map +0 -1
  382. package/dist/tools/cloudTools.js +0 -1258
  383. package/dist/tools/cloudTools.js.map +0 -1
  384. package/dist/tools/codeAnalysisTools.d.ts +0 -74
  385. package/dist/tools/codeAnalysisTools.d.ts.map +0 -1
  386. package/dist/tools/codeAnalysisTools.js +0 -664
  387. package/dist/tools/codeAnalysisTools.js.map +0 -1
  388. package/dist/tools/codeGenerationTools.d.ts +0 -3
  389. package/dist/tools/codeGenerationTools.d.ts.map +0 -1
  390. package/dist/tools/codeGenerationTools.js +0 -439
  391. package/dist/tools/codeGenerationTools.js.map +0 -1
  392. package/dist/tools/codeQualityTools.d.ts +0 -3
  393. package/dist/tools/codeQualityTools.d.ts.map +0 -1
  394. package/dist/tools/codeQualityTools.js +0 -297
  395. package/dist/tools/codeQualityTools.js.map +0 -1
  396. package/dist/tools/dependencyTools.d.ts +0 -3
  397. package/dist/tools/dependencyTools.d.ts.map +0 -1
  398. package/dist/tools/dependencyTools.js +0 -284
  399. package/dist/tools/dependencyTools.js.map +0 -1
  400. package/dist/tools/devTools.d.ts +0 -10
  401. package/dist/tools/devTools.d.ts.map +0 -1
  402. package/dist/tools/devTools.js +0 -2126
  403. package/dist/tools/devTools.js.map +0 -1
  404. package/dist/tools/emailTools.d.ts +0 -21
  405. package/dist/tools/emailTools.d.ts.map +0 -1
  406. package/dist/tools/emailTools.js +0 -449
  407. package/dist/tools/emailTools.js.map +0 -1
  408. package/dist/tools/enhancedAnalysisTools.d.ts +0 -9
  409. package/dist/tools/enhancedAnalysisTools.d.ts.map +0 -1
  410. package/dist/tools/enhancedAnalysisTools.js +0 -370
  411. package/dist/tools/enhancedAnalysisTools.js.map +0 -1
  412. package/dist/tools/enhancedCodeIntelligenceTools.d.ts +0 -7
  413. package/dist/tools/enhancedCodeIntelligenceTools.d.ts.map +0 -1
  414. package/dist/tools/enhancedCodeIntelligenceTools.js +0 -540
  415. package/dist/tools/enhancedCodeIntelligenceTools.js.map +0 -1
  416. package/dist/tools/enhancedDevWorkflowTools.d.ts +0 -7
  417. package/dist/tools/enhancedDevWorkflowTools.d.ts.map +0 -1
  418. package/dist/tools/enhancedDevWorkflowTools.js +0 -432
  419. package/dist/tools/enhancedDevWorkflowTools.js.map +0 -1
  420. package/dist/tools/frontendTestingTools.d.ts +0 -35
  421. package/dist/tools/frontendTestingTools.d.ts.map +0 -1
  422. package/dist/tools/frontendTestingTools.js +0 -1258
  423. package/dist/tools/frontendTestingTools.js.map +0 -1
  424. package/dist/tools/globTools.d.ts +0 -15
  425. package/dist/tools/globTools.d.ts.map +0 -1
  426. package/dist/tools/globTools.js +0 -174
  427. package/dist/tools/globTools.js.map +0 -1
  428. package/dist/tools/grepTools.d.ts +0 -19
  429. package/dist/tools/grepTools.d.ts.map +0 -1
  430. package/dist/tools/grepTools.js +0 -411
  431. package/dist/tools/grepTools.js.map +0 -1
  432. package/dist/tools/interactionTools.d.ts +0 -6
  433. package/dist/tools/interactionTools.d.ts.map +0 -1
  434. package/dist/tools/interactionTools.js +0 -209
  435. package/dist/tools/interactionTools.js.map +0 -1
  436. package/dist/tools/learnTools.d.ts +0 -164
  437. package/dist/tools/learnTools.d.ts.map +0 -1
  438. package/dist/tools/learnTools.js +0 -2098
  439. package/dist/tools/learnTools.js.map +0 -1
  440. package/dist/tools/notebookEditTools.d.ts +0 -15
  441. package/dist/tools/notebookEditTools.d.ts.map +0 -1
  442. package/dist/tools/notebookEditTools.js +0 -197
  443. package/dist/tools/notebookEditTools.js.map +0 -1
  444. package/dist/tools/refactoringTools.d.ts +0 -3
  445. package/dist/tools/refactoringTools.d.ts.map +0 -1
  446. package/dist/tools/refactoringTools.js +0 -294
  447. package/dist/tools/refactoringTools.js.map +0 -1
  448. package/dist/tools/repoChecksTools.d.ts +0 -3
  449. package/dist/tools/repoChecksTools.d.ts.map +0 -1
  450. package/dist/tools/repoChecksTools.js +0 -276
  451. package/dist/tools/repoChecksTools.js.map +0 -1
  452. package/dist/tools/taskManagementTools.d.ts +0 -10
  453. package/dist/tools/taskManagementTools.d.ts.map +0 -1
  454. package/dist/tools/taskManagementTools.js +0 -133
  455. package/dist/tools/taskManagementTools.js.map +0 -1
  456. package/dist/tools/testingTools.d.ts +0 -3
  457. package/dist/tools/testingTools.d.ts.map +0 -1
  458. package/dist/tools/testingTools.js +0 -237
  459. package/dist/tools/testingTools.js.map +0 -1
  460. package/dist/tools/validationTools.d.ts +0 -7
  461. package/dist/tools/validationTools.d.ts.map +0 -1
  462. package/dist/tools/validationTools.js +0 -344
  463. package/dist/tools/validationTools.js.map +0 -1
  464. package/dist/tools/webTools.d.ts +0 -3
  465. package/dist/tools/webTools.d.ts.map +0 -1
  466. package/dist/tools/webTools.js +0 -502
  467. package/dist/tools/webTools.js.map +0 -1
@@ -0,0 +1,1304 @@
1
+ /**
2
+ * Defensive Security Toolkit
3
+ *
4
+ * Legitimate security capabilities for:
5
+ * - Threat intelligence gathering (OSINT)
6
+ * - Evidence documentation with chain of custody
7
+ * - Transparency reporting and public disclosure
8
+ * - Authorized penetration testing support
9
+ * - Incident response and forensics
10
+ *
11
+ * All capabilities designed for DEFENSIVE use:
12
+ * - Understanding attack surfaces to defend them
13
+ * - Documenting threats for legal/regulatory action
14
+ * - Transparency to deter bad actors through exposure
15
+ * - Authorized security assessments
16
+ */
17
+ import { execSync } from 'child_process';
18
+ import * as fs from 'fs';
19
+ import * as path from 'path';
20
+ import * as crypto from 'crypto';
21
+ /**
22
+ * Open Source Intelligence gathering
23
+ * Uses only publicly available information
24
+ */
25
+ export class OSINTGatherer {
26
+ cache = new Map();
27
+ /**
28
+ * Gather intelligence on a domain
29
+ */
30
+ async investigateDomain(domain) {
31
+ const findings = [];
32
+ const indicators = [];
33
+ const timestamp = new Date().toISOString();
34
+ // DNS records (public information)
35
+ try {
36
+ const dnsInfo = await this.queryDNS(domain);
37
+ findings.push({
38
+ source: 'DNS',
39
+ category: 'infrastructure',
40
+ data: dnsInfo,
41
+ reliability: 'confirmed',
42
+ timestamp,
43
+ });
44
+ // Extract IPs as indicators
45
+ if (dnsInfo['a']) {
46
+ for (const ip of dnsInfo['a']) {
47
+ indicators.push({
48
+ type: 'ip',
49
+ value: ip,
50
+ confidence: 1.0,
51
+ source: 'DNS A record',
52
+ timestamp,
53
+ });
54
+ }
55
+ }
56
+ }
57
+ catch (e) {
58
+ // DNS query failed
59
+ }
60
+ // WHOIS (public registration data)
61
+ try {
62
+ const whoisInfo = await this.queryWHOIS(domain);
63
+ findings.push({
64
+ source: 'WHOIS',
65
+ category: 'registration',
66
+ data: whoisInfo,
67
+ reliability: 'confirmed',
68
+ timestamp,
69
+ });
70
+ }
71
+ catch (e) {
72
+ // WHOIS query failed
73
+ }
74
+ // SSL Certificate transparency logs (public)
75
+ try {
76
+ const certInfo = await this.queryCertificateTransparency(domain);
77
+ findings.push({
78
+ source: 'Certificate Transparency',
79
+ category: 'certificates',
80
+ data: certInfo,
81
+ reliability: 'confirmed',
82
+ timestamp,
83
+ });
84
+ }
85
+ catch (e) {
86
+ // CT query failed
87
+ }
88
+ // Check public threat intelligence feeds
89
+ const threatFeeds = await this.checkThreatFeeds(domain, 'domain');
90
+ findings.push(...threatFeeds);
91
+ return {
92
+ query: domain,
93
+ queryType: 'domain',
94
+ timestamp,
95
+ sources: ['DNS', 'WHOIS', 'Certificate Transparency', 'Public Threat Feeds'],
96
+ findings,
97
+ relatedIndicators: indicators,
98
+ riskAssessment: this.assessRisk(findings, indicators),
99
+ };
100
+ }
101
+ /**
102
+ * Gather intelligence on an IP address
103
+ */
104
+ async investigateIP(ip) {
105
+ const findings = [];
106
+ const indicators = [];
107
+ const timestamp = new Date().toISOString();
108
+ // Reverse DNS
109
+ try {
110
+ const reverseDNS = await this.queryReverseDNS(ip);
111
+ findings.push({
112
+ source: 'Reverse DNS',
113
+ category: 'infrastructure',
114
+ data: { hostnames: reverseDNS },
115
+ reliability: 'confirmed',
116
+ timestamp,
117
+ });
118
+ for (const hostname of reverseDNS) {
119
+ indicators.push({
120
+ type: 'domain',
121
+ value: hostname,
122
+ confidence: 1.0,
123
+ source: 'Reverse DNS',
124
+ timestamp,
125
+ });
126
+ }
127
+ }
128
+ catch (e) {
129
+ // Reverse DNS failed
130
+ }
131
+ // IP geolocation (public databases)
132
+ try {
133
+ const geoInfo = await this.queryGeoIP(ip);
134
+ findings.push({
135
+ source: 'GeoIP',
136
+ category: 'location',
137
+ data: geoInfo,
138
+ reliability: 'likely',
139
+ timestamp,
140
+ });
141
+ }
142
+ catch (e) {
143
+ // GeoIP query failed
144
+ }
145
+ // ASN information (public)
146
+ try {
147
+ const asnInfo = await this.queryASN(ip);
148
+ findings.push({
149
+ source: 'ASN Registry',
150
+ category: 'network',
151
+ data: asnInfo,
152
+ reliability: 'confirmed',
153
+ timestamp,
154
+ });
155
+ }
156
+ catch (e) {
157
+ // ASN query failed
158
+ }
159
+ // Check public threat intelligence feeds
160
+ const threatFeeds = await this.checkThreatFeeds(ip, 'ip');
161
+ findings.push(...threatFeeds);
162
+ return {
163
+ query: ip,
164
+ queryType: 'ip',
165
+ timestamp,
166
+ sources: ['Reverse DNS', 'GeoIP', 'ASN Registry', 'Public Threat Feeds'],
167
+ findings,
168
+ relatedIndicators: indicators,
169
+ riskAssessment: this.assessRisk(findings, indicators),
170
+ };
171
+ }
172
+ /**
173
+ * Investigate email address using public sources
174
+ */
175
+ async investigateEmail(email) {
176
+ const findings = [];
177
+ const indicators = [];
178
+ const timestamp = new Date().toISOString();
179
+ const [, domain] = email.split('@');
180
+ if (domain) {
181
+ // Check if domain exists
182
+ const domainInfo = await this.investigateDomain(domain);
183
+ findings.push({
184
+ source: 'Domain Investigation',
185
+ category: 'email_domain',
186
+ data: { domainRisk: domainInfo.riskAssessment },
187
+ reliability: 'confirmed',
188
+ timestamp,
189
+ });
190
+ indicators.push({
191
+ type: 'domain',
192
+ value: domain,
193
+ confidence: 1.0,
194
+ source: 'Email domain',
195
+ timestamp,
196
+ });
197
+ }
198
+ // Check public breach databases (haveibeenpwned style - metadata only)
199
+ try {
200
+ const breachInfo = await this.checkBreachDatabases(email);
201
+ if (breachInfo.breached) {
202
+ findings.push({
203
+ source: 'Public Breach Database',
204
+ category: 'security',
205
+ data: breachInfo,
206
+ reliability: 'confirmed',
207
+ timestamp,
208
+ });
209
+ }
210
+ }
211
+ catch (e) {
212
+ // Breach check failed
213
+ }
214
+ return {
215
+ query: email,
216
+ queryType: 'email',
217
+ timestamp,
218
+ sources: ['Domain Analysis', 'Public Breach Databases'],
219
+ findings,
220
+ relatedIndicators: indicators,
221
+ riskAssessment: this.assessRisk(findings, indicators),
222
+ };
223
+ }
224
+ /**
225
+ * Search for organization information using public sources
226
+ */
227
+ async investigateOrganization(name) {
228
+ const findings = [];
229
+ const indicators = [];
230
+ const timestamp = new Date().toISOString();
231
+ // Corporate registries (public records)
232
+ try {
233
+ const corpInfo = await this.searchCorporateRegistries(name);
234
+ findings.push({
235
+ source: 'Corporate Registry',
236
+ category: 'registration',
237
+ data: corpInfo,
238
+ reliability: 'confirmed',
239
+ timestamp,
240
+ });
241
+ }
242
+ catch (e) {
243
+ // Corporate registry search failed
244
+ }
245
+ // SEC filings (for US companies - public)
246
+ try {
247
+ const secInfo = await this.searchSECFilings(name);
248
+ if (secInfo.found) {
249
+ findings.push({
250
+ source: 'SEC EDGAR',
251
+ category: 'regulatory',
252
+ data: secInfo,
253
+ reliability: 'confirmed',
254
+ timestamp,
255
+ });
256
+ }
257
+ }
258
+ catch (e) {
259
+ // SEC search failed
260
+ }
261
+ // Court records (public)
262
+ try {
263
+ const courtInfo = await this.searchCourtRecords(name);
264
+ if (courtInfo.cases.length > 0) {
265
+ findings.push({
266
+ source: 'Court Records',
267
+ category: 'legal',
268
+ data: courtInfo,
269
+ reliability: 'confirmed',
270
+ timestamp,
271
+ });
272
+ }
273
+ }
274
+ catch (e) {
275
+ // Court search failed
276
+ }
277
+ return {
278
+ query: name,
279
+ queryType: 'organization',
280
+ timestamp,
281
+ sources: ['Corporate Registry', 'SEC EDGAR', 'Court Records'],
282
+ findings,
283
+ relatedIndicators: indicators,
284
+ riskAssessment: this.assessRisk(findings, indicators),
285
+ };
286
+ }
287
+ // DNS query helper
288
+ async queryDNS(domain) {
289
+ const result = {};
290
+ try {
291
+ const output = execSync(`dig +short ${domain} A`, { encoding: 'utf-8', timeout: 10000 });
292
+ result['a'] = output.trim().split('\n').filter(Boolean);
293
+ }
294
+ catch (e) { /* ignore */ }
295
+ try {
296
+ const output = execSync(`dig +short ${domain} MX`, { encoding: 'utf-8', timeout: 10000 });
297
+ result['mx'] = output.trim().split('\n').filter(Boolean);
298
+ }
299
+ catch (e) { /* ignore */ }
300
+ try {
301
+ const output = execSync(`dig +short ${domain} NS`, { encoding: 'utf-8', timeout: 10000 });
302
+ result['ns'] = output.trim().split('\n').filter(Boolean);
303
+ }
304
+ catch (e) { /* ignore */ }
305
+ try {
306
+ const output = execSync(`dig +short ${domain} TXT`, { encoding: 'utf-8', timeout: 10000 });
307
+ result['txt'] = output.trim().split('\n').filter(Boolean);
308
+ }
309
+ catch (e) { /* ignore */ }
310
+ return result;
311
+ }
312
+ // WHOIS query helper
313
+ async queryWHOIS(domain) {
314
+ try {
315
+ const output = execSync(`whois ${domain}`, { encoding: 'utf-8', timeout: 30000 });
316
+ return this.parseWHOIS(output);
317
+ }
318
+ catch (e) {
319
+ return {};
320
+ }
321
+ }
322
+ parseWHOIS(raw) {
323
+ const result = {};
324
+ const lines = raw.split('\n');
325
+ for (const line of lines) {
326
+ const match = line.match(/^([^:]+):\s*(.+)$/);
327
+ if (match) {
328
+ const key = match[1].trim().toLowerCase().replace(/\s+/g, '_');
329
+ result[key] = match[2].trim();
330
+ }
331
+ }
332
+ return result;
333
+ }
334
+ // Reverse DNS helper
335
+ async queryReverseDNS(ip) {
336
+ try {
337
+ const output = execSync(`dig +short -x ${ip}`, { encoding: 'utf-8', timeout: 10000 });
338
+ return output.trim().split('\n').filter(Boolean);
339
+ }
340
+ catch (e) {
341
+ return [];
342
+ }
343
+ }
344
+ // Certificate Transparency helper (using crt.sh)
345
+ async queryCertificateTransparency(domain) {
346
+ // Would query crt.sh or similar CT log aggregator
347
+ return { note: 'CT log query would be performed here' };
348
+ }
349
+ // GeoIP helper
350
+ async queryGeoIP(ip) {
351
+ // Would use a public GeoIP database
352
+ return { note: 'GeoIP lookup would be performed here' };
353
+ }
354
+ // ASN helper
355
+ async queryASN(ip) {
356
+ try {
357
+ const output = execSync(`whois -h whois.radb.net ${ip}`, { encoding: 'utf-8', timeout: 10000 });
358
+ return { raw: output.slice(0, 1000) };
359
+ }
360
+ catch (e) {
361
+ return {};
362
+ }
363
+ }
364
+ // Public threat feeds
365
+ async checkThreatFeeds(indicator, type) {
366
+ const findings = [];
367
+ const timestamp = new Date().toISOString();
368
+ // Would check various public threat intelligence feeds:
369
+ // - AbuseIPDB (public API)
370
+ // - VirusTotal (public API with rate limits)
371
+ // - URLhaus
372
+ // - PhishTank
373
+ // - Spamhaus (DNS-based)
374
+ return findings;
375
+ }
376
+ // Breach database check
377
+ async checkBreachDatabases(email) {
378
+ // Would check haveibeenpwned or similar (respecting API terms)
379
+ return { breached: false };
380
+ }
381
+ // Corporate registry search
382
+ async searchCorporateRegistries(name) {
383
+ // Would search OpenCorporates or state registries
384
+ return { note: 'Corporate registry search would be performed here' };
385
+ }
386
+ // SEC filings search
387
+ async searchSECFilings(name) {
388
+ // Would search SEC EDGAR
389
+ return { found: false };
390
+ }
391
+ // Court records search
392
+ async searchCourtRecords(name) {
393
+ // Would search PACER or state court systems
394
+ return { cases: [] };
395
+ }
396
+ // Risk assessment
397
+ assessRisk(findings, indicators) {
398
+ const factors = [];
399
+ let totalScore = 0;
400
+ let totalWeight = 0;
401
+ // Check for threat feed hits
402
+ const threatHits = findings.filter(f => f.source.includes('Threat'));
403
+ if (threatHits.length > 0) {
404
+ factors.push({
405
+ name: 'Threat Intelligence Hits',
406
+ score: 80,
407
+ weight: 3,
408
+ description: `Found in ${threatHits.length} threat intelligence source(s)`,
409
+ });
410
+ totalScore += 80 * 3;
411
+ totalWeight += 3;
412
+ }
413
+ // Check for breach exposure
414
+ const breachHits = findings.filter(f => f.category === 'security');
415
+ if (breachHits.length > 0) {
416
+ factors.push({
417
+ name: 'Breach Exposure',
418
+ score: 60,
419
+ weight: 2,
420
+ description: 'Found in public breach databases',
421
+ });
422
+ totalScore += 60 * 2;
423
+ totalWeight += 2;
424
+ }
425
+ // Default baseline
426
+ if (factors.length === 0) {
427
+ factors.push({
428
+ name: 'Baseline',
429
+ score: 20,
430
+ weight: 1,
431
+ description: 'No significant risk indicators found',
432
+ });
433
+ totalScore += 20;
434
+ totalWeight += 1;
435
+ }
436
+ const overallScore = totalWeight > 0 ? Math.round(totalScore / totalWeight) : 0;
437
+ let recommendation = 'No immediate action required';
438
+ if (overallScore >= 70) {
439
+ recommendation = 'High risk - immediate investigation recommended';
440
+ }
441
+ else if (overallScore >= 50) {
442
+ recommendation = 'Moderate risk - monitor and investigate further';
443
+ }
444
+ else if (overallScore >= 30) {
445
+ recommendation = 'Low risk - standard monitoring recommended';
446
+ }
447
+ return { overallScore, factors, recommendation };
448
+ }
449
+ }
450
+ /**
451
+ * Evidence collection and chain of custody management
452
+ * Maintains forensic integrity for legal proceedings
453
+ */
454
+ export class EvidenceManager {
455
+ evidenceDir;
456
+ casesDir;
457
+ constructor(baseDir = '.erosolar-evidence') {
458
+ this.evidenceDir = path.join(baseDir, 'evidence');
459
+ this.casesDir = path.join(baseDir, 'cases');
460
+ this.ensureDirectories();
461
+ }
462
+ ensureDirectories() {
463
+ fs.mkdirSync(this.evidenceDir, { recursive: true });
464
+ fs.mkdirSync(this.casesDir, { recursive: true });
465
+ }
466
+ /**
467
+ * Collect evidence from a file with full chain of custody
468
+ */
469
+ async collectFileEvidence(filePath, description, collectedBy, caseId, tags = []) {
470
+ const id = this.generateEvidenceId();
471
+ const timestamp = new Date().toISOString();
472
+ // Read and hash the file
473
+ const content = fs.readFileSync(filePath);
474
+ const hashes = this.computeHashes(content);
475
+ const stat = fs.statSync(filePath);
476
+ // Store evidence copy
477
+ const storedPath = path.join(this.evidenceDir, id, path.basename(filePath));
478
+ fs.mkdirSync(path.dirname(storedPath), { recursive: true });
479
+ fs.writeFileSync(storedPath, content);
480
+ const evidence = {
481
+ id,
482
+ type: 'file',
483
+ description,
484
+ collectedAt: timestamp,
485
+ collectedBy,
486
+ source: filePath,
487
+ hash: hashes,
488
+ size: stat.size,
489
+ originalPath: filePath,
490
+ storedPath,
491
+ metadata: {
492
+ mtime: stat.mtime.toISOString(),
493
+ ctime: stat.ctime.toISOString(),
494
+ mode: stat.mode,
495
+ },
496
+ chainOfCustody: [{
497
+ timestamp,
498
+ action: 'collected',
499
+ actor: collectedBy,
500
+ description: `Evidence collected from ${filePath}`,
501
+ newHash: hashes.sha256,
502
+ }],
503
+ tags,
504
+ caseId,
505
+ };
506
+ // Save evidence metadata
507
+ this.saveEvidenceMetadata(evidence);
508
+ // Add to case if specified
509
+ if (caseId) {
510
+ await this.addEvidenceToCase(caseId, id);
511
+ }
512
+ return evidence;
513
+ }
514
+ /**
515
+ * Collect screenshot evidence
516
+ */
517
+ async collectScreenshotEvidence(screenshotPath, description, collectedBy, caseId, tags = []) {
518
+ const evidence = await this.collectFileEvidence(screenshotPath, description, collectedBy, caseId, tags);
519
+ evidence.type = 'screenshot';
520
+ this.saveEvidenceMetadata(evidence);
521
+ return evidence;
522
+ }
523
+ /**
524
+ * Collect log evidence (preserves line-by-line integrity)
525
+ */
526
+ async collectLogEvidence(logContent, source, description, collectedBy, caseId, tags = []) {
527
+ const id = this.generateEvidenceId();
528
+ const timestamp = new Date().toISOString();
529
+ const content = Buffer.from(logContent, 'utf-8');
530
+ const hashes = this.computeHashes(content);
531
+ const storedPath = path.join(this.evidenceDir, id, 'log.txt');
532
+ fs.mkdirSync(path.dirname(storedPath), { recursive: true });
533
+ fs.writeFileSync(storedPath, content);
534
+ // Also compute per-line hashes for integrity verification
535
+ const lines = logContent.split('\n');
536
+ const lineHashes = lines.map((line, i) => ({
537
+ line: i + 1,
538
+ hash: crypto.createHash('sha256').update(line).digest('hex'),
539
+ }));
540
+ const evidence = {
541
+ id,
542
+ type: 'log',
543
+ description,
544
+ collectedAt: timestamp,
545
+ collectedBy,
546
+ source,
547
+ hash: hashes,
548
+ size: content.length,
549
+ storedPath,
550
+ metadata: {
551
+ lineCount: lines.length,
552
+ lineHashes,
553
+ },
554
+ chainOfCustody: [{
555
+ timestamp,
556
+ action: 'collected',
557
+ actor: collectedBy,
558
+ description: `Log evidence collected from ${source}`,
559
+ newHash: hashes.sha256,
560
+ }],
561
+ tags,
562
+ caseId,
563
+ };
564
+ this.saveEvidenceMetadata(evidence);
565
+ if (caseId) {
566
+ await this.addEvidenceToCase(caseId, id);
567
+ }
568
+ return evidence;
569
+ }
570
+ /**
571
+ * Verify evidence integrity
572
+ */
573
+ verifyEvidence(evidenceId) {
574
+ const metadata = this.loadEvidenceMetadata(evidenceId);
575
+ if (!metadata) {
576
+ return { valid: false, details: 'Evidence not found' };
577
+ }
578
+ if (!fs.existsSync(metadata.storedPath)) {
579
+ return { valid: false, details: 'Evidence file missing' };
580
+ }
581
+ const content = fs.readFileSync(metadata.storedPath);
582
+ const currentHashes = this.computeHashes(content);
583
+ if (currentHashes.sha256 !== metadata.hash.sha256) {
584
+ return {
585
+ valid: false,
586
+ details: `Hash mismatch: expected ${metadata.hash.sha256}, got ${currentHashes.sha256}`,
587
+ };
588
+ }
589
+ return { valid: true, details: 'Evidence integrity verified' };
590
+ }
591
+ /**
592
+ * Add custody event to evidence
593
+ */
594
+ addCustodyEvent(evidenceId, action, actor, description) {
595
+ const metadata = this.loadEvidenceMetadata(evidenceId);
596
+ if (!metadata) {
597
+ throw new Error(`Evidence ${evidenceId} not found`);
598
+ }
599
+ const content = fs.readFileSync(metadata.storedPath);
600
+ const currentHash = crypto.createHash('sha256').update(content).digest('hex');
601
+ const event = {
602
+ timestamp: new Date().toISOString(),
603
+ action,
604
+ actor,
605
+ description,
606
+ previousHash: metadata.hash.sha256,
607
+ newHash: currentHash,
608
+ };
609
+ metadata.chainOfCustody.push(event);
610
+ this.saveEvidenceMetadata(metadata);
611
+ }
612
+ /**
613
+ * Create a new case
614
+ */
615
+ createCase(name, description, priority = 'medium', assignee, tags = []) {
616
+ const id = this.generateCaseId();
617
+ const timestamp = new Date().toISOString();
618
+ const caseData = {
619
+ id,
620
+ name,
621
+ description,
622
+ createdAt: timestamp,
623
+ updatedAt: timestamp,
624
+ status: 'open',
625
+ priority,
626
+ assignee,
627
+ evidenceIds: [],
628
+ timeline: [{
629
+ timestamp,
630
+ eventType: 'case_created',
631
+ description: `Case "${name}" created`,
632
+ evidenceIds: [],
633
+ actors: assignee ? [assignee] : [],
634
+ source: 'system',
635
+ }],
636
+ notes: [],
637
+ tags,
638
+ };
639
+ this.saveCaseData(caseData);
640
+ return caseData;
641
+ }
642
+ /**
643
+ * Add evidence to case
644
+ */
645
+ async addEvidenceToCase(caseId, evidenceId) {
646
+ const caseData = this.loadCaseData(caseId);
647
+ if (!caseData) {
648
+ throw new Error(`Case ${caseId} not found`);
649
+ }
650
+ if (!caseData.evidenceIds.includes(evidenceId)) {
651
+ caseData.evidenceIds.push(evidenceId);
652
+ caseData.updatedAt = new Date().toISOString();
653
+ caseData.timeline.push({
654
+ timestamp: new Date().toISOString(),
655
+ eventType: 'evidence_added',
656
+ description: `Evidence ${evidenceId} added to case`,
657
+ evidenceIds: [evidenceId],
658
+ actors: [],
659
+ source: 'system',
660
+ });
661
+ this.saveCaseData(caseData);
662
+ }
663
+ }
664
+ /**
665
+ * Add timeline event to case
666
+ */
667
+ addTimelineEvent(caseId, eventType, description, evidenceIds = [], actors = [], eventTimestamp) {
668
+ const caseData = this.loadCaseData(caseId);
669
+ if (!caseData) {
670
+ throw new Error(`Case ${caseId} not found`);
671
+ }
672
+ caseData.timeline.push({
673
+ timestamp: eventTimestamp || new Date().toISOString(),
674
+ eventType,
675
+ description,
676
+ evidenceIds,
677
+ actors,
678
+ source: 'manual',
679
+ });
680
+ caseData.updatedAt = new Date().toISOString();
681
+ this.saveCaseData(caseData);
682
+ }
683
+ /**
684
+ * Export case for legal proceedings
685
+ */
686
+ exportCase(caseId, outputDir) {
687
+ const caseData = this.loadCaseData(caseId);
688
+ if (!caseData) {
689
+ throw new Error(`Case ${caseId} not found`);
690
+ }
691
+ const exportDir = path.join(outputDir, `case_${caseId}_export`);
692
+ fs.mkdirSync(exportDir, { recursive: true });
693
+ // Export case metadata
694
+ fs.writeFileSync(path.join(exportDir, 'case_metadata.json'), JSON.stringify(caseData, null, 2));
695
+ // Export timeline
696
+ fs.writeFileSync(path.join(exportDir, 'timeline.json'), JSON.stringify(caseData.timeline, null, 2));
697
+ // Export evidence
698
+ const evidenceDir = path.join(exportDir, 'evidence');
699
+ fs.mkdirSync(evidenceDir, { recursive: true });
700
+ for (const evidenceId of caseData.evidenceIds) {
701
+ const evidence = this.loadEvidenceMetadata(evidenceId);
702
+ if (evidence && fs.existsSync(evidence.storedPath)) {
703
+ const destDir = path.join(evidenceDir, evidenceId);
704
+ fs.mkdirSync(destDir, { recursive: true });
705
+ // Copy evidence file
706
+ fs.copyFileSync(evidence.storedPath, path.join(destDir, path.basename(evidence.storedPath)));
707
+ // Write evidence metadata
708
+ fs.writeFileSync(path.join(destDir, 'metadata.json'), JSON.stringify(evidence, null, 2));
709
+ // Write chain of custody
710
+ fs.writeFileSync(path.join(destDir, 'chain_of_custody.json'), JSON.stringify(evidence.chainOfCustody, null, 2));
711
+ }
712
+ }
713
+ // Generate integrity manifest
714
+ const manifest = this.generateExportManifest(exportDir);
715
+ fs.writeFileSync(path.join(exportDir, 'integrity_manifest.json'), JSON.stringify(manifest, null, 2));
716
+ return exportDir;
717
+ }
718
+ computeHashes(content) {
719
+ return {
720
+ sha256: crypto.createHash('sha256').update(content).digest('hex'),
721
+ sha1: crypto.createHash('sha1').update(content).digest('hex'),
722
+ md5: crypto.createHash('md5').update(content).digest('hex'),
723
+ };
724
+ }
725
+ generateEvidenceId() {
726
+ return `EVD-${Date.now()}-${crypto.randomBytes(4).toString('hex').toUpperCase()}`;
727
+ }
728
+ generateCaseId() {
729
+ return `CASE-${Date.now()}-${crypto.randomBytes(4).toString('hex').toUpperCase()}`;
730
+ }
731
+ saveEvidenceMetadata(evidence) {
732
+ const metaPath = path.join(this.evidenceDir, evidence.id, 'metadata.json');
733
+ fs.mkdirSync(path.dirname(metaPath), { recursive: true });
734
+ fs.writeFileSync(metaPath, JSON.stringify(evidence, null, 2));
735
+ }
736
+ loadEvidenceMetadata(evidenceId) {
737
+ const metaPath = path.join(this.evidenceDir, evidenceId, 'metadata.json');
738
+ if (!fs.existsSync(metaPath)) {
739
+ return null;
740
+ }
741
+ return JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
742
+ }
743
+ saveCaseData(caseData) {
744
+ const casePath = path.join(this.casesDir, `${caseData.id}.json`);
745
+ fs.writeFileSync(casePath, JSON.stringify(caseData, null, 2));
746
+ }
747
+ loadCaseData(caseId) {
748
+ const casePath = path.join(this.casesDir, `${caseId}.json`);
749
+ if (!fs.existsSync(casePath)) {
750
+ return null;
751
+ }
752
+ return JSON.parse(fs.readFileSync(casePath, 'utf-8'));
753
+ }
754
+ generateExportManifest(exportDir) {
755
+ const files = [];
756
+ const walkDir = (dir) => {
757
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
758
+ for (const entry of entries) {
759
+ const fullPath = path.join(dir, entry.name);
760
+ if (entry.isDirectory()) {
761
+ walkDir(fullPath);
762
+ }
763
+ else if (entry.name !== 'integrity_manifest.json') {
764
+ const content = fs.readFileSync(fullPath);
765
+ files.push({
766
+ path: path.relative(exportDir, fullPath),
767
+ sha256: crypto.createHash('sha256').update(content).digest('hex'),
768
+ size: content.length,
769
+ });
770
+ }
771
+ }
772
+ };
773
+ walkDir(exportDir);
774
+ return {
775
+ generatedAt: new Date().toISOString(),
776
+ exportDir,
777
+ fileCount: files.length,
778
+ files,
779
+ manifestHash: crypto.createHash('sha256')
780
+ .update(JSON.stringify(files))
781
+ .digest('hex'),
782
+ };
783
+ }
784
+ }
785
+ /**
786
+ * Generate transparency reports for public disclosure
787
+ * Supports responsible disclosure practices
788
+ */
789
+ export class TransparencyReporter {
790
+ reportsDir;
791
+ constructor(baseDir = '.erosolar-reports') {
792
+ this.reportsDir = baseDir;
793
+ fs.mkdirSync(this.reportsDir, { recursive: true });
794
+ }
795
+ /**
796
+ * Create a new transparency report
797
+ */
798
+ createReport(type, title, summary, severity, authors) {
799
+ const id = `RPT-${Date.now()}-${crypto.randomBytes(4).toString('hex').toUpperCase()}`;
800
+ const report = {
801
+ id,
802
+ type,
803
+ title,
804
+ summary,
805
+ severity,
806
+ status: 'draft',
807
+ createdAt: new Date().toISOString(),
808
+ authors,
809
+ sections: [],
810
+ indicators: [],
811
+ recommendations: [],
812
+ references: [],
813
+ legalDisclaimer: this.getDefaultDisclaimer(),
814
+ redactions: [],
815
+ };
816
+ this.saveReport(report);
817
+ return report;
818
+ }
819
+ /**
820
+ * Add section to report
821
+ */
822
+ addSection(reportId, title, content, evidenceRefs = []) {
823
+ const report = this.loadReport(reportId);
824
+ if (!report) {
825
+ throw new Error(`Report ${reportId} not found`);
826
+ }
827
+ report.sections.push({
828
+ title,
829
+ content,
830
+ evidenceRefs,
831
+ order: report.sections.length,
832
+ });
833
+ this.saveReport(report);
834
+ }
835
+ /**
836
+ * Add indicators of compromise
837
+ */
838
+ addIndicators(reportId, indicators) {
839
+ const report = this.loadReport(reportId);
840
+ if (!report) {
841
+ throw new Error(`Report ${reportId} not found`);
842
+ }
843
+ report.indicators.push(...indicators);
844
+ this.saveReport(report);
845
+ }
846
+ /**
847
+ * Add recommendations
848
+ */
849
+ addRecommendations(reportId, recommendations) {
850
+ const report = this.loadReport(reportId);
851
+ if (!report) {
852
+ throw new Error(`Report ${reportId} not found`);
853
+ }
854
+ report.recommendations.push(...recommendations);
855
+ this.saveReport(report);
856
+ }
857
+ /**
858
+ * Publish report (makes it final)
859
+ */
860
+ publishReport(reportId) {
861
+ const report = this.loadReport(reportId);
862
+ if (!report) {
863
+ throw new Error(`Report ${reportId} not found`);
864
+ }
865
+ report.status = 'published';
866
+ report.publishedAt = new Date().toISOString();
867
+ this.saveReport(report);
868
+ return report;
869
+ }
870
+ /**
871
+ * Export report in various formats
872
+ */
873
+ exportReport(reportId, format) {
874
+ const report = this.loadReport(reportId);
875
+ if (!report) {
876
+ throw new Error(`Report ${reportId} not found`);
877
+ }
878
+ switch (format) {
879
+ case 'json':
880
+ return JSON.stringify(report, null, 2);
881
+ case 'markdown':
882
+ return this.toMarkdown(report);
883
+ case 'html':
884
+ return this.toHTML(report);
885
+ default:
886
+ return JSON.stringify(report, null, 2);
887
+ }
888
+ }
889
+ /**
890
+ * Generate STIX 2.1 bundle for threat intelligence sharing
891
+ */
892
+ toSTIX(reportId) {
893
+ const report = this.loadReport(reportId);
894
+ if (!report) {
895
+ throw new Error(`Report ${reportId} not found`);
896
+ }
897
+ const objects = [];
898
+ // Create report object
899
+ objects.push({
900
+ type: 'report',
901
+ spec_version: '2.1',
902
+ id: `report--${report.id}`,
903
+ created: report.createdAt,
904
+ modified: report.publishedAt || report.createdAt,
905
+ name: report.title,
906
+ description: report.summary,
907
+ report_types: [this.mapTypeToSTIX(report.type)],
908
+ published: report.publishedAt || report.createdAt,
909
+ object_refs: report.indicators.map((_, i) => `indicator--${report.id}-${i}`),
910
+ });
911
+ // Create indicator objects
912
+ report.indicators.forEach((indicator, i) => {
913
+ objects.push({
914
+ type: 'indicator',
915
+ spec_version: '2.1',
916
+ id: `indicator--${report.id}-${i}`,
917
+ created: indicator.timestamp,
918
+ modified: indicator.timestamp,
919
+ name: `${indicator.type}: ${indicator.value}`,
920
+ description: indicator.context || '',
921
+ pattern: this.toSTIXPattern(indicator),
922
+ pattern_type: 'stix',
923
+ valid_from: indicator.timestamp,
924
+ confidence: Math.round(indicator.confidence * 100),
925
+ });
926
+ });
927
+ return {
928
+ type: 'bundle',
929
+ id: `bundle--${report.id}`,
930
+ objects,
931
+ };
932
+ }
933
+ toMarkdown(report) {
934
+ const lines = [];
935
+ lines.push(`# ${report.title}`);
936
+ lines.push('');
937
+ lines.push(`**Report ID:** ${report.id}`);
938
+ lines.push(`**Type:** ${report.type}`);
939
+ lines.push(`**Severity:** ${report.severity}`);
940
+ lines.push(`**Status:** ${report.status}`);
941
+ lines.push(`**Created:** ${report.createdAt}`);
942
+ if (report.publishedAt) {
943
+ lines.push(`**Published:** ${report.publishedAt}`);
944
+ }
945
+ lines.push(`**Authors:** ${report.authors.join(', ')}`);
946
+ lines.push('');
947
+ lines.push('## Summary');
948
+ lines.push('');
949
+ lines.push(report.summary);
950
+ lines.push('');
951
+ for (const section of report.sections.sort((a, b) => a.order - b.order)) {
952
+ lines.push(`## ${section.title}`);
953
+ lines.push('');
954
+ lines.push(section.content);
955
+ lines.push('');
956
+ }
957
+ if (report.indicators.length > 0) {
958
+ lines.push('## Indicators of Compromise');
959
+ lines.push('');
960
+ lines.push('| Type | Value | Confidence | Source |');
961
+ lines.push('|------|-------|------------|--------|');
962
+ for (const ioc of report.indicators) {
963
+ lines.push(`| ${ioc.type} | \`${ioc.value}\` | ${Math.round(ioc.confidence * 100)}% | ${ioc.source} |`);
964
+ }
965
+ lines.push('');
966
+ }
967
+ if (report.recommendations.length > 0) {
968
+ lines.push('## Recommendations');
969
+ lines.push('');
970
+ for (const rec of report.recommendations) {
971
+ lines.push(`- ${rec}`);
972
+ }
973
+ lines.push('');
974
+ }
975
+ if (report.references.length > 0) {
976
+ lines.push('## References');
977
+ lines.push('');
978
+ for (const ref of report.references) {
979
+ lines.push(`- ${ref}`);
980
+ }
981
+ lines.push('');
982
+ }
983
+ lines.push('---');
984
+ lines.push('');
985
+ lines.push('*Disclaimer:*');
986
+ lines.push('');
987
+ lines.push(report.legalDisclaimer);
988
+ return lines.join('\n');
989
+ }
990
+ toHTML(report) {
991
+ // Convert markdown to basic HTML
992
+ const md = this.toMarkdown(report);
993
+ return `<!DOCTYPE html>
994
+ <html>
995
+ <head>
996
+ <meta charset="UTF-8">
997
+ <title>${report.title}</title>
998
+ <style>
999
+ body { font-family: system-ui, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
1000
+ pre, code { background: #f4f4f4; padding: 2px 6px; border-radius: 3px; }
1001
+ table { border-collapse: collapse; width: 100%; }
1002
+ th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
1003
+ th { background: #f4f4f4; }
1004
+ </style>
1005
+ </head>
1006
+ <body>
1007
+ <pre>${md}</pre>
1008
+ </body>
1009
+ </html>`;
1010
+ }
1011
+ mapTypeToSTIX(type) {
1012
+ const mapping = {
1013
+ threat_actor: 'threat-actor',
1014
+ vulnerability: 'vulnerability',
1015
+ incident: 'incident',
1016
+ fraud: 'campaign',
1017
+ abuse: 'campaign',
1018
+ misconduct: 'campaign',
1019
+ };
1020
+ return mapping[type] || 'campaign';
1021
+ }
1022
+ toSTIXPattern(indicator) {
1023
+ const typeMapping = {
1024
+ ip: 'ipv4-addr:value',
1025
+ domain: 'domain-name:value',
1026
+ url: 'url:value',
1027
+ hash: 'file:hashes.SHA-256',
1028
+ email: 'email-addr:value',
1029
+ };
1030
+ const stixType = typeMapping[indicator.type] || 'x-custom:value';
1031
+ return `[${stixType} = '${indicator.value}']`;
1032
+ }
1033
+ getDefaultDisclaimer() {
1034
+ return `This report is provided for informational and educational purposes only.
1035
+ The information contained herein is based on publicly available data and authorized research.
1036
+ The authors make no warranties about the completeness, reliability, or accuracy of this information.
1037
+ Any action taken based on this report is at your own risk.
1038
+ This report should not be construed as legal advice.`;
1039
+ }
1040
+ saveReport(report) {
1041
+ const reportPath = path.join(this.reportsDir, `${report.id}.json`);
1042
+ fs.writeFileSync(reportPath, JSON.stringify(report, null, 2));
1043
+ }
1044
+ loadReport(reportId) {
1045
+ const reportPath = path.join(this.reportsDir, `${reportId}.json`);
1046
+ if (!fs.existsSync(reportPath)) {
1047
+ return null;
1048
+ }
1049
+ return JSON.parse(fs.readFileSync(reportPath, 'utf-8'));
1050
+ }
1051
+ }
1052
+ /**
1053
+ * Authorized penetration testing support
1054
+ * Requires explicit scope and authorization
1055
+ */
1056
+ export class AuthorizedPentestSupport {
1057
+ scopesDir;
1058
+ resultsDir;
1059
+ constructor(baseDir = '.erosolar-pentest') {
1060
+ this.scopesDir = path.join(baseDir, 'scopes');
1061
+ this.resultsDir = path.join(baseDir, 'results');
1062
+ fs.mkdirSync(this.scopesDir, { recursive: true });
1063
+ fs.mkdirSync(this.resultsDir, { recursive: true });
1064
+ }
1065
+ /**
1066
+ * Create a new pentest scope (authorization document)
1067
+ */
1068
+ createScope(name, authorizedBy, targets, expirationDays = 30, rules = []) {
1069
+ const id = `SCOPE-${Date.now()}-${crypto.randomBytes(4).toString('hex').toUpperCase()}`;
1070
+ const now = new Date();
1071
+ const expiration = new Date(now.getTime() + expirationDays * 24 * 60 * 60 * 1000);
1072
+ const scope = {
1073
+ id,
1074
+ name,
1075
+ authorizedBy,
1076
+ authorizationDate: now.toISOString(),
1077
+ expirationDate: expiration.toISOString(),
1078
+ targets,
1079
+ excludedTargets: [],
1080
+ allowedTests: [
1081
+ 'port_scan',
1082
+ 'service_detection',
1083
+ 'vulnerability_scan',
1084
+ 'ssl_analysis',
1085
+ 'header_analysis',
1086
+ 'dns_enumeration',
1087
+ ],
1088
+ disallowedTests: [
1089
+ 'dos',
1090
+ 'ddos',
1091
+ 'data_exfiltration',
1092
+ 'destructive_tests',
1093
+ ],
1094
+ rules: [
1095
+ 'Stop immediately if unauthorized access is detected',
1096
+ 'Document all findings with timestamps',
1097
+ 'Report critical findings within 24 hours',
1098
+ 'Do not access or modify production data',
1099
+ ...rules,
1100
+ ],
1101
+ emergencyContact: '',
1102
+ };
1103
+ this.saveScope(scope);
1104
+ return scope;
1105
+ }
1106
+ /**
1107
+ * Verify target is in scope
1108
+ */
1109
+ isInScope(scopeId, target) {
1110
+ const scope = this.loadScope(scopeId);
1111
+ if (!scope) {
1112
+ return { inScope: false, reason: 'Scope not found' };
1113
+ }
1114
+ // Check expiration
1115
+ if (new Date() > new Date(scope.expirationDate)) {
1116
+ return { inScope: false, reason: 'Scope has expired' };
1117
+ }
1118
+ // Check if explicitly excluded
1119
+ for (const excluded of scope.excludedTargets) {
1120
+ if (target.includes(excluded) || excluded.includes(target)) {
1121
+ return { inScope: false, reason: `Target is explicitly excluded: ${excluded}` };
1122
+ }
1123
+ }
1124
+ // Check if in allowed targets
1125
+ for (const allowed of scope.targets) {
1126
+ if (this.matchesTarget(target, allowed)) {
1127
+ return { inScope: true, reason: `Matches authorized target: ${allowed.value}` };
1128
+ }
1129
+ }
1130
+ return { inScope: false, reason: 'Target not in authorized scope' };
1131
+ }
1132
+ /**
1133
+ * Check if test type is allowed
1134
+ */
1135
+ isTestAllowed(scopeId, testType) {
1136
+ const scope = this.loadScope(scopeId);
1137
+ if (!scope) {
1138
+ return { allowed: false, reason: 'Scope not found' };
1139
+ }
1140
+ if (scope.disallowedTests.includes(testType)) {
1141
+ return { allowed: false, reason: `Test type "${testType}" is explicitly disallowed` };
1142
+ }
1143
+ if (scope.allowedTests.length > 0 && !scope.allowedTests.includes(testType)) {
1144
+ return { allowed: false, reason: `Test type "${testType}" is not in allowed list` };
1145
+ }
1146
+ return { allowed: true, reason: 'Test type is authorized' };
1147
+ }
1148
+ /**
1149
+ * Log test result
1150
+ */
1151
+ logTestResult(scopeId, testType, target, status, findings = [], rawOutput) {
1152
+ const id = `TEST-${Date.now()}-${crypto.randomBytes(4).toString('hex').toUpperCase()}`;
1153
+ const result = {
1154
+ id,
1155
+ scopeId,
1156
+ testType,
1157
+ target,
1158
+ timestamp: new Date().toISOString(),
1159
+ status,
1160
+ findings,
1161
+ rawOutput,
1162
+ };
1163
+ const resultPath = path.join(this.resultsDir, scopeId, `${id}.json`);
1164
+ fs.mkdirSync(path.dirname(resultPath), { recursive: true });
1165
+ fs.writeFileSync(resultPath, JSON.stringify(result, null, 2));
1166
+ return result;
1167
+ }
1168
+ /**
1169
+ * Generate pentest report
1170
+ */
1171
+ generateReport(scopeId) {
1172
+ const scope = this.loadScope(scopeId);
1173
+ if (!scope) {
1174
+ throw new Error(`Scope ${scopeId} not found`);
1175
+ }
1176
+ const resultsDir = path.join(this.resultsDir, scopeId);
1177
+ const results = [];
1178
+ if (fs.existsSync(resultsDir)) {
1179
+ const files = fs.readdirSync(resultsDir);
1180
+ for (const file of files) {
1181
+ if (file.endsWith('.json')) {
1182
+ const content = fs.readFileSync(path.join(resultsDir, file), 'utf-8');
1183
+ results.push(JSON.parse(content));
1184
+ }
1185
+ }
1186
+ }
1187
+ // Sort results by timestamp
1188
+ results.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
1189
+ // Aggregate findings
1190
+ const allFindings = [];
1191
+ for (const result of results) {
1192
+ allFindings.push(...result.findings);
1193
+ }
1194
+ // Sort findings by severity
1195
+ const severityOrder = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
1196
+ allFindings.sort((a, b) => severityOrder[a.severity] - severityOrder[b.severity]);
1197
+ // Generate report
1198
+ const lines = [];
1199
+ lines.push(`# Penetration Test Report`);
1200
+ lines.push('');
1201
+ lines.push(`**Scope:** ${scope.name}`);
1202
+ lines.push(`**Scope ID:** ${scope.id}`);
1203
+ lines.push(`**Authorized By:** ${scope.authorizedBy}`);
1204
+ lines.push(`**Authorization Date:** ${scope.authorizationDate}`);
1205
+ lines.push(`**Expiration Date:** ${scope.expirationDate}`);
1206
+ lines.push('');
1207
+ lines.push('## Executive Summary');
1208
+ lines.push('');
1209
+ lines.push(`- **Total Tests Performed:** ${results.length}`);
1210
+ lines.push(`- **Total Findings:** ${allFindings.length}`);
1211
+ lines.push(`- **Critical:** ${allFindings.filter(f => f.severity === 'critical').length}`);
1212
+ lines.push(`- **High:** ${allFindings.filter(f => f.severity === 'high').length}`);
1213
+ lines.push(`- **Medium:** ${allFindings.filter(f => f.severity === 'medium').length}`);
1214
+ lines.push(`- **Low:** ${allFindings.filter(f => f.severity === 'low').length}`);
1215
+ lines.push(`- **Info:** ${allFindings.filter(f => f.severity === 'info').length}`);
1216
+ lines.push('');
1217
+ lines.push('## Scope');
1218
+ lines.push('');
1219
+ lines.push('### Authorized Targets');
1220
+ for (const target of scope.targets) {
1221
+ lines.push(`- ${target.type}: ${target.value}${target.description ? ` (${target.description})` : ''}`);
1222
+ }
1223
+ lines.push('');
1224
+ lines.push('### Rules of Engagement');
1225
+ for (const rule of scope.rules) {
1226
+ lines.push(`- ${rule}`);
1227
+ }
1228
+ lines.push('');
1229
+ lines.push('## Findings');
1230
+ lines.push('');
1231
+ for (const finding of allFindings) {
1232
+ lines.push(`### [${finding.severity.toUpperCase()}] ${finding.title}`);
1233
+ lines.push('');
1234
+ lines.push(`**ID:** ${finding.id}`);
1235
+ if (finding.cvss)
1236
+ lines.push(`**CVSS:** ${finding.cvss}`);
1237
+ if (finding.cwe)
1238
+ lines.push(`**CWE:** ${finding.cwe}`);
1239
+ lines.push('');
1240
+ lines.push('**Description:**');
1241
+ lines.push(finding.description);
1242
+ lines.push('');
1243
+ lines.push('**Evidence:**');
1244
+ lines.push('```');
1245
+ lines.push(finding.evidence);
1246
+ lines.push('```');
1247
+ lines.push('');
1248
+ lines.push('**Recommendation:**');
1249
+ lines.push(finding.recommendation);
1250
+ lines.push('');
1251
+ if (finding.references.length > 0) {
1252
+ lines.push('**References:**');
1253
+ for (const ref of finding.references) {
1254
+ lines.push(`- ${ref}`);
1255
+ }
1256
+ lines.push('');
1257
+ }
1258
+ }
1259
+ lines.push('## Test Log');
1260
+ lines.push('');
1261
+ lines.push('| Timestamp | Test Type | Target | Status |');
1262
+ lines.push('|-----------|-----------|--------|--------|');
1263
+ for (const result of results) {
1264
+ lines.push(`| ${result.timestamp} | ${result.testType} | ${result.target} | ${result.status} |`);
1265
+ }
1266
+ return lines.join('\n');
1267
+ }
1268
+ matchesTarget(target, scopeTarget) {
1269
+ switch (scopeTarget.type) {
1270
+ case 'ip':
1271
+ return target === scopeTarget.value;
1272
+ case 'ip_range':
1273
+ // Simple CIDR check would go here
1274
+ return target.startsWith(scopeTarget.value.split('/')[0]?.split('.').slice(0, 3).join('.') || '');
1275
+ case 'domain':
1276
+ return target === scopeTarget.value || target.endsWith(`.${scopeTarget.value}`);
1277
+ case 'url':
1278
+ return target.startsWith(scopeTarget.value);
1279
+ case 'application':
1280
+ return target.includes(scopeTarget.value);
1281
+ default:
1282
+ return false;
1283
+ }
1284
+ }
1285
+ saveScope(scope) {
1286
+ const scopePath = path.join(this.scopesDir, `${scope.id}.json`);
1287
+ fs.writeFileSync(scopePath, JSON.stringify(scope, null, 2));
1288
+ }
1289
+ loadScope(scopeId) {
1290
+ const scopePath = path.join(this.scopesDir, `${scopeId}.json`);
1291
+ if (!fs.existsSync(scopePath)) {
1292
+ return null;
1293
+ }
1294
+ return JSON.parse(fs.readFileSync(scopePath, 'utf-8'));
1295
+ }
1296
+ }
1297
+ // ============================================================================
1298
+ // EXPORTS
1299
+ // ============================================================================
1300
+ export const osint = new OSINTGatherer();
1301
+ export const evidence = new EvidenceManager();
1302
+ export const transparency = new TransparencyReporter();
1303
+ export const pentest = new AuthorizedPentestSupport();
1304
+ //# sourceMappingURL=defensiveSecurityToolkit.js.map