2018-10-19 23:53:33 +02:00
|
|
|
import re
|
2017-03-03 19:01:52 +01:00
|
|
|
from typing import Any, Dict
|
2016-06-05 07:51:18 +02:00
|
|
|
|
2017-01-29 23:04:06 +01:00
|
|
|
from django.http import HttpRequest
|
2017-11-16 00:50:28 +01:00
|
|
|
from django.views.debug import SafeExceptionReporterFilter
|
2012-12-07 23:00:13 +01:00
|
|
|
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2013-08-06 21:38:05 +02:00
|
|
|
class ZulipExceptionReporterFilter(SafeExceptionReporterFilter):
|
2017-11-27 07:33:05 +01:00
|
|
|
def get_post_parameters(self, request: 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',
|
2019-04-30 23:10:59 +02:00
|
|
|
'subscriptions', 'to', 'csrfmiddlewaretoken', 'api_key',
|
|
|
|
'realm_counts', 'installation_counts']
|
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
|
2018-10-19 23:53:33 +02:00
|
|
|
|
|
|
|
def clean_data_from_query_parameters(val: str) -> str:
|
|
|
|
return re.sub(r"([a-z_-]+=)([^&]+)([&]|$)", r"\1******\3", val)
|