From 41abe7e5d64f00a544daedede77314af332739aa Mon Sep 17 00:00:00 2001 From: Dan Puttick Date: Fri, 14 Jul 2017 17:52:21 -0400 Subject: [PATCH] Prevent following arbitrarily nested symlinks --- bin/filecheck.py | 4 +++- tests/test_filecheck.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/filecheck.py b/bin/filecheck.py index bbd8680..41836a8 100644 --- a/bin/filecheck.py +++ b/bin/filecheck.py @@ -737,7 +737,9 @@ class KittenGroomerFileCheck(KittenGroomerBase): if os.path.isdir(full_path): queue.append(full_path) queue += self.list_files_dirs(full_path) - elif os.path.isfile(full_path): + elif os.path.isfile(full_path, follow_symlinks=False): + queue.append(full_path) + elif os.path.islink(full_path): queue.append(full_path) return queue diff --git a/tests/test_filecheck.py b/tests/test_filecheck.py index 4155df7..26b8318 100644 --- a/tests/test_filecheck.py +++ b/tests/test_filecheck.py @@ -90,6 +90,10 @@ def get_filename(sample_file): return os.path.basename(sample_file.path) +@fixture(scope='module') +def src_dir_path(tmpdir_factory): + return tmpdir_factory.mktemp('src').strpath + @fixture(scope='module') def dest_dir_path(tmpdir_factory): return tmpdir_factory.mktemp('dest').strpath