本文整理汇总了Python中golismero.api.data.db.Database.keys方法的典型用法代码示例。如果您正苦于以下问题:Python Database.keys方法的具体用法?Python Database.keys怎么用?Python Database.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类golismero.api.data.db.Database
的用法示例。
在下文中一共展示了Database.keys方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __iterate_data
# 需要导入模块: from golismero.api.data.db import Database [as 别名]
# 或者: from golismero.api.data.db.Database import keys [as 别名]
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
示例2: do_audit_results
# 需要导入模块: from golismero.api.data.db import Database [as 别名]
# 或者: from golismero.api.data.db.Database import keys [as 别名]
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!")
示例3: test_import
# 需要导入模块: from golismero.api.data.db import Database [as 别名]
# 或者: from golismero.api.data.db.Database import keys [as 别名]
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
示例4: common_get_resources
# 需要导入模块: from golismero.api.data.db import Database [as 别名]
# 或者: from golismero.api.data.db.Database import keys [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
示例5: __iterate
# 需要导入模块: from golismero.api.data.db import Database [as 别名]
# 或者: from golismero.api.data.db.Database import keys [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)
示例6: list
# 需要导入模块: from golismero.api.data.db import Database [as 别名]
# 或者: from golismero.api.data.db.Database import keys [as 别名]
- "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):