summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsebres <serg.brester@sebres.de>2022-09-08 16:32:34 +0200
committersebres <serg.brester@sebres.de>2022-09-08 16:32:34 +0200
commit8dccf099e4852483a4e6245f62103499dededae8 (patch)
treefffa8a8f471b2f7985389fcddc1196789d58c2b6
parent467024797f07f2c488d12cafd8fd84f079a310a9 (diff)
parent5e74499ffd2358d39cf6d4017fc66ce2e093eb6d (diff)
downloadfail2ban-8dccf099e4852483a4e6245f62103499dededae8.tar.gz
Merge branch '0.10' into 0.11
(conflicts resolved)
-rw-r--r--fail2ban/server/failregex.py6
-rw-r--r--fail2ban/tests/fail2banregextestcase.py8
2 files changed, 11 insertions, 3 deletions
diff --git a/fail2ban/server/failregex.py b/fail2ban/server/failregex.py
index e8042ddc..a9b144af 100644
--- a/fail2ban/server/failregex.py
+++ b/fail2ban/server/failregex.py
@@ -157,9 +157,9 @@ class Regex:
self._tupleValues.sort()
self._altValues = self._altValues if len(self._altValues) else None
self._tupleValues = self._tupleValues if len(self._tupleValues) else None
- except sre_constants.error:
- raise RegexException("Unable to compile regular expression '%s'" %
- regex)
+ except sre_constants.error as e:
+ raise RegexException("Unable to compile regular expression '%s':\n%s" %
+ (regex, e))
# set fetch handler depending on presence of alternate (or tuple) tags:
self.getGroups = self._getGroupsWithAlt if (self._altValues or self._tupleValues) else self._getGroups
diff --git a/fail2ban/tests/fail2banregextestcase.py b/fail2ban/tests/fail2banregextestcase.py
index 884f313a..db2d7562 100644
--- a/fail2ban/tests/fail2banregextestcase.py
+++ b/fail2ban/tests/fail2banregextestcase.py
@@ -133,6 +133,13 @@ class Fail2banRegexTest(LogCaptureTestCase):
"test", r".** from <HOST>$"
))
self.assertLogged("Unable to compile regular expression")
+ self.assertLogged("multiple repeat", "at position 2", all=False); # details of failed compilation
+ self.pruneLog()
+ self.assertFalse(_test_exec(
+ "test", r"^(?:(?P<type>A)|B)? (?(typo)...) from <ADDR>"
+ ))
+ self.assertLogged("Unable to compile regular expression")
+ self.assertLogged("unknown group name: 'typo'", "at position 23", all=False); # details of failed compilation
def testWrongIngnoreRE(self):
self.assertFalse(_test_exec(
@@ -140,6 +147,7 @@ class Fail2banRegexTest(LogCaptureTestCase):
"test", r".*? from <HOST>$", r".**"
))
self.assertLogged("Unable to compile regular expression")
+ self.assertLogged("multiple repeat", "at position 2", all=False); # details of failed compilation
def testWrongFilterOptions(self):
self.assertFalse(_test_exec(