From 5f714e0d9846f84474d1ba2011a0e8da4f9672c5 Mon Sep 17 00:00:00 2001 From: Shreya Date: Tue, 22 Jun 2021 19:45:50 +0530 Subject: [PATCH] agent: Move get_all_files_in_directory() from ransomware/utils.py to utils/file_utils.py --- monkey/infection_monkey/ransomware/utils.py | 7 +------ monkey/infection_monkey/utils/file_utils.py | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 monkey/infection_monkey/utils/file_utils.py diff --git a/monkey/infection_monkey/ransomware/utils.py b/monkey/infection_monkey/ransomware/utils.py index 8d4cbcc8a..50e49683c 100644 --- a/monkey/infection_monkey/ransomware/utils.py +++ b/monkey/infection_monkey/ransomware/utils.py @@ -2,6 +2,7 @@ import os from typing import List from infection_monkey.ransomware.valid_file_extensions import VALID_FILE_EXTENSIONS_FOR_ENCRYPTION +from infection_monkey.utils.file_utils import get_all_files_in_directory def get_files_to_encrypt(dir_path: str) -> List[str]: @@ -13,9 +14,3 @@ def get_files_to_encrypt(dir_path: str) -> List[str]: files_to_encrypt.append(file) return files_to_encrypt - - -def get_all_files_in_directory(dir_path: str) -> List: - return list( - filter(os.path.isfile, [os.path.join(dir_path, item) for item in os.listdir(dir_path)]) - ) diff --git a/monkey/infection_monkey/utils/file_utils.py b/monkey/infection_monkey/utils/file_utils.py new file mode 100644 index 000000000..5562dd6ec --- /dev/null +++ b/monkey/infection_monkey/utils/file_utils.py @@ -0,0 +1,8 @@ +import os +from typing import List + + +def get_all_files_in_directory(dir_path: str) -> List: + return list( + filter(os.path.isfile, [os.path.join(dir_path, item) for item in os.listdir(dir_path)]) + )