forked from mayur-3112/Aegis_Agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport_generator.py
More file actions
371 lines (329 loc) · 10.6 KB
/
Copy pathreport_generator.py
File metadata and controls
371 lines (329 loc) · 10.6 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
#!/usr/bin/env python3
"""
Aegis PDF Report Generator
Creates professional security audit reports
"""
from datetime import datetime
from pathlib import Path
import json
def generate_html_report(results: dict, baseline_path: str, output_file: str = "aegis_report.html"):
"""Generate comprehensive HTML report"""
modified = results.get('MODIFIED', [])
created = results.get('CREATED', [])
deleted = results.get('DELETED', [])
total_changes = len(modified) + len(created) + len(deleted)
# Determine status
status = "SECURE" if total_changes == 0 else "BREACH DETECTED"
status_color = "#28a745" if total_changes == 0 else "#dc3545"
status_icon = "✓" if total_changes == 0 else "⚠"
# Generate timestamp
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
html_content = f"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aegis Security Report</title>
<style>
* {{
margin: 0;
padding: 0;
box-sizing: border-box;
}}
body {{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
color: #333;
}}
.container {{
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
overflow: hidden;
}}
.header {{
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
color: white;
padding: 40px;
text-align: center;
}}
.header h1 {{
font-size: 3em;
margin-bottom: 10px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}}
.header .subtitle {{
font-size: 1.2em;
opacity: 0.9;
}}
.status-banner {{
background-color: {status_color};
color: white;
padding: 30px;
text-align: center;
font-size: 2em;
font-weight: bold;
}}
.content {{
padding: 40px;
}}
.info-grid {{
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-bottom: 40px;
}}
.info-card {{
background: #f8f9fa;
border-left: 4px solid #667eea;
padding: 20px;
border-radius: 8px;
}}
.info-card h3 {{
color: #667eea;
margin-bottom: 10px;
font-size: 0.9em;
text-transform: uppercase;
letter-spacing: 1px;
}}
.info-card p {{
font-size: 1.5em;
font-weight: bold;
color: #333;
}}
.section {{
margin-bottom: 40px;
}}
.section h2 {{
color: #1e3c72;
border-bottom: 3px solid #667eea;
padding-bottom: 10px;
margin-bottom: 20px;
}}
.file-table {{
width: 100%;
border-collapse: collapse;
margin-top: 20px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}}
.file-table th {{
background: #667eea;
color: white;
padding: 15px;
text-align: left;
font-weight: 600;
}}
.file-table td {{
padding: 12px 15px;
border-bottom: 1px solid #e0e0e0;
}}
.file-table tr:hover {{
background: #f8f9fa;
}}
.severity-critical {{
background: #fee;
color: #dc3545;
font-weight: bold;
padding: 5px 10px;
border-radius: 5px;
}}
.severity-warning {{
background: #fff3cd;
color: #856404;
font-weight: bold;
padding: 5px 10px;
border-radius: 5px;
}}
.no-changes {{
text-align: center;
padding: 40px;
color: #28a745;
font-size: 1.2em;
}}
.footer {{
background: #f8f9fa;
padding: 20px;
text-align: center;
color: #666;
font-size: 0.9em;
}}
.footer strong {{
color: #667eea;
}}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🛡️ AEGIS</h1>
<div class="subtitle">File Integrity Monitoring System</div>
<div class="subtitle">Security Audit Report</div>
</div>
<div class="status-banner">
{status_icon} SYSTEM STATUS: {status}
</div>
<div class="content">
<div class="info-grid">
<div class="info-card">
<h3>Report Generated</h3>
<p>{timestamp}</p>
</div>
<div class="info-card">
<h3>Total Changes</h3>
<p>{total_changes}</p>
</div>
<div class="info-card">
<h3>Modified Files</h3>
<p style="color: #dc3545;">{len(modified)}</p>
</div>
<div class="info-card">
<h3>Created Files</h3>
<p style="color: #ffc107;">{len(created)}</p>
</div>
<div class="info-card">
<h3>Deleted Files</h3>
<p style="color: #ff9800;">{len(deleted)}</p>
</div>
<div class="info-card">
<h3>Baseline Reference</h3>
<p style="font-size: 1em;">{Path(baseline_path).name}</p>
</div>
</div>
"""
# Modified Files Section
if modified:
html_content += """
<div class="section">
<h2>🔴 Modified Files - Critical Severity</h2>
<table class="file-table">
<thead>
<tr>
<th>#</th>
<th>File Path</th>
<th>Status</th>
<th>Severity</th>
</tr>
</thead>
<tbody>
"""
for i, filepath in enumerate(modified, 1):
html_content += f"""
<tr>
<td>{i}</td>
<td>{filepath}</td>
<td>MODIFIED</td>
<td><span class="severity-critical">CRITICAL</span></td>
</tr>
"""
html_content += """
</tbody>
</table>
</div>
"""
# Created Files Section
if created:
html_content += """
<div class="section">
<h2>🟢 Created Files - Warning</h2>
<table class="file-table">
<thead>
<tr>
<th>#</th>
<th>File Path</th>
<th>Status</th>
<th>Severity</th>
</tr>
</thead>
<tbody>
"""
for i, filepath in enumerate(created, 1):
html_content += f"""
<tr>
<td>{i}</td>
<td>{filepath}</td>
<td>NEW FILE</td>
<td><span class="severity-warning">WARNING</span></td>
</tr>
"""
html_content += """
</tbody>
</table>
</div>
"""
# Deleted Files Section
if deleted:
html_content += """
<div class="section">
<h2>🟠 Deleted Files - Warning</h2>
<table class="file-table">
<thead>
<tr>
<th>#</th>
<th>File Path</th>
<th>Status</th>
<th>Severity</th>
</tr>
</thead>
<tbody>
"""
for i, filepath in enumerate(deleted, 1):
html_content += f"""
<tr>
<td>{i}</td>
<td>{filepath}</td>
<td>DELETED</td>
<td><span class="severity-warning">WARNING</span></td>
</tr>
"""
html_content += """
</tbody>
</table>
</div>
"""
# No Changes
if total_changes == 0:
html_content += """
<div class="no-changes">
<h2>✓ All Monitored Files Match Baseline</h2>
<p>No unauthorized changes detected. System is secure.</p>
</div>
"""
html_content += f"""
<div class="section">
<h2>📊 Technical Details</h2>
<div class="info-card">
<h3>Cryptographic Algorithm</h3>
<p>BLAKE3 (High-Performance Hash Function)</p>
</div>
<div class="info-card" style="margin-top: 20px;">
<h3>Monitoring Configuration</h3>
<p>config.json</p>
</div>
</div>
</div>
<div class="footer">
<p>Generated by <strong>Aegis Core Engine v2.0</strong></p>
<p>File Integrity Monitoring System (BLAKE3)</p>
<p>© 2025 Aegis Security Team</p>
</div>
</div>
</body>
</html>
"""
# Write to file
with open(output_file, 'w') as f:
f.write(html_content)
return output_file
if __name__ == "__main__":
# Example usage
sample_results = {
'MODIFIED': ['./test_data/config.conf', './test_data/secrets.env'],
'CREATED': ['./test_data/backdoor.sh'],
'DELETED': []
}
output = generate_html_report(sample_results, "baseline.json")
print(f"Report generated: {output}")