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

Function find_srdns_by_zone

python3_cron_scripts/create_graphs2.py:171–220  ·  view source on GitHub ↗

Collect all the Sonar Reverse DNS records for the provided zone and add them to NetworkX graph

(graph, zone, groups, mongo_connector, ip_manager)

Source from the content-addressed store, hash-verified

169
170
171def find_srdns_by_zone(graph, zone, groups, mongo_connector, ip_manager):
172 """
173 Collect all the Sonar Reverse DNS records for the provided zone and add them to NetworkX graph
174 """
175 srdns_collection = mongo_connector.get_sonar_reverse_dns_connection()
176 rdns_results = srdns_collection.find({"zone": zone})
177
178 for result in rdns_results:
179 zone_g_index = add_to_list(zone, groups)
180 if result["fqdn"] != zone:
181 graph.add_node(
182 result["fqdn"].replace("." + zone, ""),
183 data_type="domain",
184 type=zone_g_index,
185 depends=[zone],
186 dependedOnBy=[result["ip"]],
187 docs="",
188 )
189 else:
190 graph.add_node(
191 result["fqdn"],
192 data_type="tld",
193 type=zone_g_index,
194 depends=[],
195 dependedOnBy=[result["ip"]],
196 docs="",
197 )
198 temp = result["ip"].split(".")
199
200 ip_group = ".".join(temp[:-1])
201 if ip_manager.is_aws_ip(result["ip"]):
202 ip_group = "aws"
203 elif ip_manager.is_akamai_ip(result["ip"]):
204 ip_group = "akamai"
205 elif ip_manager.is_azure_ip(result["ip"]):
206 ip_group = "azure"
207 elif ip_manager.is_gcp_ip(result["ip"]):
208 ip_group = "gcp"
209
210 ip_g_index = add_to_list(ip_group, groups)
211 graph.add_node(
212 result["ip"],
213 data_type="ip",
214 type=ip_g_index,
215 depends=[result["fqdn"].replace("." + zone, "")],
216 dependedOnBy=[],
217 docs="",
218 )
219 graph.add_edge(zone, result["fqdn"].replace("." + zone, ""), value=2)
220 graph.add_edge(result["fqdn"].replace("." + zone, ""), result["ip"], value=1)
221
222
223def build_docs(node, zone, groups):

Callers 1

mainFunction · 0.70

Calls 6

is_aws_ipMethod · 0.80
is_akamai_ipMethod · 0.80
is_azure_ipMethod · 0.80
is_gcp_ipMethod · 0.80
add_to_listFunction · 0.70

Tested by

no test coverage detected