From 17a34b152854bd4eba33a20094f30eaf65d72a5b Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 7 Jan 2020 21:31:21 +0100 Subject: [PATCH] amend with missing parameter of actionreban in actionreader and coverage --- fail2ban/client/actionreader.py | 1 + fail2ban/server/actions.py | 3 +-- fail2ban/tests/actionstestcase.py | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fail2ban/client/actionreader.py b/fail2ban/client/actionreader.py index 0840fe68..e5bee154 100644 --- a/fail2ban/client/actionreader.py +++ b/fail2ban/client/actionreader.py @@ -46,6 +46,7 @@ class ActionReader(DefinitionInitConfigReader): "actionrepair": ["string", None], "actionrepair_on_unban": ["string", None], "actionban": ["string", None], + "actionreban": ["string", None], "actionunban": ["string", None], "norestored": ["string", None], } diff --git a/fail2ban/server/actions.py b/fail2ban/server/actions.py index 91912eb0..57be293a 100644 --- a/fail2ban/server/actions.py +++ b/fail2ban/server/actions.py @@ -493,8 +493,7 @@ class Actions(JailThread, Mapping): (name, action) for name, action in self._actions.iteritems() if action.banEpoch > bTicket.banEpoch) cnt += self.__reBan(bTicket, actions=rebanacts) - else: - # pragma: no cover - unexpected: ticket is not banned for some reasons - reban using all actions: + else: # pragma: no cover - unexpected: ticket is not banned for some reasons - reban using all actions: cnt += self.__reBan(bTicket) if cnt: logSys.debug("Banned %s / %s, %s ticket(s) in %r", cnt, diff --git a/fail2ban/tests/actionstestcase.py b/fail2ban/tests/actionstestcase.py index e55ef0ce..d97d9921 100644 --- a/fail2ban/tests/actionstestcase.py +++ b/fail2ban/tests/actionstestcase.py @@ -495,3 +495,10 @@ class ExecuteActions(LogCaptureTestCase): '2001:db8::2 inet6 -- rebanned', all=True) self.assertNotLogged('192.0.2.1 inet4 -- rebanned') + # coverage - intended error in reban (no unhandled exception, message logged): + act.actionreban = '' + act.actionban = 'exit 1' + self.assertEqual(self.__actions._Actions__reBan(FailTicket("192.0.2.1", 0)), 0) + self.assertLogged( + 'Failed to execute reban', + 'Error banning 192.0.2.1', all=True)