Skip to content

Real-time network monitor + outbound firewall — see & block every connection. Privacy-first, local-first, Rust fleet agent, SIEM exports, 8 languages. / Moniteur réseau temps réel + pare-feu sortant, agent de flotte Rust, exports SIEM. 100 % local.

fix(windows): CJK ANSI codepage broke subprocess decoding, killing the WebSocket init

MoneyLisa5d7afaf2f2af
diff --git a/backend/api/main.py b/backend/api/main.py
index f19d27d..e8b1b15 100644
--- a/backend/api/main.py
+++ b/backend/api/main.py
@@ -622,9 +622,10 @@ def _local_hostname() -> str:
"""
try:
if sys.platform == "darwin":
- out = subprocess.run(["scutil", "--get", "ComputerName"],
+ out = (subprocess.run(["scutil", "--get", "ComputerName"],
capture_output=True, text=True,
- timeout=3, **spawn_kwargs()).stdout.strip()
+ errors="replace", timeout=3,
+ **spawn_kwargs()).stdout or "").strip()
if out:
return out
elif sys.platform.startswith("win"):
@@ -633,9 +634,10 @@ def _local_hostname() -> str:
return name
elif sys.platform.startswith("linux"):
try:
- out = subprocess.run(["hostnamectl", "--pretty"],
+ out = (subprocess.run(["hostnamectl", "--pretty"],
capture_output=True, text=True,
- timeout=3, **spawn_kwargs()).stdout.strip()
+ errors="replace", timeout=3,
+ **spawn_kwargs()).stdout or "").strip()
if out:
return out
except (OSError, subprocess.TimeoutExpired):
@@ -1971,27 +1973,29 @@ def _current_ssid() -> str:
iface = (_sniffer.iface if _sniffer else None) or "en0"
out = subprocess.run(
["ipconfig", "getsummary", iface],
- capture_output=True, text=True, timeout=3, **spawn_kwargs()).stdout
+ capture_output=True, text=True, timeout=3, errors="replace",
+ **spawn_kwargs()).stdout or ""
for line in out.splitlines():
if "SSID :" in line:
ssid = line.split("SSID :", 1)[1].strip()
break
elif sys.platform.startswith("linux"):
- out = subprocess.run(
+ out = (subprocess.run(
["iwgetid", "-r"], capture_output=True, text=True, timeout=3,
- **spawn_kwargs()
- ).stdout.strip()
+ errors="replace", **spawn_kwargs()
+ ).stdout or "").strip()
if out:
ssid = out
elif sys.platform == "win32":
out = subprocess.run(
["netsh", "wlan", "show", "interfaces"],
- capture_output=True, text=True, timeout=3, **spawn_kwargs()).stdout
+ capture_output=True, text=True, timeout=3, errors="replace",
+ **spawn_kwargs()).stdout or ""
for line in out.splitlines():
if line.strip().startswith("SSID"):
ssid = line.split(":", 1)[1].strip()
break
- except (OSError, subprocess.TimeoutExpired):
+ except (OSError, subprocess.TimeoutExpired, AttributeError):
pass
_ssid_cache["ssid"] = ssid
_ssid_cache["ts"] = now
diff --git a/backend/detection/firewall.py b/backend/detection/firewall.py
index 0b88b59..fd3f09d 100644
--- a/backend/detection/firewall.py
+++ b/backend/detection/firewall.py
@@ -429,7 +429,8 @@ class FirewallManager:
"""EN: Run one firewall command, never through a shell. Returns
(success, stderr). / FR: Exécute une commande pare-feu sans shell."""
try:
- p = subprocess.run(args, capture_output=True, text=True, timeout=15, **spawn_kwargs())
+ p = subprocess.run(args, capture_output=True, text=True, errors="replace",
+ timeout=15, **spawn_kwargs())
err = (p.stderr or p.stdout or "").strip()
return p.returncode == 0, err[:300]
except Exception as e: # noqa: BLE001 — report, don't crash
diff --git a/backend/scanner/arp_scanner.py b/backend/scanner/arp_scanner.py
index 37e831a..32e2641 100644
--- a/backend/scanner/arp_scanner.py
+++ b/backend/scanner/arp_scanner.py
@@ -185,9 +185,9 @@ def _read_arp_cmd() -> list[tuple[str, str]]:
« - ») et macOS (IP entre parenthèses)."""
try:
proc = subprocess.run(["arp", "-a"], capture_output=True, text=True,
- **spawn_kwargs(),
+ errors="replace", **spawn_kwargs(),
timeout=10)
- out_text = proc.stdout
+ out_text = proc.stdout or ""
except (OSError, subprocess.TimeoutExpired) as exc:
logger.debug("arp -a failed: %s", exc)
return []
@@ -251,15 +251,15 @@ def default_gateway() -> Optional[str]:
elif sys.platform == "darwin":
proc = subprocess.run(["route", "-n", "get", "default"],
**spawn_kwargs(),
- capture_output=True, text=True, timeout=5)
- m = re.search(r"gateway:\s*(\S+)", proc.stdout)
+ capture_output=True, text=True, errors="replace", timeout=5)
+ m = re.search(r"gateway:\s*(\S+)", proc.stdout or "")
if m:
return m.group(1)
elif sys.platform.startswith("win"):
proc = subprocess.run(["route", "print", "-4", "0.0.0.0"],
**spawn_kwargs(),
- capture_output=True, text=True, timeout=10)
- for line in proc.stdout.splitlines():
+ capture_output=True, text=True, errors="replace", timeout=10)
+ for line in (proc.stdout or "").splitlines():
cols = line.split()
if len(cols) >= 3 and cols[0] == "0.0.0.0" and IPV4_RE.fullmatch(cols[2]):
return cols[2]