security app causing django Internal Server Error: /archives/search emails
Greetings,
I have set up a few lists and all seems to be working as expected, however I get a large number of emails due to internal server errors received when my security application is testing exploits to list URLs such as the following:
Is there any django logging filter changes that can be made to avoid receiving these emails? Any assistance would be greatly appreciated.
Thank you!
On 6/26/24 10:43 AM, msimpson@oicr.on.ca wrote:
Is there any django logging filter changes that can be made to avoid receiving these emails? Any assistance would be greatly appreciated.
Have you seen https://docs.djangoproject.com/en/5.0/howto/error-reporting/#server-errors and https://docs.djangoproject.com/en/5.0/topics/logging/
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Thanks, I am familiar with the links, but not too experienced with django logging filters. I will do some experimenting though.
Ok, after some trial and error, I was able to resolve the issue. Here's what I did in case someone else encounters this issue. Updated logging as follows:
created function:
def skip_scanner(record): """Returns Boolean value for filter to distinguish between real and scanner requests""" scanner = ("<scanner IPs>") record.ip = record.request.META.get('HTTP_X_FORWARDED_FOR') # ip if record.ip in scanner: return False # the request does not require an email as it is from my scanners else: return True # the request DOES require an email as it is NOT from my scanners
Addition to the filters section:
'skip_scanner': {
'()': 'django.utils.log.CallbackFilter',
'callback': skip_scanner
}
Update to the 'mail_admins' in the 'handlers' section:
'filters': ['require_debug_false','skip_scanner'],
participants (3)
-
Mark Sapiro
-
sun zi
-
sun zi