diff --git a/monkey/monkey_island/cc/resources/netmap.py b/monkey/monkey_island/cc/resources/netmap.py index ed83414f5..96ea38b28 100644 --- a/monkey/monkey_island/cc/resources/netmap.py +++ b/monkey/monkey_island/cc/resources/netmap.py @@ -1,4 +1,7 @@ +import json + import flask_restful +from flask import request from monkey_island.cc.auth import jwt_required from monkey_island.cc.services.edge import EdgeService @@ -28,4 +31,32 @@ class NetMap(flask_restful.Resource): "edges": edges } + @jwt_required() + def post(self, **kw): + post_data = json.loads(request.data) + print(post_data) + + monkeys = [NodeService.monkey_to_net_node(x) for x in mongo.db.monkey.find({})] + nodes = [NodeService.node_to_net_node(x) for x in mongo.db.node.find({})] + edges = [EdgeService.edge_to_net_edge(x) for x in mongo.db.edge.find({})] + + if NodeService.get_monkey_island_monkey() is None: + monkey_island = [NodeService.get_monkey_island_pseudo_net_node()] + edges += EdgeService.get_monkey_island_pseudo_edges() + else: + monkey_island = [] + edges += EdgeService.get_infected_monkey_island_pseudo_edges() + + all_nodes = monkeys + nodes + monkey_island + def filter_linux(machine): + if machine["os"] == "linux": + return False + return True + all_nodes = filter(filter_linux, all_nodes) + + return \ + { + "nodes": all_nodes, + "edges": edges + } diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js index eb94792ab..65a8b9003 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -103,7 +103,17 @@ class ReportPageComponent extends AuthComponent { }; updateMapFromServer = () => { - this.authFetch('/api/netmap') + this.authFetch('/api/netmap', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + firstParam: 'yourValue', + secondParam: 'yourOtherValue', + }) + }) .then(res => res.json()) .then(res => { res.edges.forEach(edge => {