def __init__(self):
"""Finds available plugins by discovering any class that implements the PluginBase abstract class.
Returns PluginsFinder: An object encapsulating the list of available sslyze plugin classess.
"""
self._plugin_classes = set([])
self._commands = {}
self._aggressive_comands = []
if hasattr(sys,"frozen") and sys.frozen in ("windows_exe", "console_exe"):
# For py2exe builds we have to load the plugins statically using a hardcoded list
plugin_modules = self.get_plugin_modules_static()
else:
# When ran from the interpreter, just dynamically find the available plugins
plugin_modules = self.get_plugin_modules_dynamic()
for module in plugin_modules:
# Check every declaration in that module
for name in dir(module):
obj = getattr(module, name)
if inspect.isclass(obj):
# A class declaration was found in that module; checking if it's a subclass of PluginBase
# Discarding PluginBase as a subclass of PluginBase
if obj != sslyze.plugins.plugin_base.PluginBase:
for base in obj.__bases__:
# H4ck because issubclass() doesn't seem to work as expected on Linux
# It has to do with PluginBase being imported multiple times (within plugins) or something
if base.__name__ == 'PluginBase':
# A plugin was found, keep it
self._plugin_classes.add(obj)
#if issubclass(obj, plugins.PluginBase.PluginBase):
# A plugin was found, keep it
# self._plugin_classes.add(obj)
# Store the plugin's commands
for (cmd, is_aggressive) in obj.get_interface().get_commands_as_text():
self._commands[cmd] = obj
# Store a list of aggressive commands
if is_aggressive:
self._aggressive_comands.append(cmd)
评论列表
文章目录