mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
log refusal to serve hidden files dirs
This commit is contained in:
parent
8c5b32c987
commit
d6f2dfefea
@ -263,6 +263,7 @@ class AuthenticatedFileHandler(IPythonHandler, web.StaticFileHandler):
|
||||
abs_path = super(AuthenticatedFileHandler, self).validate_absolute_path(root, absolute_path)
|
||||
abs_root = os.path.abspath(root)
|
||||
if is_hidden(abs_path, abs_root):
|
||||
self.log.info("Refusing to serve hidden file, via 404 Error")
|
||||
raise web.HTTPError(404)
|
||||
return abs_path
|
||||
|
||||
|
@ -180,6 +180,8 @@ class FileNotebookManager(NotebookManager):
|
||||
"""List the directories for a given API style path."""
|
||||
path = path.strip('/')
|
||||
os_path = self._get_os_path('', path)
|
||||
if is_hidden(os_path, self.notebook_dir):
|
||||
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
||||
if not os.path.isdir(os_path) or is_hidden(os_path, self.notebook_dir):
|
||||
raise web.HTTPError(404, u'directory does not exist: %r' % os_path)
|
||||
dir_names = os.listdir(os_path)
|
||||
|
@ -62,6 +62,8 @@ class TreeHandler(IPythonHandler):
|
||||
self.log.debug("Redirecting %s to %s", self.request.path, url)
|
||||
self.redirect(url)
|
||||
else:
|
||||
if nbm.is_hidden(path):
|
||||
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
||||
if not nbm.path_exists(path=path) or nbm.is_hidden(path):
|
||||
# Directory is hidden or does not exist.
|
||||
raise web.HTTPError(404)
|
||||
|
Loading…
Reference in New Issue
Block a user