From cfba8ee2b8ca67148b515e76c2221cf7b517ba43 Mon Sep 17 00:00:00 2001 From: Kovasky Buezo Date: Thu, 21 Mar 2024 14:48:17 -0400 Subject: [PATCH] add fail2ban scripts --- {docker/authelia => fail2ban}/action.d/cloudflare.conf | 2 +- {docker/authelia => fail2ban}/action.d/entryPoint.py | 7 ++++--- {docker/authelia => fail2ban}/action.d/modifyBanList.py | 6 ++++++ 3 files changed, 11 insertions(+), 4 deletions(-) rename {docker/authelia => fail2ban}/action.d/cloudflare.conf (52%) rename {docker/authelia => fail2ban}/action.d/entryPoint.py (81%) mode change 100644 => 100755 rename {docker/authelia => fail2ban}/action.d/modifyBanList.py (92%) diff --git a/docker/authelia/action.d/cloudflare.conf b/fail2ban/action.d/cloudflare.conf similarity index 52% rename from docker/authelia/action.d/cloudflare.conf rename to fail2ban/action.d/cloudflare.conf index f1f27cc..627fed3 100644 --- a/docker/authelia/action.d/cloudflare.conf +++ b/fail2ban/action.d/cloudflare.conf @@ -1,3 +1,3 @@ [Definition] actionban = /data/action.d/entryPoint.py add -actionunban = /data/action.d/entryPoint.py clea del +actionunban = /data/action.d/entryPoint.py del diff --git a/docker/authelia/action.d/entryPoint.py b/fail2ban/action.d/entryPoint.py old mode 100644 new mode 100755 similarity index 81% rename from docker/authelia/action.d/entryPoint.py rename to fail2ban/action.d/entryPoint.py index ea83039..5d9273d --- a/docker/authelia/action.d/entryPoint.py +++ b/fail2ban/action.d/entryPoint.py @@ -1,5 +1,9 @@ #!/usr/bin/python3 +""" +Creates a virtual environment, installs dependencies, and then calls modifyBanList.py +""" + import os import sys @@ -12,8 +16,5 @@ venv_dir = 'env' if not os.path.exists(venv_dir): os.system(f"{sys.executable} -m venv {venv_dir}") -activate_script = os.path.join(venv_dir, 'bin', 'activate') -os.system(f"chmod +x {activate_script}") os.system(f"{os.path.join(venv_dir, 'bin', 'pip')} install --upgrade requests ipaddress") - os.system(f"{os.path.join(venv_dir, 'bin', 'python')} /data/action.d/modifyBanList.py {sys.argv[1]} {sys.argv[2]}") diff --git a/docker/authelia/action.d/modifyBanList.py b/fail2ban/action.d/modifyBanList.py similarity index 92% rename from docker/authelia/action.d/modifyBanList.py rename to fail2ban/action.d/modifyBanList.py index 82ae3de..18ec1dc 100644 --- a/docker/authelia/action.d/modifyBanList.py +++ b/fail2ban/action.d/modifyBanList.py @@ -1,5 +1,10 @@ #!/usr/bin/python3 +""" +Called by entryPoint.py, performs the addition or deletion of an item in a Cloudflare custom list. +Support for IPV6 is limited as it blocks the entire /64 subnet. +""" + import sys import requests from requests import Response @@ -53,6 +58,7 @@ if __name__ == "__main__": } existingIpList = getIPList(apiEndpoint,headers) + print(existingIpList) response = None if action == "del":