From 03d15ddded4704a667d3eddb229911d9945871d6 Mon Sep 17 00:00:00 2001 From: thomas girod Date: Sun, 21 Jul 2024 22:17:54 +0200 Subject: [PATCH] better honeypot logging --- sith/honeypot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sith/honeypot.py b/sith/honeypot.py index 3659c0ea..a64b428b 100644 --- a/sith/honeypot.py +++ b/sith/honeypot.py @@ -1,12 +1,15 @@ import logging +from time import localtime, strftime from typing import Any -from django.http import HttpResponse -from django.test.client import WSGIRequest +from django.http import HttpRequest, HttpResponse def custom_honeypot_error( - request: WSGIRequest, context: dict[str, Any] + request: HttpRequest, context: dict[str, Any] ) -> HttpResponse: - logging.warning(f"HoneyPot blocked user with ip {request.META.get('REMOTE_ADDR')}") + logging.warning( + f"[{strftime('%c', localtime())}] " + f"HoneyPot blocked user with ip {request.META.get('X-Forwarded-For')}" + ) return HttpResponse("Upon reading this, the http client was enlightened.")