From 91191e30f30443af612ce09fc4cea5e11d062a08 Mon Sep 17 00:00:00 2001 From: Lennart Friberg Date: Wed, 22 May 2024 14:36:13 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20if=20base=5Fdomain=20is=20None=20before?= =?UTF-8?q?=20get=5Fservice=5Ffrom=5Freverse=5Fdns=5Fbase=5Fd=E2=80=A6=20(?= =?UTF-8?q?#514)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix if base_domain is None before get_service_from_reverse_dns_base_domain call - Added if statement for base_domain before getting get_service_from_reverse_dns_base_domain(). If base_domain is None, get_service_from_reverse_dns_base_domain() will fail the report. - Added .xml test file * Create protection.outlook.com!example.com!1711756800!1711843200.xml added .xml test sample report where base_domain return none --- parsedmarc/utils.py | 21 ++++----- ....com!example.com!1711756800!1711843200.xml | 45 +++++++++++++++++++ 2 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 samples/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml diff --git a/parsedmarc/utils.py b/parsedmarc/utils.py index 62745343..994fbb0d 100644 --- a/parsedmarc/utils.py +++ b/parsedmarc/utils.py @@ -403,16 +403,17 @@ def get_ip_address_info(ip_address, info["type"] = None if reverse_dns is not None: base_domain = get_base_domain(reverse_dns) - service = get_service_from_reverse_dns_base_domain( - base_domain, - offline=offline, - local_file_path=reverse_dns_map_path, - url=reverse_dns_map_url, - always_use_local_file=always_use_local_files, - reverse_dns_map=reverse_dns_map) - info["base_domain"] = base_domain - info["type"] = service["type"] - info["name"] = service["name"] + if base_domain is not None: + service = get_service_from_reverse_dns_base_domain( + base_domain, + offline=offline, + local_file_path=reverse_dns_map_path, + url=reverse_dns_map_url, + always_use_local_file=always_use_local_files, + reverse_dns_map=reverse_dns_map) + info["base_domain"] = base_domain + info["type"] = service["type"] + info["name"] = service["name"] if cache is not None: cache[ip_address] = info diff --git a/samples/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml b/samples/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml new file mode 100644 index 00000000..ccb2e40f --- /dev/null +++ b/samples/aggregate/protection.outlook.com!example.com!1711756800!1711843200.xml @@ -0,0 +1,45 @@ + + + 1.0 + + Outlook.com + dmarcreport@microsoft.com + cfeafefe4129445e8c81018bd9177197 + + 1711756800 + 1711843200 + + + + example.com + r + r +

none

+ none + 100 + 0 +
+ + + 100.24.188.149 + 1 + + none + fail + fail + + + + hotmail.com + example.com + example.com + + + + example.com + mfrom + fail + + + +