log refusal to serve hidden files dirs

This commit is contained in:
Paul Ivanov 2014-03-03 12:35:37 -08:00
parent 8c5b32c987
commit d6f2dfefea
3 changed files with 5 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)