erosolar-cli 1.7.55 → 1.7.56

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 (273) hide show
  1. package/package.json +1 -1
  2. package/dist/active-stack-security.d.ts +0 -110
  3. package/dist/active-stack-security.js +0 -313
  4. package/dist/active-stack-security.js.map +0 -1
  5. package/dist/advanced-targeting.d.ts +0 -113
  6. package/dist/advanced-targeting.js +0 -252
  7. package/dist/advanced-targeting.js.map +0 -1
  8. package/dist/bin/adapters/node/index.js +0 -33
  9. package/dist/bin/adapters/types.js +0 -1
  10. package/dist/bin/alpha-zero/agentWrapper.js +0 -165
  11. package/dist/bin/alpha-zero/codeEvaluator.js +0 -272
  12. package/dist/bin/alpha-zero/competitiveRunner.js +0 -219
  13. package/dist/bin/alpha-zero/index.js +0 -98
  14. package/dist/bin/alpha-zero/introspection.js +0 -298
  15. package/dist/bin/alpha-zero/metricsTracker.js +0 -207
  16. package/dist/bin/alpha-zero/security/core.js +0 -269
  17. package/dist/bin/alpha-zero/security/google.js +0 -308
  18. package/dist/bin/alpha-zero/security/googleLoader.js +0 -40
  19. package/dist/bin/alpha-zero/security/index.js +0 -31
  20. package/dist/bin/alpha-zero/security/simulation.js +0 -274
  21. package/dist/bin/alpha-zero/selfModification.js +0 -231
  22. package/dist/bin/alpha-zero/types.js +0 -30
  23. package/dist/bin/bin/erosolar-optimized.js +0 -205
  24. package/dist/bin/capabilities/agentSpawningCapability.js +0 -116
  25. package/dist/bin/capabilities/bashCapability.js +0 -22
  26. package/dist/bin/capabilities/cloudCapability.js +0 -36
  27. package/dist/bin/capabilities/codeAnalysisCapability.js +0 -22
  28. package/dist/bin/capabilities/codeQualityCapability.js +0 -23
  29. package/dist/bin/capabilities/dependencySecurityCapability.js +0 -22
  30. package/dist/bin/capabilities/devCapability.js +0 -22
  31. package/dist/bin/capabilities/editCapability.js +0 -28
  32. package/dist/bin/capabilities/emailCapability.js +0 -20
  33. package/dist/bin/capabilities/enhancedGitCapability.js +0 -221
  34. package/dist/bin/capabilities/filesystemCapability.js +0 -22
  35. package/dist/bin/capabilities/globCapability.js +0 -28
  36. package/dist/bin/capabilities/interactionCapability.js +0 -20
  37. package/dist/bin/capabilities/learnCapability.js +0 -22
  38. package/dist/bin/capabilities/mcpCapability.js +0 -20
  39. package/dist/bin/capabilities/notebookCapability.js +0 -28
  40. package/dist/bin/capabilities/planningCapability.js +0 -27
  41. package/dist/bin/capabilities/refactoringCapability.js +0 -23
  42. package/dist/bin/capabilities/repoChecksCapability.js +0 -22
  43. package/dist/bin/capabilities/searchCapability.js +0 -22
  44. package/dist/bin/capabilities/skillCapability.js +0 -76
  45. package/dist/bin/capabilities/taskManagementCapability.js +0 -20
  46. package/dist/bin/capabilities/testingCapability.js +0 -23
  47. package/dist/bin/capabilities/toolManifest.js +0 -159
  48. package/dist/bin/capabilities/toolRegistry.js +0 -114
  49. package/dist/bin/capabilities/webCapability.js +0 -20
  50. package/dist/bin/config.js +0 -139
  51. package/dist/bin/contracts/v1/agent.js +0 -7
  52. package/dist/bin/contracts/v1/agentProfileManifest.js +0 -8
  53. package/dist/bin/contracts/v1/agentRules.js +0 -9
  54. package/dist/bin/contracts/v1/toolAccess.js +0 -8
  55. package/dist/bin/erosolar-optimized.d.ts +0 -12
  56. package/dist/bin/erosolar-optimized.d.ts.map +0 -1
  57. package/dist/bin/erosolar-optimized.js +0 -239
  58. package/dist/bin/erosolar-optimized.js.map +0 -1
  59. package/dist/bin/headless/headlessApp.js +0 -172
  60. package/dist/bin/mcp/config.js +0 -202
  61. package/dist/bin/mcp/stdioClient.js +0 -172
  62. package/dist/bin/mcp/toolBridge.js +0 -104
  63. package/dist/bin/mcp/types.js +0 -1
  64. package/dist/bin/plugins/index.js +0 -113
  65. package/dist/bin/plugins/providers/anthropic/index.js +0 -25
  66. package/dist/bin/plugins/providers/deepseek/index.js +0 -24
  67. package/dist/bin/plugins/providers/google/index.js +0 -26
  68. package/dist/bin/plugins/providers/index.js +0 -19
  69. package/dist/bin/plugins/providers/ollama/index.js +0 -59
  70. package/dist/bin/plugins/providers/openai/index.js +0 -26
  71. package/dist/bin/plugins/providers/xai/index.js +0 -24
  72. package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +0 -8
  73. package/dist/bin/plugins/tools/bash/localBashPlugin.js +0 -13
  74. package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +0 -13
  75. package/dist/bin/plugins/tools/cloud/cloudPlugin.js +0 -13
  76. package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +0 -13
  77. package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +0 -13
  78. package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +0 -11
  79. package/dist/bin/plugins/tools/development/devPlugin.js +0 -13
  80. package/dist/bin/plugins/tools/edit/editPlugin.js +0 -14
  81. package/dist/bin/plugins/tools/email/emailPlugin.js +0 -11
  82. package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +0 -8
  83. package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +0 -13
  84. package/dist/bin/plugins/tools/glob/globPlugin.js +0 -14
  85. package/dist/bin/plugins/tools/index.js +0 -2
  86. package/dist/bin/plugins/tools/interaction/interactionPlugin.js +0 -11
  87. package/dist/bin/plugins/tools/learn/learnPlugin.js +0 -13
  88. package/dist/bin/plugins/tools/mcp/mcpPlugin.js +0 -8
  89. package/dist/bin/plugins/tools/nodeDefaults.js +0 -56
  90. package/dist/bin/plugins/tools/notebook/notebookPlugin.js +0 -14
  91. package/dist/bin/plugins/tools/planning/planningPlugin.js +0 -14
  92. package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +0 -11
  93. package/dist/bin/plugins/tools/registry.js +0 -57
  94. package/dist/bin/plugins/tools/search/localSearchPlugin.js +0 -13
  95. package/dist/bin/plugins/tools/skills/skillPlugin.js +0 -8
  96. package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +0 -11
  97. package/dist/bin/plugins/tools/testing/testingPlugin.js +0 -11
  98. package/dist/bin/plugins/tools/web/webPlugin.js +0 -11
  99. package/dist/bin/providers/anthropicProvider.js +0 -329
  100. package/dist/bin/providers/googleProvider.js +0 -203
  101. package/dist/bin/providers/openaiChatCompletionsProvider.js +0 -208
  102. package/dist/bin/providers/openaiResponsesProvider.js +0 -249
  103. package/dist/bin/providers/providerFactory.js +0 -24
  104. package/dist/bin/runtime/agentController.js +0 -321
  105. package/dist/bin/runtime/agentHost.js +0 -153
  106. package/dist/bin/runtime/agentSession.js +0 -195
  107. package/dist/bin/runtime/node.js +0 -10
  108. package/dist/bin/runtime/universal.js +0 -28
  109. package/dist/bin/skills/skillRepository.js +0 -236
  110. package/dist/bin/skills/types.js +0 -1
  111. package/dist/bin/subagents/taskRunner.js +0 -269
  112. package/dist/bin/tools/backgroundBashTools.js +0 -211
  113. package/dist/bin/tools/bashTools.js +0 -159
  114. package/dist/bin/tools/cloudTools.js +0 -864
  115. package/dist/bin/tools/codeAnalysisTools.js +0 -641
  116. package/dist/bin/tools/codeQualityTools.js +0 -294
  117. package/dist/bin/tools/dependencyTools.js +0 -282
  118. package/dist/bin/tools/devTools.js +0 -238
  119. package/dist/bin/tools/diffUtils.js +0 -137
  120. package/dist/bin/tools/editTools.js +0 -134
  121. package/dist/bin/tools/emailTools.js +0 -448
  122. package/dist/bin/tools/fileTools.js +0 -282
  123. package/dist/bin/tools/globTools.js +0 -173
  124. package/dist/bin/tools/grepTools.js +0 -332
  125. package/dist/bin/tools/interactionTools.js +0 -170
  126. package/dist/bin/tools/learnTools.js +0 -1818
  127. package/dist/bin/tools/notebookEditTools.js +0 -196
  128. package/dist/bin/tools/planningTools.js +0 -46
  129. package/dist/bin/tools/refactoringTools.js +0 -293
  130. package/dist/bin/tools/repoChecksTools.js +0 -160
  131. package/dist/bin/tools/searchTools.js +0 -206
  132. package/dist/bin/tools/skillTools.js +0 -177
  133. package/dist/bin/tools/taskManagementTools.js +0 -156
  134. package/dist/bin/tools/testingTools.js +0 -232
  135. package/dist/bin/tools/webTools.js +0 -480
  136. package/dist/bin/workspace.js +0 -106
  137. package/dist/bin/workspace.validator.js +0 -213
  138. package/dist/capabilities/offensiveSecurityCapability.d.ts +0 -26
  139. package/dist/capabilities/offensiveSecurityCapability.d.ts.map +0 -1
  140. package/dist/capabilities/offensiveSecurityCapability.js +0 -58
  141. package/dist/capabilities/offensiveSecurityCapability.js.map +0 -1
  142. package/dist/capabilities/realSecurityCapability.d.ts +0 -26
  143. package/dist/capabilities/realSecurityCapability.d.ts.map +0 -1
  144. package/dist/capabilities/realSecurityCapability.js +0 -53
  145. package/dist/capabilities/realSecurityCapability.js.map +0 -1
  146. package/dist/capabilities/securityCapability.d.ts +0 -32
  147. package/dist/capabilities/securityCapability.d.ts.map +0 -1
  148. package/dist/capabilities/securityCapability.js +0 -57
  149. package/dist/capabilities/securityCapability.js.map +0 -1
  150. package/dist/capabilities/ultimateSecurityCapability.d.ts +0 -42
  151. package/dist/capabilities/ultimateSecurityCapability.d.ts.map +0 -1
  152. package/dist/capabilities/ultimateSecurityCapability.js +0 -96
  153. package/dist/capabilities/ultimateSecurityCapability.js.map +0 -1
  154. package/dist/core/designThoughtCheck.d.ts +0 -196
  155. package/dist/core/designThoughtCheck.d.ts.map +0 -1
  156. package/dist/core/designThoughtCheck.js +0 -287
  157. package/dist/core/designThoughtCheck.js.map +0 -1
  158. package/dist/core/designThoughtCheckEngine.d.ts +0 -58
  159. package/dist/core/designThoughtCheckEngine.d.ts.map +0 -1
  160. package/dist/core/designThoughtCheckEngine.js +0 -358
  161. package/dist/core/designThoughtCheckEngine.js.map +0 -1
  162. package/dist/core/designThoughtCheckIntegration.d.ts +0 -103
  163. package/dist/core/designThoughtCheckIntegration.d.ts.map +0 -1
  164. package/dist/core/designThoughtCheckIntegration.js +0 -207
  165. package/dist/core/designThoughtCheckIntegration.js.map +0 -1
  166. package/dist/core/intelligenceTools.d.ts +0 -19
  167. package/dist/core/intelligenceTools.d.ts.map +0 -1
  168. package/dist/core/intelligenceTools.js +0 -453
  169. package/dist/core/intelligenceTools.js.map +0 -1
  170. package/dist/core/operationalTools.d.ts +0 -19
  171. package/dist/core/operationalTools.d.ts.map +0 -1
  172. package/dist/core/operationalTools.js +0 -467
  173. package/dist/core/operationalTools.js.map +0 -1
  174. package/dist/offensive/core/offensive-engine.d.ts +0 -171
  175. package/dist/offensive/core/offensive-engine.d.ts.map +0 -1
  176. package/dist/offensive/core/offensive-engine.js +0 -345
  177. package/dist/offensive/core/offensive-engine.js.map +0 -1
  178. package/dist/offensive/core/offensive-integration.d.ts +0 -129
  179. package/dist/offensive/core/offensive-integration.d.ts.map +0 -1
  180. package/dist/offensive/core/offensive-integration.js +0 -364
  181. package/dist/offensive/core/offensive-integration.js.map +0 -1
  182. package/dist/offensive/core/offensive-tools.d.ts +0 -55
  183. package/dist/offensive/core/offensive-tools.d.ts.map +0 -1
  184. package/dist/offensive/core/offensive-tools.js +0 -438
  185. package/dist/offensive/core/offensive-tools.js.map +0 -1
  186. package/dist/offensive/offensive-cli.d.ts +0 -48
  187. package/dist/offensive/offensive-cli.d.ts.map +0 -1
  188. package/dist/offensive/offensive-cli.js +0 -233
  189. package/dist/offensive/offensive-cli.js.map +0 -1
  190. package/dist/security/apt-simulation-cli.d.ts +0 -57
  191. package/dist/security/apt-simulation-cli.d.ts.map +0 -1
  192. package/dist/security/apt-simulation-cli.js +0 -278
  193. package/dist/security/apt-simulation-cli.js.map +0 -1
  194. package/dist/security/apt-simulation-engine-complete.d.ts +0 -97
  195. package/dist/security/apt-simulation-engine-complete.d.ts.map +0 -1
  196. package/dist/security/apt-simulation-engine-complete.js +0 -441
  197. package/dist/security/apt-simulation-engine-complete.js.map +0 -1
  198. package/dist/security/apt-simulation-engine.d.ts +0 -97
  199. package/dist/security/apt-simulation-engine.d.ts.map +0 -1
  200. package/dist/security/apt-simulation-engine.js +0 -441
  201. package/dist/security/apt-simulation-engine.js.map +0 -1
  202. package/dist/security/authorization.d.ts +0 -45
  203. package/dist/security/authorization.d.ts.map +0 -1
  204. package/dist/security/authorization.js +0 -128
  205. package/dist/security/authorization.js.map +0 -1
  206. package/dist/security/comprehensive-security-research.d.ts +0 -84
  207. package/dist/security/comprehensive-security-research.d.ts.map +0 -1
  208. package/dist/security/comprehensive-security-research.js +0 -211
  209. package/dist/security/comprehensive-security-research.js.map +0 -1
  210. package/dist/security/offensive/exploitationEngine.d.ts +0 -54
  211. package/dist/security/offensive/exploitationEngine.d.ts.map +0 -1
  212. package/dist/security/offensive/exploitationEngine.js +0 -263
  213. package/dist/security/offensive/exploitationEngine.js.map +0 -1
  214. package/dist/security/real/networkExploitation.d.ts +0 -92
  215. package/dist/security/real/networkExploitation.d.ts.map +0 -1
  216. package/dist/security/real/networkExploitation.js +0 -316
  217. package/dist/security/real/networkExploitation.js.map +0 -1
  218. package/dist/security/real/persistenceImplementation.d.ts +0 -62
  219. package/dist/security/real/persistenceImplementation.d.ts.map +0 -1
  220. package/dist/security/real/persistenceImplementation.js +0 -323
  221. package/dist/security/real/persistenceImplementation.js.map +0 -1
  222. package/dist/security/real/vulnerabilityScanner.d.ts +0 -73
  223. package/dist/security/real/vulnerabilityScanner.d.ts.map +0 -1
  224. package/dist/security/real/vulnerabilityScanner.js +0 -341
  225. package/dist/security/real/vulnerabilityScanner.js.map +0 -1
  226. package/dist/shell/capturePastePatch.d.ts +0 -9
  227. package/dist/shell/capturePastePatch.d.ts.map +0 -1
  228. package/dist/shell/capturePastePatch.js +0 -98
  229. package/dist/shell/capturePastePatch.js.map +0 -1
  230. package/dist/shell/enhancedInteractiveShell.d.ts +0 -90
  231. package/dist/shell/enhancedInteractiveShell.d.ts.map +0 -1
  232. package/dist/shell/enhancedInteractiveShell.js +0 -248
  233. package/dist/shell/enhancedInteractiveShell.js.map +0 -1
  234. package/dist/shell/inputProcessor.d.ts +0 -56
  235. package/dist/shell/inputProcessor.d.ts.map +0 -1
  236. package/dist/shell/inputProcessor.js +0 -172
  237. package/dist/shell/inputProcessor.js.map +0 -1
  238. package/dist/shell/interactiveShell-patch.d.ts +0 -27
  239. package/dist/shell/interactiveShell-patch.d.ts.map +0 -1
  240. package/dist/shell/interactiveShell-patch.js +0 -38
  241. package/dist/shell/interactiveShell-patch.js.map +0 -1
  242. package/dist/shell/interactiveShell-robust.d.ts +0 -26
  243. package/dist/shell/interactiveShell-robust.d.ts.map +0 -1
  244. package/dist/shell/interactiveShell-robust.js +0 -34
  245. package/dist/shell/interactiveShell-robust.js.map +0 -1
  246. package/dist/shell/multiLinePasteManager.d.ts +0 -106
  247. package/dist/shell/multiLinePasteManager.d.ts.map +0 -1
  248. package/dist/shell/multiLinePasteManager.js +0 -308
  249. package/dist/shell/multiLinePasteManager.js.map +0 -1
  250. package/dist/shell/processInputBlockPatch.d.ts +0 -8
  251. package/dist/shell/processInputBlockPatch.d.ts.map +0 -1
  252. package/dist/shell/processInputBlockPatch.js +0 -133
  253. package/dist/shell/processInputBlockPatch.js.map +0 -1
  254. package/dist/shell/unifiedInputProcessor.d.ts +0 -23
  255. package/dist/shell/unifiedInputProcessor.d.ts.map +0 -1
  256. package/dist/shell/unifiedInputProcessor.js +0 -92
  257. package/dist/shell/unifiedInputProcessor.js.map +0 -1
  258. package/dist/tools/enhancedSecurityTools.d.ts +0 -19
  259. package/dist/tools/enhancedSecurityTools.d.ts.map +0 -1
  260. package/dist/tools/enhancedSecurityTools.js +0 -215
  261. package/dist/tools/enhancedSecurityTools.js.map +0 -1
  262. package/dist/tools/offensiveSecurityTools.d.ts +0 -16
  263. package/dist/tools/offensiveSecurityTools.d.ts.map +0 -1
  264. package/dist/tools/offensiveSecurityTools.js +0 -285
  265. package/dist/tools/offensiveSecurityTools.js.map +0 -1
  266. package/dist/tools/realSecurityTools.d.ts +0 -18
  267. package/dist/tools/realSecurityTools.d.ts.map +0 -1
  268. package/dist/tools/realSecurityTools.js +0 -468
  269. package/dist/tools/realSecurityTools.js.map +0 -1
  270. package/dist/tools/securityTools.d.ts +0 -20
  271. package/dist/tools/securityTools.d.ts.map +0 -1
  272. package/dist/tools/securityTools.js +0 -449
  273. package/dist/tools/securityTools.js.map +0 -1
