BB: Rename raw_config -> serialized_config everywhere
This commit is contained in:
parent
690fb71e10
commit
f0993d94cf
|
@ -11,7 +11,7 @@ class IslandConfigParser:
|
||||||
return agent_configuration.to_json()
|
return agent_configuration.to_json()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_target_ips_from_serialized_config(raw_config: Mapping) -> Iterable:
|
def get_target_ips_from_serialized_config(serialized_config: Mapping) -> Iterable:
|
||||||
return dpath.util.get(
|
return dpath.util.get(
|
||||||
raw_config, "agent_configuration.propagation.network_scan.targets.subnets", "."
|
serialized_config, "agent_configuration.propagation.network_scan.targets.subnets", "."
|
||||||
)
|
)
|
||||||
|
|
|
@ -89,9 +89,10 @@ class TestMonkeyBlackbox:
|
||||||
test_name: str,
|
test_name: str,
|
||||||
timeout_in_seconds=DEFAULT_TIMEOUT_SECONDS,
|
timeout_in_seconds=DEFAULT_TIMEOUT_SECONDS,
|
||||||
):
|
):
|
||||||
raw_config = IslandConfigParser.get_serialized_config(agent_configuration)
|
serialized_config = IslandConfigParser.get_serialized_config(agent_configuration)
|
||||||
analyzer = CommunicationAnalyzer(
|
analyzer = CommunicationAnalyzer(
|
||||||
island_client, IslandConfigParser.get_target_ips_from_serialized_config(raw_config)
|
island_client,
|
||||||
|
IslandConfigParser.get_target_ips_from_serialized_config(serialized_config),
|
||||||
)
|
)
|
||||||
log_handler = TestLogsHandler(
|
log_handler = TestLogsHandler(
|
||||||
test_name, island_client, TestMonkeyBlackbox.get_log_dir_path()
|
test_name, island_client, TestMonkeyBlackbox.get_log_dir_path()
|
||||||
|
@ -99,7 +100,7 @@ class TestMonkeyBlackbox:
|
||||||
ExploitationTest(
|
ExploitationTest(
|
||||||
name=test_name,
|
name=test_name,
|
||||||
island_client=island_client,
|
island_client=island_client,
|
||||||
raw_config=raw_config,
|
serialized_config=serialized_config,
|
||||||
analyzers=[analyzer],
|
analyzers=[analyzer],
|
||||||
timeout=timeout_in_seconds,
|
timeout=timeout_in_seconds,
|
||||||
log_handler=log_handler,
|
log_handler=log_handler,
|
||||||
|
@ -143,10 +144,11 @@ class TestMonkeyBlackbox:
|
||||||
"aad3b435b51404eeaad3b435b51404ee",
|
"aad3b435b51404eeaad3b435b51404ee",
|
||||||
"2864b62ea4496934a5d6e86f50b834a5",
|
"2864b62ea4496934a5d6e86f50b834a5",
|
||||||
]
|
]
|
||||||
raw_config = IslandConfigParser.get_serialized_config(zerologon_test_configuration)
|
serialized_config = IslandConfigParser.get_serialized_config(zerologon_test_configuration)
|
||||||
zero_logon_analyzer = ZerologonAnalyzer(island_client, expected_creds)
|
zero_logon_analyzer = ZerologonAnalyzer(island_client, expected_creds)
|
||||||
communication_analyzer = CommunicationAnalyzer(
|
communication_analyzer = CommunicationAnalyzer(
|
||||||
island_client, IslandConfigParser.get_target_ips_from_serialized_config(raw_config)
|
island_client,
|
||||||
|
IslandConfigParser.get_target_ips_from_serialized_config(serialized_config),
|
||||||
)
|
)
|
||||||
log_handler = TestLogsHandler(
|
log_handler = TestLogsHandler(
|
||||||
test_name, island_client, TestMonkeyBlackbox.get_log_dir_path()
|
test_name, island_client, TestMonkeyBlackbox.get_log_dir_path()
|
||||||
|
@ -154,7 +156,7 @@ class TestMonkeyBlackbox:
|
||||||
ExploitationTest(
|
ExploitationTest(
|
||||||
name=test_name,
|
name=test_name,
|
||||||
island_client=island_client,
|
island_client=island_client,
|
||||||
raw_config=raw_config,
|
serialized_config=serialized_config,
|
||||||
analyzers=[zero_logon_analyzer, communication_analyzer],
|
analyzers=[zero_logon_analyzer, communication_analyzer],
|
||||||
timeout=DEFAULT_TIMEOUT_SECONDS + 30,
|
timeout=DEFAULT_TIMEOUT_SECONDS + 30,
|
||||||
log_handler=log_handler,
|
log_handler=log_handler,
|
||||||
|
|
|
@ -13,16 +13,16 @@ LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ExploitationTest(BasicTest):
|
class ExploitationTest(BasicTest):
|
||||||
def __init__(self, name, island_client, raw_config, analyzers, timeout, log_handler):
|
def __init__(self, name, island_client, serialized_config, analyzers, timeout, log_handler):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.island_client = island_client
|
self.island_client = island_client
|
||||||
self.raw_config = raw_config
|
self.serialized_config = serialized_config
|
||||||
self.analyzers = analyzers
|
self.analyzers = analyzers
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.log_handler = log_handler
|
self.log_handler = log_handler
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.island_client.import_config(self.raw_config)
|
self.island_client.import_config(self.serialized_config)
|
||||||
self.print_test_starting_info()
|
self.print_test_starting_info()
|
||||||
try:
|
try:
|
||||||
self.island_client.run_monkey_local()
|
self.island_client.run_monkey_local()
|
||||||
|
@ -37,7 +37,7 @@ class ExploitationTest(BasicTest):
|
||||||
def print_test_starting_info(self):
|
def print_test_starting_info(self):
|
||||||
LOGGER.info("Started {} test".format(self.name))
|
LOGGER.info("Started {} test".format(self.name))
|
||||||
machine_list = ", ".join(
|
machine_list = ", ".join(
|
||||||
IslandConfigParser.get_target_ips_from_serialized_config(self.raw_config)
|
IslandConfigParser.get_target_ips_from_serialized_config(self.serialized_config)
|
||||||
)
|
)
|
||||||
LOGGER.info(f"Machines participating in test: {machine_list}")
|
LOGGER.info(f"Machines participating in test: {machine_list}")
|
||||||
print("")
|
print("")
|
||||||
|
|
|
@ -20,11 +20,16 @@ class MapGenerationTest(PerformanceTest):
|
||||||
TEST_NAME = "Map generation performance test"
|
TEST_NAME = "Map generation performance test"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, island_client, raw_config, analyzers, timeout, log_handler, break_on_timeout
|
self, island_client, serialized_config, analyzers, timeout, log_handler, break_on_timeout
|
||||||
):
|
):
|
||||||
self.island_client = island_client
|
self.island_client = island_client
|
||||||
exploitation_test = ExploitationTest(
|
exploitation_test = ExploitationTest(
|
||||||
MapGenerationTest.TEST_NAME, island_client, raw_config, analyzers, timeout, log_handler
|
MapGenerationTest.TEST_NAME,
|
||||||
|
island_client,
|
||||||
|
serialized_config,
|
||||||
|
analyzers,
|
||||||
|
timeout,
|
||||||
|
log_handler,
|
||||||
)
|
)
|
||||||
performance_config = PerformanceTestConfig(
|
performance_config = PerformanceTestConfig(
|
||||||
max_allowed_single_page_time=MAX_ALLOWED_SINGLE_PAGE_TIME,
|
max_allowed_single_page_time=MAX_ALLOWED_SINGLE_PAGE_TIME,
|
||||||
|
|
|
@ -6,7 +6,7 @@ from envs.monkey_zoo.blackbox.tests.basic_test import BasicTest
|
||||||
class PerformanceTest(BasicTest, metaclass=ABCMeta):
|
class PerformanceTest(BasicTest, metaclass=ABCMeta):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __init__(
|
def __init__(
|
||||||
self, island_client, raw_config, analyzers, timeout, log_handler, break_on_timeout
|
self, island_client, serialized_config, analyzers, timeout, log_handler, break_on_timeout
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@ class PerformanceTestWorkflow(BasicTest):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.exploitation_test = exploitation_test
|
self.exploitation_test = exploitation_test
|
||||||
self.island_client = exploitation_test.island_client
|
self.island_client = exploitation_test.island_client
|
||||||
self.raw_config = exploitation_test.raw_config
|
self.serialized_config = exploitation_test.serialized_config
|
||||||
self.performance_config = performance_config
|
self.performance_config = performance_config
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.island_client.import_config(self.raw_config)
|
self.island_client.import_config(self.serialized_config)
|
||||||
self.exploitation_test.print_test_starting_info()
|
self.exploitation_test.print_test_starting_info()
|
||||||
try:
|
try:
|
||||||
self.island_client.run_monkey_local()
|
self.island_client.run_monkey_local()
|
||||||
|
|
|
@ -23,13 +23,13 @@ class ReportGenerationTest(PerformanceTest):
|
||||||
TEST_NAME = "Report generation performance test"
|
TEST_NAME = "Report generation performance test"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, island_client, raw_config, analyzers, timeout, log_handler, break_on_timeout
|
self, island_client, serialized_config, analyzers, timeout, log_handler, break_on_timeout
|
||||||
):
|
):
|
||||||
self.island_client = island_client
|
self.island_client = island_client
|
||||||
exploitation_test = ExploitationTest(
|
exploitation_test = ExploitationTest(
|
||||||
ReportGenerationTest.TEST_NAME,
|
ReportGenerationTest.TEST_NAME,
|
||||||
island_client,
|
island_client,
|
||||||
raw_config,
|
serialized_config,
|
||||||
analyzers,
|
analyzers,
|
||||||
timeout,
|
timeout,
|
||||||
log_handler,
|
log_handler,
|
||||||
|
|
Loading…
Reference in New Issue