From 7bdbdb1bfbbeaaa2118d748384b4754a208da7d0 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 12 Oct 2021 15:42:40 +0530 Subject: [PATCH] island: Go through internal config when generating reverse schema for unscanned attack techniques' reasons --- .../config_schema_per_attack_technique.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 9b7cd6bb2..1b4c39413 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 @@ -25,6 +25,21 @@ def get_config_schema_per_attack_technique(schema: Dict) -> Dict[str, Dict[str, definition_type, config_field, attack_technique, reverse_schema ) + properties = schema["properties"] + for prop in properties: + property_type = properties[prop]["title"] + for tab_name in properties[prop]["properties"]: + tab = properties[prop]["properties"][tab_name] + for config_option_name in tab["properties"]: + config_option = tab["properties"][config_option_name] + for attack_technique in config_option.get("related_attack_techniques", []): + # No config values could be a reason that related attack techniques are left + # unscanned. See https://github.com/guardicore/monkey/issues/1518 for more. + config_field = f"{config_option['title']} ({tab['title']})" + _add_config_field_to_reverse_schema( + property_type, config_field, attack_technique, reverse_schema + ) + return reverse_schema