Excessive 404 Middleware

class smarter.lib.django.middleware.excessive_404.SmarterBlockExcessive404Middleware(get_response, *args, **kwargs)[source]

Bases: SmarterMiddlewareMixin

Middleware that throttles unauthenticated clients producing excessive 404s.

This mitigates: - automated scanners - brute-force URL probing - broken crawlers - vulnerability enumeration attempts

async async_process_response(request, response)[source]

Async entry point for ASGI deployments.

Return type:

HttpResponseBase

property formatted_class_name: str

Returns the class name formatted for logging.

Returns:

The formatted class name as a string.

Return type:

str

increment_throttle(throttle_key)[source]

Increment the client’s 404 counter.

Return type:

None

log_404_event(request, client_ip, blocked_count)[source]

Sample logs to reduce spam during bot scans.

Return type:

None

process_response(request, response)[source]

Sync response middleware entry point.

Return type:

HttpResponseBase