mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-10 00:03:24 +00:00
better honeypot logging
This commit is contained in:
parent
002d8f80a6
commit
03d15ddded
@ -1,12 +1,15 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from time import localtime, strftime
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from django.http import HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
from django.test.client import WSGIRequest
|
|
||||||
|
|
||||||
|
|
||||||
def custom_honeypot_error(
|
def custom_honeypot_error(
|
||||||
request: WSGIRequest, context: dict[str, Any]
|
request: HttpRequest, context: dict[str, Any]
|
||||||
) -> HttpResponse:
|
) -> 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.")
|
return HttpResponse("Upon reading this, the http client was enlightened.")
|
||||||
|
Loading…
Reference in New Issue
Block a user