From 72caf5a80ae2f06fecdb8d27441692a0910fcd04 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Mon, 27 Sep 2021 22:13:37 +0530 Subject: [PATCH] island: Simplify logic when creating reverse schema Co-authored-by: Mike Salvatore --- .../config_schema/config_schema_per_attack_technique.py | 7 +++---- 1 file changed, 3 insertions(+), 4 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 4aeab0085..9b7cd6bb2 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 @@ -31,7 +31,6 @@ def get_config_schema_per_attack_technique(schema: Dict) -> Dict[str, Dict[str, def _add_config_field_to_reverse_schema( definition_type: str, config_field: str, attack_technique: str, reverse_schema: Dict ) -> None: - if attack_technique in reverse_schema: - reverse_schema[attack_technique].setdefault(definition_type, []).append(config_field) - else: - reverse_schema[attack_technique] = {definition_type: [config_field]} + reverse_schema.setdefault(attack_technique, {}) + reverse_schema[attack_technique].setdefault(definition_type, []) + reverse_schema[attack_technique][definition_type].append(config_field)