From 3f85c336b91cc6f58beb3dfccdd2909ad65f6f97 Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Wed, 21 Aug 2019 18:32:39 +0300 Subject: [PATCH] Moved init of mappings to init file --- monkey/common/data/__init__.py | 2 ++ monkey/common/data/zero_trust_consts.py | 39 ++++++++++++------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/monkey/common/data/__init__.py b/monkey/common/data/__init__.py index e69de29bb..a8c1a93f7 100644 --- a/monkey/common/data/__init__.py +++ b/monkey/common/data/__init__.py @@ -0,0 +1,2 @@ +from zero_trust_consts import populate_mappings +populate_mappings() diff --git a/monkey/common/data/zero_trust_consts.py b/monkey/common/data/zero_trust_consts.py index dbb28a991..5e3791d40 100644 --- a/monkey/common/data/zero_trust_consts.py +++ b/monkey/common/data/zero_trust_consts.py @@ -61,9 +61,9 @@ TESTS_MAP = { TEST_SEGMENTATION: { TEST_EXPLANATION_KEY: u"The Monkey tried to scan and find machines that it can communicate with from the machine it's running on, that belong to different network segments.", FINDING_EXPLANATION_BY_STATUS_KEY: { - STATUS_CONCLUSIVE: "Monkey performed cross-segment communication. Check firewall rules and logs.", - STATUS_POSITIVE: "Monkey couldn't perform cross-segment communication. If relevant, check firewall logs." - }, + STATUS_CONCLUSIVE: "Monkey performed cross-segment communication. Check firewall rules and logs.", + STATUS_POSITIVE: "Monkey couldn't perform cross-segment communication. If relevant, check firewall logs." + }, DIRECTIVE_KEY: DIRECTIVE_SEGMENTATION, PILLARS_KEY: [NETWORKS], POSSIBLE_STATUSES_KEY: [STATUS_UNEXECUTED, STATUS_POSITIVE, STATUS_CONCLUSIVE] @@ -128,6 +128,11 @@ TESTS_MAP = { }, } +EVENT_TYPE_ISLAND = "island" +EVENT_TYPE_MONKEY_NETWORK = "monkey_network" +EVENT_TYPE_MONKEY_LOCAL = "monkey_local" +EVENT_TYPES = (EVENT_TYPE_MONKEY_LOCAL, EVENT_TYPE_MONKEY_NETWORK, EVENT_TYPE_ISLAND) + PILLARS_TO_TESTS = { DATA: [], PEOPLE: [], @@ -138,6 +143,16 @@ PILLARS_TO_TESTS = { AUTOMATION_ORCHESTRATION: [] } +DIRECTIVES_TO_TESTS = {} + +DIRECTIVES_TO_PILLARS = {} + + +def populate_mappings(): + populate_pillars_to_tests() + populate_directives_to_tests() + populate_directives_to_pillars() + def populate_pillars_to_tests(): for pillar in PILLARS: @@ -146,11 +161,6 @@ def populate_pillars_to_tests(): PILLARS_TO_TESTS[pillar].append(test) -populate_pillars_to_tests() - -DIRECTIVES_TO_TESTS = {} - - def populate_directives_to_tests(): for single_directive in DIRECTIVES: DIRECTIVES_TO_TESTS[single_directive] = [] @@ -158,11 +168,6 @@ def populate_directives_to_tests(): DIRECTIVES_TO_TESTS[test_info[DIRECTIVE_KEY]].append(test) -populate_directives_to_tests() - -DIRECTIVES_TO_PILLARS = {} - - def populate_directives_to_pillars(): for directive, directive_tests in DIRECTIVES_TO_TESTS.items(): directive_pillars = set() @@ -170,11 +175,3 @@ def populate_directives_to_pillars(): for pillar in TESTS_MAP[test][PILLARS_KEY]: directive_pillars.add(pillar) DIRECTIVES_TO_PILLARS[directive] = directive_pillars - - -populate_directives_to_pillars() - -EVENT_TYPE_ISLAND = "island" -EVENT_TYPE_MONKEY_NETWORK = "monkey_network" -EVENT_TYPE_MONKEY_LOCAL = "monkey_local" -EVENT_TYPES = (EVENT_TYPE_MONKEY_LOCAL, EVENT_TYPE_MONKEY_NETWORK, EVENT_TYPE_ISLAND)