From b6703becbc83a71eca0926e05d9fc187677f3b9e Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Fri, 22 Jul 2022 12:54:20 +0530 Subject: [PATCH] BB: Get rid of TestConfigurationParser and move its functions outside --- .../blackbox/island_client/test_configuration_parser.py | 6 ++---- envs/monkey_zoo/blackbox/test_blackbox.py | 6 +++--- envs/monkey_zoo/blackbox/tests/exploitation.py | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/envs/monkey_zoo/blackbox/island_client/test_configuration_parser.py b/envs/monkey_zoo/blackbox/island_client/test_configuration_parser.py index 139d18f24..9fcb6c8a6 100644 --- a/envs/monkey_zoo/blackbox/island_client/test_configuration_parser.py +++ b/envs/monkey_zoo/blackbox/island_client/test_configuration_parser.py @@ -3,7 +3,5 @@ from typing import Iterable from envs.monkey_zoo.blackbox.test_configurations.test_configuration import TestConfiguration -class TestConfigurationParser: - @staticmethod - def get_target_ips(test_configuration: TestConfiguration) -> Iterable[str]: - return test_configuration.agent_configuration.propagation.network_scan.targets.subnets +def get_target_ips(test_configuration: TestConfiguration) -> Iterable[str]: + return test_configuration.agent_configuration.propagation.network_scan.targets.subnets diff --git a/envs/monkey_zoo/blackbox/test_blackbox.py b/envs/monkey_zoo/blackbox/test_blackbox.py index 59af36147..961d094fb 100644 --- a/envs/monkey_zoo/blackbox/test_blackbox.py +++ b/envs/monkey_zoo/blackbox/test_blackbox.py @@ -8,7 +8,7 @@ from envs.monkey_zoo.blackbox.analyzers.communication_analyzer import Communicat from envs.monkey_zoo.blackbox.analyzers.zerologon_analyzer import ZerologonAnalyzer from envs.monkey_zoo.blackbox.gcp_test_machine_list import GCP_TEST_MACHINE_LIST from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient -from envs.monkey_zoo.blackbox.island_client.test_configuration_parser import TestConfigurationParser +from envs.monkey_zoo.blackbox.island_client.test_configuration_parser import get_target_ips from envs.monkey_zoo.blackbox.log_handlers.test_logs_handler import TestLogsHandler from envs.monkey_zoo.blackbox.test_configurations import ( depth_1_a_test_configuration, @@ -87,7 +87,7 @@ class TestMonkeyBlackbox: ): analyzer = CommunicationAnalyzer( island_client, - TestConfigurationParser.get_target_ips(test_configuration), + get_target_ips(test_configuration), ) log_handler = TestLogsHandler( test_name, island_client, TestMonkeyBlackbox.get_log_dir_path() @@ -142,7 +142,7 @@ class TestMonkeyBlackbox: zero_logon_analyzer = ZerologonAnalyzer(island_client, expected_creds) communication_analyzer = CommunicationAnalyzer( island_client, - TestConfigurationParser.get_target_ips(zerologon_test_configuration), + get_target_ips(zerologon_test_configuration), ) log_handler = TestLogsHandler( test_name, island_client, TestMonkeyBlackbox.get_log_dir_path() diff --git a/envs/monkey_zoo/blackbox/tests/exploitation.py b/envs/monkey_zoo/blackbox/tests/exploitation.py index f551afaa5..b4cf40eba 100644 --- a/envs/monkey_zoo/blackbox/tests/exploitation.py +++ b/envs/monkey_zoo/blackbox/tests/exploitation.py @@ -1,7 +1,7 @@ import logging from time import sleep -from envs.monkey_zoo.blackbox.island_client.test_configuration_parser import TestConfigurationParser +from envs.monkey_zoo.blackbox.island_client.test_configuration_parser import get_target_ips from envs.monkey_zoo.blackbox.tests.basic_test import BasicTest from envs.monkey_zoo.blackbox.utils.test_timer import TestTimer @@ -36,7 +36,7 @@ class ExploitationTest(BasicTest): def print_test_starting_info(self): LOGGER.info("Started {} test".format(self.name)) - machine_list = ", ".join(TestConfigurationParser.get_target_ips(self.test_configuration)) + machine_list = ", ".join(get_target_ips(self.test_configuration)) LOGGER.info(f"Machines participating in test: {machine_list}") print("")