From fb1a577823122826325035bd416b85f7adb3acd6 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 13 Jun 2022 12:55:41 +0200 Subject: [PATCH] Agent: Add control client proxies to tunnel telem initialization --- monkey/infection_monkey/monkey.py | 2 +- monkey/infection_monkey/telemetry/tunnel_telem.py | 7 ++++--- .../infection_monkey/telemetry/test_tunnel_telem.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/monkey/infection_monkey/monkey.py b/monkey/infection_monkey/monkey.py index 13930ecda..e8be1f05d 100644 --- a/monkey/infection_monkey/monkey.py +++ b/monkey/infection_monkey/monkey.py @@ -167,7 +167,7 @@ class InfectionMonkey: self._monkey_inbound_tunnel.start() StateTelem(is_done=False, version=get_version()).send() - TunnelTelem().send() + TunnelTelem(self.cc_client.proxies).send() self._build_master() diff --git a/monkey/infection_monkey/telemetry/tunnel_telem.py b/monkey/infection_monkey/telemetry/tunnel_telem.py index f8d562771..efe917643 100644 --- a/monkey/infection_monkey/telemetry/tunnel_telem.py +++ b/monkey/infection_monkey/telemetry/tunnel_telem.py @@ -1,15 +1,16 @@ +from typing import Mapping + from common.common_consts.telem_categories import TelemCategoryEnum -from infection_monkey.control import ControlClient from infection_monkey.telemetry.base_telem import BaseTelem class TunnelTelem(BaseTelem): - def __init__(self): + def __init__(self, proxy: Mapping[str, str]): """ Default tunnel telemetry constructor """ super(TunnelTelem, self).__init__() - self.proxy = ControlClient.proxies.get("https") + self.proxy = proxy.get("https") telem_category = TelemCategoryEnum.TUNNEL diff --git a/monkey/tests/unit_tests/infection_monkey/telemetry/test_tunnel_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_tunnel_telem.py index eab763790..eb18307ce 100644 --- a/monkey/tests/unit_tests/infection_monkey/telemetry/test_tunnel_telem.py +++ b/monkey/tests/unit_tests/infection_monkey/telemetry/test_tunnel_telem.py @@ -7,7 +7,7 @@ from infection_monkey.telemetry.tunnel_telem import TunnelTelem @pytest.fixture def tunnel_telem_test_instance(): - return TunnelTelem() + return TunnelTelem({}) def test_tunnel_telem_send(tunnel_telem_test_instance, spy_send_telemetry):