From 500895dcfa31f11c81b3c9128781a49a05e3bd05 Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" 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(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ff31db1952..09fa1edbbf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, '3.10', '3.11.0-alpha.1', pypy2, pypy3] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, '3.10', '3.11.0-alpha.7', pypy2, pypy3] fail-fast: false # Steps represent a sequence of tasks that will be executed as part of the job steps: From 7e2ab36d86998575853150c0a57de5e22518cf66 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 21 Jun 2022 16:55:57 +0200 Subject: [PATCH 2/5] move global groups to start of expression (python 3.11 compat) --- fail2ban/client/fail2banregex.py | 2 +- fail2ban/server/datetemplate.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fail2ban/client/fail2banregex.py b/fail2ban/client/fail2banregex.py index 8c03b2dd17..de7cde60fd 100644 --- a/fail2ban/client/fail2banregex.py +++ b/fail2ban/client/fail2banregex.py @@ -334,7 +334,7 @@ def readRegex(self, value, regextype): fltFile = None fltOpt = {} if regextype == 'fail': - if re.search(r'^(?ms)/{0,3}[\w/_\-.]+(?:\[.*\])?$', value): + if re.search(r'(?ms)^/{0,3}[\w/_\-.]+(?:\[.*\])?$', value): try: fltName, fltOpt = extractOptions(value) if "." in fltName[~5:]: diff --git a/fail2ban/server/datetemplate.py b/fail2ban/server/datetemplate.py index 8f1aaeb44b..e02772d850 100644 --- a/fail2ban/server/datetemplate.py +++ b/fail2ban/server/datetemplate.py @@ -35,6 +35,7 @@ # check already grouped contains "(", but ignores char "\(" and conditional "(?(id)...)": RE_GROUPED = re.compile(r'(? Date: Tue, 21 Jun 2022 16:56:57 +0200 Subject: [PATCH 3/5] wrap global flags like ((?i)xxx) or (?:(?i)xxx) to local flags (?i:xxx) if supported by RE-engine in the python version --- fail2ban/server/failregex.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fail2ban/server/failregex.py b/fail2ban/server/failregex.py index 0ae9acc5d9..15a7699fe9 100644 --- a/fail2ban/server/failregex.py +++ b/fail2ban/server/failregex.py @@ -91,6 +91,13 @@ "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"(? Date: Tue, 21 Jun 2022 17:05:39 +0200 Subject: [PATCH 4/5] skip test if readline module missing (add it as optional module installs in GHA workflow) --- .github/workflows/main.yml | 2 ++ fail2ban/tests/fail2banclienttestcase.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09fa1edbbf..50c49c80d8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -61,6 +61,8 @@ jobs: #sudo apt-get -y install python${F2B_PY/2/}-systemd || echo 'systemd not available' sudo apt-get -y install libsystemd-dev || echo 'systemd dependencies seems to be unavailable' python -m pip install systemd-python || echo 'systemd not available' + #readline if available as module: + python -c 'import readline' 2> /dev/null || python -m pip install readline || echo 'readline not available' - name: Before scripts run: | diff --git a/fail2ban/tests/fail2banclienttestcase.py b/fail2ban/tests/fail2banclienttestcase.py index d1aec5abb4..f89988414b 100644 --- a/fail2ban/tests/fail2banclienttestcase.py +++ b/fail2ban/tests/fail2banclienttestcase.py @@ -568,6 +568,11 @@ def testClientStartBackgroundCall(self, tmp): 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", From 5d9d86e2f4d40d7e1ee915e40d6ba06ee27b4547 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 21 Jun 2022 17:10:48 +0200 Subject: [PATCH 5/5] GHA: update python 3.11 version (3.11.0-beta.3) --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 50c49c80d8..39c85231b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, '3.10', '3.11.0-alpha.7', pypy2, pypy3] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, '3.10', '3.11.0-beta.3', pypy2, pypy3] fail-fast: false # Steps represent a sequence of tasks that will be executed as part of the job steps: