Esempio n. 1
0
    def get_plugin_name(self, plugin_id, ack_identity):

        # If the message comes from the Orchestrator.
        if not plugin_id:
            return "GoLismero"

        # If the message is for us, just return our name.
        if plugin_id == Config.plugin_id:
            return Config.plugin_info.display_name

        # Get the plugin display name.
        plugin_name = self.plugin_names.get(plugin_id, None)
        if plugin_name is None:
            plugin_name = get_plugin_info(plugin_id).display_name
            self.plugin_names[plugin_id] = plugin_name

        # Append the simple ID if it's greater than zero.
        if ack_identity:
            ack_dict = self.current_plugins[plugin_id]
            simple_id = ack_dict.get(ack_identity, None)
            if simple_id is None:
                simple_id = len(ack_dict)
                ack_dict[ack_identity] = simple_id
            elif simple_id > 0:
                plugin_name = "%s (%d)" % (plugin_name, simple_id + 1)

        # Return the display name.
        return plugin_name
Esempio n. 2
0
    def get_plugin_name(self, plugin_id, ack_identity):

        # If the message comes from the Orchestrator.
        if not plugin_id:
            return "GoLismero"

        # If the message is for us, just return our name.
        if plugin_id == Config.plugin_id:
            return Config.plugin_info.display_name

        # Get the plugin display name.
        plugin_name = self.plugin_names.get(plugin_id, None)
        if plugin_name is None:
            plugin_name = get_plugin_info(plugin_id).display_name
            self.plugin_names[plugin_id] = plugin_name

        # Append the simple ID if it's greater than zero.
        if ack_identity:
            ack_dict = self.current_plugins[plugin_id]
            simple_id = ack_dict.get(ack_identity, None)
            if simple_id is None:
                simple_id = len(ack_dict)
                ack_dict[ack_identity] = simple_id
            elif simple_id > 0:
                plugin_name = "%s (%d)" % (plugin_name, simple_id + 1)

        # Return the display name.
        return plugin_name
Esempio n. 3
0
    def do_plugin_details(self, plugin_name):
        """
        Implementation of: /plugin/details

        :param plugin_name: Name of the plugin to query.
        :type plugin_name: str

        :returns: Plugin information.
        :rtype: PluginInfo
        """
        return get_plugin_info(plugin_name)    # XXX TODO encode as JSON
Esempio n. 4
0
    def get_plugin_name(message):
        """
        Helper method to get a user-friendly name
        for the plugin that sent a given message.

        :param message: Message sent by a plugin.
        :type message: Message

        :returns: User-friendly name for the plugin.
        :rtype: str
        """
        if message.plugin_name:
            plugin_info = get_plugin_info(message.plugin_name)
            if plugin_info:
                return plugin_info.display_name
        return "GoLismero"
Esempio n. 5
0
    def get_plugin_name(self, plugin_id, ack_identity):

        # If the message comes from the Orchestrator.
        if not plugin_id:
            return "GoLismero"

        # If the message is for us, just return our name.
        if plugin_id == Config.plugin_id:
            return Config.plugin_info.display_name

        # Get the plugin display name.
        plugin_name = get_plugin_info(plugin_id).display_name

        # Append the simple ID if it's greater than zero.
        if ack_identity:
            simple_id = self.current_plugins[Config.audit_name][plugin_id][ack_identity]
            if simple_id:
                plugin_name = "%s (%d)" % (plugin_name, simple_id + 1)

        # Return the display name.
        return plugin_name
Esempio n. 6
0
    def get_plugin_name(self, audit_name, plugin_id, identity):
        """
        Helper method to get a user-friendly name
        for the plugin that sent a given message.

        :param audit_name: Name of the audit.
        :type audit_name: str | None

        :param plugin_id: ID of the plugin.
        :type plugin_id: str | None

        :param identity: Identity hash of the Data object being processed.
        :type identity: str | None

        :returns: User-friendly name for the plugin.
        :rtype: str
        """

        # If the message comes from the Orchestrator.
        if not plugin_id:
            return "GoLismero"

        # If the message is for us, just return our name.
        if plugin_id == Config.plugin_id:
            return Config.plugin_info.display_name

        # Get the plugin display name.
        plugin_name = get_plugin_info(plugin_id).display_name

        # Append the simple ID if it's greater than zero.
        if identity:
            simple_id = self.current_plugins[audit_name][plugin_id][identity]
            if simple_id:
                plugin_name = "%s (%d)" % (plugin_name, simple_id + 1)

        # Return the display name.
        return plugin_name
Esempio n. 7
0
    def do_plugin_details(self, plugin_id): # TODO: control audits with error at start
        """
        Implementation of: /plugin/details

        Returns the full information for a plugin in the following format::
            {
                "plugin_id"           : str,
                "descriptor_file"     : str,
                "category"            : str,
                "stage"               : str,
                "stage_number"        : int,
                "dependencies"        : tuple(str...),
                "recursive"           : bool,
                "plugin_module"       : str,
                "plugin_class"        : str,
                "display_name"        : str,
                "description"         : str,
                "version"             : str,
                "author"              : str,
                "copyright"           : str,
                "license"             : str,
                "website"             : str,
                "plugin_args"         : dict(str -> str),
                "plugin_passwd_args"  : set(str),
                "plugin_config"       : dict(str -> str),
                "plugin_extra_config" : dict(str -> dict(str -> str)),
            }

        :param plugin_id: ID of the plugin to query.
        :type plugin_id: str

        :returns: Plugin information. Returns None if the plugin was not found.
        :rtype: dict(str -> \\*) | None
        """
        info = get_plugin_info(plugin_id)
        if info:
            return info.to_dict()
Esempio n. 8
0
 def get_plugin_name(plugin_name):
     if plugin_name:
         return get_plugin_info(plugin_name).display_name
     return "GoLismero"
Esempio n. 9
0
 def get_plugin_name(plugin_name):
     if plugin_name:
         return get_plugin_info(plugin_name).display_name
     return "GoLismero"