本文整理汇总了Python中lib.cuckoo.core.database.Database.view_errors方法的典型用法代码示例。如果您正苦于以下问题:Python Database.view_errors方法的具体用法?Python Database.view_errors怎么用?Python Database.view_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.cuckoo.core.database.Database
的用法示例。
在下文中一共展示了Database.view_errors方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def index(request):
db = Database()
tasks_files = db.list_tasks(limit=50, category="file", not_status=TASK_PENDING)
tasks_urls = db.list_tasks(limit=50, category="url", not_status=TASK_PENDING)
analyses_files = []
analyses_urls = []
if tasks_files:
for task in tasks_files:
new = task.to_dict()
new["sample"] = db.view_sample(new["sample_id"]).to_dict()
if db.view_errors(task.id):
new["errors"] = True
analyses_files.append(new)
if tasks_urls:
for task in tasks_urls:
new = task.to_dict()
if db.view_errors(task.id):
new["errors"] = True
analyses_urls.append(new)
return render_to_response("analysis/index.html",
{"files": analyses_files, "urls": analyses_urls},
context_instance=RequestContext(request))
示例2: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def index(request):
db = Database()
tasks_files = db.list_tasks(limit=50, category="file", not_status=TASK_PENDING)
tasks_urls = db.list_tasks(limit=50, category="url", not_status=TASK_PENDING)
analyses_files = []
analyses_urls = []
if tasks_files:
for task in tasks_files:
new = task.to_dict()
new["sample"] = db.view_sample(new["sample_id"]).to_dict()
filename = os.path.basename(new["target"])
new.update({"filename": filename})
if db.view_errors(task.id):
new["errors"] = True
analyses_files.append(new)
if tasks_urls:
for task in tasks_urls:
new = task.to_dict()
if db.view_errors(task.id):
new["errors"] = True
analyses_urls.append(new)
return render(request, "analysis/index.html", {
"files": analyses_files,
"urls": analyses_urls,
})
示例3: show_reports
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def show_reports(request,binary_sha1):
db = Database()
tasks_files = db.list_tasks_by_binary( binary_sha1, limit=50, category="file" )
analyses_files = []
if tasks_files:
for tup in tasks_files:
sample = tup[0]
task = tup[1]
new = task.to_dict()
#new["sample"] = db.view_sample(new["sample_id"]).to_dict()
new["sample"] = sample.to_dict()
if db.view_errors(task.id):
new["errors"] = True
# obtain station and file name with target
filepath = new["target"]
filedata = filepath.split('/')
new["file"] = filedata[3] if len(filedata) > 3 else filedata[2]
new["station"] = filedata[2] if len(filedata) > 3 else ""
analyses_files.append(new)
return render_to_response("analysis/show_reports.html",
{"files": analyses_files, "urls": None},
context_instance=RequestContext(request))
示例4: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def index(request):
db = Database()
tasks_files = db.list_tasks(limit=50, category="file", not_status=[TASK_PENDING,TASK_SCHEDULED,TASK_UNSCHEDULED])
tasks_urls = db.list_tasks(limit=50, category="url", not_status=[TASK_PENDING,TASK_SCHEDULED,TASK_UNSCHEDULED])
analyses_files = []
analyses_urls = []
if tasks_files:
for task in tasks_files:
new = task.to_dict()
new["target"] = os.path.basename(new["target"])
new["sample"] = db.view_sample(new["sample_id"]).to_dict()
new["pcap_file_id"] = ""
new["pcap_file_length"] = 0
report = results_db.analysis.find({"info.id": int(task.id)}, sort=[("_id", pymongo.DESCENDING)])
if report.count() and "pcap_id" in report[0]["network"]:
file_object = results_db.fs.files.find_one({"_id": ObjectId(report[0]["network"]["pcap_id"])})
file_item = fs.get(ObjectId(file_object["_id"]))
new["pcap_file_id"] = report[0]["network"]["pcap_id"]
new["pcap_file_length"] = file_item.length
if db.view_errors(task.id):
new["errors"] = True
new["experiment"] = task.experiment
analyses_files.append(new)
if tasks_urls:
for task in tasks_urls:
new = task.to_dict()
if db.view_errors(task.id):
new["errors"] = True
new["experiment"] = task.experiment
analyses_urls.append(new)
return render_to_response("analysis/index.html",
{"files": analyses_files, "urls": analyses_urls},
context_instance=RequestContext(request))
示例5: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def index(request):
db = Database()
tasks_files = db.list_tasks(limit=50, category="file", not_status=TASK_PENDING)
tasks_urls = db.list_tasks(limit=50, category="url", not_status=TASK_PENDING)
analyses_files = []
analyses_urls = []
##import pprint
if tasks_files:
for task in tasks_files:
new = task.to_dict()
new["sample"] = db.view_sample(new["sample_id"]).to_dict()
if db.view_errors(task.id):
new["errors"] = True
# obtain station and file name with target
filepath = new["target"]
filedata = filepath.split('/')
new["file"] = filedata[3] if len(filedata) > 3 else filedata[2]
new["station"] = filedata[2] if len(filedata) > 3 else ""
analyses_files.append(new)
if tasks_urls:
for task in tasks_urls:
new = task.to_dict()
if db.view_errors(task.id):
new["errors"] = True
analyses_urls.append(new)
#pprint.pprint(analyses_files[0])
return render_to_response("analysis/index.html",
{"files": analyses_files, "urls": analyses_urls},
context_instance=RequestContext(request))
示例6: experiment
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def experiment(request, experiment_id=None):
db = Database()
if experiment_id:
# Get tasks for the provided experiment
tasks_files = db.list_tasks(limit=50, category="file", experiment=experiment_id)
analyses_files = []
if tasks_files:
for task in tasks_files:
new = task.to_dict()
new["timeout"] = time.strftime('%H:%M:%S', time.gmtime(new["timeout"]))
new["target"] = os.path.basename(new["target"])
new["sample"] = db.view_sample(new["sample_id"]).to_dict()
new["pcap_file_id"] = ""
new["pcap_file_length"] = 0
report = results_db.analysis.find({"info.id": int(task.id)}, sort=[("_id", pymongo.DESCENDING)])
if report.count() and "pcap_id" in report[0]["network"]:
file_object = results_db.fs.files.find_one({"_id": ObjectId(report[0]["network"]["pcap_id"])})
file_item = fs.get(ObjectId(file_object["_id"]))
new["pcap_file_id"] = report[0]["network"]["pcap_id"]
new["pcap_file_length"] = file_item.length
if db.view_errors(task.id):
new["errors"] = True
new["experiment"] = task.experiment
analyses_files.append(new)
return render_to_response("analysis/index.html",
{"files": analyses_files},
context_instance=RequestContext(request))
else:
# List all experiments
experiments = db.list_experiments()
for experiment in experiments:
experiment.last_task.timeout = datetime.timedelta(seconds=experiment.last_task.timeout).__str__()
return render_to_response("analysis/experiment.html",
{"experiments": experiments},
context_instance=RequestContext(request))
示例7: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def index(request, page=1):
page = int(page)
db = Database()
if page == 0:
page = 1
off = (page - 1) * TASK_LIMIT
tasks_files = db.list_tasks(limit=TASK_LIMIT, offset=off, category="file", not_status=TASK_PENDING)
tasks_urls = db.list_tasks(limit=TASK_LIMIT, offset=off, category="url", not_status=TASK_PENDING)
analyses_files = []
analyses_urls = []
# Vars to define when to show Next/Previous buttons
paging = dict()
paging["show_file_next"] = "show"
paging["show_url_next"] = "show"
paging["next_page"] = str(page + 1)
paging["prev_page"] = str(page - 1)
# On a fresh install, we need handle where there are 0 tasks.
buf = db.list_tasks(limit=1, category="file", not_status=TASK_PENDING, order_by="added_on asc")
if len(buf) == 1:
first_file = db.list_tasks(limit=1, category="file", not_status=TASK_PENDING, order_by="added_on asc")[
0
].to_dict()["id"]
paging["show_file_prev"] = "show"
else:
paging["show_file_prev"] = "hide"
buf = db.list_tasks(limit=1, category="url", not_status=TASK_PENDING, order_by="added_on asc")
if len(buf) == 1:
first_url = db.list_tasks(limit=1, category="url", not_status=TASK_PENDING, order_by="added_on asc")[
0
].to_dict()["id"]
paging["show_url_prev"] = "show"
else:
paging["show_url_prev"] = "hide"
if tasks_files:
for task in tasks_files:
new = get_analysis_info(db, task=task)
if new["id"] == first_file:
paging["show_file_next"] = "hide"
if page <= 1:
paging["show_file_prev"] = "hide"
if db.view_errors(task.id):
new["errors"] = True
analyses_files.append(new)
else:
paging["show_file_next"] = "hide"
if tasks_urls:
for task in tasks_urls:
new = get_analysis_info(db, task=task)
if new["id"] == first_url:
paging["show_url_next"] = "hide"
if page <= 1:
paging["show_url_prev"] = "hide"
if db.view_errors(task.id):
new["errors"] = True
analyses_urls.append(new)
else:
paging["show_url_next"] = "hide"
return render_to_response(
"analysis/index.html",
{"files": analyses_files, "urls": analyses_urls, "paging": paging, "config": enabledconf},
context_instance=RequestContext(request),
)
示例8: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def index(request, page=1):
page = int(page)
db = Database()
if page == 0:
page = 1
off = (page - 1) * TASK_LIMIT
tasks_files = db.list_tasks(limit=TASK_LIMIT, offset=off, category="file", not_status=TASK_PENDING)
tasks_urls = db.list_tasks(limit=TASK_LIMIT, offset=off, category="url", not_status=TASK_PENDING)
analyses_files = []
analyses_urls = []
# Vars to define when to show Next/Previous buttons
paging = dict()
paging["show_file_next"] = "show"
paging["show_url_next"] = "show"
paging["next_page"] = str(page + 1)
paging["prev_page"] = str(page - 1)
# On a fresh install, we need handle where there are 0 tasks.
buf = db.list_tasks(limit=1, category="file", not_status=TASK_PENDING, order_by="added_on asc")
if len(buf) == 1:
first_file = db.list_tasks(limit=1, category="file", not_status=TASK_PENDING, order_by="added_on asc")[0].to_dict()["id"]
paging["show_file_prev"] = "show"
else:
paging["show_file_prev"] = "hide"
buf = db.list_tasks(limit=1, category="url", not_status=TASK_PENDING, order_by="added_on asc")
if len(buf) == 1:
first_url = db.list_tasks(limit=1, category="url", not_status=TASK_PENDING, order_by="added_on asc")[0].to_dict()["id"]
paging["show_url_prev"] = "show"
else:
paging["show_url_prev"] = "hide"
if tasks_files:
for task in tasks_files:
new = task.to_dict()
if new["id"] == first_file:
paging["show_file_next"] = "hide"
if page <= 1:
paging["show_file_prev"] = "hide"
new["sample"] = db.view_sample(new["sample_id"]).to_dict()
filename = os.path.basename(new["target"])
new.update({"filename": filename})
if db.view_errors(task.id):
new["errors"] = True
rtmp = results_db.analysis.find_one({"info.id": int(new["id"])},{"virustotal_summary": 1, "suri_tls_cnt": 1, "suri_alert_cnt": 1, "suri_http_cnt": 1, "suri_file_cnt": 1},sort=[("_id", pymongo.DESCENDING)])
if rtmp:
if rtmp.has_key("virustotal_summary") and rtmp["virustotal_summary"]:
new["virustotal_summary"] = rtmp["virustotal_summary"]
if rtmp.has_key("suri_tls_cnt") and rtmp["suri_tls_cnt"]:
new["suri_tls_cnt"] = rtmp["suri_tls_cnt"]
if rtmp.has_key("suri_alert_cnt") and rtmp["suri_alert_cnt"]:
new["suri_alert_cnt"] = rtmp["suri_alert_cnt"]
if rtmp.has_key("suri_file_cnt") and rtmp["suri_file_cnt"]:
new["suri_file_cnt"] = rtmp["suri_file_cnt"]
if rtmp.has_key("suri_http_cnt") and rtmp["suri_http_cnt"]:
new["suri_http_cnt"] = rtmp["suri_http_cnt"]
if settings.MOLOCH_ENABLED:
if settings.MOLOCH_BASE[-1] != "/":
settings.MOLOCH_BASE = settings.MOLOCH_BASE + "/"
new["moloch_url"] = settings.MOLOCH_BASE + "?date=-1&expression=tags" + quote("\x3d\x3d\x22%s\x3a%s\x22" % (settings.MOLOCH_NODE,new["id"]),safe='')
analyses_files.append(new)
else:
paging["show_file_next"] = "hide"
if tasks_urls:
for task in tasks_urls:
new = task.to_dict()
if new["id"] == first_url:
paging["show_url_next"] = "hide"
if page <= 1:
paging["show_url_prev"] = "hide"
if db.view_errors(task.id):
new["errors"] = True
rtmp = results_db.analysis.find_one({"info.id": int(new["id"])},{"virustotal_summary": 1, "suri_tls_cnt": 1, "suri_alert_cnt": 1, "suri_http_cnt": 1, "suri_file_cnt": 1},sort=[("_id", pymongo.DESCENDING)])
if rtmp:
if rtmp.has_key("virustotal_summary") and rtmp["virustotal_summary"]:
new["virustotal_summary"] = rtmp["virustotal_summary"]
if rtmp.has_key("suri_tls_cnt") and rtmp["suri_tls_cnt"]:
new["suri_tls_cnt"] = rtmp["suri_tls_cnt"]
if rtmp.has_key("suri_alert_cnt") and rtmp["suri_alert_cnt"]:
new["suri_alert_cnt"] = rtmp["suri_alert_cnt"]
if rtmp.has_key("suri_file_cnt") and rtmp["suri_file_cnt"]:
new["suri_file_cnt"] = rtmp["suri_file_cnt"]
if rtmp.has_key("suri_http_cnt") and rtmp["suri_http_cnt"]:
new["suri_http_cnt"] = rtmp["suri_http_cnt"]
if settings.MOLOCH_ENABLED:
if settings.MOLOCH_BASE[-1] != "/":
settings.MOLOCH_BASE = settings.MOLOCH_BASE + "/"
new["moloch_url"] = settings.MOLOCH_BASE + "?date=-1&expression=tags" + quote("\x3d\x3d\x22%s\x3a%s\x22" % (settings.MOLOCH_NODE,new["id"]),safe='')
analyses_urls.append(new)
else:
#.........这里部分代码省略.........
示例9: index
# 需要导入模块: from lib.cuckoo.core.database import Database [as 别名]
# 或者: from lib.cuckoo.core.database.Database import view_errors [as 别名]
def index(request):
db = Database()
tasks_files = db.list_tasks(limit=50, category="file", not_status=TASK_PENDING)
tasks_urls = db.list_tasks(limit=50, category="url", not_status=TASK_PENDING)
analyses_files = []
analyses_urls = []
if tasks_files:
for task in tasks_files:
new = task.to_dict()
new["sample"] = db.view_sample(new["sample_id"]).to_dict()
if db.view_errors(task.id):
new["errors"] = True
rtmp = results_db.analysis.find_one({"info.id": int(new["id"])},{"virustotal_summary": 1, "suri_tls_cnt": 1, "suri_alert_cnt": 1, "suri_http_cnt": 1, "suri_file_cnt": 1, "suricata.http_log_id": 1, "suricata.tls_log_id": 1, "suricata.fast_log_id": 1, "suricata.file_log_id": 1, "mlist_cnt": 1, "network.pcap_id":1},sort=[("_id", pymongo.DESCENDING)])
if rtmp:
if rtmp.has_key("virustotal_summary") and rtmp["virustotal_summary"]:
new["virustotal_summary"] = rtmp["virustotal_summary"]
if rtmp.has_key("suri_tls_cnt") and rtmp["suri_tls_cnt"]:
new["suri_tls_cnt"] = rtmp["suri_tls_cnt"]
if rtmp.has_key("suri_alert_cnt") and rtmp["suri_alert_cnt"]:
new["suri_alert_cnt"] = rtmp["suri_alert_cnt"]
if rtmp.has_key("suri_file_cnt") and rtmp["suri_file_cnt"]:
new["suri_file_cnt"] = rtmp["suri_file_cnt"]
if rtmp.has_key("suri_http_cnt") and rtmp["suri_http_cnt"]:
new["suri_http_cnt"] = rtmp["suri_http_cnt"]
if rtmp.has_key("suricata") and rtmp["suricata"]:
if rtmp["suricata"].has_key("http_log_id") and rtmp["suricata"]["http_log_id"]:
new["suricata_http_log_id"] = rtmp["suricata"]["http_log_id"]
if rtmp["suricata"].has_key("tls_log_id") and rtmp["suricata"]["tls_log_id"]:
new["suricata_tls_log_id"] = rtmp["suricata"]["tls_log_id"]
if rtmp["suricata"].has_key("fast_log_id") and rtmp["suricata"]["fast_log_id"]:
new["suricata_fast_log_id"] = rtmp["suricata"]["fast_log_id"]
if rtmp["suricata"].has_key("file_log_id") and rtmp["suricata"]["file_log_id"]:
new["suricata_file_log_id"] = rtmp["suricata"]["file_log_id"]
if rtmp.has_key("mlist_cnt") and rtmp["mlist_cnt"]:
new["mlist_cnt"] = rtmp["mlist_cnt"]
if rtmp.has_key("network") and rtmp["network"].has_key("pcap_id") and rtmp["network"]["pcap_id"]:
new["pcap_id"] = rtmp["network"]["pcap_id"]
if settings.MOLOCH_ENABLED:
if settings.MOLOCH_BASE[-1] != "/":
settings.MOLOCH_BASE = settings.MOLOCH_BASE + "/"
new["moloch_url"] = settings.MOLOCH_BASE + "?date=-1&expression=tags" + quote("\x3d\x3d\x22%s\x3a%s\x22" % (settings.MOLOCH_NODE,new["id"]),safe='')
analyses_files.append(new)
if tasks_urls:
for task in tasks_urls:
new = task.to_dict()
if db.view_errors(task.id):
new["errors"] = True
rtmp = results_db.analysis.find_one({"info.id": int(new["id"])},{"virustotal_summary": 1, "suri_tls_cnt": 1, "suri_alert_cnt": 1, "suri_http_cnt": 1, "suri_file_cnt": 1, "suricata.http_log_id": 1, "suricata.tls_log_id": 1, "suricata.fast_log_id": 1, "suricata.file_log_id": 1, "mlist_cnt": 1, "network.pcap_id":1},sort=[("_id", pymongo.DESCENDING)])
if rtmp:
if rtmp.has_key("virustotal_summary") and rtmp["virustotal_summary"]:
new["virustotal_summary"] = rtmp["virustotal_summary"]
if rtmp.has_key("suri_tls_cnt") and rtmp["suri_tls_cnt"]:
new["suri_tls_cnt"] = rtmp["suri_tls_cnt"]
if rtmp.has_key("suri_alert_cnt") and rtmp["suri_alert_cnt"]:
new["suri_alert_cnt"] = rtmp["suri_alert_cnt"]
if rtmp.has_key("suri_file_cnt") and rtmp["suri_file_cnt"]:
new["suri_file_cnt"] = rtmp["suri_file_cnt"]
if rtmp.has_key("suri_http_cnt") and rtmp["suri_http_cnt"]:
new["suri_http_cnt"] = rtmp["suri_http_cnt"]
if rtmp.has_key("suricata") and rtmp["suricata"]:
if rtmp["suricata"].has_key("http_log_id") and rtmp["suricata"]["http_log_id"]:
new["suricata_http_log_id"] = rtmp["suricata"]["http_log_id"]
if rtmp["suricata"].has_key("tls_log_id") and rtmp["suricata"]["tls_log_id"]:
new["suricata_tls_log_id"] = rtmp["suricata"]["tls_log_id"]
if rtmp["suricata"].has_key("fast_log_id") and rtmp["suricata"]["fast_log_id"]:
new["suricata_fast_log_id"] = rtmp["suricata"]["fast_log_id"]
if rtmp["suricata"].has_key("file_log_id") and rtmp["suricata"]["file_log_id"]:
new["suricata_file_log_id"] = rtmp["suricata"]["file_log_id"]
if rtmp.has_key("mlist_cnt") and rtmp["mlist_cnt"]:
new["mlist_cnt"] = rtmp["mlist_cnt"]
if rtmp.has_key("network") and rtmp["network"].has_key("pcap_id") and rtmp["network"]["pcap_id"]:
new["pcap_id"] = rtmp["network"]["pcap_id"]
if settings.MOLOCH_ENABLED:
if settings.MOLOCH_BASE[-1] != "/":
settings.MOLOCH_BASE = settings.MOLOCH_BASE + "/"
new["moloch_url"] = settings.MOLOCH_BASE + "?date=-1&expression=tags" + quote("\x3d\x3d\x22%s\x3a%s\x22" % (settings.MOLOCH_NODE,new["id"]),safe='')
analyses_urls.append(new)
return render_to_response("analysis/index.html",
{"files": analyses_files, "urls": analyses_urls},
context_instance=RequestContext(request))