mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-08-15 03:43:27 +00:00
Persist additional_info_uri from parsed SMTP TLS failure details
Copilot caught that the savers read additional_information_uri from the parsed failure-detail dict, but the parser's key is additional_info_uri (SMTPTLSFailureDetailsOptional in types.py, set in parse_smtp_tls_report_json), so the URI was never persisted — the read-side half of the dead-field bug whose write-side half (wrong constructor kwarg) was fixed earlier. Read the parser's key first, keeping the long-form key as a fallback for dicts built by other callers. Regression test proven to fail on the unfixed savers. Also restructured the expected combined-string test values into named locals so no implicit string concatenation sits inside a list literal. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
8f92a36622
commit
0e90c13475
@@ -1296,7 +1296,12 @@ def save_smtp_tls_report_to_elasticsearch(
|
||||
|
||||
if "receiving_mx_hostname" in failure_detail:
|
||||
receiving_mx_hostname = failure_detail["receiving_mx_hostname"]
|
||||
if "additional_information_uri" in failure_detail:
|
||||
# The parser's key is additional_info_uri (see
|
||||
# SMTPTLSFailureDetailsOptional in types.py); accept the
|
||||
# long-form key too for dicts built by other callers.
|
||||
if "additional_info_uri" in failure_detail:
|
||||
additional_information_uri = failure_detail["additional_info_uri"]
|
||||
elif "additional_information_uri" in failure_detail:
|
||||
additional_information_uri = failure_detail[
|
||||
"additional_information_uri"
|
||||
]
|
||||
|
||||
@@ -1268,7 +1268,12 @@ def save_smtp_tls_report_to_opensearch(
|
||||
|
||||
if "receiving_mx_hostname" in failure_detail:
|
||||
receiving_mx_hostname = failure_detail["receiving_mx_hostname"]
|
||||
if "additional_information_uri" in failure_detail:
|
||||
# The parser's key is additional_info_uri (see
|
||||
# SMTPTLSFailureDetailsOptional in types.py); accept the
|
||||
# long-form key too for dicts built by other callers.
|
||||
if "additional_info_uri" in failure_detail:
|
||||
additional_information_uri = failure_detail["additional_info_uri"]
|
||||
elif "additional_information_uri" in failure_detail:
|
||||
additional_information_uri = failure_detail[
|
||||
"additional_information_uri"
|
||||
]
|
||||
|
||||
+19
-6
@@ -1190,6 +1190,9 @@ class TestSaveSmtpTlsReport(unittest.TestCase):
|
||||
"sending_mta_ip": "192.0.2.1",
|
||||
"receiving_ip": "203.0.113.1",
|
||||
"receiving_mx_hostname": "mx1.example.com",
|
||||
"additional_info_uri": (
|
||||
"https://reports.example.com/tls-help"
|
||||
),
|
||||
},
|
||||
{
|
||||
"result_type": "starttls-not-supported",
|
||||
@@ -1220,14 +1223,24 @@ class TestSaveSmtpTlsReport(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
list(doc.policies_combined), ["example.com / sts", "example.net / tlsa"]
|
||||
)
|
||||
expected_detail_expired = (
|
||||
"example.com / sts / certificate-expired / 192.0.2.1 / "
|
||||
"203.0.113.1 / mx1.example.com"
|
||||
)
|
||||
expected_detail_starttls = (
|
||||
"example.com / sts / starttls-not-supported / 192.0.2.2 / "
|
||||
"203.0.113.2 / mx2.example.com"
|
||||
)
|
||||
self.assertEqual(
|
||||
list(doc.failure_details_combined),
|
||||
[
|
||||
"example.com / sts / certificate-expired / 192.0.2.1 / "
|
||||
"203.0.113.1 / mx1.example.com",
|
||||
"example.com / sts / starttls-not-supported / 192.0.2.2 / "
|
||||
"203.0.113.2 / mx2.example.com",
|
||||
],
|
||||
[expected_detail_expired, expected_detail_starttls],
|
||||
)
|
||||
# The parser emits additional_info_uri (SMTPTLSFailureDetailsOptional
|
||||
# in types.py); the saver must persist it on the declared
|
||||
# additional_information_uri field rather than dropping it.
|
||||
self.assertEqual(
|
||||
doc.policies[0].failure_details[0].additional_information_uri,
|
||||
"https://reports.example.com/tls-help",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1314,6 +1314,9 @@ class TestSaveSmtpTlsReport(unittest.TestCase):
|
||||
"sending_mta_ip": "192.0.2.1",
|
||||
"receiving_ip": "203.0.113.1",
|
||||
"receiving_mx_hostname": "mx1.example.com",
|
||||
"additional_info_uri": (
|
||||
"https://reports.example.com/tls-help"
|
||||
),
|
||||
},
|
||||
{
|
||||
"result_type": "starttls-not-supported",
|
||||
@@ -1344,14 +1347,24 @@ class TestSaveSmtpTlsReport(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
list(doc.policies_combined), ["example.com / sts", "example.net / tlsa"]
|
||||
)
|
||||
expected_detail_expired = (
|
||||
"example.com / sts / certificate-expired / 192.0.2.1 / "
|
||||
"203.0.113.1 / mx1.example.com"
|
||||
)
|
||||
expected_detail_starttls = (
|
||||
"example.com / sts / starttls-not-supported / 192.0.2.2 / "
|
||||
"203.0.113.2 / mx2.example.com"
|
||||
)
|
||||
self.assertEqual(
|
||||
list(doc.failure_details_combined),
|
||||
[
|
||||
"example.com / sts / certificate-expired / 192.0.2.1 / "
|
||||
"203.0.113.1 / mx1.example.com",
|
||||
"example.com / sts / starttls-not-supported / 192.0.2.2 / "
|
||||
"203.0.113.2 / mx2.example.com",
|
||||
],
|
||||
[expected_detail_expired, expected_detail_starttls],
|
||||
)
|
||||
# The parser emits additional_info_uri (SMTPTLSFailureDetailsOptional
|
||||
# in types.py); the saver must persist it on the declared
|
||||
# additional_information_uri field rather than dropping it.
|
||||
self.assertEqual(
|
||||
doc.policies[0].failure_details[0].additional_information_uri,
|
||||
"https://reports.example.com/tls-help",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user