Island: Add missing return types to some functions in ConfigService

This commit is contained in:
Mike Salvatore 2022-02-08 07:38:24 -05:00
parent 916222c2d9
commit 0b33aacb82
1 changed files with 10 additions and 10 deletions

View File

@ -3,7 +3,7 @@ import copy
import functools import functools
import logging import logging
import re import re
from typing import Dict, List from typing import Any, Dict, List
from jsonschema import Draft4Validator, validators from jsonschema import Draft4Validator, validators
@ -406,7 +406,7 @@ class ConfigService:
return ConfigService.get_config_value(EXPORT_MONKEY_TELEMS_PATH) return ConfigService.get_config_value(EXPORT_MONKEY_TELEMS_PATH)
@staticmethod @staticmethod
def get_config_propagation_credentials_from_flat_config(config): def get_config_propagation_credentials_from_flat_config(config) -> Dict[str, List[str]]:
return { return {
"exploit_user_list": config.get("exploit_user_list", []), "exploit_user_list": config.get("exploit_user_list", []),
"exploit_password_list": config.get("exploit_password_list", []), "exploit_password_list": config.get("exploit_password_list", []),
@ -483,8 +483,8 @@ class ConfigService:
config["propagation"] = formatted_propagation_config config["propagation"] = formatted_propagation_config
@staticmethod @staticmethod
def _format_network_scan_from_flat_config(config: Dict): def _format_network_scan_from_flat_config(config: Dict) -> Dict[str, Any]:
formatted_network_scan_config = {"tcp": {}, "icmp": {}} formatted_network_scan_config = {"tcp": {}, "icmp": {}, "fingerprinters": []}
formatted_network_scan_config["tcp"] = ConfigService._format_tcp_scan_from_flat_config( formatted_network_scan_config["tcp"] = ConfigService._format_tcp_scan_from_flat_config(
config config
@ -499,7 +499,7 @@ class ConfigService:
return formatted_network_scan_config return formatted_network_scan_config
@staticmethod @staticmethod
def _format_tcp_scan_from_flat_config(config: Dict): def _format_tcp_scan_from_flat_config(config: Dict) -> Dict[str, Any]:
flat_http_ports_field = "HTTP_PORTS" flat_http_ports_field = "HTTP_PORTS"
flat_tcp_timeout_field = "tcp_scan_timeout" flat_tcp_timeout_field = "tcp_scan_timeout"
flat_tcp_ports_field = "tcp_target_ports" flat_tcp_ports_field = "tcp_target_ports"
@ -526,7 +526,7 @@ class ConfigService:
return sorted(combined_ports) return sorted(combined_ports)
@staticmethod @staticmethod
def _format_icmp_scan_from_flat_config(config: Dict): def _format_icmp_scan_from_flat_config(config: Dict) -> Dict[str, Any]:
flat_ping_timeout_field = "ping_scan_timeout" flat_ping_timeout_field = "ping_scan_timeout"
formatted_icmp_scan_config = {} formatted_icmp_scan_config = {}
@ -537,7 +537,7 @@ class ConfigService:
return formatted_icmp_scan_config return formatted_icmp_scan_config
@staticmethod @staticmethod
def _format_fingerprinters_from_flat_config(config: Dict): def _format_fingerprinters_from_flat_config(config: Dict) -> List[Dict[str, Any]]:
flat_fingerprinter_classes_field = "finger_classes" flat_fingerprinter_classes_field = "finger_classes"
flat_http_ports_field = "HTTP_PORTS" flat_http_ports_field = "HTTP_PORTS"
@ -556,11 +556,11 @@ class ConfigService:
return formatted_fingerprinters return formatted_fingerprinters
@staticmethod @staticmethod
def _translate_fingerprinter_name(name: str): def _translate_fingerprinter_name(name: str) -> str:
return re.sub(r"Finger", "", name).lower() return re.sub(r"Finger", "", name).lower()
@staticmethod @staticmethod
def _format_targets_from_flat_config(config: Dict): def _format_targets_from_flat_config(config: Dict) -> Dict[str, Any]:
flat_blocked_ips_field = "blocked_ips" flat_blocked_ips_field = "blocked_ips"
flat_inaccessible_subnets_field = "inaccessible_subnets" flat_inaccessible_subnets_field = "inaccessible_subnets"
flat_local_network_scan_field = "local_network_scan" flat_local_network_scan_field = "local_network_scan"
@ -587,7 +587,7 @@ class ConfigService:
return formatted_scan_targets_config return formatted_scan_targets_config
@staticmethod @staticmethod
def _format_exploiters_from_flat_config(config: Dict): def _format_exploiters_from_flat_config(config: Dict) -> Dict[str, List[Dict[str, Any]]]:
flat_config_exploiter_classes_field = "exploiter_classes" flat_config_exploiter_classes_field = "exploiter_classes"
brute_force_category = "brute_force" brute_force_category = "brute_force"
vulnerability_category = "vulnerability" vulnerability_category = "vulnerability"