Runs zgrab and stores the result if necessary
(logger, domains, port, run_command, zone, zgrab_collection, tnum)
| 209 | |
| 210 | |
| 211 | def process_thread(logger, domains, port, run_command, zone, zgrab_collection, tnum): |
| 212 | """ |
| 213 | Runs zgrab and stores the result if necessary |
| 214 | """ |
| 215 | json_output = run_command(domains, tnum) |
| 216 | if ("success_count" in json_output and json_output["success_count"] > 0) or ( |
| 217 | "statuses" in json_output and json_output["statuses"]["http"]["successes"] > 0 |
| 218 | ): |
| 219 | result_file = open( |
| 220 | "./json_p" + port + "/p" + port + "-" + str(tnum) + ".json", "r" |
| 221 | ) |
| 222 | results = [] |
| 223 | for result in result_file: |
| 224 | results.append(json.loads(result)) |
| 225 | result_file.close() |
| 226 | for result in results: |
| 227 | if ( |
| 228 | "zgrab2" in global_zgrab_path and "error" in result["data"]["http"] |
| 229 | ) or "error" in result: |
| 230 | logger.warning("Failed " + port + ": " + str(result["domain"])) |
| 231 | else: |
| 232 | result["zones"] = [zone] |
| 233 | insert_result(result, zgrab_collection) |
| 234 | logger.debug("Inserted " + port + ": " + result["domain"]) |
| 235 | else: |
| 236 | logger.warning("Failed " + port + ": " + str(domains)) |
| 237 | |
| 238 | |
| 239 | def process_data(logger, tnum, q, port, command, zone, zgrab_collection): |
no test coverage detected