diff --git a/app/pluginmanager.py b/app/pluginmanager.py index 0ca66bd..83349d2 100644 --- a/app/pluginmanager.py +++ b/app/pluginmanager.py @@ -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 diff --git a/plugins/base/plugin_base.py b/plugins/base/plugin_base.py index b18ae32..706e8f1 100644 --- a/plugins/base/plugin_base.py +++ b/plugins/base/plugin_base.py @@ -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) diff --git a/plugins/default/vm_controller/vagrant/vagrant_plugin.py b/plugins/default/vm_controller/vagrant/vagrant_plugin.py index 5bf5689..5180390 100644 --- a/plugins/default/vm_controller/vagrant/vagrant_plugin.py +++ b/plugins/default/vm_controller/vagrant/vagrant_plugin.py @@ -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 """