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

Function find_sub_zones

python3_cron_scripts/marinus_dns.py:43–67  ·  view source on GitHub ↗

Search for FQDNs that are two or more subdomains deep. For instance, the script would ignore images.example.org. However, it would pay attention to customer.images.example.org and bob.customer.images.example.org. The goal is to see if images.example.org or customer.images.example.or

(all_dns)

Source from the content-addressed store, hash-verified

41
42
43def find_sub_zones(all_dns):
44 """
45 Search for FQDNs that are two or more subdomains deep.
46 For instance, the script would ignore images.example.org.
47 However, it would pay attention to customer.images.example.org and bob.customer.images.example.org.
48 The goal is to see if images.example.org or customer.images.example.org have different SOA records.
49 """
50 dns_regex = re.compile(r".+\\..+\\..+\\..+")
51
52 sub_zone_results = all_dns.find({"fqdn": {"$regex": dns_regex}}, {"fqdn": 1})
53
54 qualifiers = []
55 for domain in sub_zone_results:
56 parts = domain["fqdn"].split(".")
57 result = ""
58 for i in reversed(range(len(parts))):
59 if i == len(parts) - 1:
60 result = parts[i]
61 elif i > len(parts) - 3:
62 result = parts[i] + "." + result
63 elif i != 0:
64 result = parts[i] + "." + result
65 if result not in qualifiers:
66 qualifiers.append(result)
67 return qualifiers
68
69
70def main(logger=None):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected