public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-authheaders] f44: Add patch to fix spf_result.smtp_mailfrom parsing issues. Fixes rhbz#2552050
@ 2026-11-23 20:50 Kevin Fenzi
  0 siblings, 0 replies; only message in thread
From: Kevin Fenzi @ 2026-11-23 20:50 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/python-authheaders
Branch : f44
Commit : 1db842e0853ca1ef6673adeee8701a2b8a2dded0
Author : Kevin Fenzi <kevin@scrye.com>
Date   : 2026-11-23T12:49:00-08:00
Stats  : +119/-2 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/python-authheaders/c/1db842e0853ca1ef6673adeee8701a2b8a2dded0?branch=f44

Log:
Add patch to fix spf_result.smtp_mailfrom parsing issues. Fixes rhbz#2552050

---
diff --git a/37.patch b/37.patch
new file mode 100644
index 0000000..d4953e2
--- /dev/null
+++ b/37.patch
@@ -0,0 +1,110 @@
+From 2298a7e3c81dec33ed5fbdddf3a8d89e0f00ffe7 Mon Sep 17 00:00:00 2001
+From: SATOH Fumiyasu <fumiyas@osstech.co.jp>
+Date: Mon, 23 Mar 2026 17:26:33 +0900
+Subject: [PATCH] fix: authenticate_message: Do not set None to
+ spf_result.smtp_mailfrom
+
+Closes issue #33.
+
+```
+self = <test_authentication.TestAuthenticateMessage testMethod=test_authenticate_dmarc_prev_spf>
+
+    def test_authenticate_dmarc_prev_spf(self):
+        prev = "Authentication-Results: example.com; spf=pass smtp.mailfrom=gmail.com"
+>       res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dkim=True, dmarc=True, dnsfunc=self.dnsfunc)
+              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+authheaders/test/test_authentication.py:155:
+_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
+authheaders/__init__.py:434: in authenticate_message
+    return str(auth_res)
+           ^^^^^^^^^^^^^
+/usr/lib/python3/dist-packages/authres/core.py:476: in __str__
+    return ''.join((self.HEADER_FIELD_NAME, ': ', self.header_value()))
+                                                  ^^^^^^^^^^^^^^^^^^^
+/usr/lib/python3/dist-packages/authres/core.py:492: in header_value
+    strs.append(str(result))
+                ^^^^^^^^^^^
+/usr/lib/python3/dist-packages/authres/core.py:222: in __str__
+    strs.append(str(property_))
+                ^^^^^^^^^^^^^^
+_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
+
+self = <authres.core.AuthenticationResultProperty object at 0x7fc4178465f0>
+
+    def __str__(self):
+        if self.comment:
+            return '%s.%s=%s (%s)' % (self.type, self.name, self.value.quote_if_needed(), self.comment)
+        else:
+>           return '%s.%s=%s' % (self.type, self.name, self.value.quote_if_needed())
+                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
+E           AttributeError: 'NoneType' object has no attribute 'quote_if_needed'
+
+/usr/lib/python3/dist-packages/authres/core.py:132: AttributeError
+```
+---
+ authheaders/__init__.py                 | 12 +++++++-----
+ authheaders/test/test_authentication.py | 26 ++++++++++++++++++++++---
+ 2 files changed, 30 insertions(+), 8 deletions(-)
+
+diff --git a/authheaders/__init__.py b/authheaders/__init__.py
+index 37a2c00..e7ba1e7 100644
+--- a/authheaders/__init__.py
++++ b/authheaders/__init__.py
+@@ -232,11 +232,13 @@ def dmarc_per_from(from_domain, spf_result=None, dkim_result=None, dnsfunc=None,
+         if not policy_only and spf_result and spf_result.result == "pass":
+             # The domain in SPF results often includes the local part, even though
+             # generally it SHOULD NOT (RFC 7601, Section 2.7.2, last paragraph).
+-            try:
+-                mail_from_domain = get_domain_part(spf_result.smtp_mailfrom)
+-            except IndexError:
+-                mail_from_domain = None
+-            spf_result.smtp_mailfrom = mail_from_domain
++            mail_from_domain = spf_result.smtp_mailfrom
++            if mail_from_domain is not None and '@' in mail_from_domain:
++                try:
++                    mail_from_domain = get_domain_part(mail_from_domain)
++                    spf_result.smtp_mailfrom = mail_from_domain
++                except IndexError:
++                    mail_from_domain = None
+             if aspf == "s" and from_domain == mail_from_domain:
+                 result = "pass"
+             elif aspf == "r" and get_org_domain(from_domain) == get_org_domain(mail_from_domain):
+diff --git a/authheaders/test/test_authentication.py b/authheaders/test/test_authentication.py
+index 486b4c6..64ab6a3 100755
+--- a/authheaders/test/test_authentication.py
++++ b/authheaders/test/test_authentication.py
+@@ -145,10 +145,30 @@ def test_authenticate_dmarc_comma(self):
+         res = authenticate_message(self.message8, "example.com", spf=False, dnsfunc=self.dnsfunc)
+         self.assertEqual(res, "Authentication-Results: example.com; dkim=pass header.d=example.com header.i=@example.com; dmarc=pass (Used From Domain Record) header.from=example.com policy.dmarc=reject")
+ 
+-    def test_prev(self):
++    def test_authenticate_dkim_prev_spf(self):
+         prev = "Authentication-Results: example.com; spf=pass smtp.mailfrom=gmail.com"
+-        res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dmarc=False, dnsfunc=self.dnsfunc)
+-        self.assertEqual(res, "Authentication-Results: example.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=example.com header.i=@example.com")
++        res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dkim=True, dmarc=False, dnsfunc=self.dnsfunc)
++        self.assertEqual(res, f"{prev}; dkim=pass header.d=example.com header.i=@example.com")
++
++    def test_authenticate_dmarc_prev_spf(self):
++        prev = "Authentication-Results: example.com; spf=pass smtp.mailfrom=gmail.com"
++        res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dkim=True, dmarc=True, dnsfunc=self.dnsfunc)
++        self.assertEqual(res, f"{prev}; dkim=pass header.d=example.com header.i=@example.com; dmarc=pass (Used From Domain Record) header.from=example.com policy.dmarc=reject")
++
++    def test_authenticate_dmarc_prev_spf_mailfrom_at_domain(self):
++        prev = "Authentication-Results: example.com; spf=pass smtp.mailfrom=bogus@gmail.com"
++        res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dkim=True, dmarc=True, dnsfunc=self.dnsfunc)
++        self.assertEqual(res, f"{prev.replace('bogus@', '')}; dkim=pass header.d=example.com header.i=@example.com; dmarc=pass (Used From Domain Record) header.from=example.com policy.dmarc=reject")
++
++    def test_authenticate_dmarc_prev_spf_mailfrom_at_invalid(self):
++        prev = "Authentication-Results: example.com; spf=pass smtp.mailfrom=bogus@"
++        res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dkim=True, dmarc=True, dnsfunc=self.dnsfunc)
++        self.assertEqual(res, f"{prev}; dkim=pass header.d=example.com header.i=@example.com; dmarc=pass (Used From Domain Record) header.from=example.com policy.dmarc=reject")
++
++    def test_authenticate_dmarc_prev_spf_no_mailfrom(self):
++        prev = "Authentication-Results: example.com; spf=pass"
++        res = authenticate_message(self.message2, "example.com", prev=prev, spf=False, dkim=True, dmarc=True, dnsfunc=self.dnsfunc)
++        self.assertEqual(res, f"{prev}; dkim=pass header.d=example.com header.i=@example.com; dmarc=pass (Used From Domain Record) header.from=example.com policy.dmarc=reject")
+ 
+     def test_get_domain_part(self):
+         froms_to_test = [['test@example.com', 'example.com'], [""""Test, User" <test@example.com>""", 'example.com'], ["""Test User <test@sub2.example.biz>""", 'sub2.example.biz'], ["""=?UTF-8?B?QmVkIEJhdGggJiBCZXlvbmQ=?=<BdBth&Byond@example.com>""", 'example.com'], ]

