From a360e8514e72d9cb40233e02663d054f703417f7 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 13 May 2020 16:39:47 +0300 Subject: [PATCH] Fixed a bug of multiple telemetry exports in a single island run. --- monkey/monkey_island/cc/resources/test/utils/telem_store.py | 3 +++ monkey/monkey_island/cc/services/infection_lifecycle.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/resources/test/utils/telem_store.py b/monkey/monkey_island/cc/resources/test/utils/telem_store.py index 18ebfd244..ed15ae22e 100644 --- a/monkey/monkey_island/cc/resources/test/utils/telem_store.py +++ b/monkey/monkey_island/cc/resources/test/utils/telem_store.py @@ -19,6 +19,8 @@ logger = logging.getLogger(__name__) class TestTelemStore: + TELEMS_EXPORTED = False + @staticmethod def store_test_telem(f): @wraps(f) @@ -46,6 +48,7 @@ class TestTelemStore: for test_telem in TestTelem.objects(): with open(TestTelemStore.get_unique_file_path_for_test_telem(TELEM_SAMPLE_DIR, test_telem), 'w') as file: file.write(test_telem.to_json(indent=2)) + TestTelemStore.TELEMS_EXPORTED = True logger.info("Telemetries exported!") @staticmethod diff --git a/monkey/monkey_island/cc/services/infection_lifecycle.py b/monkey/monkey_island/cc/services/infection_lifecycle.py index e79cfe947..425937c7b 100644 --- a/monkey/monkey_island/cc/services/infection_lifecycle.py +++ b/monkey/monkey_island/cc/services/infection_lifecycle.py @@ -47,5 +47,5 @@ class InfectionLifecycle: # we want to skip and reply. if not is_report_being_generated() and not ReportService.is_latest_report_exists(): safe_generate_reports() - if ConfigService.is_test_telem_export_enabled(): + if ConfigService.is_test_telem_export_enabled() and not TestTelemStore.TELEMS_EXPORTED: TestTelemStore.export_test_telems()