mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Apply CSP sandboxing for nbconvert responses
These may contain untrusted content, so they should be treated as being from a different domain to the notebook server.
This commit is contained in:
parent
04a686dbaf
commit
107a89fce5
@ -78,6 +78,13 @@ class NbconvertFileHandler(IPythonHandler):
|
||||
|
||||
SUPPORTED_METHODS = ('GET',)
|
||||
|
||||
@property
|
||||
def content_security_policy(self):
|
||||
# In case we're serving HTML/SVG, confine any Javascript to a unique
|
||||
# origin so it can't interact with the notebook server.
|
||||
return super(NbconvertFileHandler, self).content_security_policy + \
|
||||
"; sandbox allow-scripts"
|
||||
|
||||
@web.authenticated
|
||||
def get(self, format, path):
|
||||
|
||||
@ -145,6 +152,13 @@ class NbconvertFileHandler(IPythonHandler):
|
||||
class NbconvertPostHandler(IPythonHandler):
|
||||
SUPPORTED_METHODS = ('POST',)
|
||||
|
||||
@property
|
||||
def content_security_policy(self):
|
||||
# In case we're serving HTML/SVG, confine any Javascript to a unique
|
||||
# origin so it can't interact with the notebook server.
|
||||
return super(NbconvertPostHandler, self).content_security_policy + \
|
||||
"; sandbox allow-scripts"
|
||||
|
||||
@web.authenticated
|
||||
def post(self, format):
|
||||
exporter = get_exporter(format, config=self.config)
|
||||
|
Loading…
Reference in New Issue
Block a user