From d74c3d15ca7a82d0e5a4695b6d3a4c0968dab955 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 3 Aug 2020 11:45:31 +0300 Subject: [PATCH] Fixed island's config.py default value setting method to handle 3 layers of nested objects --- monkey/monkey_island/cc/services/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index ac1ee1417..8d6210739 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -246,6 +246,16 @@ class ConfigService: for property3, subschema3 in list(subschema2["properties"].items()): if "default" in subschema3: sub_dict[property3] = subschema3["default"] + elif "properties" in subschema3: + layer_3_dict = {} + for property4, subschema4 in list(subschema3["properties"].items()): + if "properties" in subschema4: + raise ValueError("monkey/monkey_island/cc/services/config.py " + "can't handle 5 level config. " + "Either change back the config or refactor.") + if "default" in subschema4: + layer_3_dict[property4] = subschema4["default"] + sub_dict[property3] = layer_3_dict main_dict[property2] = sub_dict instance.setdefault(property1, main_dict)