From a7ade07bf404e157472b0f6b5eccb0c33a406746 Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" Date: Sun, 19 Jun 2022 23:06:42 +0200 Subject: fixes typo (copy&paste) by logging of flush impossibility at consistency check, #3306 --- fail2ban/server/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fail2ban/server/actions.py b/fail2ban/server/actions.py index eb14c14f..7eff48f6 100644 --- a/fail2ban/server/actions.py +++ b/fail2ban/server/actions.py @@ -616,7 +616,7 @@ class Actions(JailThread, Mapping): if hasattr(action, 'consistencyCheck'): def _beforeRepair(): if stop and not getattr(action, 'actionrepair_on_unban', None): # don't need repair on stop - self._logSys.error("Invariant check failed. Flush is impossible.") + logSys.error("Invariant check failed. Flush is impossible.") return False return True action.consistencyCheck(_beforeRepair) -- cgit v1.2.1 From 500895dcfa31f11c81b3c9128781a49a05e3bd05 Mon Sep 17 00:00:00 2001 From: "Sergey G. Brester" Date: Mon, 25 Apr 2022 18:53:19 +0200 Subject: 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 ff31db19..09fa1edb 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: -- cgit v1.2.1 From 7e2ab36d86998575853150c0a57de5e22518cf66 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 21 Jun 2022 16:55:57 +0200 Subject: 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 8c03b2dd..de7cde60 100644 --- a/fail2ban/client/fail2banregex.py +++ b/fail2ban/client/fail2banregex.py @@ -334,7 +334,7 @@ class Fail2banRegex(object): 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 8f1aaeb4..e02772d8 100644 --- a/fail2ban/server/datetemplate.py +++ b/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'(? Date: Tue, 21 Jun 2022 16:56:57 +0200 Subject: 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 0ae9acc5..15a7699f 100644 --- a/fail2ban/server/failregex.py +++ b/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"(? Date: Tue, 21 Jun 2022 17:05:39 +0200 Subject: 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 09fa1edb..50c49c80 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 d1aec5ab..f8998841 100644 --- a/fail2ban/tests/fail2banclienttestcase.py +++ b/fail2ban/tests/fail2banclienttestcase.py @@ -568,6 +568,11 @@ class Fail2banClientTest(Fail2banClientServerBase): 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", -- cgit v1.2.1 From 5d9d86e2f4d40d7e1ee915e40d6ba06ee27b4547 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 21 Jun 2022 17:10:48 +0200 Subject: 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 50c49c80..39c85231 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: -- cgit v1.2.1