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


Python db.Database類代碼示例

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


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

示例1: __iterate_data

 def __iterate_data(self, identities = None, data_type = None, data_subtype = None):
     if identities is None:
         identities = list(Database.keys(data_type))
     if identities:
         for page in xrange(0, len(identities), 100):
             for data in Database.get_many(identities[page:page + 100], data_type):
                 yield data
開發者ID:elcodigok,項目名稱:golismero,代碼行數:7,代碼來源:rst.py

示例2: import_results

 def import_results(self, input_file):
     results = NmapScanPlugin.parse_nmap_results(None, input_file)
     if results:
         Database.async_add_many(results)
         Logger.log("Loaded %d elements from file: %s" % (len(results), input_file))
     else:
         Logger.log_verbose("No data found in file: %s" % input_file)
開發者ID:JMassapina,項目名稱:golismero-devel,代碼行數:7,代碼來源:nmap.py

示例3: notify_summary

    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,代碼行數:31,代碼來源:server_plugin.py

示例4: import_results

 def import_results(self, input_file):
     results, count = SSLScanPlugin.parse_sslscan_results(input_file)
     if results:
         Database.async_add_many(results)
         Logger.log("Loaded %d hosts and %d vulnerabilities from file: %s" %
                    (len(results) - count, count, input_file))
     else:
         Logger.log_verbose("No data found in file: %s" % input_file)
開發者ID:IFGHou,項目名稱:golismero,代碼行數:8,代碼來源:sslscan.py

示例5: import_results

 def import_results(self, input_file):
     try:
         results, vuln_count = NiktoPlugin.parse_nikto_results(
             None, input_file)
         if results:
             Database.async_add_many(results)
     except Exception, e:
         Logger.log_error(
             "Could not load Nikto results from file: %s" % input_file)
         Logger.log_error_verbose(str(e))
         Logger.log_error_more_verbose(format_exc())
開發者ID:atimorin,項目名稱:golismero,代碼行數:11,代碼來源:nikto.py

示例6: import_results

 def import_results(self, input_file):
     try:
         openvas_results = report_parser(input_file);
         golismero_results = OpenVASPlugin.parse_results(openvas_results)
         if golismero_results:
             Database.async_add_many(golismero_results)
     except Exception, e:
         fmt = format_exc()
         Logger.log_error(
             "Could not load OpenVAS results from file: %s" % input_file)
         Logger.log_error_verbose(str(e))
         Logger.log_error_more_verbose(fmt)
開發者ID:Autoscan,項目名稱:golismero,代碼行數:12,代碼來源:openvas.py

示例7: import_results

 def import_results(self, input_file):
     try:
         xml_results       = etree.parse(input_file)
         openvas_results   = VulnscanManager.transform(xml_results.getroot())
         golismero_results = OpenVASPlugin.parse_results(openvas_results)
         if golismero_results:
             Database.async_add_many(golismero_results)
     except Exception, e:
         Logger.log_error(
             "Could not load OpenVAS results from file: %s" % input_file)
         Logger.log_error_verbose(str(e))
         Logger.log_error_more_verbose(format_exc())
開發者ID:atimorin,項目名稱:golismero,代碼行數:12,代碼來源:openvas.py

示例8: test_import

def test_import():
    print "Testing OpenVAS importer..."
    orchestrator_config = OrchestratorConfig()
    orchestrator_config.ui_mode = "disabled"
    audit_config = AuditConfig()
    audit_config.targets  = ["192.168.56.101"]
    audit_config.audit_db = ":memory:"
    with PluginTester(orchestrator_config, audit_config) as t:
        t.run_plugin("import/xml_openvas", path.join(here, "test_openvas.xml"))
        results = Database.get_many( Database.keys(Data.TYPE_VULNERABILITY) )
        assert len(results) == 1, len(results)
        v = results[0]
        assert v.level == "informational", v.level
        assert v.plugin_id == "import/xml_openvas", v.plugin_id
        assert "Remote web server does not reply with 404 error code." in v.description, v.description
