File size: 3,060 Bytes
6fb88e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const fs = require('fs');
const path = require('path');

/**
 * ZETA REPORTING ENGINE
 * Converts security assessment data into professional Markdown reports.
 */
class ReportingEngine {
    constructor(reportsDir) {
        this.reportsDir = reportsDir;
        if (!fs.existsSync(this.reportsDir)) {
            fs.mkdirSync(this.reportsDir, { recursive: true });
        }
    }

    /**
     * Generates a security report based on pentest data.
     * @param {Object} data - The results from ZetaCommander
     */
    generateReport(data) {
        const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
        const safeTarget = (data.target || 'unknown').replace(/[^a-z0-9]/gi, '_');
        const fileName = `zeta-report-${safeTarget}-${timestamp}.md`;
        const filePath = path.join(this.reportsDir, fileName);

        const content = `# ZETA SOVEREIGN SECURITY ASSESSMENT REPORT
## Target: ${data.target || 'N/A'}
## Date: ${new Date().toLocaleString()}
## Mission ID: ${data.missionId || 'N/A'}

---

## 1. Executive Summary
This report details the findings of an autonomous security assessment conducted by the Zeta Sovereign Intelligence Suite. The assessment focused on reconnaissance, network mapping, and vulnerability identification for the specified target.

## 2. Technical Findings
### 2.1 Network Discovery
- **Target Host**: ${data.target || 'N/A'}
- **Target IP**: ${data.ip || 'Resolved during scan'}

### 2.2 Detailed Vulnerability Analysis
${(data.tactical_metadata && data.tactical_metadata.length > 0)
    ? data.tactical_metadata.map(m => `
#### [${m.risk}] Port ${m.port} - ${m.vector}
- **Remediation**: ${m.remediation}
`).join('\n')
    : '  - No high-risk vulnerabilities were explicitly mapped during this phase.'}

### 2.3 Raw Execution Logs
\`\`\`text
${data.log || 'No log data available.'}
\`\`\`

---

## 3. Recommended Remediation Roadmap
${(data.tactical_metadata && data.tactical_metadata.length > 0)
    ? data.tactical_metadata.map((m, i) => `${i+1}. **Hardening Port ${m.port}**: ${m.remediation}`).join('\n')
    : '1. Maintain standard security patches and monitor logs.'}

---
*Generated by Z374_LL4M4 - Zeta Sovereign Intelligence Suite v25.0*
`;

        fs.writeFileSync(filePath, content);
        return { fileName, filePath };
    }

    /**
     * Lists all available reports in the directory.
     */
    listReports() {
        if (!fs.existsSync(this.reportsDir)) return [];
        return fs.readdirSync(this.reportsDir)
            .filter(f => f.endsWith('.md'))
            .map(f => ({
                name: f,
                created: fs.statSync(path.join(this.reportsDir, f)).birthtime
            }))
            .sort((a, b) => b.created - a.created);
    }

    /**
     * Reads a specific report content.
     */
    getReport(fileName) {
        const filePath = path.join(this.reportsDir, fileName);
        if (fs.existsSync(filePath)) {
            return fs.readFileSync(filePath, 'utf8');
        }
        return null;
    }
}

module.exports = { ReportingEngine };