erosolar-cli 2.1.238 → 2.1.240

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 (142) hide show
  1. package/README.md +9 -0
  2. package/dist/contracts/tools.schema.json +3 -1
  3. package/dist/core/agent.d.ts.map +1 -1
  4. package/dist/core/agent.js +5 -1
  5. package/dist/core/agent.js.map +1 -1
  6. package/dist/core/agentOrchestrator.d.ts +4 -0
  7. package/dist/core/agentOrchestrator.d.ts.map +1 -1
  8. package/dist/core/agentOrchestrator.js +58 -6
  9. package/dist/core/agentOrchestrator.js.map +1 -1
  10. package/dist/core/autoExecutionOrchestrator.d.ts +172 -0
  11. package/dist/core/autoExecutionOrchestrator.d.ts.map +1 -0
  12. package/dist/core/autoExecutionOrchestrator.js +591 -0
  13. package/dist/core/autoExecutionOrchestrator.js.map +1 -0
  14. package/dist/core/contextManager.d.ts.map +1 -1
  15. package/dist/core/contextManager.js.map +1 -1
  16. package/dist/core/dualAgentOrchestrator.d.ts +34 -0
  17. package/dist/core/dualAgentOrchestrator.d.ts.map +1 -0
  18. package/dist/core/dualAgentOrchestrator.js +94 -0
  19. package/dist/core/dualAgentOrchestrator.js.map +1 -0
  20. package/dist/core/errors/safetyValidator.d.ts +25 -12
  21. package/dist/core/errors/safetyValidator.d.ts.map +1 -1
  22. package/dist/core/errors/safetyValidator.js +165 -17
  23. package/dist/core/errors/safetyValidator.js.map +1 -1
  24. package/dist/core/governmentProcedures.d.ts +118 -0
  25. package/dist/core/governmentProcedures.d.ts.map +1 -0
  26. package/dist/core/governmentProcedures.js +912 -0
  27. package/dist/core/governmentProcedures.js.map +1 -0
  28. package/dist/core/infrastructureTemplates.d.ts +123 -0
  29. package/dist/core/infrastructureTemplates.d.ts.map +1 -0
  30. package/dist/core/infrastructureTemplates.js +1326 -0
  31. package/dist/core/infrastructureTemplates.js.map +1 -0
  32. package/dist/core/integrityVerification.d.ts +250 -0
  33. package/dist/core/integrityVerification.d.ts.map +1 -0
  34. package/dist/core/integrityVerification.js +616 -0
  35. package/dist/core/integrityVerification.js.map +1 -0
  36. package/dist/core/orchestration.d.ts +534 -0
  37. package/dist/core/orchestration.d.ts.map +1 -0
  38. package/dist/core/orchestration.js +2009 -0
  39. package/dist/core/orchestration.js.map +1 -0
  40. package/dist/core/persistentObjectiveStore.d.ts +292 -0
  41. package/dist/core/persistentObjectiveStore.d.ts.map +1 -0
  42. package/dist/core/persistentObjectiveStore.js +613 -0
  43. package/dist/core/persistentObjectiveStore.js.map +1 -0
  44. package/dist/core/preferences.js +1 -1
  45. package/dist/core/preferences.js.map +1 -1
  46. package/dist/core/reliabilityPrompt.d.ts.map +1 -1
  47. package/dist/core/reliabilityPrompt.js +3 -0
  48. package/dist/core/reliabilityPrompt.js.map +1 -1
  49. package/dist/core/securityDeliverableGenerator.d.ts +292 -0
  50. package/dist/core/securityDeliverableGenerator.d.ts.map +1 -0
  51. package/dist/core/securityDeliverableGenerator.js +1590 -0
  52. package/dist/core/securityDeliverableGenerator.js.map +1 -0
  53. package/dist/core/taskCompletionDetector.d.ts.map +1 -1
  54. package/dist/core/taskCompletionDetector.js +4 -1
  55. package/dist/core/taskCompletionDetector.js.map +1 -1
  56. package/dist/shell/autoExecutor.d.ts.map +1 -1
  57. package/dist/shell/autoExecutor.js +32 -3
  58. package/dist/shell/autoExecutor.js.map +1 -1
  59. package/dist/shell/interactiveShell.d.ts +9 -0
  60. package/dist/shell/interactiveShell.d.ts.map +1 -1
  61. package/dist/shell/interactiveShell.js +282 -190
  62. package/dist/shell/interactiveShell.js.map +1 -1
  63. package/dist/tools/bashTools.d.ts +3 -5
  64. package/dist/tools/bashTools.d.ts.map +1 -1
  65. package/dist/tools/bashTools.js +259 -161
  66. package/dist/tools/bashTools.js.map +1 -1
  67. package/dist/tools/tao/index.d.ts +4 -4
  68. package/dist/tools/tao/index.d.ts.map +1 -1
  69. package/dist/tools/tao/index.js +15 -5
  70. package/dist/tools/tao/index.js.map +1 -1
  71. package/dist/tools/tao/rl.d.ts +164 -0
  72. package/dist/tools/tao/rl.d.ts.map +1 -0
  73. package/dist/tools/tao/rl.js +2998 -0
  74. package/dist/tools/tao/rl.js.map +1 -0
  75. package/dist/tools/taoTools.d.ts +2 -2
  76. package/dist/tools/taoTools.d.ts.map +1 -1
  77. package/dist/tools/taoTools.js +103 -20
  78. package/dist/tools/taoTools.js.map +1 -1
  79. package/dist/ui/PromptController.d.ts +3 -0
  80. package/dist/ui/PromptController.d.ts.map +1 -1
  81. package/dist/ui/PromptController.js +3 -0
  82. package/dist/ui/PromptController.js.map +1 -1
  83. package/dist/ui/UnifiedUIRenderer.d.ts +4 -0
  84. package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
  85. package/dist/ui/UnifiedUIRenderer.js +37 -6
  86. package/dist/ui/UnifiedUIRenderer.js.map +1 -1
  87. package/dist/ui/display.d.ts +9 -1
  88. package/dist/ui/display.d.ts.map +1 -1
  89. package/dist/ui/display.js +66 -9
  90. package/dist/ui/display.js.map +1 -1
  91. package/dist/ui/shortcutsHelp.d.ts.map +1 -1
  92. package/dist/ui/shortcutsHelp.js +1 -0
  93. package/dist/ui/shortcutsHelp.js.map +1 -1
  94. package/package.json +3 -2
  95. package/dist/capabilities/askUserCapability.d.ts +0 -14
  96. package/dist/capabilities/askUserCapability.d.ts.map +0 -1
  97. package/dist/capabilities/askUserCapability.js +0 -134
  98. package/dist/capabilities/askUserCapability.js.map +0 -1
  99. package/dist/capabilities/codeGenerationCapability.d.ts +0 -13
  100. package/dist/capabilities/codeGenerationCapability.d.ts.map +0 -1
  101. package/dist/capabilities/codeGenerationCapability.js +0 -25
  102. package/dist/capabilities/codeGenerationCapability.js.map +0 -1
  103. package/dist/capabilities/performanceMonitoringCapability.d.ts +0 -108
  104. package/dist/capabilities/performanceMonitoringCapability.d.ts.map +0 -1
  105. package/dist/capabilities/performanceMonitoringCapability.js +0 -176
  106. package/dist/capabilities/performanceMonitoringCapability.js.map +0 -1
  107. package/dist/capabilities/todoCapability.d.ts +0 -19
  108. package/dist/capabilities/todoCapability.d.ts.map +0 -1
  109. package/dist/capabilities/todoCapability.js +0 -170
  110. package/dist/capabilities/todoCapability.js.map +0 -1
  111. package/dist/core/baseToolFactory.d.ts +0 -187
  112. package/dist/core/baseToolFactory.d.ts.map +0 -1
  113. package/dist/core/baseToolFactory.js +0 -352
  114. package/dist/core/baseToolFactory.js.map +0 -1
  115. package/dist/core/intelligentSummarizer.d.ts +0 -79
  116. package/dist/core/intelligentSummarizer.d.ts.map +0 -1
  117. package/dist/core/intelligentSummarizer.js +0 -273
  118. package/dist/core/intelligentSummarizer.js.map +0 -1
  119. package/dist/core/memorySystem.d.ts +0 -67
  120. package/dist/core/memorySystem.d.ts.map +0 -1
  121. package/dist/core/memorySystem.js +0 -334
  122. package/dist/core/memorySystem.js.map +0 -1
  123. package/dist/core/outputStyles.d.ts +0 -48
  124. package/dist/core/outputStyles.d.ts.map +0 -1
  125. package/dist/core/outputStyles.js +0 -270
  126. package/dist/core/outputStyles.js.map +0 -1
  127. package/dist/core/toolPatternAnalyzer.d.ts +0 -87
  128. package/dist/core/toolPatternAnalyzer.d.ts.map +0 -1
  129. package/dist/core/toolPatternAnalyzer.js +0 -272
  130. package/dist/core/toolPatternAnalyzer.js.map +0 -1
  131. package/dist/tools/backgroundBashTools.d.ts +0 -21
  132. package/dist/tools/backgroundBashTools.d.ts.map +0 -1
  133. package/dist/tools/backgroundBashTools.js +0 -215
  134. package/dist/tools/backgroundBashTools.js.map +0 -1
  135. package/dist/tools/code-quality-dashboard.d.ts +0 -57
  136. package/dist/tools/code-quality-dashboard.d.ts.map +0 -1
  137. package/dist/tools/code-quality-dashboard.js +0 -218
  138. package/dist/tools/code-quality-dashboard.js.map +0 -1
  139. package/dist/tools/tao/rlEngine.d.ts +0 -40
  140. package/dist/tools/tao/rlEngine.d.ts.map +0 -1
  141. package/dist/tools/tao/rlEngine.js +0 -237
  142. package/dist/tools/tao/rlEngine.js.map +0 -1
