From c58a1b486fc25e51cc32d86704f58077d030f642 Mon Sep 17 00:00:00 2001 From: Seb Date: Sat, 21 Dec 2024 23:03:25 +0800 Subject: [PATCH] Added fixes to Caddy and Ngnix Did the same fixes that have been done to Apache to Caddy and Nginx --- import_apache_waf.py | 1 - import_caddy_waf.py | 5 ++++- import_nginx_waf.py | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/import_apache_waf.py b/import_apache_waf.py index 50b294b..6f6d060 100644 --- a/import_apache_waf.py +++ b/import_apache_waf.py @@ -15,7 +15,6 @@ def copy_waf_files(): logging.info("Copying Apache WAF patterns...") os.makedirs(APACHE_WAF_DIR, exist_ok=True) list_of_files = os.listdir(WAF_DIR) - workaround = "{" for conf_file in list_of_files: if conf_file.endswith('.conf'): subprocess.run(["cp", f"{WAF_DIR}/{conf_file}", APACHE_WAF_DIR], check=True) diff --git a/import_caddy_waf.py b/import_caddy_waf.py index e099862..65e0b7e 100644 --- a/import_caddy_waf.py +++ b/import_caddy_waf.py @@ -12,7 +12,10 @@ INCLUDE_STATEMENT = "import waf/*.conf" def copy_waf_files(): logging.info("Copying Caddy WAF patterns...") os.makedirs(CADDY_WAF_DIR, exist_ok=True) - subprocess.run(["cp", "-R", f"{WAF_DIR}/*", CADDY_WAF_DIR], check=True) + list_of_files = os.listdir(WAF_DIR) + for conf_file in list_of_files: + if conf_file.endswith('.conf'): + subprocess.run(["cp", f"{WAF_DIR}/{conf_file}", CADDY_WAF_DIR], check=True) def update_caddyfile(): logging.info("Ensuring WAF patterns are imported in Caddyfile...") diff --git a/import_nginx_waf.py b/import_nginx_waf.py index 4fa42d9..8d99954 100644 --- a/import_nginx_waf.py +++ b/import_nginx_waf.py @@ -12,7 +12,10 @@ INCLUDE_STATEMENT = "include /etc/nginx/waf/*.conf;" def copy_waf_files(): logging.info("Copying Nginx WAF patterns...") os.makedirs(NGINX_WAF_DIR, exist_ok=True) - subprocess.run(["cp", "-R", f"{WAF_DIR}/*", NGINX_WAF_DIR], check=True) + list_of_files = os.listdir(WAF_DIR) + for conf_file in list_of_files: + if conf_file.endswith('.conf'): + subprocess.run(["cp", f"{WAF_DIR}/{conf_file}", NGINX_WAF_DIR], check=True) def update_nginx_conf(): logging.info("Ensuring WAF patterns are included in nginx.conf...")