diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 839e4f7..d0c00cd 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -3,7 +3,7 @@ name: krawl-chart description: A Helm chart for Krawl honeypot server type: application version: 1.0.0 -appVersion: 1.0.1 +appVersion: 1.0.2 keywords: - honeypot - security diff --git a/src/database.py b/src/database.py index beca629..1834802 100644 --- a/src/database.py +++ b/src/database.py @@ -147,7 +147,9 @@ class DatabaseManager: migrations_run.append("region") if "region_name" not in columns: - cursor.execute("ALTER TABLE ip_stats ADD COLUMN region_name VARCHAR(100)") + cursor.execute( + "ALTER TABLE ip_stats ADD COLUMN region_name VARCHAR(100)" + ) migrations_run.append("region_name") if "timezone" not in columns: diff --git a/src/geo_utils.py b/src/geo_utils.py index 34b5265..9c4538e 100644 --- a/src/geo_utils.py +++ b/src/geo_utils.py @@ -41,7 +41,9 @@ def fetch_ip_geolocation(ip_address: str) -> Optional[Dict[str, Any]]: # Check if the API call was successful if data.get("status") != "success": - app_logger.warning(f"IP lookup failed for {ip_address}: {data.get('message')}") + app_logger.warning( + f"IP lookup failed for {ip_address}: {data.get('message')}" + ) return None # Cache the result @@ -113,7 +115,7 @@ def fetch_blocklist_data(ip_address: str) -> Optional[Dict[str, Any]]: # Get the most recent result (first in list, sorted by record_added) most_recent = results[0] list_on = most_recent.get("list_on", {}) - + app_logger.debug(f"Fetched blocklist data for {ip_address}") return list_on except requests.RequestException as e: diff --git a/src/tasks/fetch_ip_rep.py b/src/tasks/fetch_ip_rep.py index 8737fae..ddaea49 100644 --- a/src/tasks/fetch_ip_rep.py +++ b/src/tasks/fetch_ip_rep.py @@ -29,7 +29,7 @@ def main(): try: # Fetch geolocation data using ip-api.com geoloc_data = extract_geolocation_from_ip(ip) - + # Fetch blocklist data from lcrawl API blocklist_data = fetch_blocklist_data(ip) @@ -55,7 +55,7 @@ def main(): list_on = blocklist_data else: list_on = {} - + # Add flags to list_on list_on["is_proxy"] = is_proxy list_on["is_hosting"] = is_hosting @@ -69,7 +69,9 @@ def main(): sanitized_city = sanitize_for_storage(city, 100) if city else None sanitized_timezone = sanitize_for_storage(timezone, 50) sanitized_isp = sanitize_for_storage(isp, 100) - sanitized_reverse = sanitize_for_storage(reverse, 255) if reverse else None + sanitized_reverse = ( + sanitize_for_storage(reverse, 255) if reverse else None + ) sanitized_list_on = sanitize_dict(list_on, 100000) db_manager.update_ip_rep_infos( diff --git a/src/templates/dashboard_template.py b/src/templates/dashboard_template.py index 30628c7..a31f929 100644 --- a/src/templates/dashboard_template.py +++ b/src/templates/dashboard_template.py @@ -50,7 +50,9 @@ def generate_dashboard(stats: dict, dashboard_path: str = "") -> str: # Generate suspicious accesses rows with clickable IPs suspicious_rows = ( - "\n".join([f""" + "\n".join( + [ + f""" {_escape(log["ip"])} {_escape(log["path"])} {_escape(log["user_agent"][:60])} @@ -62,7 +64,10 @@ def generate_dashboard(stats: dict, dashboard_path: str = "") -> str:
Loading stats...
- """ for log in stats["recent_suspicious"][-10:]]) + """ + for log in stats["recent_suspicious"][-10:] + ] + ) or 'No suspicious activity detected' )