當前位置: 首頁>>代碼示例>>Python>>正文


Python Database.iterate方法代碼示例

本文整理匯總了Python中golismero.api.data.db.Database.iterate方法的典型用法代碼示例。如果您正苦於以下問題:Python Database.iterate方法的具體用法?Python Database.iterate怎麽用?Python Database.iterate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在golismero.api.data.db.Database的用法示例。


在下文中一共展示了Database.iterate方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: notify_summary

# 需要導入模塊: from golismero.api.data.db import Database [as 別名]
# 或者: from golismero.api.data.db.Database import iterate [as 別名]
    def notify_summary(self, audit_name):
        """
        This method is called when an audit ends and when a plugin ends.

        :param audit_name: Name of the audit.
        :type audit_name: str
        """

        # Get the number of vulnerabilities in the database.
        vulns_number = Database.count(Data.TYPE_VULNERABILITY)

        # Count the vulnerabilities by severity.
        vulns_counter = collections.defaultdict(int)
        for l_vuln in Database.iterate(Data.TYPE_VULNERABILITY):
            vulns_counter[l_vuln.level] += 1

        # Get the number of IP addresses and hostnames.
        total_hosts  = Database.count(Data.TYPE_RESOURCE,
                                           Resource.RESOURCE_DOMAIN)
        total_hosts += Database.count(Data.TYPE_RESOURCE,
                                           Resource.RESOURCE_IP)

        # Substract the ones that were passed as targets.
        discovered_hosts = total_hosts - len(Config.audit_scope.targets)
        discovered_hosts = discovered_hosts if discovered_hosts > 0 else 0

        # Send the summary.
        packet = ("summary", audit_name, vulns_number, discovered_hosts, total_hosts,
                  vulns_counter['info'], vulns_counter['low'], vulns_counter['medium'],
                  vulns_counter['high'], vulns_counter['critical'],)
        self.bridge.send(packet)
開發者ID:jekkay,項目名稱:golismero,代碼行數:33,代碼來源:server_plugin.py

示例2: generate_report

# 需要導入模塊: from golismero.api.data.db import Database [as 別名]
# 或者: from golismero.api.data.db.Database import iterate [as 別名]
    def generate_report(self, output_file):

        # Dump all objects in the database.
        print "-" * 79
        print "Report:"
        for data in Database.iterate():
            print
            print data.identity
            print repr(data)
            print sorted(data.links)
            for linked in data.linked_data:
                print "--> " + linked.identity
                print "--> " + repr(linked)
        print
開發者ID:0day1day,項目名稱:golismero,代碼行數:16,代碼來源:screen.py

示例3: common_get_resources

# 需要導入模塊: from golismero.api.data.db import Database [as 別名]
# 或者: from golismero.api.data.db.Database import iterate [as 別名]
    def common_get_resources(self, data_type=None, data_subtype=None):
        """
        Get a list of datas.

        :return: List of resources.
        :rtype: list(Resource)
        """
        # Get each resource
        m_resource = None
        m_len_urls = Database.count(data_type, data_type)
        if m_len_urls < 200:   # increase as you see fit...
            # fast but memory consuming method
            m_resource   = Database.get_many( Database.keys(data_type=data_type, data_subtype=data_subtype))
        else:
            # slow but lean method
            m_resource   = Database.iterate(data_type=data_type, data_subtype=data_subtype)

        return m_resource
開發者ID:jekkay,項目名稱:golismero,代碼行數:20,代碼來源:html.py

示例4: __iterate

# 需要導入模塊: from golismero.api.data.db import Database [as 別名]
# 或者: from golismero.api.data.db.Database import iterate [as 別名]
 def __iterate(self, data_type = None, data_subtype = None):
     if Database.count(data_type, data_type) < 100:
         return Database.get_many(
             Database.keys(data_type=data_type, data_subtype=data_subtype)
         )
     return Database.iterate(data_type=data_type, data_subtype=data_subtype)
開發者ID:jekkay,項目名稱:golismero,代碼行數:8,代碼來源:text.py

示例5: do_audit_summary

# 需要導入模塊: from golismero.api.data.db import Database [as 別名]
# 或者: from golismero.api.data.db.Database import iterate [as 別名]
    def do_audit_summary(self, audit_name):
        """
        Implementation of: /audit/summary

        :param audit_name: Name of the audit to query.
        :type audit_name: str

        :returns:
            Summary in the following format::
                {
                    'vulns_number'     : int,
                    'discovered_hosts' : int,
                    'total_hosts'      : int,
                    'vulns_by_level'   : {
                       'info'     : int,
                       'low'      : int,
                       'medium'   : int,
                       'high'     : int,
                       'critical' : int,
                    },
                }
            Returns None on error.
        :rtype: dict(str -> \\*) | None
        """
        # Checks for errors
        if audit_name in self.audit_error:
            return "error"

        try:
            if self.is_audit_running(audit_name):
                with SwitchToAudit(audit_name):

                    # Get the number of vulnerabilities in the database.
                    vulns_number = Database.count(Data.TYPE_VULNERABILITY)

                    # Count the vulnerabilities by severity.
                    vulns_counter = collections.Counter()
                    for l_vuln in Database.iterate(Data.TYPE_VULNERABILITY):
                        vulns_counter[l_vuln.level] += 1

                    # Get the number of IP addresses and hostnames.
                    total_hosts  = Database.count(Data.TYPE_RESOURCE,
                                                       Resource.RESOURCE_DOMAIN)
                    total_hosts += Database.count(Data.TYPE_RESOURCE,
                                                       Resource.RESOURCE_IP)

                # Substract the ones that were passed as targets.
                discovered_hosts = total_hosts - len(Config.audit_scope.targets)

                # Return the data in the expected format.
                return {
                    'vulns_number'     : vulns_number,
                    'discovered_hosts' : discovered_hosts,
                    'total_hosts'      : total_hosts,
                    'vulns_by_level'   : {
                        'info'     : vulns_counter['info'],
                        'low'      : vulns_counter['low'],
                        'medium'   : vulns_counter['medium'],
                        'high'     : vulns_counter['high'],
                        'critical' : vulns_counter['critical'],
                    }
                }

            else:
                # XXX TODO open the database manually here
                raise NotImplementedError(
                    "Querying finished audits is not implemented yet!")

        except Exception:
            Logger.log_error(traceback.format_exc())
開發者ID:qiuyuanchunwei,項目名稱:golismero,代碼行數:72,代碼來源:server_plugin.py


注:本文中的golismero.api.data.db.Database.iterate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。