From e549a4f8f40b8bad3daececbdde46e0aa4f1b018 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Sun, 27 Jun 2021 18:11:42 -0400 Subject: [PATCH] agent: Rename TelemetryMessengerWrapper The term "wrapper" is sometimes used as synonym for the decorator pattern, whereas this class is a textbook adapter. Use the term "adapter" instead of "wrapper" and rename "TelemetryMessengerWrapper" to "LegacyTelemetryMessengerAdapter", as this class servers as an adapter between the new ITelemetryMessenger interface and the (soon to be) legacy way of sending telemetry. --- monkey/infection_monkey/monkey.py | 6 +++--- ...er_wrapper.py => legacy_telemetry_messenger_adapter.py} | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) rename monkey/infection_monkey/telemetry/messengers/{telemetry_messenger_wrapper.py => legacy_telemetry_messenger_adapter.py} (52%) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index bf3ae80a6..845f754f7 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -25,8 +25,8 @@ from infection_monkey.system_singleton import SystemSingleton from infection_monkey.telemetry.attack.t1106_telem import T1106Telem from infection_monkey.telemetry.attack.t1107_telem import T1107Telem from infection_monkey.telemetry.attack.victim_host_telem import VictimHostTelem -from infection_monkey.telemetry.messengers.telemetry_messenger_wrapper import ( - TelemetryMessengerWrapper, +from infection_monkey.telemetry.messengers.legacy_telemetry_messenger_adapter import ( + LegacyTelemetryMessengerAdapter, ) from infection_monkey.telemetry.scan_telem import ScanTelem from infection_monkey.telemetry.state_telem import StateTelem @@ -470,7 +470,7 @@ class InfectionMonkey(object): @staticmethod def run_ransomware(): try: - telemetry_messenger = TelemetryMessengerWrapper() + telemetry_messenger = LegacyTelemetryMessengerAdapter() RansomewarePayload(WormConfiguration.ransomware, telemetry_messenger).run_payload() except Exception as ex: LOG.error(f"An unexpected error occurred while running the ransomware payload: {ex}") diff --git a/monkey/infection_monkey/telemetry/messengers/telemetry_messenger_wrapper.py b/monkey/infection_monkey/telemetry/messengers/legacy_telemetry_messenger_adapter.py similarity index 52% rename from monkey/infection_monkey/telemetry/messengers/telemetry_messenger_wrapper.py rename to monkey/infection_monkey/telemetry/messengers/legacy_telemetry_messenger_adapter.py index e436cdd46..cbbe03595 100644 --- a/monkey/infection_monkey/telemetry/messengers/telemetry_messenger_wrapper.py +++ b/monkey/infection_monkey/telemetry/messengers/legacy_telemetry_messenger_adapter.py @@ -2,6 +2,11 @@ from infection_monkey.telemetry.i_telem import ITelem from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger -class TelemetryMessengerWrapper(ITelemetryMessenger): +class LegacyTelemetryMessengerAdapter(ITelemetryMessenger): + """ + Provides an adapter between modules that require an ITelemetryMessenger and the + legacy method for sending telemetry. + """ + def send_telemetry(self, telemetry: ITelem): telemetry.send()