Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,10 +22,7 @@ def analyze_email(file_path, export_pdf=False):
|
|
| 22 |
score_val = int(round(float(attack_score)))
|
| 23 |
except Exception:
|
| 24 |
score_val = 0
|
| 25 |
-
|
| 26 |
-
score_val = 100
|
| 27 |
-
if score_val < 0:
|
| 28 |
-
score_val = 0
|
| 29 |
|
| 30 |
attack_type = summary.get("Attack Type", "Unknown")
|
| 31 |
verdict = summary.get("Final Verdict", "No Verdict")
|
|
@@ -45,13 +42,15 @@ 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 |
-
auth_results = details.get("Auth Results",
|
| 49 |
|
| 50 |
-
# Render authentication results
|
| 51 |
-
|
| 52 |
-
"<ul>" + "".join(f"<li>{k.upper()}: {v}</li>" for k, v in auth_results.items()) + "</ul>"
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# Tags (from summary Main Tags if present)
|
| 57 |
main_tags_str = summary.get("Main Tags", "")
|
|
|
|
| 22 |
score_val = int(round(float(attack_score)))
|
| 23 |
except Exception:
|
| 24 |
score_val = 0
|
| 25 |
+
score_val = max(0, min(score_val, 100))
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
attack_type = summary.get("Attack Type", "Unknown")
|
| 28 |
verdict = summary.get("Final Verdict", "No Verdict")
|
|
|
|
| 42 |
body_findings = details.get("Body Findings", []) or []
|
| 43 |
url_findings = details.get("URL Findings", []) or []
|
| 44 |
highlighted_body = details.get("Highlighted Body", "") or ""
|
| 45 |
+
auth_results = details.get("Auth Results", None)
|
| 46 |
|
| 47 |
+
# Render authentication results safely
|
| 48 |
+
if isinstance(auth_results, dict):
|
| 49 |
+
auth_html = "<ul>" + "".join(f"<li>{k.upper()}: {v}</li>" for k, v in auth_results.items()) + "</ul>"
|
| 50 |
+
elif isinstance(auth_results, str):
|
| 51 |
+
auth_html = f"<p>{auth_results}</p>"
|
| 52 |
+
else:
|
| 53 |
+
auth_html = "<p>No auth results found.</p>"
|
| 54 |
|
| 55 |
# Tags (from summary Main Tags if present)
|
| 56 |
main_tags_str = summary.get("Main Tags", "")
|