forked from p15670423/monkey
Agent: Add plugin_name attribute to puppet's load_plugin
This commit is contained in:
parent
8e6abcb795
commit
b798255249
|
@ -27,9 +27,10 @@ PostBreachData = namedtuple("PostBreachData", ["command", "result"])
|
|||
|
||||
class IPuppet(metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def load_plugin(self, plugin: object, plugin_type: PluginType) -> None:
|
||||
def load_plugin(self, plugin_name: str, plugin: object, plugin_type: PluginType) -> None:
|
||||
"""
|
||||
Loads a plugin into the puppet.
|
||||
Loads a plugin into the puppet
|
||||
:param str plugin_name: The plugin class name
|
||||
:param object plugin: The plugin object to load
|
||||
:param PluginType plugin_type: The type of plugin being loaded
|
||||
"""
|
||||
|
|
|
@ -23,11 +23,11 @@ class PluginRegistry:
|
|||
"""
|
||||
self._registry = {}
|
||||
|
||||
def load_plugin(self, plugin: object, plugin_type: PluginType) -> None:
|
||||
def load_plugin(self, plugin_name: str, plugin: object, plugin_type: PluginType) -> None:
|
||||
self._registry.setdefault(plugin_type, {})
|
||||
self._registry[plugin_type][plugin.__class__.__name__] = plugin
|
||||
self._registry[plugin_type][plugin_name] = plugin
|
||||
|
||||
logger.debug(f"Plugin '{plugin.__class__.__name__}' loaded")
|
||||
logger.debug(f"Plugin '{plugin_name}' loaded")
|
||||
|
||||
def get_plugin(self, plugin_name: str, plugin_type: PluginType) -> Optional[object]:
|
||||
try:
|
||||
|
|
|
@ -20,8 +20,8 @@ class Puppet(IPuppet):
|
|||
def __init__(self) -> None:
|
||||
self._plugin_registry = PluginRegistry()
|
||||
|
||||
def load_plugin(self, plugin: object, plugin_type: PluginType) -> None:
|
||||
self._plugin_registry.load_plugin(plugin, plugin_type)
|
||||
def load_plugin(self, plugin_name: str, plugin: object, plugin_type: PluginType) -> None:
|
||||
self._plugin_registry.load_plugin(plugin, plugin_name, plugin_type)
|
||||
|
||||
def run_sys_info_collector(self, name: str) -> Dict:
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue