implement loading logic for laser plugins

pull/1353/head
Joran Honig 5 years ago
parent 52b7b7cbf7
commit f47604a4c3
  1. 9
      mythril/plugin/interface.py
  2. 10
      mythril/plugin/loader.py

@ -1,5 +1,5 @@
from abc import ABC
from mythril.laser.plugin import LaserPlugin
from abc import ABC, abstractmethod
from mythril.laser.plugin import PluginBuilder as LaserPluginBuilder
class MythrilPlugin:
@ -36,10 +36,13 @@ class MythrilCLIPlugin(MythrilPlugin):
pass
class MythrilLaserPlugin(MythrilPlugin, LaserPlugin, ABC):
class MythrilLaserPlugin(MythrilPlugin, ABC):
""" Mythril Laser Plugin interface
Plugins of this type are used to instrument the laser EVM
"""
@abstractmethod
@property
def builder(self) -> LaserPluginBuilder:
pass

@ -1,11 +1,12 @@
from mythril.analysis.module import DetectionModule
from mythril.plugin.interface import MythrilCLIPlugin, MythrilPlugin
from mythril.plugin.interface import MythrilCLIPlugin, MythrilPlugin, MythrilLaserPlugin
from mythril.plugin.discovery import PluginDiscovery
from mythril.support.support_utils import Singleton
from mythril.analysis.module.loader import ModuleLoader
from mythril.laser.plugin import PluginBuilder as LaserPluginBuilder
from mythril.laser.plugin.loader import LaserPluginLoader
import logging
log = logging.getLogger(__name__)
@ -48,6 +49,11 @@ class MythrilPluginLoader(object, metaclass=Singleton):
log.info(f"Loading detection module: {plugin.name}")
ModuleLoader().register_module(plugin)
@staticmethod
def _load_laser_plugin(plugin: MythrilLaserPlugin):
log.info(f"Loading laser plugin: {plugin.name}")
LaserPluginLoader().load(plugin.builder)
def _load_default_enabled(self):
log.info("Loading installed analysis modules that are enabled by default")
for plugin_name in PluginDiscovery().get_plugins(default_enabled=True):

Loading…
Cancel
Save