From 55fcfa981389dfa86bae9285c4f158a716e1b1b9 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 13 Oct 2021 18:06:42 +0530 Subject: [PATCH] island: Move code for generating reverse schema into functions for better readibility --- .../config_schema_per_attack_technique.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/services/config_schema/config_schema_per_attack_technique.py b/monkey/monkey_island/cc/services/config_schema/config_schema_per_attack_technique.py index 1b4c39413..9003e25a1 100644 --- a/monkey/monkey_island/cc/services/config_schema/config_schema_per_attack_technique.py +++ b/monkey/monkey_island/cc/services/config_schema/config_schema_per_attack_technique.py @@ -15,6 +15,13 @@ def get_config_schema_per_attack_technique(schema: Dict) -> Dict[str, Dict[str, """ reverse_schema = {} + _crawl_config_schema_definitions_for_reverse_schema(schema, reverse_schema) + _crawl_config_schema_properties_for_reverse_schema(schema, reverse_schema) + + return reverse_schema + + +def _crawl_config_schema_definitions_for_reverse_schema(schema: Dict, reverse_schema: Dict): definitions = schema["definitions"] for definition in definitions: definition_type = definitions[definition]["title"] @@ -25,6 +32,8 @@ def get_config_schema_per_attack_technique(schema: Dict) -> Dict[str, Dict[str, definition_type, config_field, attack_technique, reverse_schema ) + +def _crawl_config_schema_properties_for_reverse_schema(schema: Dict, reverse_schema: Dict): properties = schema["properties"] for prop in properties: property_type = properties[prop]["title"] @@ -40,8 +49,6 @@ def get_config_schema_per_attack_technique(schema: Dict) -> Dict[str, Dict[str, property_type, config_field, attack_technique, reverse_schema ) - return reverse_schema - def _add_config_field_to_reverse_schema( definition_type: str, config_field: str, attack_technique: str, reverse_schema: Dict