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

Proposed by Jim Popovitch on 2018-11-30
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 2018-11-30 Approve on 2018-12-15
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.
Jim Popovitch (jimpop) wrote :

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

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 on 2018-12-01

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

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
1=== modified file 'Mailman/Gui/Privacy.py'
2--- Mailman/Gui/Privacy.py 2018-07-15 03:18:00 +0000
3+++ Mailman/Gui/Privacy.py 2018-12-01 04:14:39 +0000
4@@ -356,6 +356,20 @@
5 be sent to anyone who posts to this list from a domain
6 with a DMARC Reject%(quarantine)s Policy.""")),
7
8+ ('dmarc_moderation_addresses', mm_cfg.EmailListEx, (10, WIDTH), 1,
9+ _("""List of addresses (or regexps) whose posts should always apply
10+ <a href="?VARHELP=privacy/sender/dmarc_moderation_action"
11+ >dmarc_moderation_action</a>
12+ regardless of any domain specific DMARC Policy."""),
13+
14+ _("""Postings from any of these addresses will automatically
15+ apply any DMARC action mitigation. This can be utilized to
16+ automatically wrap or munge postings from known addresses or
17+ domains such as internal domains.
18+
19+ <p>Add member addresses one per line; start the line with a ^
20+ character to designate a regular expression match.""")),
21+
22 ('dmarc_wrapped_message_text', mm_cfg.Text, (10, WIDTH), 1,
23 _("""If dmarc_moderation_action applies and is Wrap Message,
24 and this text is provided, the text will be placed in a
25
26=== modified file 'Mailman/Handlers/SpamDetect.py'
27--- Mailman/Handlers/SpamDetect.py 2018-06-17 23:47:34 +0000
28+++ Mailman/Handlers/SpamDetect.py 2018-12-01 04:14:39 +0000
29@@ -109,7 +109,8 @@
30 msgdata['from_is_list'] = 0
31 dn, addr = parseaddr(msg.get('from'))
32 if addr and mlist.dmarc_moderation_action > 0:
33- if Utils.IsDMARCProhibited(mlist, addr):
34+ if (mlist.GetPattern(addr, mlist.dmarc_moderation_addresses) or
35+ Utils.IsDMARCProhibited(mlist, addr)):
36 # Note that for dmarc_moderation_action, 0 = Accept,
37 # 1 = Munge, 2 = Wrap, 3 = Reject, 4 = Discard
38 if mlist.dmarc_moderation_action == 1:
39
40=== modified file 'Mailman/MailList.py'
41--- Mailman/MailList.py 2018-06-21 16:23:09 +0000
42+++ Mailman/MailList.py 2018-12-01 04:14:39 +0000
43@@ -424,6 +424,7 @@
44 self.dmarc_none_moderation_action = (
45 mm_cfg.DEFAULT_DMARC_NONE_MODERATION_ACTION)
46 self.dmarc_moderation_notice = ''
47+ self.dmarc_moderation_addresses = []
48 self.dmarc_wrapped_message_text = (
49 mm_cfg.DEFAULT_DMARC_WRAPPED_MESSAGE_TEXT)
50 self.equivalent_domains = (
51
52=== modified file 'Mailman/Version.py'
53--- Mailman/Version.py 2018-07-24 21:58:31 +0000
54+++ Mailman/Version.py 2018-12-01 04:14:39 +0000
55@@ -37,7 +37,7 @@
56 (REL_LEVEL << 4) | (REL_SERIAL << 0))
57
58 # config.pck schema version number
59-DATA_FILE_VERSION = 110
60+DATA_FILE_VERSION = 111
61
62 # qfile/*.db schema version number
63 QFILE_SCHEMA_VERSION = 3
64
65=== modified file 'Mailman/versions.py'
66--- Mailman/versions.py 2018-06-17 23:47:34 +0000
67+++ Mailman/versions.py 2018-12-01 04:14:39 +0000
68@@ -497,6 +497,7 @@
69 add_only_if_missing('dmarc_none_moderation_action',
70 mm_cfg.DEFAULT_DMARC_NONE_MODERATION_ACTION)
71 add_only_if_missing('dmarc_moderation_notice', '')
72+ add_only_if_missing('dmarc_moderation_addresses', [])
73 add_only_if_missing('dmarc_wrapped_message_text',
74 mm_cfg.DEFAULT_DMARC_WRAPPED_MESSAGE_TEXT)
75 add_only_if_missing('member_verbosity_threshold',

Subscribers

People subscribed via source and target branches