Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core
Commits: 0efc831a by Mark Sapiro at 2020-05-28T13:07:33-07:00 Fix dmarc rule case sensitivity. - - - - - 9ecad5a6 by Mark Sapiro at 2020-05-28T20:19:31+00:00 Merge branch 'fix_726' into 'master' Fix dmarc rule case sensitivity. Closes #726 See merge request mailman/mailman!654 - - - - - 3 changed files: - src/mailman/docs/NEWS.rst - src/mailman/rules/dmarc.py - src/mailman/rules/tests/test_dmarc.py Changes: ===================================== src/mailman/docs/NEWS.rst ===================================== @@ -21,6 +21,8 @@ Bugs * Bounce probes are now encoded in the correct charset. (Closes #712) * We now unfold address containing headers before parsing in avoid_duplicates. (Closes #725) +* The ``dmarc`` rule no longer misses if DNS returns a name containing upper + case. (Closes #726) REST ===================================== src/mailman/rules/dmarc.py ===================================== @@ -216,7 +216,8 @@ def is_reject_or_quarantine(mlist, email, dmarc_domain, org=False): str(record, encoding='utf-8') for record in txt_rec.items[0].strings) name = txt_rec.name.to_text() - results_by_name.setdefault(name, []).append(result) + # Don't be fooled by an answer with uppercase in the name. + results_by_name.setdefault(name.lower(), []).append(result) expands = list(want_names) seen = set(expands) while expands: ===================================== src/mailman/rules/tests/test_dmarc.py ===================================== @@ -50,7 +50,8 @@ def get_dns_resolver( rmult=False, cmult=False, cloop=False, - cmiss=False): + cmiss=False, + ucase=False): """Create a dns.resolver.Resolver mock. This is used to return a predictable response to a _dmarc query. It @@ -140,6 +141,8 @@ def get_dns_resolver( ] elif rmult: self.answer = [Ans_e(), Ans_e(rdata=b'v=DMARC1; p=none;')] + elif ucase: + self.answer = [Ans_e(name='_dmarc.EXAMPLE.biz.')] else: self.answer = [Ans_e()] @@ -206,6 +209,21 @@ class TestDMARCRules(TestCase): dmarc.get_organizational_domain('ssub.sub.city.kobe.jp'), 'city.kobe.jp') + def test_uppercase_in_returned_domain(self): + # Test that we can recognize an answer with case mismatch in the + # domain. + mlist = create_list('a...@example.com') + # Use action reject. The rule only hits on reject and discard. + mlist.dmarc_mitigate_action = DMARCMitigateAction.reject + msg = mfs("""\ +From: a...@example.biz +To: a...@example.com + +""") + rule = dmarc.DMARCMitigation() + with get_dns_resolver(ucase=True): + self.assertTrue(rule.check(mlist, msg, {})) + def test_no_at_sign_in_from_address(self): # If there's no @ sign in the From: address, the rule can't hit. mlist = create_list('a...@example.com') View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/69e48ac68eb3a731eecb376b08a7999869a85ba2...9ecad5a6af122f4f17bd720ec8ca7e4fb26759c3 -- View it on GitLab: https://gitlab.com/mailman/mailman/-/compare/69e48ac68eb3a731eecb376b08a7999869a85ba2...9ecad5a6af122f4f17bd720ec8ca7e4fb26759c3 You're receiving this email because of your account on gitlab.com.
_______________________________________________ Mailman-checkins mailing list -- mailman-checkins@python.org To unsubscribe send an email to mailman-checkins-le...@python.org https://mail.python.org/mailman3/lists/mailman-checkins.python.org/ Member address: arch...@jab.org