diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2011-06-08 22:18:46 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2011-06-08 22:18:46 +0000 |
| commit | 45e55b91435541203f517770c654675f67fa6a3b (patch) | |
| tree | b11800b084b32d91cf3a59cd40993c9b05503321 /django/utils/log.py | |
| parent | bb12a02bd8cd6e33b947b2cfa01292822099bb19 (diff) | |
Fixed #14614 - filtering of sensitive information in 500 error reports.
This adds a flexible mechanism for filtering what request/traceback
information is shown in 500 error emails and logs. It also applies
screening to some views known to be sensitive e.g. views that handle
passwords.
Thanks to oaylanc for the report and many thanks to Julien Phalip for the
patch and the rest of the work on this.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16339 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/log.py')
| -rw-r--r-- | django/utils/log.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/django/utils/log.py b/django/utils/log.py index 93e38d1e4b..969a9d9609 100644 --- a/django/utils/log.py +++ b/django/utils/log.py @@ -1,6 +1,10 @@ import logging import sys +import traceback + +from django.conf import settings from django.core import mail +from django.views.debug import ExceptionReporter, get_exception_reporter_filter # Make sure a NullHandler is available # This was added in Python 2.7/3.2 @@ -35,13 +39,9 @@ class AdminEmailHandler(logging.Handler): """An exception log handler that emails log entries to site admins. If the request is passed as the first argument to the log record, - request data will be provided in the + request data will be provided in the email report. """ def emit(self, record): - import traceback - from django.conf import settings - from django.views.debug import ExceptionReporter - try: request = record.request subject = '%s (%s IP): %s' % ( @@ -49,15 +49,15 @@ class AdminEmailHandler(logging.Handler): (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), record.msg ) - request_repr = repr(request) + filter = get_exception_reporter_filter(request) + request_repr = filter.get_request_repr(request) except: subject = '%s: %s' % ( record.levelname, record.msg ) - request = None - request_repr = "Request repr() unavailable" + request_repr = "Request repr() unavailable." if record.exc_info: exc_info = record.exc_info |