@@ -0,0 +1,1590 @@
1
+ /**
2
+ * Security Deliverable Generator
3
+ *
4
+ * Auto-executes to completion producing concrete security deliverables:
5
+ * - Penetration test reports
6
+ * - Incident response procedures
7
+ * - Security controls checklists
8
+ * - Training modules
9
+ * - Compliance audit templates
10
+ * - Threat assessment documents
11
+ * - APT kill-chain analysis reports
12
+ */
13
+ import { getChainStats, getRLState, } from '../tools/tao/index.js';
14
+ // ═══════════════════════════════════════════════════════════════════════════════
15
+ // DELIVERABLE GENERATOR CLASS
16
+ // ═══════════════════════════════════════════════════════════════════════════════
17
+ export class SecurityDeliverableGenerator {
18
+ conversationHistory = [];
19
+ toolOutputs = new Map();
20
+ findings = [];
21
+ attackChains = [];
22
+ /**
23
+ * Generate a complete security deliverable from orchestration results
24
+ */
25
+ async generate(type, orchestratorResult, conversationHistory, options = {}) {
26
+ this.conversationHistory = conversationHistory;
27
+ this.extractToolOutputs();
28
+ this.extractFindings();
29
+ const deliverable = {
30
+ id: `${type}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
31
+ type,
32
+ title: this.generateTitle(type, options),
33
+ version: '1.0.0',
34
+ classification: options.classification || 'confidential',
35
+ created: Date.now(),
36
+ modified: Date.now(),
37
+ author: options.author || 'Security Assessment Team',
38
+ reviewers: options.reviewers || [],
39
+ executiveSummary: this.generateExecutiveSummary(type, orchestratorResult),
40
+ scope: this.generateScope(options),
41
+ methodology: this.getMethodology(type),
42
+ findings: this.findings,
43
+ metrics: this.calculateMetrics(orchestratorResult),
44
+ appendices: this.generateAppendices(),
45
+ signoff: [],
46
+ };
47
+ // Add type-specific content
48
+ switch (type) {
49
+ case 'incident-response':
50
+ deliverable.procedures = this.generateIncidentProcedures();
51
+ break;
52
+ case 'security-controls':
53
+ deliverable.controls = this.generateSecurityControls();
54
+ break;
55
+ case 'training-module':
56
+ deliverable.training = this.generateTrainingModules();
57
+ break;
58
+ case 'persistence-procedures':
59
+ deliverable.persistence = this.generatePersistenceMechanisms();
60
+ break;
61
+ case 'infrastructure-assessment':
62
+ deliverable.infrastructure = this.generateInfrastructureComponents();
63
+ break;
64
+ case 'red-team-playbook':
65
+ deliverable.persistence = this.generatePersistenceMechanisms();
66
+ deliverable.infrastructure = this.generateInfrastructureComponents();
67
+ deliverable.procedures = this.generateRedTeamProcedures();
68
+ break;
69
+ }
70
+ return deliverable;
71
+ }
72
+ /**
73
+ * Extract tool outputs from conversation history
74
+ */
75
+ extractToolOutputs() {
76
+ for (const msg of this.conversationHistory) {
77
+ if (msg.role === 'tool' && typeof msg.content === 'string') {
78
+ const toolName = msg.name || 'unknown';
79
+ const existing = this.toolOutputs.get(toolName) || [];
80
+ existing.push(msg.content);
81
+ this.toolOutputs.set(toolName, existing);
82
+ }
83
+ }
84
+ }
85
+ /**
86
+ * Extract security findings from conversation and tool outputs
87
+ */
88
+ extractFindings() {
89
+ const findingPatterns = [
90
+ { pattern: /vulnerability|vuln|cve-\d+/i, severity: 'high' },
91
+ { pattern: /open\s+port|exposed\s+service/i, severity: 'medium' },
92
+ { pattern: /missing\s+header|security\s+header/i, severity: 'medium' },
93
+ { pattern: /credential|password|secret|key\s*=/i, severity: 'critical' },
94
+ { pattern: /injection|xss|sqli|rce|lfi|rfi/i, severity: 'critical' },
95
+ { pattern: /misconfiguration|default\s+config/i, severity: 'medium' },
96
+ { pattern: /information\s+disclosure|version\s+disclosure/i, severity: 'low' },
97
+ ];
98
+ let findingId = 1;
99
+ for (const [toolName, outputs] of this.toolOutputs) {
100
+ for (const output of outputs) {
101
+ for (const { pattern, severity } of findingPatterns) {
102
+ const matches = output.match(pattern);
103
+ if (matches) {
104
+ const finding = this.createFinding(`FIND-${String(findingId++).padStart(3, '0')}`, matches[0], severity, output, toolName);
105
+ this.findings.push(finding);
106
+ }
107
+ }
108
+ }
109
+ }
110
+ // Deduplicate by title
111
+ const seen = new Set();
112
+ this.findings = this.findings.filter(f => {
113
+ const key = f.title.toLowerCase();
114
+ if (seen.has(key))
115
+ return false;
116
+ seen.add(key);
117
+ return true;
118
+ });
119
+ }
120
+ /**
121
+ * Create a security finding from detected pattern
122
+ */
123
+ createFinding(id, match, severity, evidence, source) {
124
+ return {
125
+ id,
126
+ title: this.titleCase(match),
127
+ severity,
128
+ description: `Security issue detected: ${match}`,
129
+ evidence: [evidence.slice(0, 500)],
130
+ affectedAssets: this.extractAffectedAssets(evidence),
131
+ technicalDetails: evidence,
132
+ businessImpact: this.getBusinessImpact(severity),
133
+ remediation: this.generateRemediation(match, severity),
134
+ references: this.getReferences(match),
135
+ timeline: {
136
+ discovered: Date.now(),
137
+ },
138
+ };
139
+ }
140
+ /**
141
+ * Generate title for the deliverable
142
+ */
143
+ generateTitle(type, options) {
144
+ const titles = {
145
+ 'pentest-report': 'Penetration Test Report',
146
+ 'incident-response': 'Incident Response Procedures',
147
+ 'security-controls': 'Security Controls Assessment',
148
+ 'training-module': 'Security Awareness Training Module',
149
+ 'compliance-audit': 'Compliance Audit Report',
150
+ 'threat-assessment': 'Threat Assessment Report',
151
+ 'apt-analysis': 'APT Kill-Chain Analysis',
152
+ 'vulnerability-report': 'Vulnerability Assessment Report',
153
+ 'infrastructure-assessment': 'Infrastructure Security Assessment',
154
+ 'persistence-procedures': 'Persistence Mechanism Documentation',
155
+ 'red-team-playbook': 'Red Team Operations Playbook',
156
+ };
157
+ return options.customTitle || titles[type] || 'Security Assessment Report';
158
+ }
159
+ /**
160
+ * Generate executive summary based on findings
161
+ */
162
+ generateExecutiveSummary(type, result) {
163
+ const criticalCount = this.findings.filter(f => f.severity === 'critical').length;
164
+ const highCount = this.findings.filter(f => f.severity === 'high').length;
165
+ const riskLevel = criticalCount > 0 ? 'CRITICAL' : highCount > 2 ? 'HIGH' : highCount > 0 ? 'MEDIUM' : 'LOW';
166
+ const summaries = {
167
+ 'pentest-report': `
168
+ ## Executive Summary
169
+
170
+ This penetration test identified **${this.findings.length}** security findings, including **${criticalCount}** critical and **${highCount}** high severity issues. The overall security posture is assessed as **${riskLevel}**.
171
+
172
+ ### Key Findings
173
+ ${this.findings.slice(0, 5).map(f => `- **${f.severity.toUpperCase()}**: ${f.title}`).join('\n')}
174
+
175
+ ### Immediate Actions Required
176
+ ${criticalCount > 0 ? '1. Address all critical findings within 24-48 hours\n2. Implement emergency patches for exposed vulnerabilities\n3. Review access controls and credential management' : '1. Review and prioritize high severity findings\n2. Implement recommended security controls\n3. Schedule follow-up assessment'}
177
+
178
+ ### Tools & Techniques Used
179
+ ${result.toolsUsed.slice(0, 10).join(', ')}
180
+ `,
181
+ 'incident-response': `
182
+ ## Executive Summary
183
+
184
+ This document provides comprehensive incident response procedures for security events. It includes ${this.findings.length > 0 ? `response procedures for ${this.findings.length} identified threat scenarios` : 'standard response procedures'}.
185
+
186
+ ### Coverage
187
+ - Detection and triage procedures
188
+ - Containment strategies
189
+ - Eradication steps
190
+ - Recovery procedures
191
+ - Post-incident analysis
192
+
193
+ ### Response Readiness: ${riskLevel === 'LOW' ? 'PREPARED' : 'NEEDS IMPROVEMENT'}
194
+ `,
195
+ 'security-controls': `
196
+ ## Executive Summary
197
+
198
+ Security controls assessment covering technical, administrative, and physical controls. Assessment identified gaps requiring attention.
199
+
200
+ ### Control Categories Assessed
201
+ - Access Control
202
+ - Network Security
203
+ - Data Protection
204
+ - Incident Response
205
+ - Business Continuity
206
+ - Compliance Requirements
207
+ `,
208
+ 'training-module': `
209
+ ## Executive Summary
210
+
211
+ Security awareness training module designed to educate personnel on security best practices and threat awareness.
212
+
213
+ ### Training Objectives
214
+ - Recognize common attack vectors
215
+ - Understand security policies
216
+ - Practice secure behaviors
217
+ - Report security incidents
218
+ `,
219
+ 'compliance-audit': `
220
+ ## Executive Summary
221
+
222
+ Compliance audit report assessing alignment with security frameworks and regulatory requirements.
223
+
224
+ ### Compliance Status: ${riskLevel === 'LOW' ? 'COMPLIANT' : 'PARTIALLY COMPLIANT'}
225
+ `,
226
+ 'threat-assessment': `
227
+ ## Executive Summary
228
+
229
+ Threat assessment analyzing potential adversaries, attack vectors, and organizational risk exposure.
230
+
231
+ ### Threat Level: ${riskLevel}
232
+ ${this.findings.length} potential threat vectors identified.
233
+ `,
234
+ 'apt-analysis': `
235
+ ## Executive Summary
236
+
237
+ Advanced Persistent Threat (APT) analysis documenting kill-chain phases, techniques, tactics, and procedures (TTPs).
238
+
239
+ ### Kill-Chain Coverage
240
+ - Reconnaissance
241
+ - Weaponization
242
+ - Delivery
243
+ - Exploitation
244
+ - Installation
245
+ - Command & Control
246
+ - Actions on Objectives
247
+ `,
248
+ 'vulnerability-report': `
249
+ ## Executive Summary
250
+
251
+ Vulnerability assessment identified **${this.findings.length}** security issues across the target environment.
252
+
253
+ ### Risk Distribution
254
+ - Critical: ${criticalCount}
255
+ - High: ${highCount}
256
+ - Medium: ${this.findings.filter(f => f.severity === 'medium').length}
257
+ - Low: ${this.findings.filter(f => f.severity === 'low').length}
258
+ - Info: ${this.findings.filter(f => f.severity === 'info').length}
259
+ `,
260
+ 'infrastructure-assessment': `
261
+ ## Executive Summary
262
+
263
+ Infrastructure security assessment evaluating network architecture, systems configuration, and operational security.
264
+
265
+ ### Infrastructure Components Assessed
266
+ - Network perimeter
267
+ - Internal segmentation
268
+ - Cloud resources
269
+ - Endpoint security
270
+ `,
271
+ 'persistence-procedures': `
272
+ ## Executive Summary
273
+
274
+ Documentation of persistence mechanisms for authorized red team operations and security testing.
275
+
276
+ ### Mechanisms Documented
277
+ - Registry-based persistence
278
+ - Service manipulation
279
+ - Scheduled tasks
280
+ - Startup modifications
281
+ - DLL-based techniques
282
+ `,
283
+ 'red-team-playbook': `
284
+ ## Executive Summary
285
+
286
+ Comprehensive red team operations playbook for authorized adversary simulation.
287
+
288
+ ### Playbook Contents
289
+ - Infrastructure setup
290
+ - Initial access techniques
291
+ - Persistence mechanisms
292
+ - Lateral movement
293
+ - Data exfiltration
294
+ - Operational security
295
+ `,
296
+ };
297
+ return summaries[type] || summaries['pentest-report'];
298
+ }
299
+ /**
300
+ * Generate scope documentation
301
+ */
302
+ generateScope(options) {
303
+ return {
304
+ targets: options.targets || this.extractTargets(),
305
+ excludedTargets: options.excludedTargets || [],
306
+ timeframe: {
307
+ start: options.startTime || Date.now() - 86400000,
308
+ end: options.endTime || Date.now(),
309
+ },
310
+ constraints: options.constraints || ['Standard rules of engagement apply'],
311
+ authorizationRef: options.authorizationRef || 'AUTH-' + Date.now().toString(36),
312
+ };
313
+ }
314
+ /**
315
+ * Get methodology based on deliverable type
316
+ */
317
+ getMethodology(type) {
318
+ const methodologies = {
319
+ 'pentest-report': [
320
+ 'PTES (Penetration Testing Execution Standard)',
321
+ 'OWASP Testing Guide v4',
322
+ 'NIST SP 800-115',
323
+ 'MITRE ATT&CK Framework',
324
+ ],
325
+ 'incident-response': [
326
+ 'NIST SP 800-61 Rev. 2',
327
+ 'SANS Incident Handler\'s Handbook',
328
+ 'ISO 27035',
329
+ ],
330
+ 'security-controls': [
331
+ 'NIST CSF',
332
+ 'CIS Controls v8',
333
+ 'ISO 27001/27002',
334
+ ],
335
+ 'training-module': [
336
+ 'NIST SP 800-50',
337
+ 'SANS Security Awareness',
338
+ ],
339
+ 'compliance-audit': [
340
+ 'SOC 2 Type II',
341
+ 'ISO 27001',
342
+ 'PCI DSS v4.0',
343
+ 'HIPAA Security Rule',
344
+ ],
345
+ 'threat-assessment': [
346
+ 'STRIDE',
347
+ 'DREAD',
348
+ 'MITRE ATT&CK',
349
+ 'Cyber Kill Chain',
350
+ ],
351
+ 'apt-analysis': [
352
+ 'Lockheed Martin Cyber Kill Chain',
353
+ 'MITRE ATT&CK Enterprise',
354
+ 'Diamond Model',
355
+ ],
356
+ 'vulnerability-report': [
357
+ 'CVSS v3.1',
358
+ 'CWE',
359
+ 'OWASP Top 10',
360
+ ],
361
+ 'infrastructure-assessment': [
362
+ 'CIS Benchmarks',
363
+ 'NIST SP 800-53',
364
+ 'Cloud Security Alliance',
365
+ ],
366
+ 'persistence-procedures': [
367
+ 'MITRE ATT&CK Persistence Tactics',
368
+ 'Red Team Operations Guide',
369
+ ],
370
+ 'red-team-playbook': [
371
+ 'MITRE ATT&CK Framework',
372
+ 'Adversary Simulation Framework',
373
+ 'Red Team Operations Methodology',
374
+ ],
375
+ };
376
+ return methodologies[type] || methodologies['pentest-report'];
377
+ }
378
+ /**
379
+ * Calculate metrics from the assessment
380
+ */
381
+ calculateMetrics(result) {
382
+ const bySeverity = {
383
+ critical: 0,
384
+ high: 0,
385
+ medium: 0,
386
+ low: 0,
387
+ info: 0,
388
+ };
389
+ const byCategory = {};
390
+ for (const finding of this.findings) {
391
+ bySeverity[finding.severity]++;
392
+ const category = this.categorize(finding);
393
+ byCategory[category] = (byCategory[category] || 0) + 1;
394
+ }
395
+ const riskScore = this.calculateRiskScore(bySeverity);
396
+ const chainStats = getChainStats();
397
+ const rlState = getRLState();
398
+ return {
399
+ totalFindings: this.findings.length,
400
+ bySeverity,
401
+ byCategory,
402
+ remediationProgress: 0,
403
+ riskScore,
404
+ toolsUsed: result.toolsUsed,
405
+ techniquesExecuted: rlState.topActions.map(a => a.action),
406
+ chainStats: {
407
+ total: chainStats.total,
408
+ completed: chainStats.completed,
409
+ failed: chainStats.failed,
410
+ avgReward: chainStats.avgReward,
411
+ },
412
+ };
413
+ }
414
+ /**
415
+ * Generate incident response procedures
416
+ */
417
+ generateIncidentProcedures() {
418
+ const procedures = [
419
+ {
420
+ id: 'IR-001',
421
+ name: 'Malware Infection Response',
422
+ triggerConditions: [
423
+ 'Antivirus alert triggered',
424
+ 'Suspicious process detected',
425
+ 'Network anomaly indicating C2 traffic',
426
+ ],
427
+ severity: 'high',
428
+ responseSteps: [
429
+ {
430
+ order: 1,
431
+ action: 'Isolate affected system from network',
432
+ responsible: 'SOC Analyst',
433
+ timeframe: '15 minutes',
434
+ tools: ['Network switch', 'EDR console'],
435
+ outputs: ['Isolation confirmation', 'Initial triage notes'],
436
+ decisionPoints: ['Is system critical?', 'Are other systems affected?'],
437
+ },
438
+ {
439
+ order: 2,
440
+ action: 'Capture volatile memory and disk image',
441
+ responsible: 'Forensics Team',
442
+ timeframe: '2 hours',
443
+ tools: ['FTK Imager', 'Volatility', 'dd'],
444
+ outputs: ['Memory dump', 'Disk image', 'Hash values'],
445
+ decisionPoints: ['Evidence preservation priority'],
446
+ },
447
+ {
448
+ order: 3,
449
+ action: 'Analyze malware sample',
450
+ responsible: 'Malware Analyst',
451
+ timeframe: '4 hours',
452
+ tools: ['Sandbox', 'IDA Pro', 'Ghidra'],
453
+ outputs: ['IOCs', 'Behavior analysis', 'Network indicators'],
454
+ decisionPoints: ['Is this known malware?', 'Severity assessment'],
455
+ },
456
+ ],
457
+ escalationPath: [
458
+ { level: 1, criteria: 'Single system affected', contacts: ['SOC Lead'], timeframe: '30 minutes' },
459
+ { level: 2, criteria: 'Multiple systems affected', contacts: ['IR Manager', 'CISO'], timeframe: '1 hour' },
460
+ { level: 3, criteria: 'Critical systems compromised', contacts: ['Executive Team', 'Legal'], timeframe: '2 hours' },
461
+ ],
462
+ communicationPlan: [
463
+ { audience: 'IT Team', timing: 'Immediate', channel: 'Slack/Teams', template: 'Security incident in progress. Stand by for instructions.' },
464
+ { audience: 'Management', timing: 'Within 1 hour', channel: 'Email', template: 'Security incident notification - details to follow.' },
465
+ { audience: 'External', timing: 'As required', channel: 'Official statement', template: 'Prepared PR statement' },
466
+ ],
467
+ recoveryProcedures: [
468
+ 'Verify malware removal',
469
+ 'Restore from clean backup',
470
+ 'Reset all credentials',
471
+ 'Monitor for reinfection',
472
+ ],
473
+ postIncidentActions: [
474
+ 'Complete incident report',
475
+ 'Update detection rules',
476
+ 'Conduct lessons learned session',
477
+ 'Update response procedures',
478
+ ],
479
+ },
480
+ {
481
+ id: 'IR-002',
482
+ name: 'Data Breach Response',
483
+ triggerConditions: [
484
+ 'Unusual data exfiltration detected',
485
+ 'Unauthorized access to sensitive data',
486
+ 'Third-party breach notification',
487
+ ],
488
+ severity: 'critical',
489
+ responseSteps: [
490
+ {
491
+ order: 1,
492
+ action: 'Assess scope of data exposure',
493
+ responsible: 'IR Lead',
494
+ timeframe: '2 hours',
495
+ tools: ['DLP logs', 'SIEM', 'Database audit logs'],
496
+ outputs: ['Data classification', 'Affected records count', 'Data types exposed'],
497
+ decisionPoints: ['Is PII involved?', 'Regulatory notification required?'],
498
+ },
499
+ {
500
+ order: 2,
501
+ action: 'Contain the breach',
502
+ responsible: 'Security Team',
503
+ timeframe: '4 hours',
504
+ tools: ['Firewall', 'IAM system', 'DLP'],
505
+ outputs: ['Containment confirmation', 'Access revocations'],
506
+ decisionPoints: ['Block source IPs?', 'Disable compromised accounts?'],
507
+ },
508
+ ],
509
+ escalationPath: [
510
+ { level: 1, criteria: 'Non-sensitive data', contacts: ['Security Manager'], timeframe: '1 hour' },
511
+ { level: 2, criteria: 'PII affected', contacts: ['DPO', 'Legal', 'CISO'], timeframe: '4 hours' },
512
+ { level: 3, criteria: 'Regulatory breach', contacts: ['Board', 'External counsel'], timeframe: '24 hours' },
513
+ ],
514
+ communicationPlan: [
515
+ { audience: 'Legal', timing: 'Immediate', channel: 'Phone', template: 'Potential data breach - legal review needed' },
516
+ { audience: 'Regulators', timing: 'Within 72 hours', channel: 'Official filing', template: 'Breach notification template' },
517
+ { audience: 'Affected individuals', timing: 'Within 30 days', channel: 'Email/Mail', template: 'Breach notification letter' },
518
+ ],
519
+ recoveryProcedures: [
520
+ 'Implement additional controls',
521
+ 'Offer credit monitoring if PII affected',
522
+ 'Conduct third-party security audit',
523
+ ],
524
+ postIncidentActions: [
525
+ 'File regulatory notifications',
526
+ 'Document timeline and response',
527
+ 'Implement preventive controls',
528
+ ],
529
+ },
530
+ {
531
+ id: 'IR-003',
532
+ name: 'Ransomware Attack Response',
533
+ triggerConditions: [
534
+ 'Ransomware note discovered',
535
+ 'Mass file encryption detected',
536
+ 'System unavailability',
537
+ ],
538
+ severity: 'critical',
539
+ responseSteps: [
540
+ {
541
+ order: 1,
542
+ action: 'Immediately isolate all affected systems',
543
+ responsible: 'IT Operations',
544
+ timeframe: '5 minutes',
545
+ tools: ['Network isolation', 'Kill switch'],
546
+ outputs: ['Isolation confirmation', 'Affected systems list'],
547
+ decisionPoints: ['Scope of infection', 'Critical systems status'],
548
+ },
549
+ {
550
+ order: 2,
551
+ action: 'Preserve evidence and identify variant',
552
+ responsible: 'Forensics Team',
553
+ timeframe: '1 hour',
554
+ tools: ['ID Ransomware', 'Sample collection'],
555
+ outputs: ['Ransomware variant ID', 'Encryption analysis'],
556
+ decisionPoints: ['Is decryption possible?', 'Known vulnerabilities in ransomware?'],
557
+ },
558
+ {
559
+ order: 3,
560
+ action: 'Assess backup integrity',
561
+ responsible: 'Backup Administrator',
562
+ timeframe: '2 hours',
563
+ tools: ['Backup system', 'Air-gapped copies'],
564
+ outputs: ['Backup status report', 'Recovery time estimate'],
565
+ decisionPoints: ['Are backups clean?', 'Recovery priority order'],
566
+ },
567
+ ],
568
+ escalationPath: [
569
+ { level: 1, criteria: 'Limited systems', contacts: ['IT Director', 'CISO'], timeframe: '15 minutes' },
570
+ { level: 2, criteria: 'Critical systems affected', contacts: ['CEO', 'Board'], timeframe: '1 hour' },
571
+ { level: 3, criteria: 'Business operations halted', contacts: ['External IR firm', 'Law enforcement'], timeframe: '2 hours' },
572
+ ],
573
+ communicationPlan: [
574
+ { audience: 'All employees', timing: 'Immediate', channel: 'All channels', template: 'Do not access any systems. Wait for instructions.' },
575
+ { audience: 'Law enforcement', timing: 'Within 24 hours', channel: 'FBI IC3 / Local', template: 'Ransomware incident report' },
576
+ ],
577
+ recoveryProcedures: [
578
+ 'Do NOT pay ransom without authorization',
579
+ 'Restore from clean backups',
580
+ 'Rebuild affected systems',
581
+ 'Implement enhanced monitoring',
582
+ ],
583
+ postIncidentActions: [
584
+ 'Full security assessment',
585
+ 'Implement email security improvements',
586
+ 'Enhanced backup procedures',
587
+ 'Staff training on phishing',
588
+ ],
589
+ },
590
+ ];
591
+ return procedures;
592
+ }
593
+ /**
594
+ * Generate security controls checklist
595
+ */
596
+ generateSecurityControls() {
597
+ return [
598
+ {
599
+ id: 'AC-1',
600
+ name: 'Access Control Policy',
601
+ category: 'Access Control',
602
+ framework: 'NIST CSF',
603
+ status: 'implemented',
604
+ evidence: 'Policy document reviewed and approved',
605
+ gaps: [],
606
+ recommendations: ['Annual review scheduled'],
607
+ },
608
+ {
609
+ id: 'AC-2',
610
+ name: 'Multi-Factor Authentication',
611
+ category: 'Access Control',
612
+ framework: 'NIST CSF',
613
+ status: 'partial',
614
+ evidence: 'MFA enabled for admin accounts',
615
+ gaps: ['MFA not enforced for all users', 'Service accounts exempt'],
616
+ recommendations: ['Enforce MFA for all users', 'Implement conditional access'],
617
+ },
618
+ {
619
+ id: 'AC-3',
620
+ name: 'Least Privilege',
621
+ category: 'Access Control',
622
+ framework: 'CIS Controls',
623
+ status: 'partial',
624
+ evidence: 'Role-based access implemented',
625
+ gaps: ['Excessive admin accounts', 'Periodic access review needed'],
626
+ recommendations: ['Quarterly access reviews', 'Admin account audit'],
627
+ },
628
+ {
629
+ id: 'NS-1',
630
+ name: 'Network Segmentation',
631
+ category: 'Network Security',
632
+ framework: 'CIS Controls',
633
+ status: 'implemented',
634
+ evidence: 'VLANs configured for different zones',
635
+ gaps: [],
636
+ recommendations: ['Implement microsegmentation'],
637
+ },
638
+ {
639
+ id: 'NS-2',
640
+ name: 'Firewall Configuration',
641
+ category: 'Network Security',
642
+ framework: 'CIS Controls',
643
+ status: 'implemented',
644
+ evidence: 'Firewall rules reviewed',
645
+ gaps: ['Some legacy rules need cleanup'],
646
+ recommendations: ['Firewall rule audit', 'Remove unused rules'],
647
+ },
648
+ {
649
+ id: 'DP-1',
650
+ name: 'Data Encryption at Rest',
651
+ category: 'Data Protection',
652
+ framework: 'ISO 27001',
653
+ status: 'partial',
654
+ evidence: 'Database encryption enabled',
655
+ gaps: ['File shares not encrypted', 'Endpoint encryption incomplete'],
656
+ recommendations: ['Full disk encryption on all endpoints', 'Encrypt file shares'],
657
+ },
658
+ {
659
+ id: 'DP-2',
660
+ name: 'Data Encryption in Transit',
661
+ category: 'Data Protection',
662
+ framework: 'ISO 27001',
663
+ status: 'implemented',
664
+ evidence: 'TLS 1.2+ enforced',
665
+ gaps: [],
666
+ recommendations: ['Upgrade to TLS 1.3 where possible'],
667
+ },
668
+ {
669
+ id: 'IR-1',
670
+ name: 'Incident Response Plan',
671
+ category: 'Incident Response',
672
+ framework: 'NIST CSF',
673
+ status: 'implemented',
674
+ evidence: 'IR plan documented and tested',
675
+ gaps: ['Last tabletop was 8 months ago'],
676
+ recommendations: ['Quarterly tabletop exercises'],
677
+ },
678
+ {
679
+ id: 'VM-1',
680
+ name: 'Vulnerability Management',
681
+ category: 'Vulnerability Management',
682
+ framework: 'CIS Controls',
683
+ status: 'implemented',
684
+ evidence: 'Weekly vulnerability scans',
685
+ gaps: ['Patch lag for critical vulns > 7 days'],
686
+ recommendations: ['Reduce critical patch SLA to 72 hours'],
687
+ },
688
+ {
689
+ id: 'LM-1',
690
+ name: 'Centralized Logging',
691
+ category: 'Logging & Monitoring',
692
+ framework: 'CIS Controls',
693
+ status: 'implemented',
694
+ evidence: 'SIEM deployed with all critical sources',
695
+ gaps: ['Some cloud services not integrated'],
696
+ recommendations: ['Integrate all cloud service logs'],
697
+ },
698
+ ];
699
+ }
700
+ /**
701
+ * Generate training modules
702
+ */
703
+ generateTrainingModules() {
704
+ return [
705
+ {
706
+ id: 'TM-001',
707
+ title: 'Security Awareness Fundamentals',
708
+ targetAudience: ['All employees', 'New hires'],
709
+ objectives: [
710
+ 'Understand common cyber threats',
711
+ 'Recognize phishing attempts',
712
+ 'Follow secure password practices',
713
+ 'Report security incidents properly',
714
+ ],
715
+ duration: '45 minutes',
716
+ prerequisites: ['Company email account'],
717
+ content: [
718
+ {
719
+ title: 'Introduction to Cybersecurity',
720
+ type: 'lecture',
721
+ duration: '10 minutes',
722
+ content: 'Overview of the threat landscape and why security matters to our organization.',
723
+ keyPoints: [
724
+ 'Cyber attacks are increasing',
725
+ 'Everyone is a target',
726
+ 'Human error causes most breaches',
727
+ ],
728
+ },
729
+ {
730
+ title: 'Phishing Attack Recognition',
731
+ type: 'demo',
732
+ duration: '15 minutes',
733
+ content: 'Live demonstration of phishing techniques and red flags to watch for.',
734
+ keyPoints: [
735
+ 'Check sender email addresses carefully',
736
+ 'Hover over links before clicking',
737
+ 'Verify unexpected attachments',
738
+ 'When in doubt, report it',
739
+ ],
740
+ },
741
+ {
742
+ title: 'Phishing Exercise',
743
+ type: 'exercise',
744
+ duration: '10 minutes',
745
+ content: 'Practice identifying phishing emails in simulated scenarios.',
746
+ keyPoints: [
747
+ 'Apply learned techniques',
748
+ 'Use reporting tools',
749
+ ],
750
+ },
751
+ {
752
+ title: 'Password Security',
753
+ type: 'lecture',
754
+ duration: '10 minutes',
755
+ content: 'Best practices for creating and managing secure passwords.',
756
+ keyPoints: [
757
+ 'Use unique passwords for each account',
758
+ 'Enable MFA everywhere',
759
+ 'Use a password manager',
760
+ 'Never share passwords',
761
+ ],
762
+ },
763
+ ],
764
+ assessment: [
765
+ {
766
+ type: 'quiz',
767
+ question: 'What should you do if you receive an unexpected email with an attachment from your CEO?',
768
+ options: [
769
+ 'Open it immediately - it\'s from the CEO',
770
+ 'Forward it to IT security',
771
+ 'Verify through another channel before opening',
772
+ 'Delete it without reading',
773
+ ],
774
+ correctAnswer: 'Verify through another channel before opening',
775
+ explanation: 'Always verify unexpected requests through a known, trusted channel, especially from executives.',
776
+ },
777
+ {
778
+ type: 'quiz',
779
+ question: 'Which is the strongest password?',
780
+ options: [
781
+ 'Password123!',
782
+ 'MyDog\'sName2024',
783
+ 'correct-horse-battery-staple',
784
+ 'P@ssw0rd',
785
+ ],
786
+ correctAnswer: 'correct-horse-battery-staple',
787
+ explanation: 'Long passphrases are more secure and easier to remember than complex short passwords.',
788
+ },
789
+ {
790
+ type: 'practical',
791
+ question: 'Report a simulated phishing email using the company reporting button.',
792
+ explanation: 'Practice using the actual reporting tools you\'ll use in a real scenario.',
793
+ },
794
+ ],
795
+ resources: [
796
+ 'NIST Cybersecurity Basics',
797
+ 'Company Security Policy',
798
+ 'IT Security Contact Information',
799
+ ],
800
+ },
801
+ {
802
+ id: 'TM-002',
803
+ title: 'Secure Development Practices',
804
+ targetAudience: ['Developers', 'DevOps engineers'],
805
+ objectives: [
806
+ 'Understand OWASP Top 10 vulnerabilities',
807
+ 'Implement secure coding practices',
808
+ 'Use security tools in CI/CD',
809
+ 'Handle sensitive data properly',
810
+ ],
811
+ duration: '2 hours',
812
+ prerequisites: ['Development experience', 'Access to code repositories'],
813
+ content: [
814
+ {
815
+ title: 'OWASP Top 10 Overview',
816
+ type: 'lecture',
817
+ duration: '30 minutes',
818
+ content: 'Detailed walkthrough of the OWASP Top 10 vulnerabilities.',
819
+ keyPoints: [
820
+ 'Injection attacks',
821
+ 'Broken authentication',
822
+ 'Sensitive data exposure',
823
+ 'Security misconfiguration',
824
+ ],
825
+ },
826
+ {
827
+ title: 'Secure Coding Lab',
828
+ type: 'lab',
829
+ duration: '45 minutes',
830
+ content: 'Hands-on exercises fixing vulnerable code samples.',
831
+ keyPoints: [
832
+ 'Input validation',
833
+ 'Parameterized queries',
834
+ 'Output encoding',
835
+ 'Error handling',
836
+ ],
837
+ },
838
+ {
839
+ title: 'Security in CI/CD',
840
+ type: 'demo',
841
+ duration: '30 minutes',
842
+ content: 'Integrating security scanning into development pipelines.',
843
+ keyPoints: [
844
+ 'SAST tools',
845
+ 'DAST integration',
846
+ 'Dependency scanning',
847
+ 'Container security',
848
+ ],
849
+ },
850
+ ],
851
+ assessment: [
852
+ {
853
+ type: 'practical',
854
+ question: 'Identify and fix the SQL injection vulnerability in the provided code.',
855
+ explanation: 'Use parameterized queries to prevent SQL injection.',
856
+ },
857
+ {
858
+ type: 'scenario',
859
+ question: 'You discover a vulnerability in production. Walk through the disclosure process.',
860
+ explanation: 'Understanding responsible disclosure protects the organization.',
861
+ },
862
+ ],
863
+ resources: [
864
+ 'OWASP Cheat Sheets',
865
+ 'Company Secure Coding Guidelines',
866
+ 'Security Tool Documentation',
867
+ ],
868
+ },
869
+ ];
870
+ }
871
+ /**
872
+ * Generate persistence mechanisms documentation
873
+ */
874
+ generatePersistenceMechanisms() {
875
+ return [
876
+ {
877
+ id: 'PERS-001',
878
+ name: 'Registry Run Key',
879
+ category: 'registry',
880
+ platform: 'windows',
881
+ stealthRating: 0.3,
882
+ detectionDifficulty: 'easy',
883
+ prerequisites: ['Local admin access'],
884
+ implementation: `
885
+ # Add registry run key for persistence
886
+ reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" /v "SecurityUpdate" /t REG_SZ /d "C:\\Windows\\Temp\\payload.exe" /f
887
+
888
+ # Verify persistence
889
+ reg query "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"
890
+ `,
891
+ artifacts: [
892
+ 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\SecurityUpdate',
893
+ 'C:\\Windows\\Temp\\payload.exe',
894
+ ],
895
+ detectionIndicators: [
896
+ 'Registry modification event (Sysmon Event ID 12/13)',
897
+ 'Process creation from unusual location',
898
+ 'Autoruns showing new entry',
899
+ ],
900
+ removalProcedure: [
901
+ 'reg delete "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" /v "SecurityUpdate" /f',
902
+ 'Remove payload file',
903
+ 'Verify removal with Autoruns',
904
+ ],
905
+ mitreTechnique: 'T1547.001',
906
+ },
907
+ {
908
+ id: 'PERS-002',
909
+ name: 'Scheduled Task',
910
+ category: 'scheduled-task',
911
+ platform: 'windows',
912
+ stealthRating: 0.5,
913
+ detectionDifficulty: 'medium',
914
+ prerequisites: ['Local admin access'],
915
+ implementation: `
916
+ # Create scheduled task for persistence
917
+ schtasks /create /tn "WindowsUpdate" /tr "C:\\Windows\\Temp\\payload.exe" /sc onlogon /ru SYSTEM
918
+
919
+ # Verify task creation
920
+ schtasks /query /tn "WindowsUpdate"
921
+ `,
922
+ artifacts: [
923
+ 'C:\\Windows\\System32\\Tasks\\WindowsUpdate',
924
+ 'Task Scheduler Library entry',
925
+ ],
926
+ detectionIndicators: [
927
+ 'Task Scheduler event (Event ID 4698)',
928
+ 'Sysmon Event ID 1 from taskeng.exe',
929
+ 'Unusual scheduled task names',
930
+ ],
931
+ removalProcedure: [
932
+ 'schtasks /delete /tn "WindowsUpdate" /f',
933
+ 'Remove payload file',
934
+ 'Audit remaining scheduled tasks',
935
+ ],
936
+ mitreTechnique: 'T1053.005',
937
+ },
938
+ {
939
+ id: 'PERS-003',
940
+ name: 'Systemd Service',
941
+ category: 'service',
942
+ platform: 'linux',
943
+ stealthRating: 0.6,
944
+ detectionDifficulty: 'medium',
945
+ prerequisites: ['Root access'],
946
+ implementation: `
947
+ # Create systemd service unit
948
+ cat > /etc/systemd/system/security-update.service << EOF
949
+ [Unit]
950
+ Description=Security Update Service
951
+
952
+ [Service]
953
+ Type=simple
954
+ ExecStart=/usr/local/bin/payload
955
+ Restart=always
956
+ RestartSec=60
957
+
958
+ [Install]
959
+ WantedBy=multi-user.target
960
+ EOF
961
+
962
+ # Enable and start service
963
+ systemctl daemon-reload
964
+ systemctl enable security-update.service
965
+ systemctl start security-update.service
966
+ `,
967
+ artifacts: [
968
+ '/etc/systemd/system/security-update.service',
969
+ '/usr/local/bin/payload',
970
+ ],
971
+ detectionIndicators: [
972
+ 'New systemd unit file',
973
+ 'Unusual service running',
974
+ 'journalctl showing unknown service',
975
+ ],
976
+ removalProcedure: [
977
+ 'systemctl stop security-update.service',
978
+ 'systemctl disable security-update.service',
979
+ 'rm /etc/systemd/system/security-update.service',
980
+ 'systemctl daemon-reload',
981
+ 'rm /usr/local/bin/payload',
982
+ ],
983
+ mitreTechnique: 'T1543.002',
984
+ },
985
+ {
986
+ id: 'PERS-004',
987
+ name: 'Cron Job',
988
+ category: 'scheduled-task',
989
+ platform: 'linux',
990
+ stealthRating: 0.5,
991
+ detectionDifficulty: 'easy',
992
+ prerequisites: ['User or root access'],
993
+ implementation: `
994
+ # Add cron job for persistence
995
+ echo "*/5 * * * * /tmp/.hidden/payload" | crontab -
996
+
997
+ # Or add to system cron
998
+ echo "*/5 * * * * root /tmp/.hidden/payload" >> /etc/crontab
999
+ `,
1000
+ artifacts: [
1001
+ '/var/spool/cron/crontabs/<user>',
1002
+ '/etc/crontab',
1003
+ '/tmp/.hidden/payload',
1004
+ ],
1005
+ detectionIndicators: [
1006
+ 'Crontab modification',
1007
+ 'Unusual cron entries',
1008
+ 'Hidden directories in /tmp',
1009
+ ],
1010
+ removalProcedure: [
1011
+ 'crontab -r (for user cron)',
1012
+ 'Edit /etc/crontab to remove entry',
1013
+ 'rm -rf /tmp/.hidden',
1014
+ ],
1015
+ mitreTechnique: 'T1053.003',
1016
+ },
1017
+ {
1018
+ id: 'PERS-005',
1019
+ name: 'Launch Agent',
1020
+ category: 'startup',
1021
+ platform: 'macos',
1022
+ stealthRating: 0.4,
1023
+ detectionDifficulty: 'easy',
1024
+ prerequisites: ['User access'],
1025
+ implementation: `
1026
+ # Create Launch Agent plist
1027
+ cat > ~/Library/LaunchAgents/com.security.update.plist << EOF
1028
+ <?xml version="1.0" encoding="UTF-8"?>
1029
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN">
1030
+ <plist version="1.0">
1031
+ <dict>
1032
+ <key>Label</key>
1033
+ <string>com.security.update</string>
1034
+ <key>ProgramArguments</key>
1035
+ <array>
1036
+ <string>/Users/Shared/.hidden/payload</string>
1037
+ </array>
1038
+ <key>RunAtLoad</key>
1039
+ <true/>
1040
+ <key>KeepAlive</key>
1041
+ <true/>
1042
+ </dict>
1043
+ </plist>
1044
+ EOF
1045
+
1046
+ # Load the agent
1047
+ launchctl load ~/Library/LaunchAgents/com.security.update.plist
1048
+ `,
1049
+ artifacts: [
1050
+ '~/Library/LaunchAgents/com.security.update.plist',
1051
+ '/Users/Shared/.hidden/payload',
1052
+ ],
1053
+ detectionIndicators: [
1054
+ 'New LaunchAgent plist',
1055
+ 'launchctl list showing unknown agent',
1056
+ 'Unified logs showing agent load',
1057
+ ],
1058
+ removalProcedure: [
1059
+ 'launchctl unload ~/Library/LaunchAgents/com.security.update.plist',
1060
+ 'rm ~/Library/LaunchAgents/com.security.update.plist',
1061
+ 'rm -rf /Users/Shared/.hidden',
1062
+ ],
1063
+ mitreTechnique: 'T1543.001',
1064
+ },
1065
+ {
1066
+ id: 'PERS-006',
1067
+ name: 'DLL Search Order Hijacking',
1068
+ category: 'dll',
1069
+ platform: 'windows',
1070
+ stealthRating: 0.7,
1071
+ detectionDifficulty: 'hard',
1072
+ prerequisites: ['Write access to application directory'],
1073
+ implementation: `
1074
+ # Identify vulnerable application
1075
+ # Place malicious DLL in application directory
1076
+ # DLL will be loaded instead of legitimate version
1077
+
1078
+ # Common targets:
1079
+ # - Applications without full DLL paths
1080
+ # - Side-loading opportunities
1081
+ # - Missing DLLs that application tries to load
1082
+ `,
1083
+ artifacts: [
1084
+ 'Malicious DLL in application directory',
1085
+ 'May overwrite or supplement existing DLLs',
1086
+ ],
1087
+ detectionIndicators: [
1088
+ 'DLL loaded from unusual location',
1089
+ 'Sysmon Event ID 7',
1090
+ 'Hash mismatch on known DLLs',
1091
+ ],
1092
+ removalProcedure: [
1093
+ 'Identify and remove malicious DLL',
1094
+ 'Restore legitimate DLL if replaced',
1095
+ 'Verify application functionality',
1096
+ ],
1097
+ mitreTechnique: 'T1574.001',
1098
+ },
1099
+ ];
1100
+ }
1101
+ /**
1102
+ * Generate infrastructure components
1103
+ */
1104
+ generateInfrastructureComponents() {
1105
+ return [
1106
+ {
1107
+ id: 'INFRA-001',
1108
+ name: 'Primary C2 Server',
1109
+ type: 'c2-server',
1110
+ provider: 'Cloud VPS',
1111
+ configuration: {
1112
+ os: 'Ubuntu 22.04 LTS',
1113
+ specs: '4 vCPU, 8GB RAM, 100GB SSD',
1114
+ framework: 'Cobalt Strike / Mythic / Sliver',
1115
+ protocols: ['HTTPS', 'DNS', 'SMB'],
1116
+ malleable_profile: 'Custom jQuery profile',
1117
+ },
1118
+ opsecConsiderations: [
1119
+ 'Use clean IP with no prior malicious history',
1120
+ 'Domain fronting or CDN for traffic masking',
1121
+ 'Separate management interface from C2',
1122
+ 'Regular log rotation and cleanup',
1123
+ 'Kill switch implementation',
1124
+ ],
1125
+ setupProcedure: [
1126
+ 'Provision VPS from clean account',
1127
+ 'Harden OS (disable services, firewall)',
1128
+ 'Install C2 framework',
1129
+ 'Configure TLS certificates',
1130
+ 'Set up domain fronting',
1131
+ 'Test connectivity',
1132
+ ],
1133
+ teardownProcedure: [
1134
+ 'Secure wipe of all data',
1135
+ 'Terminate VPS instance',
1136
+ 'Clean up DNS records',
1137
+ 'Document IOCs for deconfliction',
1138
+ ],
1139
+ monitoring: [
1140
+ 'Uptime monitoring',
1141
+ 'Certificate expiry alerts',
1142
+ 'Traffic anomaly detection',
1143
+ ],
1144
+ },
1145
+ {
1146
+ id: 'INFRA-002',
1147
+ name: 'HTTP Redirector',
1148
+ type: 'redirector',
1149
+ provider: 'Cloud VPS',
1150
+ configuration: {
1151
+ os: 'Debian 11',
1152
+ specs: '1 vCPU, 1GB RAM, 20GB SSD',
1153
+ software: 'Apache mod_rewrite / Nginx',
1154
+ rules: 'Conditional forwarding based on headers/URI',
1155
+ },
1156
+ opsecConsiderations: [
1157
+ 'Expendable infrastructure',
1158
+ 'Minimal logging',
1159
+ 'Geographic distribution',
1160
+ 'Fast spin-up capability',
1161
+ ],
1162
+ setupProcedure: [
1163
+ 'Deploy minimal VPS',
1164
+ 'Install and configure web server',
1165
+ 'Configure redirect rules',
1166
+ 'Point to C2 backend',
1167
+ 'Test redirection logic',
1168
+ ],
1169
+ teardownProcedure: [
1170
+ 'Destroy VPS instance',
1171
+ 'No data to preserve',
1172
+ ],
1173
+ monitoring: [
1174
+ 'Basic uptime check',
1175
+ 'Redirect success rate',
1176
+ ],
1177
+ },
1178
+ {
1179
+ id: 'INFRA-003',
1180
+ name: 'Payload Hosting',
1181
+ type: 'payload-host',
1182
+ provider: 'CDN / Object Storage',
1183
+ configuration: {
1184
+ service: 'AWS S3 / Azure Blob / GCS',
1185
+ access: 'Public read, authenticated write',
1186
+ caching: 'CDN caching for availability',
1187
+ },
1188
+ opsecConsiderations: [
1189
+ 'Use legitimate cloud services',
1190
+ 'Categorize as legitimate traffic',
1191
+ 'Payload obfuscation',
1192
+ 'Short-lived URLs',
1193
+ ],
1194
+ setupProcedure: [
1195
+ 'Create storage bucket',
1196
+ 'Configure access policies',
1197
+ 'Upload payloads',
1198
+ 'Enable CDN if needed',
1199
+ 'Generate presigned URLs',
1200
+ ],
1201
+ teardownProcedure: [
1202
+ 'Remove all objects',
1203
+ 'Delete bucket',
1204
+ 'Clean up IAM credentials',
1205
+ ],
1206
+ monitoring: [
1207
+ 'Download counts',
1208
+ 'Access patterns',
1209
+ 'Storage costs',
1210
+ ],
1211
+ },
1212
+ {
1213
+ id: 'INFRA-004',
1214
+ name: 'Exfiltration Endpoint',
1215
+ type: 'exfil-endpoint',
1216
+ provider: 'Cloud VPS',
1217
+ configuration: {
1218
+ os: 'Alpine Linux',
1219
+ specs: '2 vCPU, 2GB RAM, 50GB SSD',
1220
+ protocols: ['HTTPS', 'DNS', 'ICMP'],
1221
+ encryption: 'AES-256-GCM',
1222
+ },
1223
+ opsecConsiderations: [
1224
+ 'Separate from C2 infrastructure',
1225
+ 'Different provider/region',
1226
+ 'Encrypted data at rest',
1227
+ 'Rate limiting to avoid detection',
1228
+ ],
1229
+ setupProcedure: [
1230
+ 'Deploy minimal VPS',
1231
+ 'Configure receive endpoints',
1232
+ 'Set up encryption',
1233
+ 'Configure data handling',
1234
+ 'Test exfil channels',
1235
+ ],
1236
+ teardownProcedure: [
1237
+ 'Transfer data to secure storage',
1238
+ 'Secure wipe',
1239
+ 'Destroy instance',
1240
+ ],
1241
+ monitoring: [
1242
+ 'Data volume received',
1243
+ 'Connection success rate',
1244
+ 'Storage utilization',
1245
+ ],
1246
+ },
1247
+ ];
1248
+ }
1249
+ /**
1250
+ * Generate red team procedures
1251
+ */
1252
+ generateRedTeamProcedures() {
1253
+ return [
1254
+ {
1255
+ id: 'RT-001',
1256
+ name: 'Initial Access Procedure',
1257
+ triggerConditions: ['Engagement start', 'New target identified'],
1258
+ severity: 'info',
1259
+ responseSteps: [
1260
+ {
1261
+ order: 1,
1262
+ action: 'OSINT and passive reconnaissance',
1263
+ responsible: 'Red Team Lead',
1264
+ timeframe: '2-4 hours',
1265
+ tools: ['Maltego', 'Shodan', 'LinkedIn', 'theHarvester'],
1266
+ outputs: ['Target profile', 'Email addresses', 'Technology stack'],
1267
+ decisionPoints: ['Phishing vs technical entry', 'Target prioritization'],
1268
+ },
1269
+ {
1270
+ order: 2,
1271
+ action: 'Active reconnaissance',
1272
+ responsible: 'Red Team Operator',
1273
+ timeframe: '4-8 hours',
1274
+ tools: ['Nmap', 'Nuclei', 'Burp Suite'],
1275
+ outputs: ['Port scan results', 'Vulnerability assessment', 'Attack surface map'],
1276
+ decisionPoints: ['Exploit availability', 'Detection risk assessment'],
1277
+ },
1278
+ {
1279
+ order: 3,
1280
+ action: 'Initial access execution',
1281
+ responsible: 'Red Team Operator',
1282
+ timeframe: 'Variable',
1283
+ tools: ['Phishing framework', 'Exploit kit'],
1284
+ outputs: ['Beacon/shell', 'Initial foothold documentation'],
1285
+ decisionPoints: ['Persistence required?', 'Lateral movement needed?'],
1286
+ },
1287
+ ],
1288
+ escalationPath: [
1289
+ { level: 1, criteria: 'Normal operation', contacts: ['Team Lead'], timeframe: 'Daily' },
1290
+ { level: 2, criteria: 'Blue team detection', contacts: ['Engagement Manager'], timeframe: '1 hour' },
1291
+ { level: 3, criteria: 'Operational incident', contacts: ['Client POC'], timeframe: 'Immediate' },
1292
+ ],
1293
+ communicationPlan: [
1294
+ { audience: 'Red Team', timing: 'Continuous', channel: 'Secure chat', template: 'Operational updates' },
1295
+ { audience: 'Engagement Manager', timing: 'Daily', channel: 'Secure report', template: 'Daily SITREP' },
1296
+ ],
1297
+ recoveryProcedures: [
1298
+ 'Document all actions for deconfliction',
1299
+ 'Maintain detailed timestamps',
1300
+ 'Screenshot significant access',
1301
+ ],
1302
+ postIncidentActions: [
1303
+ 'Update attack narrative',
1304
+ 'Log IOCs for blue team',
1305
+ 'Prepare for debrief',
1306
+ ],
1307
+ },
1308
+ {
1309
+ id: 'RT-002',
1310
+ name: 'Privilege Escalation Procedure',
1311
+ triggerConditions: ['Initial foothold obtained', 'Need elevated access'],
1312
+ severity: 'medium',
1313
+ responseSteps: [
1314
+ {
1315
+ order: 1,
1316
+ action: 'Local enumeration',
1317
+ responsible: 'Red Team Operator',
1318
+ timeframe: '30 minutes',
1319
+ tools: ['winPEAS', 'linPEAS', 'Seatbelt'],
1320
+ outputs: ['System info', 'User context', 'Potential vectors'],
1321
+ decisionPoints: ['Local vs domain escalation', 'Quick wins available?'],
1322
+ },
1323
+ {
1324
+ order: 2,
1325
+ action: 'Attempt privilege escalation',
1326
+ responsible: 'Red Team Operator',
1327
+ timeframe: '2-4 hours',
1328
+ tools: ['Kernel exploits', 'Misconfig abuse', 'Token manipulation'],
1329
+ outputs: ['Elevated shell', 'Method documentation'],
1330
+ decisionPoints: ['Method selection', 'Cleanup required?'],
1331
+ },
1332
+ ],
1333
+ escalationPath: [
1334
+ { level: 1, criteria: 'Standard operation', contacts: ['Team Lead'], timeframe: 'Daily' },
1335
+ ],
1336
+ communicationPlan: [
1337
+ { audience: 'Red Team', timing: 'On success', channel: 'Secure chat', template: 'Elevated access achieved' },
1338
+ ],
1339
+ recoveryProcedures: [
1340
+ 'Document exploitation method',
1341
+ 'Note any system changes',
1342
+ ],
1343
+ postIncidentActions: [
1344
+ 'Update attack path documentation',
1345
+ ],
1346
+ },
1347
+ ];
1348
+ }
1349
+ /**
1350
+ * Generate appendices with raw data
1351
+ */
1352
+ generateAppendices() {
1353
+ const appendices = [];
1354
+ // Add tool outputs as appendices
1355
+ for (const [toolName, outputs] of this.toolOutputs) {
1356
+ if (outputs.length > 0) {
1357
+ appendices.push({
1358
+ id: `APP-${toolName.toUpperCase()}`,
1359
+ title: `${toolName} Output`,
1360
+ type: 'raw-output',
1361
+ content: outputs.join('\n---\n').slice(0, 10000),
1362
+ });
1363
+ }
1364
+ }
1365
+ // Add RL state
1366
+ const rlState = getRLState();
1367
+ appendices.push({
1368
+ id: 'APP-RL-STATE',
1369
+ title: 'Reinforcement Learning State',
1370
+ type: 'log',
1371
+ content: JSON.stringify(rlState, null, 2),
1372
+ });
1373
+ return appendices;
1374
+ }
1375
+ // ═══════════════════════════════════════════════════════════════════════════════
1376
+ // HELPER METHODS
1377
+ // ═══════════════════════════════════════════════════════════════════════════════
1378
+ extractTargets() {
1379
+ const targets = new Set();
1380
+ const ipPattern = /\b(?:\d{1,3}\.){3}\d{1,3}\b/g;
1381
+ const domainPattern = /\b(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}\b/gi;
1382
+ for (const [, outputs] of this.toolOutputs) {
1383
+ for (const output of outputs) {
1384
+ const ips = output.match(ipPattern);
1385
+ const domains = output.match(domainPattern);
1386
+ if (ips)
1387
+ ips.forEach(ip => targets.add(ip));
1388
+ if (domains)
1389
+ domains.forEach(d => targets.add(d));
1390
+ }
1391
+ }
1392
+ return Array.from(targets).slice(0, 20);
1393
+ }
1394
+ extractAffectedAssets(evidence) {
1395
+ const assets = [];
1396
+ const ipMatch = evidence.match(/\b(?:\d{1,3}\.){3}\d{1,3}\b/);
1397
+ const portMatch = evidence.match(/port\s*[:=]?\s*(\d+)/i);
1398
+ if (ipMatch)
1399
+ assets.push(ipMatch[0]);
1400
+ if (portMatch)
1401
+ assets.push(`Port ${portMatch[1]}`);
1402
+ return assets.length > 0 ? assets : ['Target system'];
1403
+ }
1404
+ getBusinessImpact(severity) {
1405
+ const impacts = {
1406
+ critical: 'Immediate risk of system compromise, data breach, or service disruption. Requires urgent remediation.',
1407
+ high: 'Significant security weakness that could lead to system compromise or data exposure.',
1408
+ medium: 'Security issue that could be exploited under certain conditions.',
1409
+ low: 'Minor security weakness with limited exploitation potential.',
1410
+ info: 'Informational finding for security awareness.',
1411
+ };
1412
+ return impacts[severity];
1413
+ }
1414
+ generateRemediation(match, severity) {
1415
+ return [{
1416
+ priority: severity === 'critical' ? 1 : severity === 'high' ? 2 : 3,
1417
+ action: `Address ${match} finding`,
1418
+ responsible: 'Security Team',
1419
+ effort: severity === 'critical' || severity === 'high' ? 'high' : 'medium',
1420
+ timeline: severity === 'critical' ? '24-48 hours' : severity === 'high' ? '1 week' : '30 days',
1421
+ verificationMethod: 'Re-scan and verify remediation',
1422
+ }];
1423
+ }
1424
+ getReferences(match) {
1425
+ const refs = [];
1426
+ if (/cve-\d+/i.test(match)) {
1427
+ refs.push('https://nvd.nist.gov/vuln/detail/' + match.toUpperCase());
1428
+ }
1429
+ refs.push('https://cwe.mitre.org/');
1430
+ refs.push('https://owasp.org/');
1431
+ return refs;
1432
+ }
1433
+ titleCase(str) {
1434
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
1435
+ }
1436
+ categorize(finding) {
1437
+ const title = finding.title.toLowerCase();
1438
+ if (/injection|xss|sqli/.test(title))
1439
+ return 'Injection';
1440
+ if (/auth|password|credential/.test(title))
1441
+ return 'Authentication';
1442
+ if (/config|misconfiguration/.test(title))
1443
+ return 'Configuration';
1444
+ if (/disclosure|exposure/.test(title))
1445
+ return 'Information Disclosure';
1446
+ if (/port|service/.test(title))
1447
+ return 'Network';
1448
+ return 'Other';
1449
+ }
1450
+ calculateRiskScore(bySeverity) {
1451
+ const weights = { critical: 10, high: 7, medium: 4, low: 2, info: 0.5 };
1452
+ let score = 0;
1453
+ for (const [sev, count] of Object.entries(bySeverity)) {
1454
+ score += (weights[sev] || 0) * count;
1455
+ }
1456
+ return Math.min(100, score);
1457
+ }
1458
+ }
1459
+ // ═══════════════════════════════════════════════════════════════════════════════
1460
+ // EXPORT FORMATTERS
1461
+ // ═══════════════════════════════════════════════════════════════════════════════
1462
+ export function exportToMarkdown(deliverable) {
1463
+ let md = `# ${deliverable.title}\n\n`;
1464
+ md += `**Document ID:** ${deliverable.id}\n`;
1465
+ md += `**Classification:** ${deliverable.classification.toUpperCase()}\n`;
1466
+ md += `**Version:** ${deliverable.version}\n`;
1467
+ md += `**Created:** ${new Date(deliverable.created).toISOString()}\n`;
1468
+ md += `**Author:** ${deliverable.author}\n\n`;
1469
+ md += `---\n\n`;
1470
+ md += deliverable.executiveSummary + '\n\n';
1471
+ md += `## Scope\n\n`;
1472
+ md += `**Targets:** ${deliverable.scope.targets.join(', ')}\n`;
1473
+ md += `**Timeframe:** ${new Date(deliverable.scope.timeframe.start).toISOString()} - ${new Date(deliverable.scope.timeframe.end).toISOString()}\n`;
1474
+ md += `**Authorization:** ${deliverable.scope.authorizationRef}\n\n`;
1475
+ md += `## Methodology\n\n`;
1476
+ deliverable.methodology.forEach(m => { md += `- ${m}\n`; });
1477
+ md += '\n';
1478
+ if (deliverable.findings.length > 0) {
1479
+ md += `## Findings\n\n`;
1480
+ for (const finding of deliverable.findings) {
1481
+ md += `### ${finding.id}: ${finding.title}\n\n`;
1482
+ md += `**Severity:** ${finding.severity.toUpperCase()}\n`;
1483
+ md += `**Description:** ${finding.description}\n\n`;
1484
+ md += `**Business Impact:** ${finding.businessImpact}\n\n`;
1485
+ md += `**Evidence:**\n\`\`\`\n${finding.evidence.join('\n')}\n\`\`\`\n\n`;
1486
+ md += `**Remediation:**\n`;
1487
+ finding.remediation.forEach(r => {
1488
+ md += `- ${r.action} (${r.timeline})\n`;
1489
+ });
1490
+ md += '\n';
1491
+ }
1492
+ }
1493
+ if (deliverable.procedures && deliverable.procedures.length > 0) {
1494
+ md += `## Procedures\n\n`;
1495
+ for (const proc of deliverable.procedures) {
1496
+ md += `### ${proc.id}: ${proc.name}\n\n`;
1497
+ md += `**Severity:** ${proc.severity.toUpperCase()}\n\n`;
1498
+ md += `**Trigger Conditions:**\n`;
1499
+ proc.triggerConditions.forEach(t => { md += `- ${t}\n`; });
1500
+ md += '\n**Response Steps:**\n';
1501
+ proc.responseSteps.forEach(step => {
1502
+ md += `${step.order}. **${step.action}** (${step.responsible}, ${step.timeframe})\n`;
1503
+ md += ` - Tools: ${step.tools.join(', ')}\n`;
1504
+ md += ` - Outputs: ${step.outputs.join(', ')}\n`;
1505
+ });
1506
+ md += '\n';
1507
+ }
1508
+ }
1509
+ if (deliverable.controls && deliverable.controls.length > 0) {
1510
+ md += `## Security Controls\n\n`;
1511
+ md += `| ID | Control | Status | Gaps |\n`;
1512
+ md += `|----|---------|--------|------|\n`;
1513
+ for (const ctrl of deliverable.controls) {
1514
+ md += `| ${ctrl.id} | ${ctrl.name} | ${ctrl.status} | ${ctrl.gaps.join('; ') || 'None'} |\n`;
1515
+ }
1516
+ md += '\n';
1517
+ }
1518
+ if (deliverable.persistence && deliverable.persistence.length > 0) {
1519
+ md += `## Persistence Mechanisms\n\n`;
1520
+ for (const pers of deliverable.persistence) {
1521
+ md += `### ${pers.id}: ${pers.name}\n\n`;
1522
+ md += `**Platform:** ${pers.platform}\n`;
1523
+ md += `**MITRE ATT&CK:** ${pers.mitreTechnique}\n`;
1524
+ md += `**Stealth Rating:** ${(pers.stealthRating * 100).toFixed(0)}%\n`;
1525
+ md += `**Detection Difficulty:** ${pers.detectionDifficulty}\n\n`;
1526
+ md += `**Implementation:**\n\`\`\`\n${pers.implementation}\n\`\`\`\n\n`;
1527
+ md += `**Artifacts:**\n`;
1528
+ pers.artifacts.forEach(a => { md += `- ${a}\n`; });
1529
+ md += `\n**Detection Indicators:**\n`;
1530
+ pers.detectionIndicators.forEach(d => { md += `- ${d}\n`; });
1531
+ md += '\n';
1532
+ }
1533
+ }
1534
+ md += `## Metrics\n\n`;
1535
+ md += `- Total Findings: ${deliverable.metrics.totalFindings}\n`;
1536
+ md += `- Risk Score: ${deliverable.metrics.riskScore}/100\n`;
1537
+ md += `- Severity Distribution:\n`;
1538
+ for (const [sev, count] of Object.entries(deliverable.metrics.bySeverity)) {
1539
+ if (count > 0)
1540
+ md += ` - ${sev}: ${count}\n`;
1541
+ }
1542
+ md += `- Tools Used: ${deliverable.metrics.toolsUsed.join(', ')}\n`;
1543
+ md += `- Attack Chain Stats: ${deliverable.metrics.chainStats.completed}/${deliverable.metrics.chainStats.total} completed\n`;
1544
+ return md;
1545
+ }
1546
+ export function exportToJSON(deliverable) {
1547
+ return JSON.stringify(deliverable, null, 2);
1548
+ }
1549
+ export function exportToHTML(deliverable) {
1550
+ const md = exportToMarkdown(deliverable);
1551
+ // Basic markdown to HTML conversion
1552
+ let html = `<!DOCTYPE html>
1553
+ <html>
1554
+ <head>
1555
+ <title>${deliverable.title}</title>
1556
+ <style>
1557
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 1200px; margin: 0 auto; padding: 20px; }
1558
+ h1, h2, h3 { color: #333; }
1559
+ code, pre { background: #f5f5f5; padding: 2px 6px; border-radius: 4px; }
1560
+ pre { padding: 15px; overflow-x: auto; }
1561
+ table { border-collapse: collapse; width: 100%; }
1562
+ th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
1563
+ th { background: #f5f5f5; }
1564
+ .critical { color: #d32f2f; font-weight: bold; }
1565
+ .high { color: #f57c00; font-weight: bold; }
1566
+ .medium { color: #fbc02d; }
1567
+ .low { color: #388e3c; }
1568
+ </style>
1569
+ </head>
1570
+ <body>
1571
+ ${md
1572
+ .replace(/^### (.+)$/gm, '<h3>$1</h3>')
1573
+ .replace(/^## (.+)$/gm, '<h2>$1</h2>')
1574
+ .replace(/^# (.+)$/gm, '<h1>$1</h1>')
1575
+ .replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
1576
+ .replace(/`([^`]+)`/g, '<code>$1</code>')
1577
+ .replace(/```\n([\s\S]*?)```/g, '<pre>$1</pre>')
1578
+ .replace(/^- (.+)$/gm, '<li>$1</li>')
1579
+ .replace(/\n\n/g, '</p><p>')
1580
+ .replace(/CRITICAL/g, '<span class="critical">CRITICAL</span>')
1581
+ .replace(/HIGH/g, '<span class="high">HIGH</span>')}
1582
+ </body>
1583
+ </html>`;
1584
+ return html;
1585
+ }
1586
+ // ═══════════════════════════════════════════════════════════════════════════════
1587
+ // SINGLETON INSTANCE
1588
+ // ═══════════════════════════════════════════════════════════════════════════════
1589
+ export const securityDeliverableGenerator = new SecurityDeliverableGenerator();
1590
+ //# sourceMappingURL=securityDeliverableGenerator.js.map