mypy fixes

pull/14/head
Thorsten Sick 3 years ago
parent bf0e388bb8
commit e51c46bba3

@ -30,7 +30,7 @@ class AttackLog():
@param verbosity: verbosity setting from 0 to 3 for stdout printing
"""
self.log: list[dict] = []
self.machines: dict = []
self.machines: list[dict] = []
self.verbosity = verbosity
# TODO. As soon as someone wants custom timestamps, make the format variable
@ -510,6 +510,8 @@ class AttackLog():
timestamp = self.__get_timestamp__()
logid = timestamp + "_" + str(randint(1, 100000))
cframe = currentframe()
data = {"timestamp": timestamp,
"timestamp_end": None,
"event": "start",
@ -527,8 +529,8 @@ class AttackLog():
"situation_description": kwargs.get("situation_description", None), # Description for the situation this attack was run in. Set by the plugin or attacker emulation
"countermeasure": kwargs.get("countermeasure", None), # Set by the attack
"result": None,
"sourcefile": kwargs.get("sourcefile", getsourcefile(currentframe().f_back)),
"sourceline": kwargs.get("sourceline", currentframe().f_back.f_lineno)
"sourcefile": kwargs.get("sourcefile", getsourcefile(cframe.f_back)),
"sourceline": kwargs.get("sourceline", cframe.f_back.f_lineno)
}
self.__add_to_log__(data)
@ -642,7 +644,7 @@ class AttackLog():
return res
def add_machine_info(self, machine_info):
def add_machine_info(self, machine_info: dict):
""" Adds a dict with machine info. One machine per call of this method """
self.machines.append(machine_info)

@ -151,7 +151,7 @@ class ExperimentConfig():
@param configfile: The configuration file to process
"""
self.raw_config: Optional[dict] = None
self.raw_config: MainConfig = None
self._targets: list[MachineConfig] = []
self._attackers: list[MachineConfig] = []
self.load(configfile)

@ -8,6 +8,7 @@ import time
import zipfile
import shutil
from datetime import datetime
from typing import Optional
from app.attack_log import AttackLog
from app.config import ExperimentConfig
@ -32,12 +33,14 @@ class Experiment():
@param verbosity: verbosity level between 0 and 3
@param caldera_attacks: an optional argument to override caldera attacks in the config file and run just this one caldera attack. A list of caldera ID
"""
self.attacker_1 = None
self.attacker_1: Optional[Machine] = None
self.experiment_config = ExperimentConfig(configfile)
self.attack_logger = AttackLog(verbosity)
self.plugin_manager = PluginManager(self.attack_logger)
self.__start_attacker()
if self.attacker_1 is None:
raise ServerError
caldera_url = "http://" + self.attacker_1.get_ip() + ":8888"
self.caldera_control = CalderaControl(caldera_url, attack_logger=self.attack_logger, config=self.experiment_config)
# self.caldera_control = CalderaControl("http://" + self.attacker_1.get_ip() + ":8888", self.attack_logger,

Loading…
Cancel
Save