Add tunnel info to report

This commit is contained in:
Itay Mizeretz 2017-11-07 13:17:02 +02:00
parent a0dc706a1e
commit e9b6b39a21
2 changed files with 12 additions and 0 deletions

View File

@ -89,6 +89,10 @@ class NodeService:
return True
@staticmethod
def get_monkey_label_by_id(monkey_id):
return NodeService.get_monkey_label(NodeService.get_monkey_by_id(monkey_id))
@staticmethod
def get_monkey_label(monkey):
label = monkey["hostname"] + " : " + monkey["ip_addresses"][0]

View File

@ -1,4 +1,5 @@
from cc.database import mongo
from cc.services.node import NodeService
__author__ = "itay.mizeretz"
@ -24,6 +25,12 @@ class ReportService:
exploit_types = mongo.db.command({'distinct': 'edge', 'key': 'exploits.exploiter'})['values']
return [exploit for exploit in exploit_types if ReportService.did_exploit_type_succeed(exploit)]
@staticmethod
def get_tunnels():
return [
(NodeService.get_monkey_label_by_id(tunnel['_id']), NodeService.get_monkey_label_by_id(tunnel['tunnel']))
for tunnel in mongo.db.monkey.find({'tunnel': {'$exists': True}}, {'tunnel': 1})]
@staticmethod
def get_report():
return \
@ -32,6 +39,7 @@ class ReportService:
'last_monkey_dead_time': ReportService.get_last_monkey_dead_time(),
'breach_count': ReportService.get_breach_count(),
'successful_exploit_types': ReportService.get_successful_exploit_types(),
'tunnels': ReportService.get_tunnels()
}
@staticmethod