MCPcopy Create free account
hub / github.com/adobe/Marinus / process_thread

Function process_thread

python3_cron_scripts/zgrab_port_ip.py:672–728  ·  view source on GitHub ↗

Runs zgrab and stores the result if necessary

(
    logger, ips, port, run_command, zones_struct, zgrab_collection, tnum
)

Source from the content-addressed store, hash-verified

670
671
672def process_thread(
673 logger, ips, port, run_command, zones_struct, zgrab_collection, tnum
674):
675 """
676 Runs zgrab and stores the result if necessary
677 """
678 json_output = run_command(ips, tnum)
679
680 if ("success_count" in json_output and json_output["success_count"] > 0) or (
681 "statuses" in json_output
682 and json_output["statuses"][global_port_names[port]]["successes"] > 0
683 ):
684 result_file = open(
685 "./json_p" + port + "/p" + port + "-" + str(tnum) + ".json", "r"
686 )
687 results = []
688 for result in result_file:
689 results.append(json.loads(result))
690 result_file.close()
691 for result in results:
692 if (
693 "zgrab2" in global_zgrab_path
694 and "error" in result["data"][global_port_names[port]]
695 ) or "error" in result:
696 if port == "25":
697 if (
698 (
699 "zgrab2" in global_zgrab_path
700 and "result" in result["data"]["smtp"]
701 and "starttls" in result["data"]["smtp"]["result"]
702 )
703 or "error_component" in result
704 and result["error_component"] == "starttls"
705 ):
706 logger.debug("Adding " + str(result["ip"]) + " to retest list")
707 global_retest_list.append(result["ip"])
708 else:
709 logger.warning("Failed " + port + ": " + str(result["ip"]))
710 else:
711 logger.warning("Failed " + port + ": " + str(result["ip"]))
712 else:
713 result["aws"] = zones_struct["ip_manager"].is_aws_ip(result["ip"])
714 result["azure"] = zones_struct["ip_manager"].is_azure_ip(result["ip"])
715 result["gcp"] = zones_struct["ip_manager"].is_gcp_ip(result["ip"])
716 result["tracked"] = zones_struct["ip_manager"].is_tracked_ip(
717 result["ip"]
718 )
719 insert_result(
720 result,
721 port,
722 zones_struct["ip_context"],
723 zones_struct["zones"],
724 zgrab_collection,
725 )
726 logger.debug("Inserted " + port + ": " + result["ip"])
727 else:
728 logger.warning("Failed " + port + ": " + str(ips))
729

Callers 2

process_dataFunction · 0.70
mainFunction · 0.70

Calls 5

is_aws_ipMethod · 0.80
is_azure_ipMethod · 0.80
is_gcp_ipMethod · 0.80
is_tracked_ipMethod · 0.80
insert_resultFunction · 0.70

Tested by

no test coverage detected