Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
bfdb0b5a
Unverified
Commit
bfdb0b5a
authored
Nov 29, 2017
by
Thom Wiggers
📐
Browse files
Implement exception filter
Hides HTTP Cookies and Authorization header
parent
99db59f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
website/thaliawebsite/settings/settings.py
View file @
bfdb0b5a
...
...
@@ -284,3 +284,7 @@ TINYMCE_DEFAULT_CONFIG = {
'relative_urls'
:
False
,
'remove_script_host'
:
False
,
}
DEFAULT_EXCEPTION_REPORTER_FILTER
=
(
'utils.exception_filter.ThaliaSafeExceptionReporterFilter'
)
website/utils/exception_filter.py
0 → 100644
View file @
bfdb0b5a
import
logging
from
django.views.debug
import
(
SafeExceptionReporterFilter
,
CLEANSED_SUBSTITUTE
)
logger
=
logging
.
getLogger
(
__name__
)
class
ThaliaSafeExceptionReporterFilter
(
SafeExceptionReporterFilter
):
"""Filter additional variables from tracebacks"""
def
get_traceback_frame_variables
(
self
,
request
,
tb_frame
):
"""Filter traceback frame variables"""
local_vars
=
super
().
get_traceback_frame_variables
(
request
,
tb_frame
)
if
self
.
is_active
(
request
):
for
name
,
val
in
local_vars
:
if
name
==
'request'
:
try
:
val
.
COOKIES
=
{
'cookies have been cleaned'
:
True
}
val
.
META
[
'HTTP_COOKIE'
]
=
CLEANSED_SUBSTITUTE
val
.
META
[
'HTTP_AUTHORIZATION'
]
=
CLEANSED_SUBSTITUTE
except
(
AttributeError
,
IndexError
):
logger
.
exception
(
"Somehow cleaning the request failed"
)
return
local_vars
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment