Fix find_unknown_base_reverse_dns.py and sortlist.py

This commit is contained in:
Sean Whalen
2025-08-19 20:59:42 -04:00
parent 45d3dc3b2e
commit 6d4a31a120
3 changed files with 21 additions and 4 deletions

View File

@@ -724,7 +724,6 @@ ip-51-89-240.eu,OVH,Web Host
ip-87-98-138.eu,OVH,Web Host
ip-92-204-129.us,OVH,Web Host
ip-92-204-134.us,OVH,Web Host
ip-92-204-134.us,OVH,Web Host
iphmx.com,Cisco Cloud Email Security (CES),Email Security
iphotel.net.br,IPHOTEL Hosped,Web Host
iphouse.net,Sandwich,Web Host
1 base_reverse_dns name type
724 ip-87-98-138.eu OVH Web Host
725 ip-92-204-129.us OVH Web Host
726 ip-92-204-134.us OVH Web Host
ip-92-204-134.us OVH Web Host
727 iphmx.com Cisco Cloud Email Security (CES) Email Security
728 iphotel.net.br IPHOTEL Hosped Web Host
729 iphouse.net Sandwich Web Host

View File

@@ -24,7 +24,6 @@ def _main():
if not os.path.exists(file_path):
print(f"Error: {file_path} does not exist")
print(f"Loading {file_path}")
list_var = []
with open(file_path) as f:
for line in f.readlines():
domain = line.lower().strip()
@@ -36,6 +35,25 @@ def _main():
load_list(known_unknown_list_file_path, known_unknown_domains)
load_list(psl_overrides_file_path, psl_overrides)
if not os.path.exists(base_reverse_dns_map_file_path):
print(f"Error: {base_reverse_dns_map_file_path} does not exist")
print(f"Loading {base_reverse_dns_map_file_path}")
with open(base_reverse_dns_map_file_path) as f:
for row in csv.DictReader(f):
domain = row["base_reverse_dns"].lower().strip()
if domain in known_domains:
print(
f"Error: {domain} is in {base_reverse_dns_map_file_path} multiple times"
)
exit()
else:
known_domains.append(domain)
if domain in known_unknown_domains and known_domains:
print(
f"Error:{domain} is in {known_unknown_list_file_path} and \
{base_reverse_dns_map_file_path}"
)
exit(1)
if not os.path.exists(input_csv_file_path):
print(f"Error: {input_csv_file_path} does not exist")
exit(1)

View File

@@ -70,9 +70,9 @@ def sort_csv(
) -> None:
if sort_field_value_must_be_unique:
if row[sort_field] in seen_sort_field_values:
errors.append(f"Line {line_no}: Duplicate row for '{sort_field}'")
errors.append(f"Line {line_no}: Duplicate row for '{row[sort_field]}'")
else:
seen_sort_field_values.append(sort_field)
seen_sort_field_values.append(row[sort_field])
for rf in required_fields:
val = row.get(rf)
if val is None or val == "":