You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
3.6 KiB
87 lines
3.6 KiB
2 years ago
|
From 500895dcfa31f11c81b3c9128781a49a05e3bd05 Mon Sep 17 00:00:00 2001
|
||
|
From: "Sergey G. Brester" <serg.brester@sebres.de>
|
||
|
Date: Mon, 25 Apr 2022 18:53:19 +0200
|
||
|
Subject: [PATCH 1/5] GHA: update python 3.11 version
|
||
|
|
||
|
---
|
||
|
.github/workflows/main.yml | 2 +-
|
||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
||
|
Index: fail2ban-0.11.2/fail2ban/server/datetemplate.py
|
||
|
===================================================================
|
||
|
--- fail2ban-0.11.2.orig/fail2ban/server/datetemplate.py
|
||
|
+++ fail2ban-0.11.2/fail2ban/server/datetemplate.py
|
||
|
@@ -35,6 +35,7 @@ logSys = getLogger(__name__)
|
||
|
# check already grouped contains "(", but ignores char "\(" and conditional "(?(id)...)":
|
||
|
RE_GROUPED = re.compile(r'(?<!(?:\(\?))(?<!\\)\((?!\?)')
|
||
|
RE_GROUP = ( re.compile(r'^((?:\(\?\w+\))?\^?(?:\(\?\w+\))?)(.*?)(\$?)$'), r"\1(\2)\3" )
|
||
|
+RE_GLOBALFLAGS = re.compile(r'((?:^|(?!<\\))\(\?[a-z]+\))')
|
||
|
|
||
|
RE_EXLINE_NO_BOUNDS = re.compile(r'^\{UNB\}')
|
||
|
RE_EXLINE_BOUND_BEG = re.compile(r'^\{\^LN-BEG\}')
|
||
|
@@ -110,6 +111,11 @@ class DateTemplate(object):
|
||
|
# because it may be very slow in negative case (by long log-lines not matching pattern)
|
||
|
|
||
|
regex = regex.strip()
|
||
|
+ # cut global flags like (?iu) from RE in order to pre-set it after processing:
|
||
|
+ gf = RE_GLOBALFLAGS.search(regex)
|
||
|
+ if gf:
|
||
|
+ regex = RE_GLOBALFLAGS.sub('', regex, count=1)
|
||
|
+ # check word boundaries needed:
|
||
|
boundBegin = wordBegin and not RE_NO_WRD_BOUND_BEG.search(regex)
|
||
|
boundEnd = wordEnd and not RE_NO_WRD_BOUND_END.search(regex)
|
||
|
# if no group add it now, should always have a group(1):
|
||
|
@@ -135,6 +141,8 @@ class DateTemplate(object):
|
||
|
self.flags |= DateTemplate.LINE_END
|
||
|
# remove possible special pattern "**" in front and end of regex:
|
||
|
regex = RE_DEL_WRD_BOUNDS[0].sub(RE_DEL_WRD_BOUNDS[1], regex)
|
||
|
+ if gf: # restore global flags:
|
||
|
+ regex = gf.group(1) + regex
|
||
|
self._regex = regex
|
||
|
logSys.log(7, ' constructed regex %s', regex)
|
||
|
self._cRegex = None
|
||
|
Index: fail2ban-0.11.2/fail2ban/server/failregex.py
|
||
|
===================================================================
|
||
|
--- fail2ban-0.11.2.orig/fail2ban/server/failregex.py
|
||
|
+++ fail2ban-0.11.2/fail2ban/server/failregex.py
|
||
|
@@ -91,6 +91,13 @@ R_MAP = {
|
||
|
"port": "fport",
|
||
|
}
|
||
|
|
||
|
+# map global flags like ((?i)xxx) or (?:(?i)xxx) to local flags (?i:xxx) if supported by RE-engine in this python version:
|
||
|
+try:
|
||
|
+ re.search("^re(?i:val)$", "reVAL")
|
||
|
+ R_GLOB2LOCFLAGS = ( re.compile(r"(?<!\\)\((?:\?:)?(\(\?[a-z]+)\)"), r"\1:" )
|
||
|
+except:
|
||
|
+ R_GLOB2LOCFLAGS = ()
|
||
|
+
|
||
|
def mapTag2Opt(tag):
|
||
|
tag = tag.lower()
|
||
|
return R_MAP.get(tag, tag)
|
||
|
@@ -128,6 +135,9 @@ class Regex:
|
||
|
#
|
||
|
if regex.lstrip() == '':
|
||
|
raise RegexException("Cannot add empty regex")
|
||
|
+ # special handling wrapping global flags to local flags:
|
||
|
+ if R_GLOB2LOCFLAGS:
|
||
|
+ regex = R_GLOB2LOCFLAGS[0].sub(R_GLOB2LOCFLAGS[1], regex)
|
||
|
try:
|
||
|
self._regexObj = re.compile(regex, re.MULTILINE if multiline else 0)
|
||
|
self._regex = regex
|
||
|
Index: fail2ban-0.11.2/fail2ban/tests/fail2banclienttestcase.py
|
||
|
===================================================================
|
||
|
--- fail2ban-0.11.2.orig/fail2ban/tests/fail2banclienttestcase.py
|
||
|
+++ fail2ban-0.11.2/fail2ban/tests/fail2banclienttestcase.py
|
||
|
@@ -600,6 +600,11 @@ class Fail2banClientTest(Fail2banClientS
|
||
|
os.kill(pid, signal.SIGCONT)
|
||
|
self.assertLogged("timed out")
|
||
|
self.pruneLog()
|
||
|
+ # check readline module available (expected by interactive client)
|
||
|
+ try:
|
||
|
+ import readline
|
||
|
+ except ImportError as e:
|
||
|
+ raise unittest.SkipTest('Skip test because of import error: %s' % e)
|
||
|
# interactive client chat with started server:
|
||
|
INTERACT += [
|
||
|
"echo INTERACT-ECHO",
|