|
|
|
@ -2,6 +2,8 @@ import pkg_resources |
|
|
|
|
from mythril.support.support_utils import Singleton |
|
|
|
|
from mythril.plugin.interface import MythrilPlugin |
|
|
|
|
|
|
|
|
|
from typing import List |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PluginDiscovery(object, metaclass=Singleton): |
|
|
|
|
"""PluginDiscovery class |
|
|
|
@ -9,7 +11,7 @@ class PluginDiscovery(object, metaclass=Singleton): |
|
|
|
|
This plugin implements the logic to discover and build plugins in installed python packages |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
# Installed plugins structure. Retreives all modules that have an entry point for mythril.plugins |
|
|
|
|
# Installed plugins structure. Retrieves all modules that have an entry point for mythril.plugins |
|
|
|
|
_installed_plugins = { |
|
|
|
|
entry_point.name: entry_point.load() |
|
|
|
|
for entry_point in pkg_resources.iter_entry_points("mythril.plugins") |
|
|
|
@ -30,3 +32,17 @@ class PluginDiscovery(object, metaclass=Singleton): |
|
|
|
|
raise ValueError(f"No valid plugin was found for {plugin_name}") |
|
|
|
|
|
|
|
|
|
return plugin |
|
|
|
|
|
|
|
|
|
def get_plugins(self, default_enabled=None) -> List[str]: |
|
|
|
|
""" Gets a list of installed mythril plugins |
|
|
|
|
|
|
|
|
|
:param default_enabled: Select plugins that are enabled by default |
|
|
|
|
:return: List of plugin names |
|
|
|
|
""" |
|
|
|
|
if default_enabled is None: |
|
|
|
|
return list(self._installed_plugins.keys()) |
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
|
plugin_name for plugin_name, plugin_class |
|
|
|
|
in self._installed_plugins.items() if plugin_class.default_enabled == default_enabled |
|
|
|
|
] |
|
|
|
|