2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-06-05 07:51:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2012-12-07 23:00:13 +01:00
|
|
|
from django.views.debug import SafeExceptionReporterFilter
|
2016-06-05 07:51:18 +02:00
|
|
|
from django.http import HttpRequest, build_request_repr
|
2012-12-07 23:00:13 +01:00
|
|
|
|
2013-08-06 21:38:05 +02:00
|
|
|
class ZulipExceptionReporterFilter(SafeExceptionReporterFilter):
|
2012-12-07 23:00:13 +01:00
|
|
|
def get_post_parameters(self, request):
|
2016-06-05 07:51:18 +02:00
|
|
|
# type: (HttpRequest) -> Dict[str, Any]
|
2012-12-19 08:20:49 +01:00
|
|
|
filtered_post = SafeExceptionReporterFilter.get_post_parameters(self, request).copy()
|
2013-01-23 17:35:49 +01:00
|
|
|
filtered_vars = ['content', 'secret', 'password', 'key', 'api-key', 'subject', 'stream',
|
2013-12-11 17:53:11 +01:00
|
|
|
'subscriptions', 'to', 'csrfmiddlewaretoken', 'api_key']
|
2012-12-19 08:20:49 +01:00
|
|
|
|
|
|
|
for var in filtered_vars:
|
|
|
|
if var in filtered_post:
|
|
|
|
filtered_post[var] = '**********'
|
2012-12-07 23:00:13 +01:00
|
|
|
return filtered_post
|
2013-01-25 19:34:07 +01:00
|
|
|
def get_request_repr(self, request):
|
2016-06-05 07:51:18 +02:00
|
|
|
# type: (HttpRequest) -> str
|
2013-01-25 19:34:07 +01:00
|
|
|
if request is None:
|
|
|
|
return repr(None)
|
|
|
|
else:
|
|
|
|
return build_request_repr(request,
|
|
|
|
POST_override=self.get_post_parameters(request),
|
|
|
|
COOKIES_override="**********",
|
|
|
|
META_override="**********")
|