開發者ID:IFGHou,項目名稱:golismero,代碼行數:15,代碼來源:test_openvas.py

示例9: do_audit_results

    def do_audit_results(self, audit_name, data_type = "all"): # TODO: control audits with error at start
        """
        Implementation of: /audit/results

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

        :param data_type: Data type to request. Case insensitive.
            Must be one of the following values:
             - "all": All data types.
             - "information": Information type.
             - "resource": Resource type.
             - "vulnerability": Vulnerability type.
        :type data_type: str

        :returns: Result IDs.
        :rtype: list(str)

        :raises KeyError: Data type unknown.
        """
        if self.is_audit_running(audit_name):
            with SwitchToAudit(audit_name):
                i_data_type = {
                    "all": None,
                    "information": Data.TYPE_INFORMATION,
                    "resource": Data.TYPE_RESOURCE,
                    "vulnerability": Data.TYPE_VULNERABILITY,
                    }[data_type.strip().lower()]
                return sorted( Database.keys(i_data_type) )
        else:
            # XXX TODO open the database manually here
            raise NotImplementedError(
                "Querying finished audits is not implemented yet!")
開發者ID:qiuyuanchunwei,項目名稱:golismero,代碼行數:33,代碼來源:server_plugin.py

示例10: do_scan_details

    def do_scan_details(self, id_list):
        """
        Implementation of: /scan/details

        :param id_list: List of result IDs.
        :type id_list: list(str)
        """
        return Database.get_many(id_list)
開發者ID:atimorin,項目名稱:golismero,代碼行數:8,代碼來源:web_ui_plugin.py

示例11: common_get_resources

    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,代碼行數:18,代碼來源:html.py

示例12: run

 def run(self, info):
     if not isinstance(info, Data):
         raise TypeError("Expected Data, got %r instead" % type(info))
     print "-" * 79
     print "ID:   %s" % info.identity
     print "Data: %r" % info
     history = Database.get_plugin_history(info.identity)
     if history:
         print "History:"
         for plugin_id in history:
             print "  " + plugin_id
     print
開發者ID:IFGHou,項目名稱:golismero,代碼行數:12,代碼來源:test.py

示例13: generate_report

    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,代碼行數:14,代碼來源:screen.py

示例14: do_audit_details

    def do_audit_details(self, audit_name, id_list): # TODO: control audits with error at start
        """
        Implementation of: /audit/details

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

        :param id_list: List of result IDs.
        :type id_list: list(str)
        """
        if self.is_audit_running(audit_name):
            with SwitchToAudit(audit_name):
                return Database.get_many(id_list)
        else:
            # XXX TODO open the database manually here
            raise NotImplementedError(
                "Querying finished audits is not implemented yet!")
開發者ID:qiuyuanchunwei,項目名稱:golismero,代碼行數:17,代碼來源:server_plugin.py

示例15: list

             - "resource": Resource type.
             - "vulnerability": Vulnerability type.
        :type data_type: str

        :returns: Result IDs.
        :rtype: list(str)

        :raises KeyError: Data type unknown.
        """
        i_data_type = {
                      "all": None,
              "information": Data.TYPE_INFORMATION,
                 "resource": Data.TYPE_RESOURCE,
            "vulnerability": Data.TYPE_VULNERABILITY,
        }[data_type.strip().lower()]
        return sorted( Database.keys(i_data_type) )


    #--------------------------------------------------------------------------
    def do_scan_details(self, id_list):
        """
        Implementation of: /scan/details

        :param id_list: List of result IDs.
        :type id_list: list(str)
        """
        return Database.get_many(id_list)


    #--------------------------------------------------------------------------
    def do_plugin_list(self):
開發者ID:atimorin,項目名稱:golismero,代碼行數:31,代碼來源:web_ui_plugin.py


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