From 9f279b396846b7038840074563c1ac9c715f7ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Santos?= Date: Fri, 10 Jan 2020 23:15:03 +0000 Subject: [PATCH] forbid absolute paths for plain git repositories --- dvc/repo/get.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dvc/repo/get.py b/dvc/repo/get.py index 588e13ba1c..c2a187c67b 100644 --- a/dvc/repo/get.py +++ b/dvc/repo/get.py @@ -27,6 +27,11 @@ def __init__(self): ) +def _forbid_absolute_path(path): + if os.path.isabs(path): + raise FileNotFoundError + + @staticmethod def get(url, path, out=None, rev=None): out = resolve_output(path, out) @@ -66,8 +71,7 @@ def get(url, path, out=None, rev=None): return # Either an uncached out with absolute path or a user error - if os.path.isabs(path): - raise FileNotFoundError + _forbid_absolute_path(path) fs_copy(os.path.join(repo.root_dir, path), out) return @@ -76,6 +80,7 @@ def get(url, path, out=None, rev=None): # Not a DVC repository, continue below and copy from git pass + _forbid_absolute_path(path) raw_git_dir = cached_clone(url, rev=rev) fs_copy(os.path.join(raw_git_dir, path), out) except (OutputNotFoundError, FileNotFoundError):