@@ -86,6 +86,16 @@ def clean():
8686@app .route ("/engines/nmap/clean/<scan_id>" )
8787def clean_scan (scan_id ):
8888 """Clean scan identified by id."""
89+ if scan_id not in engine .scans .keys ():
90+ return (
91+ jsonify (
92+ {
93+ "status" : "error" ,
94+ "reason" : f"Error 1002: scan_id '{ scan_id } ' not found" ,
95+ }
96+ ),
97+ 503 ,
98+ )
8999 return engine .clean_scan (scan_id )
90100
91101
@@ -568,7 +578,8 @@ def _parse_report(filename, scan_id):
568578 # Find hostnames
569579 for hostnames in host .findall ("hostnames" ):
570580 for hostname in list (hostnames ):
571- if hostname .get ("type" ) in ["user" , "PTR" ]:
581+ # if hostname.get("type") in ["user", "PTR"]:
582+ if hostname .get ("type" ) == "user" :
572583 has_hostnames = True
573584 addr = hostname .get ("name" )
574585 addr_list .append (hostname .get ("name" ))
@@ -592,6 +603,8 @@ def _parse_report(filename, scan_id):
592603 if has_hostnames :
593604 for hostnames in host .findall ("hostnames" ):
594605 for hostname in list (hostnames ):
606+ if hostname .get ("type" ) != "user" :
607+ continue
595608 ip_address = str (host .find ("address" ).get ("addr" ))
596609 issues .append (
597610 deepcopy (
@@ -1049,7 +1062,7 @@ def getfindings(scan_id):
10491062 os .remove (hosts_filename )
10501063
10511064 # remove the scan from the active scan list
1052- engine .clean_scan (scan_id )
1065+ # engine.clean_scan(scan_id)
10531066
10541067 res .update ({"summary" : summary , "issues" : issues , "status" : "success" })
10551068 return jsonify (res )
0 commit comments