type cleanup

pull/12/head
Thorsten Sick 3 years ago
parent 5eeaa02b4d
commit df03e0c74e

@ -9,8 +9,10 @@ from plugins.base.attack import AttackPlugin
from plugins.base.machinery import MachineryPlugin
from plugins.base.sensor import SensorPlugin
from plugins.base.vulnerability_plugin import VulnerabilityPlugin
import straight.plugin
import straight.plugin # type: ignore
from app.interface_sfx import CommandlineColors
from app.attack_log import AttackLog
# from app.interface_sfx import CommandlineColors
sections = [{"name": "Vulnerabilities",
@ -27,7 +29,7 @@ sections = [{"name": "Vulnerabilities",
class PluginManager():
""" Manage plugins """
def __init__(self, attack_logger):
def __init__(self, attack_logger: AttackLog):
"""
@param attack_logger: The attack logger to use

@ -4,24 +4,25 @@
import os
import yaml
# from shutil import copy
from app.exceptions import PluginError
import app.exceptions
from app.exceptions import PluginError # type: ignore
import app.exceptions # type: ignore
from typing import Optional
class BasePlugin():
""" Base class for plugins """
required_files = None # a list of files shipped with the plugin to be installed
name = None # The name of the plugin
alternative_names = [] # The is an optional list of alternative names
description = None # The description of this plugin
required_files: list[str] = [] # a list of files shipped with the plugin to be installed
name: str = "" # The name of the plugin
alternative_names: list[str] = [] # The is an optional list of alternative names
description: Optional[str] = None # The description of this plugin
def __init__(self):
def __init__(self) -> None:
# self.machine = None
self.plugin_path = None
self.machine_plugin = None
self.sysconf = {}
self.conf = {}
# self.sysconf = {}
self.conf: dict = {}
self.attack_logger = None
self.default_config_name = "default_config.yaml"
@ -126,7 +127,7 @@ class BasePlugin():
raise NotImplementedError
def get_names(self) -> []:
def get_names(self) -> list[str]:
""" Adds the name of the plugin to the alternative names and returns the list """
res = set()
@ -183,20 +184,20 @@ class BasePlugin():
if self.conf is None:
self.conf = {}
def get_config_section_name(self):
def get_config_section_name(self) -> str:
""" Returns the name for the config sub-section to use for this plugin.
Defaults to the name of the plugin. This method should be overwritten if it gets more complicated """
return self.get_name()
def main_path(self): # pylint:disable=no-self-use
def main_path(self) -> str: # pylint:disable=no-self-use
""" Returns the main path of the Purple Dome installation """
app_dir = os.path.dirname(app.exceptions.__file__)
return os.path.split(app_dir)[0]
def vprint(self, text, verbosity):
def vprint(self, text: str, verbosity: int):
""" verbosity based stdout printing
0: Errors only
@ -207,5 +208,5 @@ class BasePlugin():
@param text: The text to print
@param verbosity: the verbosity level the text has.
"""
self.attack_logger.vprint(text, verbosity)
if self.attack_logger is not None:
self.attack_logger.vprint(text, verbosity)

@ -31,7 +31,7 @@ class VagrantPlugin(SSHFeatures, MachineryPlugin):
self.connection = None
self.vagrantfilepath = None
self.vagrantfile = None
self.sysconf = {}
# self.sysconf = {}
def process_config(self, config):
""" Machine specific processing of configuration """

Loading…
Cancel
Save