aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman_pgp/chains/__init__.py0
-rw-r--r--src/mailman_pgp/chains/default.py48
-rw-r--r--src/mailman_pgp/model/list.py13
-rw-r--r--src/mailman_pgp/rules/__init__.py0
-rw-r--r--src/mailman_pgp/rules/signature.py70
-rw-r--r--src/mailman_pgp/styles/base.py1
-rw-r--r--tox.ini1
7 files changed, 131 insertions, 2 deletions
diff --git a/src/mailman_pgp/chains/__init__.py b/src/mailman_pgp/chains/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/mailman_pgp/chains/__init__.py
diff --git a/src/mailman_pgp/chains/default.py b/src/mailman_pgp/chains/default.py
new file mode 100644
index 0000000..27ee190
--- /dev/null
+++ b/src/mailman_pgp/chains/default.py
@@ -0,0 +1,48 @@
+# Copyright (C) 2017 Jan Jancar
+#
+# This file is a part of the Mailman PGP plugin.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+
+""""""
+from mailman.chains.base import Link
+from mailman.core.i18n import _
+from mailman.interfaces.chain import IChain, LinkAction
+from public import public
+from zope.interface import implementer
+
+
+@public
+@implementer(IChain)
+class EncryptedChain:
+ """Default encrypted chain."""
+
+ name = 'encrypted-posting-chain'
+ description = _('The encrypted moderation chain.')
+
+ _link_descriptions = (
+ ('signature', LinkAction.jump, 'moderation'),
+ ('truth', LinkAction.jump, 'default-posting-chain')
+ )
+
+ def __init__(self):
+ self._cached_links = None
+
+ def get_links(self, mlist, msg, msgdata):
+ """See `IChain`."""
+ if self._cached_links is None:
+ self._cached_links = links = []
+ for rule, action, chain in self._link_descriptions:
+ links.append(Link(rule, action, chain))
+ return iter(self._cached_links)
diff --git a/src/mailman_pgp/model/list.py b/src/mailman_pgp/model/list.py
index 247d263..4a25f0a 100644
--- a/src/mailman_pgp/model/list.py
+++ b/src/mailman_pgp/model/list.py
@@ -39,11 +39,20 @@ class EncryptedMailingList(Base):
id = Column(Integer, primary_key=True)
list_id = Column(SAUnicode, index=True)
+
+ # Signature related properties
unsigned_msg_action = Column(Enum(Action))
- nonencrypted_msg_action = Column(Enum(Action))
- strip_original_signature = Column(Boolean)
+ inline_pgp_action = Column(Enum(Action))
+ expired_sig_action = Column(Enum(Action))
+ revoked_sig_action = Column(Enum(Action))
+ # duplicate_sig_action = Column(Enum(Action))
+ invalid_sig_action = Column(Enum(Action))
+ strip_original_sig = Column(Boolean)
sign_outgoing = Column(Boolean)
+ # Encryption related properties
+ nonencrypted_msg_action = Column(Enum(Action))
+
def __init__(self, mlist):
super().__init__()
self.list_id = mlist.list_id
diff --git a/src/mailman_pgp/rules/__init__.py b/src/mailman_pgp/rules/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/mailman_pgp/rules/__init__.py
diff --git a/src/mailman_pgp/rules/signature.py b/src/mailman_pgp/rules/signature.py
new file mode 100644
index 0000000..28d05e4
--- /dev/null
+++ b/src/mailman_pgp/rules/signature.py
@@ -0,0 +1,70 @@
+# Copyright (C) 2017 Jan Jancar
+#
+# This file is a part of the Mailman PGP plugin.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+
+""""""
+
+from mailman.core.i18n import _
+from mailman.interfaces.rules import IRule
+from public import public
+from zope.interface import implementer
+
+from mailman_pgp.database import query
+from mailman_pgp.model.list import EncryptedMailingList
+from mailman_pgp.pgp.wrapper import PGPWrapper
+
+
+@public
+@implementer(IRule)
+class Signature:
+ """"""
+
+ name = 'signature'
+
+ description = _(
+ """
+ """)
+
+ record = True
+
+ def _record_action(self, msgdata, action, sender, reason):
+ msgdata['moderation_action'] = action
+ msgdata['moderation_sender'] = sender
+ msgdata.setdefault('moderation_reasons', []).append(reason)
+
+ def check(self, mlist, msg, msgdata):
+ """See `IRule`."""
+ enc_list = query(EncryptedMailingList).filter_by(
+ list_id=mlist.list_id).first()
+ if enc_list is None:
+ raise ValueError('Encrypted mailing list not found.')
+ wrapped = PGPWrapper(msg)
+
+ if not wrapped.is_signed():
+ action = enc_list.unsigned_msg_action
+ if action is not None:
+ self._record_action(msgdata, action, msg.sender,
+ 'The message is unsigned.')
+ return True
+
+ if wrapped.is_inline_signed():
+ action = enc_list.inline_pgp_action
+ if action is not None:
+ self._record_action(msgdata, action, msg.sender,
+ 'Inline PGP is not allowed.')
+ return True
+
+ # TODO finish this \ No newline at end of file
diff --git a/src/mailman_pgp/styles/base.py b/src/mailman_pgp/styles/base.py
index 6637ef5..f08674c 100644
--- a/src/mailman_pgp/styles/base.py
+++ b/src/mailman_pgp/styles/base.py
@@ -38,3 +38,4 @@ class EncryptedStyle:
enc_list = EncryptedMailingList(mailing_list)
with transaction():
config.db.session.add(enc_list)
+ mailing_list.posting_chain = 'encrypted-posting-chain'
diff --git a/tox.ini b/tox.ini
index 548e1ea..e16883c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -23,6 +23,7 @@ commands =
deps =
flake8>3.0
flake8-import-order
+ # This is ugly, but necessary due to the requirement on dev version of Mailman
git+https://gitlab.com/mailman/mailman.git
git+https://github.com/SecurityInnovation/PGPy