From 35c8a900130751c95d4a3a02e54a3198c8f53ca1 Mon Sep 17 00:00:00 2001 From: carnivuth Date: Mon, 2 Feb 2026 14:19:40 +0100 Subject: [PATCH] addd exports path configuration variable and default values, restored old filename --- config.yaml | 5 ++++- src/config.py | 2 ++ src/tasks/top_attacking_ips.py | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config.yaml b/config.yaml index c29ebe4..40246db 100644 --- a/config.yaml +++ b/config.yaml @@ -25,6 +25,9 @@ dashboard: # secret_path: super-secret-dashboard-path secret_path: test +exports: + path: "exports" + database: path: "data/krawl.db" retention_days: 30 @@ -43,4 +46,4 @@ analyzer: crawl: infinite_pages_for_malicious: true max_pages_limit: 250 - ban_duration_seconds: 600 \ No newline at end of file + ban_duration_seconds: 600 diff --git a/src/config.py b/src/config.py index 0882188..b98a750 100644 --- a/src/config.py +++ b/src/config.py @@ -37,6 +37,8 @@ class Config: infinite_pages_for_malicious: bool = True # Infinite pages for malicious crawlers ban_duration_seconds: int = 600 # Ban duration in seconds for IPs exceeding limits + # exporter settings + exports_path: str = "exports" # Database settings database_path: str = "data/krawl.db" database_retention_days: int = 30 diff --git a/src/tasks/top_attacking_ips.py b/src/tasks/top_attacking_ips.py index ebdf3aa..69d417b 100644 --- a/src/tasks/top_attacking_ips.py +++ b/src/tasks/top_attacking_ips.py @@ -11,6 +11,7 @@ from firewall.fwtype import FWType from firewall.iptables import Iptables from firewall.raw import Raw +config = get_config() app_logger = get_app_logger() # ---------------------- @@ -24,7 +25,7 @@ TASK_CONFIG = { } EXPORTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "exports") -OUTPUT_FILE = os.path.join(EXPORTS_DIR, "malicious_ips.txt") +EXPORTS_DIR = config.exports_path # ---------------------- @@ -52,7 +53,6 @@ def main(): ) # Filter out local/private IPs and the server's own IP - config = get_config() server_ip = config.get_server_ip() public_ips = [ @@ -71,7 +71,11 @@ def main(): fw = FWType.create(fwname) banlist = fw.getBanlist(public_ips) - output_file = os.path.join(EXPORTS_DIR, f"{fwname}.txt") + output_file = os.path.join(EXPORTS_DIR, f"{fwname}_banlist.txt") + + if fwname == "raw": + output_file = os.path.join(EXPORTS_DIR, f"malicious_ips.txt") + with open(output_file, "w") as f: f.write(f"{banlist}\n")