-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreporting.py
More file actions
71 lines (58 loc) · 2.04 KB
/
Copy pathreporting.py
File metadata and controls
71 lines (58 loc) · 2.04 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
from __future__ import annotations
from pathlib import Path
from ..config import settings
def build_mermaid(scan: dict) -> str:
provider = scan.get("mail_provider", "Unknown")
website_status = scan.get("website_status", "unknown")
return f"""graph TD
A[Domain: {scan['domain']}] --> B[Mail Provider: {provider}]
A --> C[Website: {website_status}]
A --> D[SPF: {'present' if scan.get('spf_record') else 'missing'}]
A --> E[DMARC: {'present' if scan.get('dmarc_record') else 'missing'}]
A --> F[DKIM: {'selectors found' if scan.get('dkim_selectors_found') else 'not verified'}]
"""
def generate_report(
audit_id: str,
domain: str,
company_name: str | None,
scan: dict,
findings: list[dict],
score: int,
) -> Path:
report_path = settings.report_dir / f"{audit_id}.md"
title = company_name or domain
report = f"""# Next-Gen-IT Audit Report
## Organization
- Name: {title}
- Domain: {domain}
- Security score: {score}/100
## Snapshot
- Mail provider: {scan.get('mail_provider', 'Unknown')}
- Website status: {scan.get('website_status', 'unknown')}
- MX records: {', '.join(scan.get('mx_records', [])) or 'none detected'}
- SPF: {scan.get('spf_record') or 'missing'}
- DMARC: {scan.get('dmarc_record') or 'missing'}
- DKIM selectors found: {', '.join(scan.get('dkim_selectors_found', [])) or 'none'}
## Findings
"""
for finding in findings:
report += f"""
### [{finding['severity'].upper()}] {finding['title']}
- Category: {finding['category']}
- Code: {finding['code']}
- Description: {finding['description']}
- Recommendation: {finding['recommendation']}
- Evidence: {finding['evidence']}
"""
report += f"""
## Current-State Diagram
```mermaid
{build_mermaid(scan)}
```
## Next best actions
1. Fix the highest-severity mail authentication findings first.
2. Confirm all legitimate senders before tightening SPF and DMARC.
3. Upload invoices, screenshots, or tool exports to expand this into a full ecosystem audit.
"""
report_path.write_text(report, encoding="utf-8")
return report_path