From f19aca1a231b40addeec4047effa167de295cda2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Zaj=C4=85c?= Date: Wed, 31 Jul 2024 14:53:58 +0200 Subject: [PATCH] . --- checkdmarc/dmarc.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/checkdmarc/dmarc.py b/checkdmarc/dmarc.py index ec6bef3..9b14813 100644 --- a/checkdmarc/dmarc.py +++ b/checkdmarc/dmarc.py @@ -680,10 +680,11 @@ def verify_dmarc_report_destination(source_domain: str, nameservers: list[str] = None, ignore_unrelated_records: bool = False, resolver: dns.resolver.Resolver = None, - timeout: float = 2.0) -> bool: + timeout: float = 2.0) -> None: """ Checks if the report destination accepts reports for the source domain - per RFC 7489, section 7.1 + per RFC 7489, section 7.1. Raises `checkdmarc.dmarc.UnverifiedDMARCURIDestination` + if it doesn't accept. Args: source_domain (str): The source domain @@ -694,10 +695,6 @@ def verify_dmarc_report_destination(source_domain: str, requests timeout (float): number of seconds to wait for an answer from DNS - Returns: - bool: Indicates if the report domain accepts reports from the given - domain - Raises: :exc:`checkdmarc.dmarc.UnverifiedDMARCURIDestination` :exc:`checkdmarc.dmarc.UnrelatedTXTRecordFound` @@ -712,7 +709,7 @@ def verify_dmarc_report_destination(source_domain: str, nameservers=nameservers, ignore_unrelated_records=ignore_unrelated_records, resolver=resolver): - return True + return target = f"{source_domain}._report._dmarc.{destination_domain}" message = f"{destination_domain} does not indicate that it accepts " \ f"DMARC reports about {source_domain} - " \ @@ -741,12 +738,10 @@ def verify_dmarc_report_destination(source_domain: str, f"at {target}\n\n{ur_str}", data={"target": target}) if dmarc_record_count < 1: - return False + raise UnverifiedDMARCURIDestination(message) except Exception: raise UnverifiedDMARCURIDestination(message) - return True - def parse_dmarc_record( record: str, domain: str, parked: bool = False,