Fix bug in displaying edge

This commit is contained in:
Itay Mizeretz 2017-09-17 18:54:35 +03:00
parent ea657e7b7c
commit 104320aa6a
3 changed files with 16 additions and 5 deletions

View File

@ -122,7 +122,7 @@ class Telemetry(flask_restful.Resource):
def process_scan_telemetry(self, telemetry_json):
edge = self.get_edge_by_scan_or_exploit_telemetry(telemetry_json)
data = telemetry_json['data']['machine']
data.pop("ip_addr")
ip_address = data.pop("ip_addr")
new_scan = \
{
"timestamp": telemetry_json["timestamp"],
@ -131,7 +131,8 @@ class Telemetry(flask_restful.Resource):
}
mongo.db.edge.update(
{"_id": edge["_id"]},
{"$push": {"scans": new_scan}}
{"$push": {"scans": new_scan},
"$set": {"ip_address": ip_address}}
)
node = mongo.db.node.find_one({"_id": edge["to"]})

View File

@ -60,6 +60,7 @@ class EdgeService:
"id": edge["_id"],
"from": edge["from"],
"to": edge["to"],
"ip_address": edge["ip_address"],
"services": services,
"os": os,
"exploits": exploits

View File

@ -69,10 +69,19 @@ class MapPageComponent extends React.Component {
.then(res => this.setState({selected: res, selectedType: 'node'}));
}
else if (event.edges.length === 1) {
let edgeGroup = this.state.graph.edges.filter(
function(edge) {
return edge['id'] === event.edges[0];
})[0]['group'];
if (edgeGroup == 'island') {
console.log('selection cleared.'); // eslint-disable-line no-console
this.setState({selected: null, selectedType: null});
} else {
fetch('/api/netmap/edge?id='+event.edges[0])
.then(res => res.json())
.then(res => this.setState({selected: res.edge, selectedType: 'edge'}));
}
}
else {
console.log('selection cleared.'); // eslint-disable-line no-console
this.setState({selected: null, selectedType: null});