forked from p15670423/monkey
Fixed bug in report generation, added lock release for exceptions in report generation
This commit is contained in:
parent
f8aff44e8b
commit
04b7370575
|
@ -386,10 +386,11 @@ class ReportService:
|
|||
@staticmethod
|
||||
def get_monkey_subnets(monkey_guid):
|
||||
network_info = mongo.db.telemetry.find_one(
|
||||
{'telem_category': 'system_info', 'monkey_guid': monkey_guid},
|
||||
{'telem_category': 'system_info',
|
||||
'monkey_guid': monkey_guid},
|
||||
{'data.network_info.networks': 1}
|
||||
)
|
||||
if network_info is None:
|
||||
if network_info is None or not network_info["data"]:
|
||||
return []
|
||||
|
||||
return \
|
||||
|
|
|
@ -15,8 +15,10 @@ __regular_report_generating_lock = threading.Semaphore()
|
|||
def safe_generate_reports():
|
||||
# Entering the critical section; Wait until report generation is available.
|
||||
__report_generating_lock.acquire()
|
||||
try:
|
||||
report = safe_generate_regular_report()
|
||||
attack_report = safe_generate_attack_report()
|
||||
finally:
|
||||
# Leaving the critical section.
|
||||
__report_generating_lock.release()
|
||||
return report, attack_report
|
||||
|
@ -25,8 +27,10 @@ def safe_generate_reports():
|
|||
def safe_generate_regular_report():
|
||||
# Local import to avoid circular imports
|
||||
from monkey_island.cc.services.reporting.report import ReportService
|
||||
try:
|
||||
__regular_report_generating_lock.acquire()
|
||||
report = ReportService.generate_report()
|
||||
finally:
|
||||
__regular_report_generating_lock.release()
|
||||
return report
|
||||
|
||||
|
@ -34,8 +38,10 @@ def safe_generate_regular_report():
|
|||
def safe_generate_attack_report():
|
||||
# Local import to avoid circular imports
|
||||
from monkey_island.cc.services.attack.attack_report import AttackReportService
|
||||
try:
|
||||
__attack_report_generating_lock.acquire()
|
||||
attack_report = AttackReportService.generate_new_report()
|
||||
finally:
|
||||
__attack_report_generating_lock.release()
|
||||
return attack_report
|
||||
|
||||
|
|
Loading…
Reference in New Issue