From 92da3b78db12d3abe9ab6ca361e25224890ca45d Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 19 Sep 2022 19:44:16 -0400 Subject: [PATCH] Agent: Reimplement HTTPIslandAPIClient.send_log() as member, not static --- monkey/infection_monkey/control.py | 2 +- .../island_api_client/http_island_api_client.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/monkey/infection_monkey/control.py b/monkey/infection_monkey/control.py index 82a7250c4..9d7daec6e 100644 --- a/monkey/infection_monkey/control.py +++ b/monkey/infection_monkey/control.py @@ -78,7 +78,7 @@ class ControlClient: return try: telemetry = {"monkey_guid": GUID, "log": json.dumps(log)} - HTTPIslandAPIClient.send_log(self.server_address, json.dumps(telemetry)) + self._island_api_client.send_log(json.dumps(telemetry)) except Exception as exc: logger.warning(f"Error connecting to control server {self.server_address}: {exc}") diff --git a/monkey/infection_monkey/island_api_client/http_island_api_client.py b/monkey/infection_monkey/island_api_client/http_island_api_client.py index ceddc7de2..98bca7562 100644 --- a/monkey/infection_monkey/island_api_client/http_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/http_island_api_client.py @@ -38,12 +38,13 @@ class HTTPIslandAPIClient(IIslandAPIClient): timeout=MEDIUM_REQUEST_TIMEOUT, ) - @staticmethod + self._island_server = island_server + @handle_island_errors - def send_log(server_address: str, data: str): + def send_log(self, log_contents: str): requests.post( # noqa: DUO123 - "https://%s/api/log" % (server_address,), - json=data, + f"https://{self._island_server}/api/log", + json=log_contents, verify=False, timeout=MEDIUM_REQUEST_TIMEOUT, )