Fixed telemetry expecting a 'scanner' field

This commit is contained in:
VakarisZ 2019-01-29 11:51:42 +02:00
parent e0a98664f6
commit 11c0d7773e
1 changed files with 10 additions and 12 deletions

View File

@ -149,8 +149,7 @@ class Telemetry(flask_restful.Resource):
new_scan = \ new_scan = \
{ {
"timestamp": telemetry_json["timestamp"], "timestamp": telemetry_json["timestamp"],
"data": data, "data": data
"scanner": telemetry_json['data']['scanner']
} }
mongo.db.edge.update( mongo.db.edge.update(
{"_id": edge["_id"]}, {"_id": edge["_id"]},
@ -160,16 +159,15 @@ class Telemetry(flask_restful.Resource):
node = mongo.db.node.find_one({"_id": edge["to"]}) node = mongo.db.node.find_one({"_id": edge["to"]})
if node is not None: if node is not None:
if new_scan["scanner"] == "TcpScanner": scan_os = new_scan["data"]["os"]
scan_os = new_scan["data"]["os"] if "type" in scan_os:
if "type" in scan_os: mongo.db.node.update({"_id": node["_id"]},
mongo.db.node.update({"_id": node["_id"]}, {"$set": {"os.type": scan_os["type"]}},
{"$set": {"os.type": scan_os["type"]}}, upsert=False)
upsert=False) if "version" in scan_os:
if "version" in scan_os: mongo.db.node.update({"_id": node["_id"]},
mongo.db.node.update({"_id": node["_id"]}, {"$set": {"os.version": scan_os["version"]}},
{"$set": {"os.version": scan_os["version"]}}, upsert=False)
upsert=False)
@staticmethod @staticmethod
def process_system_info_telemetry(telemetry_json): def process_system_info_telemetry(telemetry_json):