2018-05-15 20:26:46 +08:00
|
|
|
import copy
|
|
|
|
import flask_restful
|
2018-07-22 02:00:13 +08:00
|
|
|
|
2018-05-15 20:26:46 +08:00
|
|
|
|
|
|
|
from cc.auth import jwt_required
|
2018-07-22 02:00:13 +08:00
|
|
|
from cc.services.pth_report_utils import PassTheHashReport, Machine
|
|
|
|
|
2018-05-15 20:26:46 +08:00
|
|
|
|
|
|
|
class PthMap(flask_restful.Resource):
|
|
|
|
@jwt_required()
|
|
|
|
def get(self, **kw):
|
2018-05-15 21:29:02 +08:00
|
|
|
pth = PassTheHashReport()
|
|
|
|
|
|
|
|
v = copy.deepcopy(pth.vertices)
|
|
|
|
e = copy.deepcopy(pth.edges)
|
|
|
|
|
2018-05-15 20:26:46 +08:00
|
|
|
return \
|
|
|
|
{
|
2018-05-15 21:52:08 +08:00
|
|
|
"nodes": [{"id": x, "label": Machine(x).GetIp()} for x in v],
|
|
|
|
"edges": [{"id": str(s) + str(t), "from": s, "to": t, "label": label} for s, t, label in e]
|
2018-05-15 20:26:46 +08:00
|
|
|
}
|