diff --git a/python-authheaders.spec b/python-authheaders.spec
index 8600f0d..5ed282b 100644
--- a/python-authheaders.spec
+++ b/python-authheaders.spec
@@ -6,7 +6,7 @@
 
 Name:           python-%{pypi_name}
 Version:        0.16.3
-Release:        9%{?dist}
+Release:        10%{?dist}
 Summary:        A library wrapping email authentication header verification and generation
 
 # Licensing described in LICENSE file
@@ -15,6 +15,10 @@ URL:            https://github.com/ValiMail/authentication-headers
 Source0:        %{pypi_source}
 BuildArch:      noarch
 
+# Patch to fix problem with check_dmarc checks
+# see https://bugzilla.redhat.com/show_bug.cgi?id=2552050
+Patch:          https://patch-diff.githubusercontent.com/raw/ValiMail/authentication-headers/pull/37.patch
+
 BuildRequires:  python3-devel
 BuildRequires:  python3dist(pytest)
 BuildRequires:  help2man
@@ -32,7 +36,7 @@ Requires:       publicsuffix-list
 
 
 %prep
-%autosetup -n %{pypi_name}-%{version}
+%autosetup -n %{pypi_name}-%{version} -p1
 # Remove bundled publicsuffix data
 rm -f %{pypi_name}/public_suffix_list.txt
 # Use public suffix data from installed RPM
@@ -73,6 +77,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} help2man --no-info \
 %{_mandir}/man1/dmarc-policy-find.1*
 
 %changelog
+* Mon Nov 23 2026 Kevin Fenzi <kevin@scrye.com> - 0.16.3-10
+- Add patch to fix spf_result.smtp_mailfrom parsing issues. Fixes rhbz#2552050
+
 * Thu Jul 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 0.16.3-9
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-23 20:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 20:50 [rpms/python-authheaders] f44: Add patch to fix spf_result.smtp_mailfrom parsing issues. Fixes rhbz#2552050 Kevin Fenzi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox