Merge lp:~jimpop/mailman/dmarc-moderation-addresses into lp:mailman/2.1

Proposed by Jim Popovitch
Status: Merged
Merge reported by: Mark Sapiro
Merged at revision: not available
Proposed branch: lp:~jimpop/mailman/dmarc-moderation-addresses
Merge into: lp:mailman/2.1
Diff against target: 75 lines (+19/-2)
5 files modified
Mailman/Gui/Privacy.py (+14/-0)
Mailman/Handlers/SpamDetect.py (+2/-1)
Mailman/MailList.py (+1/-0)
Mailman/Version.py (+1/-1)
Mailman/versions.py (+1/-0)
To merge this branch: bzr merge lp:~jimpop/mailman/dmarc-moderation-addresses
Reviewer Review Type Date Requested Status
Mark Sapiro code Approve
Review via email: mp+359963@code.launchpad.net

Commit message

Patch for dmarc_moderation_addresses to automatically apply dmarc_moderation_action against a regexp of addresses.

Description of the change

This patch adds the new variable dmarc_moderation_addresses which accepts a list of regexp addresses that will automatically apply dmarc_moderation_action. This is for circumstances where a domain's internal policies reject external emails From their own domain (looking at you hydro.qc.ca). Even though there is no DMARC record, the dmarc_moderation_action is the perfect solution for this problem.

To post a comment you must log in.
Revision history for this message
Jim Popovitch (jimpop) wrote :

The first feedback should include recommendations for improving the logical OR on Mailman/Handlers/SpamDetect.py:32 :-)

Revision history for this message
Mark Sapiro (msapiro) wrote :

Regarding line 32 in the diff, I don't think there should be an at_list argument in the call to GetPattern. Specifying a value for this says that one can use the @listname syntax to specify a listname, all of whose members will be included in this list's dmarc_moderation_addresses. It doesn't seem this is useful, as the entries would likely be regexps matching the domain rather than individual addresses. In any case, I would write

            if (mlist.GetPattern(addr,
                                 mlist.dmarc_moderation_addresses,
                                 at_list='dmarc_moderation_addresses'
                                ) or
                Utils.IsDMARCProhibited(mlist, addr)):

with the at_list argument or

            if (mlist.GetPattern(addr, mlist.dmarc_moderation_addresses) or
                Utils.IsDMARCProhibited(mlist, addr)):

without it.

I understand the motivation for this from your description and I think it's valid, but I think some explanation of the intent is also required in the VARHELP for the setting.

Also, I'll be traveling for the next week and probably won't be able to do more until I return.

1805. By Jim Popovitch

Updated SpamDetect.py and VARHELP based on feedback from Mark S.

Revision history for this message
Mark Sapiro (msapiro) wrote :

I made a minor change to VARHELP and added a NEWS item.

