forked from p15670423/monkey
WIP - initial code, just trying to make a POST request work
This commit is contained in:
parent
fd36118c0e
commit
026cb41064
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 => {
|
||||
|
|
Loading…
Reference in New Issue