From eba577358eda29ebf55511d55dfb86c92a628fa5 Mon Sep 17 00:00:00 2001 From: limuthu123 <168603554+limuthu123@users.noreply.github.com> Date: Sun, 31 May 2026 01:37:29 +0530 Subject: [PATCH] refactor: replace bare except blocks with Exception for better signal handling --- fail2ban/client/configparserinc.py | 4 ++-- fail2ban/helpers.py | 2 +- fail2ban/server/failregex.py | 2 +- fail2ban/server/filter.py | 2 +- fail2ban/server/filtersystemd.py | 2 +- fail2ban/server/ipdns.py | 4 ++-- fail2ban/server/server.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fail2ban/client/configparserinc.py b/fail2ban/client/configparserinc.py index 11b9a461..67ea9b28 100644 --- a/fail2ban/client/configparserinc.py +++ b/fail2ban/client/configparserinc.py @@ -202,11 +202,11 @@ after = 1.conf rplcmnt = 1 try: # set it in map-vars (consider different python versions): defaults[sopt] = v - except: + except Exception: # try to set in first default map (corresponding vars): try: defaults._maps[0][sopt] = v - except: # pragma: no cover + except Exception: # pragma: no cover # no way to update vars chain map - overwrite defaults: self._defaults[sopt] = v return rplcmnt diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py index 00aca138..b3eb8ad2 100644 --- a/fail2ban/helpers.py +++ b/fail2ban/helpers.py @@ -36,7 +36,7 @@ import importlib try: import ctypes _libcap = ctypes.CDLL('libcap.so.2') -except: +except Exception: _libcap = None diff --git a/fail2ban/server/failregex.py b/fail2ban/server/failregex.py index 85636f36..e016a1e4 100644 --- a/fail2ban/server/failregex.py +++ b/fail2ban/server/failregex.py @@ -94,7 +94,7 @@ R_MAP = { try: re.search("^re(?i:val)$", "reVAL") R_GLOB2LOCFLAGS = ( re.compile(r"(?