From b77ae9964e45b037fc2d333d52feb3b555a0a626 Mon Sep 17 00:00:00 2001 From: Arthur Deierlein Date: Fri, 23 Feb 2024 10:46:21 +0100 Subject: [PATCH] fix(api/tracking): ingore symlinks --- api/outdated/outdated/tests/test_tracking.py | 11 +++++++++++ api/outdated/outdated/tracking.py | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/api/outdated/outdated/tests/test_tracking.py b/api/outdated/outdated/tests/test_tracking.py index 690d9623..14630faf 100644 --- a/api/outdated/outdated/tests/test_tracking.py +++ b/api/outdated/outdated/tests/test_tracking.py @@ -1,3 +1,4 @@ +from pathlib import Path from unittest.mock import PropertyMock, call import pytest @@ -283,6 +284,16 @@ def test_lockfiles(db, project, tmp_repo_root, exists): assert not exists +def test_lockfiles_ignore_symlinks(db, project, tmp_repo_root): + tracker = Tracker(project) + tracker.local_path.mkdir(parents=True, exist_ok=False) + + lockfiles = tracker.lockfiles + assert lockfiles == [] + (tracker.local_path / "yarn.lock").symlink_to(Path("/proc/1/environ")) + assert tracker.lockfiles == [] + + @pytest.mark.django_db() def test_delete(tmp_repo_root, project_factory): project = project_factory(repo="my.git.com/foo/bar") diff --git a/api/outdated/outdated/tracking.py b/api/outdated/outdated/tracking.py index 6a6db517..fd5ac350 100644 --- a/api/outdated/outdated/tracking.py +++ b/api/outdated/outdated/tracking.py @@ -85,7 +85,13 @@ def lockfiles(self): if ".git" in dirs: dirs.remove(".git") - lockfile_list.extend([Path(root).joinpath(file) for file in files]) + lockfile_list.extend( + [ + Path(root).joinpath(file) + for file in files + if not Path(root).joinpath(file).is_symlink() + ] + ) return lockfile_list