Group results based on network type ("Tracked", "AWS", or "Akamai")
(groups, mongo_connector)
| 76 | |
| 77 | |
| 78 | def create_network_data_sets(groups, mongo_connector): |
| 79 | """ |
| 80 | Group results based on network type ("Tracked", "AWS", or "Akamai") |
| 81 | """ |
| 82 | group_data = {} |
| 83 | group_data["aws_count"] = 0 |
| 84 | group_data["tracked_count"] = 0 |
| 85 | group_data["akamai_count"] = 0 |
| 86 | group_data["azure_count"] = 0 |
| 87 | group_data["gcp_count"] = 0 |
| 88 | |
| 89 | ip_manager = IPManager.IPManager(mongo_connector) |
| 90 | |
| 91 | for group in groups: |
| 92 | cidr = group.replace(REPLACE_CHAR, ".") |
| 93 | fake_ip = cidr + ".1" |
| 94 | group_data[group] = {} |
| 95 | group_data[group]["class_c"] = cidr |
| 96 | if ip_manager.is_aws_ip(fake_ip): |
| 97 | group_data[group]["aws"] = True |
| 98 | group_data["aws_count"] = group_data["aws_count"] + 1 |
| 99 | else: |
| 100 | group_data[group]["aws"] = False |
| 101 | |
| 102 | if ip_manager.is_azure_ip(fake_ip): |
| 103 | group_data[group]["azure"] = True |
| 104 | group_data["azure_count"] = group_data["azure_count"] + 1 |
| 105 | else: |
| 106 | group_data[group]["azure"] = False |
| 107 | |
| 108 | if ip_manager.is_akamai_ip(fake_ip): |
| 109 | group_data["akamai_count"] = group_data["akamai_count"] + 1 |
| 110 | group_data[group]["akamai"] = True |
| 111 | else: |
| 112 | group_data[group]["akamai"] = False |
| 113 | |
| 114 | if ip_manager.is_tracked_ip(fake_ip): |
| 115 | group_data[group]["tracked"] = True |
| 116 | group_data["tracked_count"] = group_data["tracked_count"] + 1 |
| 117 | else: |
| 118 | group_data[group]["tracked"] = False |
| 119 | |
| 120 | if ip_manager.is_gcp_ip(fake_ip): |
| 121 | group_data[group]["gcp"] = True |
| 122 | group_data["gcp_count"] = group_data["gcp_count"] + 1 |
| 123 | else: |
| 124 | group_data[group]["gcp"] = False |
| 125 | |
| 126 | return group_data |
| 127 | |
| 128 | |
| 129 | def find_all_dns_by_zone(graph, ipzone, groups, dns_manager): |
no test coverage detected