Пример #1
0
def list_plugins(custom_plugins_folder):
    plugins_manager = PluginsManager(custom_plugins_folder)
    click.echo(click.style(f"Faraday Plugins v{__version__}", fg="cyan"))
    click.echo(click.style("Available Plugins :", fg="cyan"))
    loaded_plugins = 0
    plugins_data = []
    for plugin_id, plugin in plugins_manager.get_plugins():
        console_enabled = plugin._command_regex is not None
        console_enabled_color = "green" if console_enabled else "red"
        console_enabled_text = click.style(
            f"{'Yes' if console_enabled else 'No'}", fg=console_enabled_color)
        report_enabled = isinstance(plugin, PluginByExtension)
        report_enabled_color = "green" if report_enabled else "red"
        report_enabled_text = click.style(
            f"{'Yes' if report_enabled else 'No'}", fg=report_enabled_color)
        plugins_data.append({
            "Name": plugin.name,
            "ID": plugin.id,
            "Command": console_enabled_text,
            "Report": report_enabled_text
        })
    click.echo(tabulate(
        plugins_data,
        headers="keys",
        tablefmt="simple",
    ))
    click.echo(click.style(f"Loaded Plugins: {len(plugins_data)}", fg="cyan"))
Пример #2
0
def list_plugins(custom_plugins_folder):
    plugins_manager = PluginsManager(custom_plugins_folder)
    click.echo(click.style("Available Plugins:", fg="cyan"))
    loaded_plugins = 0
    for plugin_id, plugin in plugins_manager.get_plugins():
        console_enabled = plugin._command_regex is not None
        console_enabled_color = "green" if console_enabled else "red"
        console_enabled_text = click.style(
            f"{'Yes' if console_enabled else 'No'}", fg=console_enabled_color)
        report_enabled = isinstance(plugin, PluginByExtension)
        report_enabled_color = "green" if report_enabled else "red"
        report_enabled_text = click.style(
            f"{'Yes' if report_enabled else 'No'}", fg=report_enabled_color)
        click.echo(
            f"{plugin.id:15}  - [Command: {console_enabled_text:>12} - Report: {report_enabled_text:>12}] - {plugin.name} "
        )

        loaded_plugins += 1
    click.echo(click.style(f"Loaded Plugins: {loaded_plugins}", fg="cyan"))
Пример #3
0
def list_plugins():
    plugins_manager = PluginsManager()
    for _, plugin in plugins_manager.get_plugins():
        click.echo(f"{plugin.id}")
Пример #4
0
class PluginManager:
    def __init__(self, plugin_repo_path, pending_actions=None):
        self._controllers = {}
        self._plugin_modules = {}
        self._plugin_instances = {}
        self._plugin_settings = {}
        self.pending_actions = pending_actions
        self._plugins_manager = PluginsManager(CONF.getCustomPluginsPath())
        self.commands_analyzer = CommandAnalyzer(self._plugins_manager)
        self.report_analyzer = ReportAnalyzer(self._plugins_manager)
        self._loadSettings()

    def addController(self, controller, id):
        self._controllers[id] = controller

    def _loadSettings(self):
        _plugin_settings = CONF.getPluginSettings()
        if _plugin_settings:
            self._plugin_settings = _plugin_settings

        activep = self.plugins()
        for plugin_id, plugin in activep:
            if plugin_id in _plugin_settings:
                plugin.updateSettings(_plugin_settings[plugin_id]["settings"])
            self._plugin_settings[plugin_id] = {
                "name": plugin.name,
                "description": plugin.description,
                "version": plugin.version,
                "plugin_version": plugin.plugin_version,
                "settings": dict(plugin.getSettings())
            }

        dplugins = []
        for k, v in self._plugin_settings.items():
            if k not in activep:
                dplugins.append(k)

        for d in dplugins:
            del self._plugin_settings[d]

        CONF.setPluginSettings(self._plugin_settings)
        CONF.saveConfig()

    def getSettings(self):
        return self._plugin_settings

    def updateSettings(self, settings):
        self._plugin_settings = settings
        CONF.setPluginSettings(settings)
        CONF.saveConfig()
        for plugin_id, params in settings.items():
            new_settings = params["settings"]
            for c_id, c_instance in self._controllers.items():
                c_instance.updatePluginSettings(plugin_id, new_settings)

    def plugins(self):
        plugins = list(self._plugins_manager.get_plugins())
        for plugin_id, plugin in plugins:
            if plugin_id in self._plugin_settings:
                plugin.updateSettings(
                    self._plugin_settings[plugin_id]["settings"])
        return plugins