From 770492a955af22bb87d015a3d7918b67504eb938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 15 Mar 2021 14:57:17 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20Make=20sure=20to=20validate=20lo?= =?UTF-8?q?g=20paths=20for=20zip=20bundle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also do the same for timelapses. For individual files, the LargeResponseHandler takes care of this validation. For zip downloads however, we need to do it. An earlier refactoring accidentally applied the same logic to the invididual downloads as well, though in a broken way, this now fixes behaviour in both variants. --- src/octoprint/server/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 6a92032bb..961b5600c 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -760,8 +760,10 @@ class Server(object): } timelapses_path_validator = { "path_validation": util.tornado.path_validation_factory( - lambda path: not octoprint.util.is_hidden_path(path) - and octoprint.timelapse.valid_timelapse(path), + lambda path: valid_timelapse(path) + and os.path.realpath(os.path.abspath(path)).startswith( + settings().getBaseFolder("timelapse") + ), status_code=400, ) } @@ -777,7 +779,10 @@ class Server(object): } logs_path_validator = { "path_validation": util.tornado.path_validation_factory( - valid_log, + lambda path: valid_log(path) + and os.path.realpath(os.path.abspath(path)).startswith( + settings().getBaseFolder("logs") + ), status_code=400, ) }