diff --git a/monkey/monkey_island/cc/services/reporting/issue_processing/exploit_processing/exploiter_descriptor_enum.py b/monkey/monkey_island/cc/services/reporting/issue_processing/exploit_processing/exploiter_descriptor_enum.py index eff1f7758..6378c77db 100644 --- a/monkey/monkey_island/cc/services/reporting/issue_processing/exploit_processing/exploiter_descriptor_enum.py +++ b/monkey/monkey_island/cc/services/reporting/issue_processing/exploit_processing/exploiter_descriptor_enum.py @@ -1,6 +1,6 @@ from dataclasses import dataclass from enum import Enum -from typing import Type +from typing import Type, Dict from monkey_island.cc.services.reporting.issue_processing.exploit_processing.processors.cred_exploit import \ CredExploitProcessor @@ -34,3 +34,10 @@ class ExploiterDescriptorEnum(Enum): VSFTPD = ExploiterDescriptor('VSFTPDExploiter', 'VSFTPD Backdoor Exploiter', CredExploitProcessor) DRUPAL = ExploiterDescriptor('DrupalExploiter', 'Drupal Server Exploiter', ExploitProcessor) ZEROLOGON = ExploiterDescriptor('ZerologonExploiter', 'ZeroLogon Exploiter', ZerologonExploitProcessor) + + @staticmethod + def __dict__() -> Dict[str, ExploiterDescriptor]: + descriptor_dict = {} + for descriptor in ExploiterDescriptorEnum: + descriptor_dict[descriptor.value.class_name] = descriptor + return descriptor_dict diff --git a/monkey/monkey_island/cc/services/reporting/report.py b/monkey/monkey_island/cc/services/reporting/report.py index a4642c694..a70634f07 100644 --- a/monkey/monkey_island/cc/services/reporting/report.py +++ b/monkey/monkey_island/cc/services/reporting/report.py @@ -2,7 +2,7 @@ import functools import ipaddress import itertools import logging -from typing import Dict, List +from typing import List from bson import json_util @@ -17,8 +17,7 @@ from common.config_value_paths import (EXPLOITER_CLASSES_PATH, LOCAL_NETWORK_SCA USER_LIST_PATH) from monkey_island.cc.services.configuration.utils import get_config_network_segments_as_subnet_groups from monkey_island.cc.services.node import NodeService -from monkey_island.cc.services.reporting.issue_processing.exploit_processing.exploiter_descriptor_enum import ExploiterDescriptorEnum, \ - ExploiterDescriptor +from monkey_island.cc.services.reporting.issue_processing.exploit_processing.exploiter_descriptor_enum import ExploiterDescriptorEnum from monkey_island.cc.services.reporting.issue_processing.exploit_processing.processors.cred_exploit import \ CredentialType from monkey_island.cc.services.reporting.issue_processing.exploit_processing.processors.exploit import \ @@ -32,15 +31,8 @@ __author__ = "itay.mizeretz" logger = logging.getLogger(__name__) -def build_exploiter_descriptor_dict() -> Dict[str, ExploiterDescriptor]: - descriptor_dict = {} - for descriptor in ExploiterDescriptorEnum: - descriptor_dict[descriptor.value.class_name] = descriptor - return descriptor_dict - - class ReportService: - exploiter_descriptors = build_exploiter_descriptor_dict() + exploiter_descriptors = ExploiterDescriptorEnum.__dict__ class DerivedIssueEnum: WEAK_PASSWORD = "weak_password"