Island: Check if machine responded before processing scan telemetry

Fixes part of #1850
This commit is contained in:
Shreya Malviya 2022-04-21 15:01:41 +05:30 committed by Mike Salvatore
parent 20ee887886
commit e06e855a48
1 changed files with 14 additions and 2 deletions

View File

@ -109,8 +109,17 @@ class TelemetryFeed(flask_restful.Resource):
)
@staticmethod
def should_show_brief(telem):
return telem["telem_category"] in TELEM_PROCESS_DICT
def should_show_brief(telem) -> bool:
should_process_telem = SHOULD_PROCESS_TELEM.get(telem["telem_category"], lambda _: True)
return telem["telem_category"] in TELEM_PROCESS_DICT and should_process_telem(telem)
@staticmethod
def should_process_scan_telem(telem) -> bool:
return TelemetryFeed._machine_responded(telem["data"]["machine"])
@staticmethod
def _machine_responded(machine) -> bool:
return machine["icmp"] and len(machine["services"].keys()) > 0
TELEM_PROCESS_DICT = {
@ -122,3 +131,6 @@ TELEM_PROCESS_DICT = {
TelemCategoryEnum.TRACE: TelemetryFeed.get_trace_telem_brief,
TelemCategoryEnum.TUNNEL: TelemetryFeed.get_tunnel_telem_brief,
}
SHOULD_PROCESS_TELEM = {TelemCategoryEnum.SCAN: TelemetryFeed.should_process_scan_telem}