diff --git a/monkey/common/utils/code_utils.py b/monkey/common/utils/code_utils.py index d7fad9062..214e6d108 100644 --- a/monkey/common/utils/code_utils.py +++ b/monkey/common/utils/code_utils.py @@ -1,10 +1,5 @@ # abstract, static method decorator # noinspection PyPep8Naming -import operator -from functools import reduce -from typing import List, Union, Any - - class abstractstatic(staticmethod): __slots__ = () @@ -13,7 +8,3 @@ class abstractstatic(staticmethod): function.__isabstractmethod__ = True __isabstractmethod__ = True - - -def get_dict_value_by_path(data: dict, path: List[str]) -> Any: - return reduce(operator.getitem, path, data) diff --git a/monkey/common/utils/test_code_utils.py b/monkey/common/utils/test_code_utils.py deleted file mode 100644 index b383b0a33..000000000 --- a/monkey/common/utils/test_code_utils.py +++ /dev/null @@ -1,9 +0,0 @@ -import unittest - -from common.utils.code_utils import get_dict_value_by_path - - -class TestCodeUtils(unittest.TestCase): - def test_get_dict_value_by_path(self): - dict_for_test = {'a': {'b': {'c': 'result'}}} - self.assertEqual(get_dict_value_by_path(dict_for_test, ['a', 'b', 'c']), 'result') diff --git a/monkey/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/rule_parser.py b/monkey/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/rule_parser.py index c5855ddd5..8da69a9bb 100644 --- a/monkey/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/rule_parser.py +++ b/monkey/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/rule_parser.py @@ -1,4 +1,5 @@ -from common.utils.code_utils import get_dict_value_by_path +import dpath.util + from common.utils.exceptions import RulePathCreatorNotFound from monkey_island.cc.services.zero_trust.scoutsuite.data_parsing.rule_path_building.rule_path_creators_list import \ RULE_PATH_CREATORS_LIST @@ -9,7 +10,7 @@ class RuleParser: @staticmethod def get_rule_data(scoutsuite_data, rule_name): rule_path = RuleParser.get_rule_path(rule_name) - return get_dict_value_by_path(data=scoutsuite_data, path=rule_path) + return dpath.util.get(scoutsuite_data, rule_path) @staticmethod def get_rule_path(rule_name):