Thanks for your contribution.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Mailman/Gui/Privacy.py'
--- Mailman/Gui/Privacy.py 2018-07-15 03:18:00 +0000
+++ Mailman/Gui/Privacy.py 2018-12-01 04:14:39 +0000
@@ -356,6 +356,20 @@
356 be sent to anyone who posts to this list from a domain356 be sent to anyone who posts to this list from a domain
357 with a DMARC Reject%(quarantine)s Policy.""")),357 with a DMARC Reject%(quarantine)s Policy.""")),
358 358
359 ('dmarc_moderation_addresses', mm_cfg.EmailListEx, (10, WIDTH), 1,
360 _("""List of addresses (or regexps) whose posts should always apply
361 <a href="?VARHELP=privacy/sender/dmarc_moderation_action"
362 >dmarc_moderation_action</a>
363 regardless of any domain specific DMARC Policy."""),
364
365 _("""Postings from any of these addresses will automatically
366 apply any DMARC action mitigation. This can be utilized to
367 automatically wrap or munge postings from known addresses or
368 domains such as internal domains.
369
370 <p>Add member addresses one per line; start the line with a ^
371 character to designate a regular expression match.""")),
372
359 ('dmarc_wrapped_message_text', mm_cfg.Text, (10, WIDTH), 1,373 ('dmarc_wrapped_message_text', mm_cfg.Text, (10, WIDTH), 1,
360 _("""If dmarc_moderation_action applies and is Wrap Message,374 _("""If dmarc_moderation_action applies and is Wrap Message,
361 and this text is provided, the text will be placed in a375 and this text is provided, the text will be placed in a
362376
=== modified file 'Mailman/Handlers/SpamDetect.py'
--- Mailman/Handlers/SpamDetect.py 2018-06-17 23:47:34 +0000
+++ Mailman/Handlers/SpamDetect.py 2018-12-01 04:14:39 +0000
@@ -109,7 +109,8 @@
109 msgdata['from_is_list'] = 0109 msgdata['from_is_list'] = 0
110 dn, addr = parseaddr(msg.get('from'))110 dn, addr = parseaddr(msg.get('from'))
111 if addr and mlist.dmarc_moderation_action > 0:111 if addr and mlist.dmarc_moderation_action > 0:
112 if Utils.IsDMARCProhibited(mlist, addr):112 if (mlist.GetPattern(addr, mlist.dmarc_moderation_addresses) or
113 Utils.IsDMARCProhibited(mlist, addr)):
113 # Note that for dmarc_moderation_action, 0 = Accept, 114 # Note that for dmarc_moderation_action, 0 = Accept,
114 # 1 = Munge, 2 = Wrap, 3 = Reject, 4 = Discard115 # 1 = Munge, 2 = Wrap, 3 = Reject, 4 = Discard
115 if mlist.dmarc_moderation_action == 1:116 if mlist.dmarc_moderation_action == 1:
116117
=== modified file 'Mailman/MailList.py'
--- Mailman/MailList.py 2018-06-21 16:23:09 +0000
+++ Mailman/MailList.py 2018-12-01 04:14:39 +0000
@@ -424,6 +424,7 @@
424 self.dmarc_none_moderation_action = (424 self.dmarc_none_moderation_action = (
425 mm_cfg.DEFAULT_DMARC_NONE_MODERATION_ACTION)425 mm_cfg.DEFAULT_DMARC_NONE_MODERATION_ACTION)
426 self.dmarc_moderation_notice = ''426 self.dmarc_moderation_notice = ''
427 self.dmarc_moderation_addresses = []
427 self.dmarc_wrapped_message_text = (428 self.dmarc_wrapped_message_text = (
428 mm_cfg.DEFAULT_DMARC_WRAPPED_MESSAGE_TEXT)429 mm_cfg.DEFAULT_DMARC_WRAPPED_MESSAGE_TEXT)
429 self.equivalent_domains = (430 self.equivalent_domains = (
430431
=== modified file 'Mailman/Version.py'
--- Mailman/Version.py 2018-07-24 21:58:31 +0000
+++ Mailman/Version.py 2018-12-01 04:14:39 +0000
@@ -37,7 +37,7 @@
37 (REL_LEVEL << 4) | (REL_SERIAL << 0))37 (REL_LEVEL << 4) | (REL_SERIAL << 0))
3838
39# config.pck schema version number39# config.pck schema version number
40DATA_FILE_VERSION = 11040DATA_FILE_VERSION = 111
4141
42# qfile/*.db schema version number42# qfile/*.db schema version number
43QFILE_SCHEMA_VERSION = 343QFILE_SCHEMA_VERSION = 3
4444
=== modified file 'Mailman/versions.py'
--- Mailman/versions.py 2018-06-17 23:47:34 +0000
+++ Mailman/versions.py 2018-12-01 04:14:39 +0000
@@ -497,6 +497,7 @@
497 add_only_if_missing('dmarc_none_moderation_action',497 add_only_if_missing('dmarc_none_moderation_action',
498 mm_cfg.DEFAULT_DMARC_NONE_MODERATION_ACTION)498 mm_cfg.DEFAULT_DMARC_NONE_MODERATION_ACTION)
499 add_only_if_missing('dmarc_moderation_notice', '')499 add_only_if_missing('dmarc_moderation_notice', '')
500 add_only_if_missing('dmarc_moderation_addresses', [])
500 add_only_if_missing('dmarc_wrapped_message_text',501 add_only_if_missing('dmarc_wrapped_message_text',
501 mm_cfg.DEFAULT_DMARC_WRAPPED_MESSAGE_TEXT)502 mm_cfg.DEFAULT_DMARC_WRAPPED_MESSAGE_TEXT)
502 add_only_if_missing('member_verbosity_threshold', 503 add_only_if_missing('member_verbosity_threshold',