From 1ad82499de6f922972909904787e53b995a029a8 Mon Sep 17 00:00:00 2001 From: Shreya Date: Thu, 25 Mar 2021 19:58:50 +0530 Subject: [PATCH] Attempt to remove custom PBA file when resetting config only if filename exists in DB --- .../monkey_island/cc/resources/pba_file_upload.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/monkey/monkey_island/cc/resources/pba_file_upload.py b/monkey/monkey_island/cc/resources/pba_file_upload.py index 16d71cfeb5f..5f41964cb88 100644 --- a/monkey/monkey_island/cc/resources/pba_file_upload.py +++ b/monkey/monkey_island/cc/resources/pba_file_upload.py @@ -69,13 +69,14 @@ def delete(self, file_type): PBA_LINUX_FILENAME_PATH if file_type == "PBAlinux" else PBA_WINDOWS_FILENAME_PATH ) filename = ConfigService.get_config_value(filename_path) - file_path = Path(env_singleton.env.get_config().data_dir_abs_path).joinpath(filename) - try: - if os.path.exists(file_path): - os.remove(file_path) - ConfigService.set_config_value(filename_path, "") - except OSError as e: - LOG.error("Can't remove previously uploaded post breach files: %s" % e) + if filename: + file_path = Path(env_singleton.env.get_config().data_dir_abs_path).joinpath(filename) + try: + if os.path.exists(file_path): + os.remove(file_path) + ConfigService.set_config_value(filename_path, "") + except OSError as e: + LOG.error("Can't remove previously uploaded post breach files: %s" % e) return {}