make laser plugins be builders

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

@ -36,13 +36,10 @@ class MythrilCLIPlugin(MythrilPlugin):
pass
class MythrilLaserPlugin(MythrilPlugin, ABC):
class MythrilLaserPlugin(MythrilPlugin, LaserPluginBuilder, ABC):
""" Mythril Laser Plugin interface
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):
"""Raised when a plugin with an unsupported type is loaded"""
pass
@ -28,7 +30,13 @@ class MythrilPluginLoader(object, metaclass=Singleton):
self._load_default_enabled()
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):
raise ValueError("Passed plugin is not of type MythrilPlugin")
logging.info(f"Loading plugin: {plugin.name}")
@ -51,10 +59,12 @@ class MythrilPluginLoader(object, metaclass=Singleton):
@staticmethod
def _load_laser_plugin(plugin: MythrilLaserPlugin):
"""Loads the laser plugin"""
log.info(f"Loading laser plugin: {plugin.name}")
LaserPluginLoader().load(plugin.builder)
LaserPluginLoader().load(plugin)
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")
for plugin_name in PluginDiscovery().get_plugins(default_enabled=True):
plugin = PluginDiscovery().build_plugin(plugin_name)

Loading…
Cancel
Save