diff --git a/monkey/infection_monkey/ransomware/ransomware_payload.py b/monkey/infection_monkey/ransomware/ransomware_payload.py index e89dc2625..d6a36ab5b 100644 --- a/monkey/infection_monkey/ransomware/ransomware_payload.py +++ b/monkey/infection_monkey/ransomware/ransomware_payload.py @@ -5,7 +5,7 @@ from infection_monkey.ransomware.valid_file_extensions import VALID_FILE_EXTENSI from infection_monkey.utils.dir_utils import ( file_extension_filter, filter_files, - get_all_files_in_directory, + get_all_regular_files_in_directory, ) from infection_monkey.utils.environment import is_windows_os @@ -26,7 +26,7 @@ class RansomewarePayload: def _find_files(self): file_filters = [file_extension_filter(VALID_FILE_EXTENSIONS_FOR_ENCRYPTION)] - all_files = get_all_files_in_directory(self.target_dir) + all_files = get_all_regular_files_in_directory(self.target_dir) return filter_files(all_files, file_filters) def _encrypt_files(self, file_list): diff --git a/monkey/infection_monkey/utils/dir_utils.py b/monkey/infection_monkey/utils/dir_utils.py index 2a7797a7b..8b026d36d 100644 --- a/monkey/infection_monkey/utils/dir_utils.py +++ b/monkey/infection_monkey/utils/dir_utils.py @@ -2,7 +2,7 @@ from pathlib import Path from typing import Callable, List, Set -def get_all_files_in_directory(dir_path: Path) -> List[Path]: +def get_all_regular_files_in_directory(dir_path: Path) -> List[Path]: return [f for f in dir_path.iterdir() if f.is_file()] diff --git a/monkey/tests/unit_tests/infection_monkey/utils/test_dir_utils.py b/monkey/tests/unit_tests/infection_monkey/utils/test_dir_utils.py index 4657155c0..d2f30a311 100644 --- a/monkey/tests/unit_tests/infection_monkey/utils/test_dir_utils.py +++ b/monkey/tests/unit_tests/infection_monkey/utils/test_dir_utils.py @@ -1,7 +1,7 @@ from infection_monkey.utils.dir_utils import ( file_extension_filter, filter_files, - get_all_files_in_directory, + get_all_regular_files_in_directory, ) FILES = ["file.jpg.zip", "file.xyz", "1.tar", "2.tgz"] @@ -29,35 +29,35 @@ def add_files_to_dir(parent_dir): return files -def test_get_all_files_in_directory__no_files(tmp_path, monkeypatch): +def test_get_all_regular_files_in_directory__no_files(tmp_path, monkeypatch): add_subdirs_to_dir(tmp_path) expected_return_value = [] - assert get_all_files_in_directory(tmp_path) == expected_return_value + assert get_all_regular_files_in_directory(tmp_path) == expected_return_value -def test_get_all_files_in_directory__has_files(tmp_path, monkeypatch): +def test_get_all_regular_files_in_directory__has_files(tmp_path, monkeypatch): add_subdirs_to_dir(tmp_path) files = add_files_to_dir(tmp_path) expected_return_value = sorted(files) - assert sorted(get_all_files_in_directory(tmp_path)) == expected_return_value + assert sorted(get_all_regular_files_in_directory(tmp_path)) == expected_return_value -def test_get_all_files_in_directory__subdir_has_files(tmp_path, monkeypatch): +def test_get_all_regular_files_in_directory__subdir_has_files(tmp_path, monkeypatch): subdirs = add_subdirs_to_dir(tmp_path) add_files_to_dir(subdirs[0]) files = add_files_to_dir(tmp_path) expected_return_value = sorted(files) - assert sorted(get_all_files_in_directory(tmp_path)) == expected_return_value + assert sorted(get_all_regular_files_in_directory(tmp_path)) == expected_return_value def test_filter_files__no_results(tmp_path): add_files_to_dir(tmp_path) - files_in_dir = get_all_files_in_directory(tmp_path) + files_in_dir = get_all_regular_files_in_directory(tmp_path) filtered_files = filter_files(files_in_dir, [lambda _: False]) assert len(filtered_files) == 0 @@ -67,7 +67,7 @@ def test_filter_files__all_true(tmp_path): files = add_files_to_dir(tmp_path) expected_return_value = sorted(files) - files_in_dir = get_all_files_in_directory(tmp_path) + files_in_dir = get_all_regular_files_in_directory(tmp_path) filtered_files = filter_files(files_in_dir, [lambda _: True]) assert sorted(filtered_files) == expected_return_value @@ -78,7 +78,7 @@ def test_file_extension_filter(tmp_path): files = add_files_to_dir(tmp_path) - files_in_dir = get_all_files_in_directory(tmp_path) + files_in_dir = get_all_regular_files_in_directory(tmp_path) filtered_files = filter_files(files_in_dir, [file_extension_filter(valid_extensions)]) assert sorted(files[0:2]) == sorted(filtered_files)