@@ -1,274 +0,0 @@
1
- /**
2
- * Attack Simulation Framework
3
- *
4
- * Provides controlled attack simulations for red team exercises.
5
- * All simulations require explicit authorization.
6
- *
7
- * Principal Investigator: Bo Shang
8
- * Framework: erosolar-cli
9
- */
10
- import { AuthorizationScope } from './core.js';
11
- /**
12
- * Categories of attack simulations
13
- */
14
- export var AttackCategory;
15
- (function (AttackCategory) {
16
- AttackCategory["RECONNAISSANCE"] = "reconnaissance";
17
- AttackCategory["WEB_APPLICATION"] = "web_application";
18
- AttackCategory["AUTHENTICATION"] = "authentication";
19
- AttackCategory["INJECTION"] = "injection";
20
- AttackCategory["MISCONFIGURATION"] = "misconfiguration";
21
- AttackCategory["PRIVILEGE_ESCALATION"] = "privilege_escalation";
22
- AttackCategory["DATA_EXFILTRATION"] = "data_exfiltration";
23
- })(AttackCategory || (AttackCategory = {}));
24
- /**
25
- * MITRE ATT&CK inspired attack phases
26
- */
27
- export var AttackPhase;
28
- (function (AttackPhase) {
29
- AttackPhase["INITIAL_ACCESS"] = "initial_access";
30
- AttackPhase["EXECUTION"] = "execution";
31
- AttackPhase["PERSISTENCE"] = "persistence";
32
- AttackPhase["PRIVILEGE_ESCALATION"] = "privilege_escalation";
33
- AttackPhase["DEFENSE_EVASION"] = "defense_evasion";
34
- AttackPhase["CREDENTIAL_ACCESS"] = "credential_access";
35
- AttackPhase["DISCOVERY"] = "discovery";
36
- AttackPhase["LATERAL_MOVEMENT"] = "lateral_movement";
37
- AttackPhase["COLLECTION"] = "collection";
38
- AttackPhase["EXFILTRATION"] = "exfiltration";
39
- AttackPhase["IMPACT"] = "impact";
40
- })(AttackPhase || (AttackPhase = {}));
41
- /**
42
- * Common attack vectors based on OWASP Top 10 and MITRE ATT&CK
43
- */
44
- export const ATTACK_VECTORS = {
45
- sql_injection: {
46
- name: 'SQL Injection',
47
- category: AttackCategory.INJECTION,
48
- phase: AttackPhase.INITIAL_ACCESS,
49
- description: 'Inject malicious SQL queries',
50
- techniqueId: 'T1190',
51
- prerequisites: ['web_application_identified', 'input_field_found'],
52
- detectionMethods: ['WAF rules', 'Database monitoring'],
53
- mitigations: ['Parameterized queries', 'Input validation'],
54
- },
55
- xss_reflected: {
56
- name: 'Reflected XSS',
57
- category: AttackCategory.WEB_APPLICATION,
58
- phase: AttackPhase.INITIAL_ACCESS,
59
- description: 'Inject scripts reflected to users',
60
- techniqueId: 'T1189',
61
- prerequisites: ['web_application_identified', 'reflection_point_found'],
62
- detectionMethods: ['CSP reports', 'WAF XSS rules'],
63
- mitigations: ['CSP', 'Output encoding', 'Input validation'],
64
- },
65
- ssrf: {
66
- name: 'Server-Side Request Forgery',
67
- category: AttackCategory.WEB_APPLICATION,
68
- phase: AttackPhase.DISCOVERY,
69
- description: 'Abuse server to make internal requests',
70
- techniqueId: 'T1090',
71
- prerequisites: ['url_parameter_found'],
72
- detectionMethods: ['Outbound request monitoring'],
73
- mitigations: ['URL allowlisting', 'Network segmentation'],
74
- },
75
- auth_bypass: {
76
- name: 'Authentication Bypass',
77
- category: AttackCategory.AUTHENTICATION,
78
- phase: AttackPhase.INITIAL_ACCESS,
79
- description: 'Bypass authentication mechanisms',
80
- techniqueId: 'T1078',
81
- prerequisites: ['auth_endpoint_identified'],
82
- detectionMethods: ['Failed login monitoring', 'Session anomalies'],
83
- mitigations: ['MFA', 'Strong session management'],
84
- },
85
- path_traversal: {
86
- name: 'Path Traversal',
87
- category: AttackCategory.WEB_APPLICATION,
88
- phase: AttackPhase.COLLECTION,
89
- description: 'Access files outside webroot',
90
- techniqueId: 'T1083',
91
- prerequisites: ['file_parameter_found'],
92
- detectionMethods: ['Path pattern monitoring', 'WAF rules'],
93
- mitigations: ['Input validation', 'Chroot/sandbox'],
94
- },
95
- };
96
- /**
97
- * Payload generator for security testing
98
- */
99
- export class PayloadGenerator {
100
- /**
101
- * Generate SQL injection test payloads
102
- */
103
- static sqlInjectionPayloads() {
104
- return [
105
- "' OR '1'='1",
106
- "'; DROP TABLE users--",
107
- "1' AND '1'='1",
108
- "1 UNION SELECT NULL--",
109
- "admin'--",
110
- ];
111
- }
112
- /**
113
- * Generate XSS test payloads
114
- */
115
- static xssPayloads() {
116
- return [
117
- "<script>alert(1)</script>",
118
- "<img src=x onerror=alert(1)>",
119
- "javascript:alert(1)",
120
- "<svg onload=alert(1)>",
121
- ];
122
- }
123
- /**
124
- * Generate path traversal test payloads
125
- */
126
- static pathTraversalPayloads() {
127
- return [
128
- "../../../etc/passwd",
129
- "..\\..\\..\\windows\\system32\\config\\sam",
130
- "....//....//....//etc/passwd",
131
- "%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd",
132
- ];
133
- }
134
- /**
135
- * Encode payload
136
- */
137
- static encodePayload(payload, encoding) {
138
- switch (encoding) {
139
- case 'base64':
140
- return Buffer.from(payload).toString('base64');
141
- case 'url':
142
- return encodeURIComponent(payload);
143
- case 'hex':
144
- return Buffer.from(payload).toString('hex');
145
- default:
146
- return payload;
147
- }
148
- }
149
- }
150
- /**
151
- * Attack simulator
152
- */
153
- export class AttackSimulator {
154
- constructor(authorization, verbose = false) {
155
- this.results = [];
156
- this.authorization = authorization;
157
- this.verbose = verbose;
158
- }
159
- /**
160
- * Check authorization
161
- */
162
- checkAuthorization(target) {
163
- if (!this.authorization) {
164
- throw new Error('No authorization record.');
165
- }
166
- // Attack simulations require stronger authorization
167
- const allowed = [
168
- AuthorizationScope.OWNED_SYSTEMS,
169
- AuthorizationScope.PENTEST_ENGAGEMENT,
170
- AuthorizationScope.RED_TEAM,
171
- AuthorizationScope.CTF_COMPETITION,
172
- ];
173
- if (!allowed.includes(this.authorization.scope)) {
174
- throw new Error('Simulations require pentest/red team authorization.');
175
- }
176
- const inScope = this.authorization.targetDomain.includes(target) ||
177
- target.endsWith(this.authorization.targetDomain);
178
- if (!inScope) {
179
- throw new Error(`Target ${target} not in scope.`);
180
- }
181
- }
182
- /**
183
- * Simulate an attack vector
184
- */
185
- async simulateAttack(target, vectorId, dryRun = true) {
186
- this.checkAuthorization(target);
187
- if (!(vectorId in ATTACK_VECTORS)) {
188
- throw new Error(`Unknown attack vector: ${vectorId}`);
189
- }
190
- const vector = ATTACK_VECTORS[vectorId];
191
- if (!vector) {
192
- throw new Error(`Unknown attack vector: ${vectorId}`);
193
- }
194
- const startTime = Date.now();
195
- if (this.verbose) {
196
- console.log(`[Simulation] ${vector.name} against ${target}`);
197
- console.log(` Technique: ${vector.techniqueId}`);
198
- console.log(` Dry run: ${dryRun}`);
199
- }
200
- const result = {
201
- vector,
202
- target,
203
- timestamp: startTime,
204
- success: false,
205
- evidence: [],
206
- artifacts: {
207
- payloads: this.getPayloadsForVector(vectorId),
208
- payloadCount: this.getPayloadsForVector(vectorId).length,
209
- },
210
- detectionTriggered: false,
211
- durationMs: 0,
212
- notes: `Dry run: ${dryRun}`,
213
- };
214
- if (!dryRun) {
215
- result.notes = 'Live simulation not implemented for safety';
216
- }
217
- result.durationMs = Date.now() - startTime;
218
- this.results.push(result);
219
- return result;
220
- }
221
- /**
222
- * Get payloads for a vector
223
- */
224
- getPayloadsForVector(vectorId) {
225
- if (vectorId.includes('sql')) {
226
- return PayloadGenerator.sqlInjectionPayloads();
227
- }
228
- if (vectorId.includes('xss')) {
229
- return PayloadGenerator.xssPayloads();
230
- }
231
- if (vectorId.includes('path') || vectorId.includes('traversal')) {
232
- return PayloadGenerator.pathTraversalPayloads();
233
- }
234
- return [];
235
- }
236
- /**
237
- * Get vectors by category
238
- */
239
- getVectorsByCategory(category) {
240
- return Object.values(ATTACK_VECTORS).filter(v => v.category === category);
241
- }
242
- /**
243
- * Get vectors by phase
244
- */
245
- getVectorsByPhase(phase) {
246
- return Object.values(ATTACK_VECTORS).filter(v => v.phase === phase);
247
- }
248
- /**
249
- * Generate report
250
- */
251
- generateReport() {
252
- const lines = [
253
- '='.repeat(60),
254
- 'ATTACK SIMULATION REPORT',
255
- '='.repeat(60),
256
- `Generated: ${new Date().toISOString()}`,
257
- `Target: ${this.authorization.targetDomain}`,
258
- `Scope: ${this.authorization.scope}`,
259
- `Simulations: ${this.results.length}`,
260
- '',
261
- ];
262
- for (let i = 0; i < this.results.length; i++) {
263
- const result = this.results[i];
264
- if (!result)
265
- continue;
266
- lines.push(`[${i + 1}] ${result.vector.name}`);
267
- lines.push(` Target: ${result.target}`);
268
- lines.push(` Success: ${result.success}`);
269
- lines.push(` Duration: ${result.durationMs}ms`);
270
- lines.push(` Payloads: ${result.artifacts['payloadCount'] || 0}`);
271
- }
272
- return lines.join('\n');
273
- }
274
- }
@@ -1,231 +0,0 @@
1
- /**
2
- * Self-Modification Engine for Alpha Zero 2
3
- *
4
- * Enables autonomous code self-modification with version control.
5
- * Agents can modify their own tool source code based on performance feedback.
6
- *
7
- * Principal Investigator: Bo Shang
8
- * Framework: erosolar-cli
9
- */
10
- import * as crypto from 'crypto';
11
- import * as fs from 'fs/promises';
12
- import * as path from 'path';
13
- const DEFAULT_CONFIG = {
14
- dataDir: '.alpha_zero_versions',
15
- maxVersions: 100,
16
- enableAutoRollback: true,
17
- minQualityThreshold: 0.7,
18
- verbose: false,
19
- };
20
- /**
21
- * Self-Modification Engine
22
- *
23
- * Manages version-controlled code modifications with automatic rollback.
24
- */
25
- export class SelfModificationEngine {
26
- constructor(config = {}) {
27
- this.versions = new Map();
28
- this.config = { ...DEFAULT_CONFIG, ...config };
29
- }
30
- /**
31
- * Create a checkpoint of current tool code
32
- */
33
- async createCheckpoint(toolId, sourceCode, metrics) {
34
- const hash = this.computeHash(sourceCode);
35
- const versionId = `${toolId}-${Date.now()}-${hash.slice(0, 8)}`;
36
- const toolVersions = this.versions.get(toolId) || [];
37
- const lastVersion = toolVersions.length > 0 ? toolVersions[toolVersions.length - 1] : undefined;
38
- const parentVersion = lastVersion?.versionId;
39
- const version = {
40
- versionId,
41
- hash,
42
- timestamp: Date.now(),
43
- sourceCode,
44
- performanceMetrics: metrics,
45
- parentVersion,
46
- };
47
- toolVersions.push(version);
48
- this.versions.set(toolId, toolVersions);
49
- // Persist to disk
50
- await this.saveVersion(toolId, version);
51
- if (this.config.verbose) {
52
- console.log(`[SelfMod] Created checkpoint ${versionId}`);
53
- }
54
- return version;
55
- }
56
- /**
57
- * Attempt to modify tool code
58
- */
59
- async modifyTool(toolId, currentCode, modifiedCode, testFn) {
60
- // Create checkpoint of current code
61
- const currentVersion = await this.createCheckpoint(toolId, currentCode);
62
- // Test modified code if test function provided
63
- let testResult;
64
- if (testFn) {
65
- try {
66
- testResult = await testFn(modifiedCode);
67
- }
68
- catch (error) {
69
- return {
70
- success: false,
71
- previousVersion: currentVersion,
72
- error: `Test execution failed: ${error}`,
73
- rolledBack: false,
74
- };
75
- }
76
- // Check if tests pass
77
- if (!testResult.passed && this.config.enableAutoRollback) {
78
- if (this.config.verbose) {
79
- console.log(`[SelfMod] Tests failed, rolling back`);
80
- }
81
- return {
82
- success: false,
83
- previousVersion: currentVersion,
84
- error: `Tests failed: ${testResult.failedTests}/${testResult.totalTests}`,
85
- rolledBack: true,
86
- };
87
- }
88
- }
89
- // Create new version
90
- const newVersion = await this.createCheckpoint(toolId, modifiedCode, {
91
- executionTimeMs: 0,
92
- memoryUsageMb: 0,
93
- errorCount: testResult?.failedTests || 0,
94
- successRate: testResult ? testResult.passedTests / testResult.totalTests : 1,
95
- qualityScore: this.evaluateCodeQuality(modifiedCode),
96
- });
97
- newVersion.testResults = testResult;
98
- // Calculate performance delta
99
- const performanceDelta = newVersion.performanceMetrics && currentVersion.performanceMetrics
100
- ? newVersion.performanceMetrics.qualityScore - currentVersion.performanceMetrics.qualityScore
101
- : 0;
102
- return {
103
- success: true,
104
- newVersion,
105
- previousVersion: currentVersion,
106
- performanceDelta,
107
- rolledBack: false,
108
- };
109
- }
110
- /**
111
- * Rollback to a previous version
112
- */
113
- async rollback(toolId, targetVersionId) {
114
- const toolVersions = this.versions.get(toolId);
115
- if (!toolVersions || toolVersions.length < 2) {
116
- return null;
117
- }
118
- if (targetVersionId) {
119
- const targetIndex = toolVersions.findIndex(v => v.versionId === targetVersionId);
120
- if (targetIndex === -1)
121
- return null;
122
- // Remove versions after target
123
- const removedVersions = toolVersions.splice(targetIndex + 1);
124
- if (this.config.verbose) {
125
- console.log(`[SelfMod] Rolled back ${removedVersions.length} versions`);
126
- }
127
- return toolVersions[targetIndex] ?? null;
128
- }
129
- // Rollback to previous version
130
- toolVersions.pop();
131
- return toolVersions[toolVersions.length - 1] ?? null;
132
- }
133
- /**
134
- * Get version history for a tool
135
- */
136
- getVersionHistory(toolId) {
137
- return this.versions.get(toolId) || [];
138
- }
139
- /**
140
- * Get current version of a tool
141
- */
142
- getCurrentVersion(toolId) {
143
- const versions = this.versions.get(toolId);
144
- return versions && versions.length > 0 ? (versions[versions.length - 1] ?? null) : null;
145
- }
146
- /**
147
- * Compare two versions
148
- */
149
- compareVersions(version1, version2) {
150
- const codeChanged = version1.hash !== version2.hash;
151
- const q1 = version1.performanceMetrics?.qualityScore || 0;
152
- const q2 = version2.performanceMetrics?.qualityScore || 0;
153
- return {
154
- codeChanged,
155
- performanceImproved: q2 > q1,
156
- qualityDelta: q2 - q1,
157
- };
158
- }
159
- /**
160
- * Evaluate code quality (simplified AST-based analysis)
161
- */
162
- evaluateCodeQuality(code) {
163
- let score = 0.5; // Base score
164
- // Check for documentation
165
- if (code.includes('/**') || code.includes('///')) {
166
- score += 0.1;
167
- }
168
- // Check for error handling
169
- if (code.includes('try') && code.includes('catch')) {
170
- score += 0.1;
171
- }
172
- // Check for type annotations (TypeScript)
173
- if (code.includes(': string') || code.includes(': number') || code.includes(': boolean')) {
174
- score += 0.1;
175
- }
176
- // Check for async/await patterns
177
- if (code.includes('async') && code.includes('await')) {
178
- score += 0.05;
179
- }
180
- // Penalize very long functions
181
- const lines = code.split('\n').length;
182
- if (lines > 200) {
183
- score -= 0.1;
184
- }
185
- return Math.max(0, Math.min(1, score));
186
- }
187
- /**
188
- * Compute SHA-256 hash of code
189
- */
190
- computeHash(code) {
191
- return crypto.createHash('sha256').update(code).digest('hex');
192
- }
193
- /**
194
- * Save version to disk
195
- */
196
- async saveVersion(toolId, version) {
197
- const dir = path.join(this.config.dataDir, toolId);
198
- await fs.mkdir(dir, { recursive: true });
199
- const filePath = path.join(dir, `${version.versionId}.json`);
200
- await fs.writeFile(filePath, JSON.stringify(version, null, 2));
201
- }
202
- /**
203
- * Load versions from disk
204
- */
205
- async loadVersions(toolId) {
206
- const dir = path.join(this.config.dataDir, toolId);
207
- try {
208
- const files = await fs.readdir(dir);
209
- const versions = [];
210
- for (const file of files) {
211
- if (file.endsWith('.json')) {
212
- const content = await fs.readFile(path.join(dir, file), 'utf-8');
213
- versions.push(JSON.parse(content));
214
- }
215
- }
216
- // Sort by timestamp
217
- versions.sort((a, b) => a.timestamp - b.timestamp);
218
- this.versions.set(toolId, versions);
219
- return versions;
220
- }
221
- catch {
222
- return [];
223
- }
224
- }
225
- }
226
- /**
227
- * Create a default self-modification engine
228
- */
229
- export function createSelfModificationEngine(config) {
230
- return new SelfModificationEngine(config);
231
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Alpha Zero 2 - Type Definitions
3
- *
4
- * Core type definitions for the competitive multi-agent RL framework.
5
- *
6
- * Principal Investigator: Bo Shang
7
- * Framework: erosolar-cli
8
- */
9
- /**
10
- * Default research metadata.
11
- */
12
- export const ALPHA_ZERO_2_METADATA = {
13
- projectName: 'Alpha Zero 2',
14
- version: '1.0.0',
15
- author: 'Bo Shang',
16
- framework: 'erosolar-cli',
17
- description: 'Recursive Self-Improvement in Competitive Multi-Agent Systems',
18
- innovations: [
19
- 'Recursive Self-Modification Engine: Agents modify their own tool source code',
20
- 'Competitive Multi-Agent Framework: Tournament system with parallel execution',
21
- 'Version-Controlled Self-Improvement: SHA-256 checkpoints with automatic rollback',
22
- 'AST-Based Code Quality Metrics: Comprehensive evaluation across 10+ dimensions',
23
- ],
24
- techStack: {
25
- python: ['typer', 'rich', 'prompt-toolkit', 'pydantic', 'aiohttp', 'tiktoken'],
26
- typescript: ['chalk', 'ora', 'gradient-string', 'boxen', 'nanospinner'],
27
- aiProviders: ['anthropic', 'openai', 'google-generativeai'],
28
- testing: ['pytest', 'pytest-asyncio', 'mypy', 'ruff', 'eslint'],
29
- },
30
- };