fix: what bandit and the remaining lint rules found

- get_wan_status: the catch-all except Exception: continue (B112) now logs
  at debug level before the next WAN service is tried, so a swallowed
  failure leaves a trace. A module logger is new.
- The "any remote host" placeholder of get_nat_translations is a named
  constant with a nosec (B104): an address reported as data, never a
  bind. The output is unchanged.
- ruff found nothing left after the mechanical pass.
This commit is contained in:
Christian Manivong committed 2026-10-23 08:52:23 +02:00
1 parent b23967417c
commit a2fc59c8ab
1 file changed
+9 -1
+9 -1
View File
@@ -32,6 +32,7 @@ management methods (``load_merge_candidate``, ``commit_config``, ...).
from __future__ import annotations
import logging
import socket
from typing import Any
@@ -55,6 +56,12 @@ from napalm_device_types.models import (
WirelessClientDict,
)
logger = logging.getLogger(__name__)
#: The remote host of a NAT translation whose port forward names none: any host.
#: Reported as data, never bound to.
_ANY_REMOTE = "0.0.0.0" # nosec B104
# Exceptions that indicate an optional/unavailable TR-064 service or action
# (e.g. a service not present on a given FritzOS version/model).
_OPTIONAL_SERVICE_ERRORS = (FritzServiceError, FritzActionError, FritzConnectionException)
@@ -469,6 +476,7 @@ class FritzBoxDriver(ResidentialGatewayDriver):
):
continue
except Exception:
logger.debug("WAN status from %s: ignored", svc, exc_info=True)
continue
if wan_service_used:
@@ -619,7 +627,7 @@ class FritzBoxDriver(ResidentialGatewayDriver):
continue
if ":" in forward["internal_ip"]:
continue
remote = forward.get("remote_host") or "0.0.0.0"
remote = forward.get("remote_host") or _ANY_REMOTE
translations.append(
{
"protocol": forward["protocol"].lower(),