1
0
Fork 0

fix level requirements, level picker

This commit is contained in:
Lili (Tlapka) 2021-03-25 18:18:56 +01:00
parent 706c9548a7
commit 9673655b44
3 changed files with 14 additions and 14 deletions

View File

@ -1,9 +1,9 @@
import yaml # reads hint configurations from a .yml file
class LevelSelector:
def __init__(self, tool_list_filename):
self.read_level_requirements(filename)
self.read_tool_list(filename)
def __init__(self, tool_list_filename, level_requirements_filename):
self.read_level_requirements(level_requirements_filename)
self.read_tool_list(tool_list_filename)
self.known_tools = []
def read_level_requirements(self, filename):
@ -20,14 +20,14 @@ class LevelSelector:
self.known_tools.append(tool)
def next_level(self, current_level, current_time):
next_levels = self.level_requirements[level]
next_levels = self.level_requirements["level" + str(current_level+1)]
if len(next_levels) == 1:
return next_levels[0][0]
candidate_level = None
for {level, requirements} in next_levels:
for level, requirements in next_levels:
if requirements is None:
candidate_level = level
elif ((requirements[0] < current_time) and (requirements[1] in self.known_tools)):
elif ((requirements[0] > current_time) and (requirements[1] in self.known_tools)):
candidate_level = level
else:
pass

View File

@ -1,7 +1,7 @@
---
# level_name: {branch_name: [machines_to_provision]}
level2: [{level2a, null}, {level2b, {10, "SQL injection"}}]
level3: [{level3, null}]
level4: [{level4a, null}, {level4b, {30, "John the Ripper"}}]
level5: [{level5, null}]
level2: [[level2a, null], [level2b, [10, "SQL injection"]]]
level3: [[level3, null]]
level4: [[level4a, null], [level4b, [30, "John the Ripper"]]]
level5: [[level5, null]]
...

View File

@ -1,6 +1,6 @@
---
metamask: null
SQL injection: {10, level2b}
nmap: null
John the Ripper: {30, level4b}
- metamask
- SQL injection
- nmap
- John the Ripper
...