import html
import json
from reports.access_points import (
format_popup_datetime,
load_access_points,
)
from reports.map_popups import build_standard_popup
from reports.map_service import get_map_style_url
from reports.template import (
ReportContext,
card,
page_begin,
page_end,
)
def verified_passwords(row):
passwords = []
seen = set()
for credential in row["passwords"]:
password = credential.get("password")
if (
not credential.get("verified")
or not isinstance(password, str)
or not password
or password in seen
):
continue
seen.add(password)
passwords.append(password)
return passwords
def classify_access_points(observations):
verified_wpa = []
open_aps = []
for row in observations:
latitude = row.get("latitude")
longitude = row.get("longitude")
if latitude is None or longitude is None:
continue
encryption = str(
row.get("encryption") or ""
).strip().upper()
if encryption == "OPEN":
open_aps.append(row)
elif verified_passwords(row):
verified_wpa.append(row)
return verified_wpa, open_aps
def build_connection_popup(row, is_open):
popup = build_standard_popup(
essid=row["essid"],
bssid=row["bssid"],
vendor=row["vendor"],
encryption=row["encryption"],
cipher=row["cipher"],
akm=row["akm"],
channel=row["channel"],
rssi=row["rssi"],
passwords=row["passwords"],
handshakes=row["handshakes"],
observed_at=format_popup_datetime(
row["observed_at"]
),
latitude=row["latitude"],
longitude=row["longitude"],
access_point_url=(
f"/reports/access-points/{row['bssid']}"
),
)
if is_open:
connect_control = """