Skip to content

Commit

Permalink
forbid absolute paths for plain git repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiosantoscode committed Jan 10, 2020
1 parent 0e2ef47 commit 9f279b3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dvc/repo/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down

0 comments on commit 9f279b3

Please sign in to comment.