Commit graph

37 commits

Author SHA1 Message Date
509aac6de3 Improve command-generation, logging and readability 2023-05-08 22:17:01 +02:00
27b07e672d Rework PGP/MIME flow 2023-05-08 22:17:01 +02:00
5e408259c0 Start using Content Manager
Also:
- Pass text to Popen in GnuPG (used to be bytes).
- Make is_payload_pgp_inline type-agnostic (str / bytes).
2023-05-08 22:17:01 +02:00
94e22caf8e When encryption fails, revert to cleartext delivery
When GnuPG refuses to encrypt a message (e.g. when key has expired), record
information about the failure and send to logs, then deliver cleartext.  This
way we won't bounce email that could be delivered without encryption.

Also: add more E2E tests.
2023-05-08 22:16:41 +02:00
588b447e69 Add basic unit tests for GnuPG module
- Cover basic GnuPG functionality with tests (confirm_key, public_keys).
- Add a test public key file.
- Fix resource leak by closing streams opened by Popen.
2022-12-14 21:09:46 +01:00
8963eee47f Reformat GnuPG module 2022-10-19 18:36:23 +00:00
3bcc1151e5 Add E2E case: a user with a key and PGP/MIME configured
- Add a new test input message for a new test identity, test scenario
  configuration and a test key.

- While retrieving message payload, determine charset based on the
  Content-Type header.  When missing, default to UTF-8.

- Use more comprehensible variables names.

- Adjust logging levels.
2022-05-30 00:49:40 +02:00
55fa0d0601 [GnuPG.confirm_key] Convert email to bytes() before comparison 2022-05-06 19:14:52 +02:00
71afd6ed05 [GnuPG.confirm_key] Set 700 mode for temp. key home 2022-04-26 18:42:48 +02:00
454b519c70 Use bytes in confirm_key's line operations 2022-04-19 21:22:34 +02:00
f472f4ac22 Use isinstance() instead of type() 2022-04-19 21:16:40 +02:00
fdadc89c31 Use bytes in GnuPG.confirm_key too 2022-04-19 20:49:49 +02:00
5a34249090 Fix minor cron.py issues
Related to #63: TypeError: memoryview: a bytes-like object is required, not
'str'.

- Allow GnuPG.add_key accept either 'str' or 'bytes'.
- Import MIMEText from email.mime.text.
2022-04-10 19:03:18 +02:00
67a938c049 GnuPG.add_key: Use build_command 2022-01-25 20:32:17 +01:00
1e7d33c1df Handle bytes properly
Fix bytes sequences handling after auto-migration.
2022-01-10 18:21:53 +01:00
5f02223ec7 Perform automatic migration to Python 3.x
Use lib2to3 automatic migration tool provided by Python 2.x to convert
codebase to new idioms.

Command line:

find . -type f -name '*.py' \
    -exec python2.7 -m lib2to3 \
    -f all -f idioms -f buffer -f set_literal -f ws_comma -w \
    '{}' '+'
2022-01-10 18:21:20 +01:00
2cf60dec40 Add unit tests for GnuPG command-line generator
Extract a function to calculate GPG commands to be executed and cover it with
unit tests.
2022-01-09 21:37:14 +01:00
f1a799d864 Adjust E2E tests to work with all scenarios
Since it's not so easy to encrypt a message exactly the same way twice, we
only verify if the message has been encrypted or not.

Introduce minor changes to the library itself, because it doesn't work very
well with modern GnuPG.

Also, include GnuPG directory (pointed at by --homedir option).
2022-01-06 16:34:47 +01:00
fkrone
2c0e342e5e Support for decrypting PGP encrypted mails. However, it has some drawbacks and might cause some security issues. So before using it please read carefully through the installation instructions. 2015-05-25 20:24:37 +02:00
fkrone
3cefd27163 Revert "Bugfix for commit before:"
This reverts commit 99a1108338.
2015-02-14 19:02:14 +01:00
fkrone
99a1108338 Bugfix for commit before:
Make check for keys in keymap case insensitive
2015-02-14 16:03:30 +01:00
fkrone
e2ef883ec2 Merged change:
584eee18dc
( Added check that config file keymap fingerprint exists in actual GPG keyring. Decline encryption if mismatch. )
2015-02-14 16:01:58 +01:00
fkrone
63435c72c5 Merged change:
779e712a5d
( Changed GPGEncryptor.encrypt() to also give PGP return code. Write rc to logfile in encrypt_payload(). )
2015-02-14 15:22:29 +01:00
fkrone
0b503fa616 Fixing critical bug: looking up email addresses for PGP encryption in keychain was done case sensitive 2015-01-31 19:14:21 +01:00
fkrone
64db1a6bc0 Adding a key on a non-English system does not fail any longer 2015-01-04 17:54:44 +01:00
perennate
9ac151f438 Merge https://github.com/ajgon/gpg-mailgate
Conflicts:
	INSTALL
	README.md
	gpg-mailgate.conf.sample
	gpg-mailgate.py
2013-11-03 10:38:04 -05:00
perennate
4aa366dea5 Fix bug causing messages to have extra characters or failing to encode properly. 2013-11-03 15:13:03 +01:00
Colin Moller
d468766f8a Patch GnuPG library to trust keys we've already got to avoid having to manually add them 2013-11-03 15:11:21 +01:00
Taylor Hornby
ffaee4c577 Correctly encode 'keyhome' into a gpg command. 2013-10-08 17:00:55 -06:00
perennate
fbe2f1bba1 Update license to GNU GPL v3. 2013-10-02 14:27:28 -04:00
perennate
e01e505374 Release under GNU Lesser General Public License. 2013-09-27 22:21:55 -04:00
perennate
98b4e341cf Initial commit for gpg-mailgate-web addition. 2013-09-26 19:40:27 -04:00
perennate
c04db9c35f Fix bug causing messages to have extra characters or failing to encode properly. 2013-09-16 19:38:31 +02:00
Colin Moller
e7bd005430 Patch GnuPG library to trust keys we've already got to avoid having to manually add them 2013-09-16 19:24:25 +02:00
Igor Rzegocki
d6aaa9f243 Fixed #1
GnuPG2.x listed keys are now properly interpreted.
2013-09-06 21:59:31 +02:00
Igor Rzegocki
078381c2dd Removed stdin.write and stdout.read from GnuPG and replaced it with subprocess.communicate, to avoid deadlocks when larger messages are passed in 2013-04-17 20:23:48 +02:00
mcmaster
782cda3639 GPG Mailgate 0.1 2010-01-20 15:53:25 -05:00