Show More
@@ -1,22 +1,23 | |||||
1 | """Tornado handlers for security logging.""" |
|
1 | """Tornado handlers for security logging.""" | |
2 |
|
2 | |||
3 | # Copyright (c) IPython Development Team. |
|
3 | # Copyright (c) IPython Development Team. | |
4 | # Distributed under the terms of the Modified BSD License. |
|
4 | # Distributed under the terms of the Modified BSD License. | |
5 |
|
5 | |||
6 | from tornado import gen, web |
|
6 | from tornado import gen, web | |
7 |
|
7 | |||
8 | from ...base.handlers import IPythonHandler, json_errors |
|
8 | from ...base.handlers import IPythonHandler, json_errors | |
9 | from . import csp_report_uri |
|
9 | from . import csp_report_uri | |
10 |
|
10 | |||
11 | class CSPReportHandler(IPythonHandler): |
|
11 | class CSPReportHandler(IPythonHandler): | |
12 | '''Accepts a content security policy violation report''' |
|
12 | '''Accepts a content security policy violation report''' | |
13 | @web.authenticated |
|
13 | @web.authenticated | |
14 | @json_errors |
|
14 | @json_errors | |
15 | def post(self): |
|
15 | def post(self): | |
16 | '''Log a content security policy violation report''' |
|
16 | '''Log a content security policy violation report''' | |
17 | csp_report = self.get_json_body() |
|
17 | csp_report = self.get_json_body() | |
18 | self.log.warn(csp_report) |
|
18 | self.log.warn("Content security violation: %s", | |
|
19 | self.request.body.decode('utf8', 'replace')) | |||
19 |
|
20 | |||
20 | default_handlers = [ |
|
21 | default_handlers = [ | |
21 | (csp_report_uri, CSPReportHandler) |
|
22 | (csp_report_uri, CSPReportHandler) | |
22 | ] |
|
23 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now