make laser plugins be builders

pull/1353/head
Joran Honig 5 years ago
parent ca8bad0a8e
commit 4def8010a3
  1. 5
      mythril/plugin/interface.py
  2. 14
      mythril/plugin/loader.py

@ -36,13 +36,10 @@ class MythrilCLIPlugin(MythrilPlugin):
pass pass
class MythrilLaserPlugin(MythrilPlugin, ABC): class MythrilLaserPlugin(MythrilPlugin, LaserPluginBuilder, ABC):
""" Mythril Laser Plugin interface """ Mythril Laser Plugin interface
Plugins of this type are used to instrument the laser EVM Plugins of this type are used to instrument the laser EVM
""" """
@abstractmethod
@property
def builder(self) -> LaserPluginBuilder:
pass pass

@ -13,6 +13,8 @@ log = logging.getLogger(__name__)
class UnsupportedPluginType(Exception): class UnsupportedPluginType(Exception):
"""Raised when a plugin with an unsupported type is loaded"""
pass pass
@ -28,7 +30,13 @@ class MythrilPluginLoader(object, metaclass=Singleton):
self._load_default_enabled() self._load_default_enabled()
def load(self, plugin: MythrilPlugin): def load(self, plugin: MythrilPlugin):
"""Loads the passed plugin""" """Loads the passed plugin
This function handles input validation and dispatches loading to type specific loaders.
Supported plugin types:
- laser plugins
- detection modules
"""
if not isinstance(plugin, MythrilPlugin): if not isinstance(plugin, MythrilPlugin):
raise ValueError("Passed plugin is not of type MythrilPlugin") raise ValueError("Passed plugin is not of type MythrilPlugin")
logging.info(f"Loading plugin: {plugin.name}") logging.info(f"Loading plugin: {plugin.name}")
@ -51,10 +59,12 @@ class MythrilPluginLoader(object, metaclass=Singleton):
@staticmethod @staticmethod
def _load_laser_plugin(plugin: MythrilLaserPlugin): def _load_laser_plugin(plugin: MythrilLaserPlugin):
"""Loads the laser plugin"""
log.info(f"Loading laser plugin: {plugin.name}") log.info(f"Loading laser plugin: {plugin.name}")
LaserPluginLoader().load(plugin.builder) LaserPluginLoader().load(plugin)
def _load_default_enabled(self): def _load_default_enabled(self):
"""Loads the plugins that have the default enabled flag"""
log.info("Loading installed analysis modules that are enabled by default") log.info("Loading installed analysis modules that are enabled by default")
for plugin_name in PluginDiscovery().get_plugins(default_enabled=True): for plugin_name in PluginDiscovery().get_plugins(default_enabled=True):
plugin = PluginDiscovery().build_plugin(plugin_name) plugin = PluginDiscovery().build_plugin(plugin_name)

Loading…
Cancel
Save