summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman_pgp/model/base.py1
-rw-r--r--src/mailman_pgp/rules/signature.py15
-rw-r--r--src/mailman_pgp/runners/incoming.py12
3 files changed, 20 insertions, 8 deletions
diff --git a/src/mailman_pgp/model/base.py b/src/mailman_pgp/model/base.py
index 16aa6cb..e126366 100644
--- a/src/mailman_pgp/model/base.py
+++ b/src/mailman_pgp/model/base.py
@@ -19,6 +19,7 @@
from public import public
from sqlalchemy.ext.declarative import as_declarative
+
from mailman_pgp.config import config
diff --git a/src/mailman_pgp/rules/signature.py b/src/mailman_pgp/rules/signature.py
index 02f13c1..126ac84 100644
--- a/src/mailman_pgp/rules/signature.py
+++ b/src/mailman_pgp/rules/signature.py
@@ -16,6 +16,7 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
"""Signature checking rule for the pgp-posting-chain."""
+import logging
from mailman.core.i18n import _
from mailman.interfaces.action import Action
@@ -30,9 +31,13 @@ from mailman_pgp.model.address import PGPAddress
from mailman_pgp.model.list import PGPMailingList
from mailman_pgp.pgp.wrapper import PGPWrapper
+log = logging.getLogger('mailman.plugin.pgp')
-def record_action(msgdata, action, sender, reason):
- msgdata['moderation_action'] = action
+
+def record_action(msg, msgdata, action, sender, reason):
+ log.info('[pgp] {}{}: {}'.format(
+ action.name, msg.get('message-id', 'n/a'), reason))
+ msgdata['moderation_action'] = action.name
msgdata['moderation_sender'] = sender
msgdata.setdefault('moderation_reasons', []).append(reason)
@@ -62,7 +67,7 @@ class Signature:
if not wrapped.is_signed():
action = enc_list.unsigned_msg_action
if action != Action.defer:
- record_action(msgdata, action, msg.sender,
+ record_action(msg, msgdata, action, msg.sender,
'The message is unsigned.')
return True
@@ -70,7 +75,7 @@ class Signature:
if wrapped.inline.is_signed():
action = enc_list.inline_pgp_action
if action != Action.defer:
- record_action(msgdata, action, msg.sender,
+ record_action(msg, msgdata, action, msg.sender,
'Inline PGP is not allowed.')
return True
@@ -92,7 +97,7 @@ class Signature:
if not wrapped.verifies(key):
action = enc_list.invalid_sig_action
if action != Action.defer:
- record_action(msgdata, action, msg.sender,
+ record_action(msg, msgdata, action, msg.sender,
'Signature did not verify.')
return True
diff --git a/src/mailman_pgp/runners/incoming.py b/src/mailman_pgp/runners/incoming.py
index 7bc14e1..2941502 100644
--- a/src/mailman_pgp/runners/incoming.py
+++ b/src/mailman_pgp/runners/incoming.py
@@ -16,6 +16,7 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
"""The encryption-aware incoming runner."""
+import logging
from mailman.config import config as mailman_config
from mailman.core.runner import Runner
@@ -28,6 +29,8 @@ from mailman_pgp.config import config
from mailman_pgp.model.list import PGPMailingList
from mailman_pgp.pgp.wrapper import PGPWrapper
+log = logging.getLogger('mailman.plugin.pgp')
+
def _pass_default(msg, msgdata, listid):
inq = config.get('queues', 'in')
@@ -42,7 +45,7 @@ class IncomingRunner(Runner):
# Is the message for an encrypted mailing list? If not, pass to default
# incoming runner. If yes, go on.
pgp_list = PGPMailingList.query().filter_by(
- list_id=mlist.list_id).first()
+ list_id=mlist.list_id).first()
if not pgp_list:
_pass_default(msg, msgdata, mlist.list_id)
return False
@@ -61,9 +64,12 @@ class IncomingRunner(Runner):
# jump to the moderation chain if `pgp_moderate` is True
action = pgp_list.nonencrypted_msg_action
if action != Action.defer:
- msgdata['moderation_action'] = action
+ reason = 'Message was not encrypted.'
+ log.info('[pgp] {}{}: {}'.format(
+ action.name, msg.get('message-id', 'n/a'), reason))
+ msgdata['moderation_action'] = action.name
msgdata['moderation_sender'] = msg.sender
- msgdata['moderation_reason'] = 'Message was not encrypted.'
+ msgdata['moderation_reason'] = reason
msgdata['pgp_moderate'] = True
_pass_default(msg, msgdata, mlist.list_id)