From 77e3c8a257443713477260a53762932d8a5278ad Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 23 Jun 2021 20:06:36 -0400 Subject: [PATCH] agent: Add telemetry messenger interface The telemetry classes have too many responsibilities. At the moment, one such responsibility is to send themselves to the island. As our plugin interfaces develop, the need may arise to send telemetry using different mechanisms. To isolate the RansomwarePayload from these changes, the ITelemetryMessenger interface is introduced in this commit. It provides a send_telemetry() method that handles the specific details of how telemetry is sent to the Island. At the present time, the TelemetryMessengerWrapper class is introduced to handle sending telemetry. It simply wraps the existing send() method on the telemetry class. --- .../telemetry/messengers/i_telemetry_messenger.py | 9 +++++++++ .../telemetry/messengers/telemetry_messenger_wrapper.py | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 monkey/infection_monkey/telemetry/messengers/i_telemetry_messenger.py create mode 100644 monkey/infection_monkey/telemetry/messengers/telemetry_messenger_wrapper.py diff --git a/monkey/infection_monkey/telemetry/messengers/i_telemetry_messenger.py b/monkey/infection_monkey/telemetry/messengers/i_telemetry_messenger.py new file mode 100644 index 000000000..7cc2efa01 --- /dev/null +++ b/monkey/infection_monkey/telemetry/messengers/i_telemetry_messenger.py @@ -0,0 +1,9 @@ +import abc + +from infection_monkey.telemetry.base_telem import BaseTelem + + +class ITelemetryMessenger(metaclass=abc.ABCMeta): + @abc.abstractmethod + def send_telemetry(self, telemetry: BaseTelem): + pass diff --git a/monkey/infection_monkey/telemetry/messengers/telemetry_messenger_wrapper.py b/monkey/infection_monkey/telemetry/messengers/telemetry_messenger_wrapper.py new file mode 100644 index 000000000..d00f0dd23 --- /dev/null +++ b/monkey/infection_monkey/telemetry/messengers/telemetry_messenger_wrapper.py @@ -0,0 +1,7 @@ +from infection_monkey.telemetry.base_telem import BaseTelem +from infection_monkey.telemetry.messengers.i_telemetry_messenger import ITelemetryMessenger + + +class TelemetryMessengerWrapper(ITelemetryMessenger): + def send_telemetry(self, telemetry: BaseTelem): + telemetry.send()