fix: what bandit and the remaining lint rules found
- The six except Exception: pass (REST logout, the extra-ports lookup, the per-port detail in get_interfaces, closing CLI and REST sessions) now log at debug level (B110), so a swallowed failure leaves a trace. - nosec for comparing a reported address with 0.0.0.0 (B104) and for the empty password field of get_users (B105, now a named constant); both are false positives. - A long error message is split into adjacent f-strings; the unused ARP entry type is named _entry_type. - tests: the failed-open test expects ConnectionException instead of any Exception; raise ... from exc.
This commit is contained in:
1 parent
c2a788fa7a
commit
fc24495b83
5 files changed
+19
-13
No files matched your search
@@ -149,7 +149,7 @@ class ProcurveApiClient:
|
||||
try:
|
||||
self._session.delete(self._base_url + "login-sessions", timeout=self.timeout)
|
||||
except Exception:
|
||||
pass
|
||||
logger.debug("REST API logout: ignored", exc_info=True)
|
||||
if self._session:
|
||||
self._session.close()
|
||||
self._session = None
|
||||
@@ -283,7 +283,7 @@ class ProcurveApiClient:
|
||||
)
|
||||
seen_ids.add(pid)
|
||||
except Exception:
|
||||
pass
|
||||
logger.debug("system/status/switch for missing ports: ignored", exc_info=True)
|
||||
|
||||
for port in port_elements:
|
||||
pid = port.get("id", "")
|
||||
@@ -330,7 +330,8 @@ class ProcurveApiClient:
|
||||
for entry in ipv4_data.get("ipv4_element", []):
|
||||
addr = entry.get("address", "")
|
||||
mask = entry.get("mask", "")
|
||||
if not addr or addr == "0.0.0.0":
|
||||
# An unset address reported by the switch, not a bind address.
|
||||
if not addr or addr == "0.0.0.0": # nosec B104
|
||||
continue
|
||||
try:
|
||||
import netaddr
|
||||
|
||||
Reference in new issue
Block a user