Moved init of mappings to init file

This commit is contained in:
Shay Nehmad 2019-08-21 18:32:39 +03:00
parent db58bf9a87
commit 3f85c336b9
2 changed files with 20 additions and 21 deletions

View File

@ -0,0 +1,2 @@
from zero_trust_consts import populate_mappings
populate_mappings()

View File

@ -61,9 +61,9 @@ TESTS_MAP = {
TEST_SEGMENTATION: { 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.", 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: { FINDING_EXPLANATION_BY_STATUS_KEY: {
STATUS_CONCLUSIVE: "Monkey performed cross-segment communication. Check firewall rules and 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." STATUS_POSITIVE: "Monkey couldn't perform cross-segment communication. If relevant, check firewall logs."
}, },
DIRECTIVE_KEY: DIRECTIVE_SEGMENTATION, DIRECTIVE_KEY: DIRECTIVE_SEGMENTATION,
PILLARS_KEY: [NETWORKS], PILLARS_KEY: [NETWORKS],
POSSIBLE_STATUSES_KEY: [STATUS_UNEXECUTED, STATUS_POSITIVE, STATUS_CONCLUSIVE] 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 = { PILLARS_TO_TESTS = {
DATA: [], DATA: [],
PEOPLE: [], PEOPLE: [],
@ -138,6 +143,16 @@ PILLARS_TO_TESTS = {
AUTOMATION_ORCHESTRATION: [] 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(): def populate_pillars_to_tests():
for pillar in PILLARS: for pillar in PILLARS:
@ -146,11 +161,6 @@ def populate_pillars_to_tests():
PILLARS_TO_TESTS[pillar].append(test) PILLARS_TO_TESTS[pillar].append(test)
populate_pillars_to_tests()
DIRECTIVES_TO_TESTS = {}
def populate_directives_to_tests(): def populate_directives_to_tests():
for single_directive in DIRECTIVES: for single_directive in DIRECTIVES:
DIRECTIVES_TO_TESTS[single_directive] = [] DIRECTIVES_TO_TESTS[single_directive] = []
@ -158,11 +168,6 @@ def populate_directives_to_tests():
DIRECTIVES_TO_TESTS[test_info[DIRECTIVE_KEY]].append(test) DIRECTIVES_TO_TESTS[test_info[DIRECTIVE_KEY]].append(test)
populate_directives_to_tests()
DIRECTIVES_TO_PILLARS = {}
def populate_directives_to_pillars(): def populate_directives_to_pillars():
for directive, directive_tests in DIRECTIVES_TO_TESTS.items(): for directive, directive_tests in DIRECTIVES_TO_TESTS.items():
directive_pillars = set() directive_pillars = set()
@ -170,11 +175,3 @@ def populate_directives_to_pillars():
for pillar in TESTS_MAP[test][PILLARS_KEY]: for pillar in TESTS_MAP[test][PILLARS_KEY]:
directive_pillars.add(pillar) directive_pillars.add(pillar)
DIRECTIVES_TO_PILLARS[directive] = directive_pillars 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)