Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,6 +45,13 @@ def analyze_email(file_path, export_pdf=False):
|
|
| 45 |
body_findings = details.get("Body Findings", []) or []
|
| 46 |
url_findings = details.get("URL Findings", []) or []
|
| 47 |
highlighted_body = details.get("Highlighted Body", "") or ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Tags (from summary Main Tags if present)
|
| 50 |
main_tags_str = summary.get("Main Tags", "")
|
|
@@ -54,36 +61,33 @@ def analyze_email(file_path, export_pdf=False):
|
|
| 54 |
html = f"""
|
| 55 |
<div style='font-family: Arial, sans-serif; padding: 20px; max-width: 900px; margin:auto;'>
|
| 56 |
<h2 style="color:#2c3e50;">π§ Email Security Report</h2>
|
| 57 |
-
|
| 58 |
<h3 style="margin-bottom:6px;">Attack Score</h3>
|
| 59 |
<div style="background:#ecf0f1; border-radius:10px; overflow:hidden; height:24px; width:100%; margin-bottom:8px;">
|
| 60 |
<div style="width:{score_val}%; background:#3498db; height:100%; text-align:center; color:white; line-height:24px;">
|
| 61 |
{score_val}/100
|
| 62 |
</div>
|
| 63 |
</div>
|
| 64 |
-
|
| 65 |
<p><b>Attack Type:</b> {attack_type}</p>
|
| 66 |
<p><b>Final Verdict:</b> <span style="background:{verdict_color}; color:white; padding:4px 10px; border-radius:6px;">
|
| 67 |
{verdict}
|
| 68 |
</span></p>
|
| 69 |
-
|
| 70 |
<details style="margin-top:15px;" open>
|
| 71 |
<summary>π Attack Analysis Tags ({len(tags)})</summary>
|
| 72 |
{"<ul>" + "".join(f"<li>{tag}</li>" for tag in tags if tag) + "</ul>" if tags else "<p>No special tags</p>"}
|
| 73 |
</details>
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
| 75 |
<details style="margin-top:15px;" open>
|
| 76 |
<summary>π΅οΈ Detailed Findings</summary>
|
| 77 |
<h4>Headers ({len(header_findings)})</h4>
|
| 78 |
{"<ul>" + "".join(f"<li>{f}</li>" for f in header_findings) + "</ul>" if header_findings else "<p>No header findings.</p>"}
|
| 79 |
-
|
| 80 |
<h4>Body ({len(body_findings)})</h4>
|
| 81 |
{"<ul>" + "".join(f"<li>{f}</li>" for f in body_findings) + "</ul>" if body_findings else "<p>No body findings.</p>"}
|
| 82 |
-
|
| 83 |
<h4>URLs ({len(url_findings)})</h4>
|
| 84 |
{"<ul>" + "".join(f"<li>{f}</li>" for f in url_findings) + "</ul>" if url_findings else "<p>No URL findings.</p>"}
|
| 85 |
</details>
|
| 86 |
-
|
| 87 |
<details style="margin-top:15px;">
|
| 88 |
<summary>π© Highlighted Email Body</summary>
|
| 89 |
<div style='border:1px solid #ccc; padding:15px; background:#fdfdfd; border-radius:8px; white-space:pre-wrap;'>
|
|
@@ -118,5 +122,4 @@ demo = gr.Interface(
|
|
| 118 |
"Check 'Export PDF Report' to download a professional PDF report."
|
| 119 |
)
|
| 120 |
|
| 121 |
-
|
| 122 |
demo.launch()
|
|
|
|
| 45 |
body_findings = details.get("Body Findings", []) or []
|
| 46 |
url_findings = details.get("URL Findings", []) or []
|
| 47 |
highlighted_body = details.get("Highlighted Body", "") or ""
|
| 48 |
+
auth_results = details.get("Auth Results", {}) or {}
|
| 49 |
+
|
| 50 |
+
# Render authentication results
|
| 51 |
+
auth_html = (
|
| 52 |
+
"<ul>" + "".join(f"<li>{k.upper()}: {v}</li>" for k, v in auth_results.items()) + "</ul>"
|
| 53 |
+
if auth_results else "<p>No auth results found.</p>"
|
| 54 |
+
)
|
| 55 |
|
| 56 |
# Tags (from summary Main Tags if present)
|
| 57 |
main_tags_str = summary.get("Main Tags", "")
|
|
|
|
| 61 |
html = f"""
|
| 62 |
<div style='font-family: Arial, sans-serif; padding: 20px; max-width: 900px; margin:auto;'>
|
| 63 |
<h2 style="color:#2c3e50;">π§ Email Security Report</h2>
|
|
|
|
| 64 |
<h3 style="margin-bottom:6px;">Attack Score</h3>
|
| 65 |
<div style="background:#ecf0f1; border-radius:10px; overflow:hidden; height:24px; width:100%; margin-bottom:8px;">
|
| 66 |
<div style="width:{score_val}%; background:#3498db; height:100%; text-align:center; color:white; line-height:24px;">
|
| 67 |
{score_val}/100
|
| 68 |
</div>
|
| 69 |
</div>
|
|
|
|
| 70 |
<p><b>Attack Type:</b> {attack_type}</p>
|
| 71 |
<p><b>Final Verdict:</b> <span style="background:{verdict_color}; color:white; padding:4px 10px; border-radius:6px;">
|
| 72 |
{verdict}
|
| 73 |
</span></p>
|
|
|
|
| 74 |
<details style="margin-top:15px;" open>
|
| 75 |
<summary>π Attack Analysis Tags ({len(tags)})</summary>
|
| 76 |
{"<ul>" + "".join(f"<li>{tag}</li>" for tag in tags if tag) + "</ul>" if tags else "<p>No special tags</p>"}
|
| 77 |
</details>
|
| 78 |
+
<details style="margin-top:15px;" open>
|
| 79 |
+
<summary>π‘ Authentication Results</summary>
|
| 80 |
+
{auth_html}
|
| 81 |
+
</details>
|
| 82 |
<details style="margin-top:15px;" open>
|
| 83 |
<summary>π΅οΈ Detailed Findings</summary>
|
| 84 |
<h4>Headers ({len(header_findings)})</h4>
|
| 85 |
{"<ul>" + "".join(f"<li>{f}</li>" for f in header_findings) + "</ul>" if header_findings else "<p>No header findings.</p>"}
|
|
|
|
| 86 |
<h4>Body ({len(body_findings)})</h4>
|
| 87 |
{"<ul>" + "".join(f"<li>{f}</li>" for f in body_findings) + "</ul>" if body_findings else "<p>No body findings.</p>"}
|
|
|
|
| 88 |
<h4>URLs ({len(url_findings)})</h4>
|
| 89 |
{"<ul>" + "".join(f"<li>{f}</li>" for f in url_findings) + "</ul>" if url_findings else "<p>No URL findings.</p>"}
|
| 90 |
</details>
|
|
|
|
| 91 |
<details style="margin-top:15px;">
|
| 92 |
<summary>π© Highlighted Email Body</summary>
|
| 93 |
<div style='border:1px solid #ccc; padding:15px; background:#fdfdfd; border-radius:8px; white-space:pre-wrap;'>
|
|
|
|
| 122 |
"Check 'Export PDF Report' to download a professional PDF report."
|
| 123 |
)
|
| 124 |
|
|
|
|
| 125 |
demo.launch()
|