Commit graph

554 commits

Author SHA1 Message Date
68e4a452d2 Split _gpg_encrypt into smaller functions 2022-10-19 18:36:23 +00:00
1edef79787 Update documentation to cover daemon tests 2022-10-19 18:36:23 +00:00
414f1d5921 Implement E2E tests for lacre.daemon
- Add a dedicated configuration file for lacre.daemon.

- Implement test/daemon_test.py like test/e2e_test.py, to automate the
following procedure:

    1. Start up lacre.daemon.
    2. For each test case, send test message to the daemon and verify that the
       output received by test/utils/relay.py contains expected pattern.

- Simplify Makefile.

- Fix indentation here and there.
2022-10-19 18:36:23 +00:00
a131cd66d3 Move different parts of Lacre tests to subdirectories
In particular, move:

- test utilities to test/utils;
- unit tests to test/modules.

Also: start implementing the Lacre daemon test (just a stub for now).
2022-10-19 18:36:23 +00:00
4c844384e3 Implement a bare minimum of advanced filtering
- Forward messages without encryption.

- Include a simple test setup in the Makefile.

- Add a test to send a test message to the daemon.
2022-10-19 18:36:23 +00:00
6455c1a280 [daemon] Add configuration, implement no-op filter
- Add a "mailop" module to define mail operations.  Each should inherit from
MailOperation class (which just defines the contract).

- Make lacre.mailgate.delivery_plan always return KeepIntact strategy to have
a daemon that just forwards messages without modifying them.

- Add sample configuration.

- Include daemon configuration in mandatory parameter check.
2022-10-19 18:36:23 +00:00
7849c55d9f Extend the daemon skeleton 2022-10-19 18:36:23 +00:00
29b5b50901 Mailgate: replace tabs with spaces 2022-10-19 18:36:23 +00:00
3f2760ba2d Create skeleton of the Lacre daemon
Also:
- Expose a function to read mail relay configuration.
- Replace tabs with 4 spaces in lacre.config.
2022-10-19 18:36:23 +00:00
8f191cae72 Restore keyring before running E2E tests 2022-10-19 18:36:23 +00:00
b198f0c4f4 Fix logging
First initialise logging, then import lacre.mailgate module.  Otherwise,
module's logging quitely initialises its own root logger that doesn't use
configuration provided by the user.

Also: remove unnecessary "global" keywords.
2022-10-19 18:36:23 +00:00
9e998b54e9 Extract a predicate to classify messages as already encrypted
Also: perform minor cleanup.
2022-10-19 18:36:23 +00:00
4d22ef9406 Merge pull request 'Removing webfrontend as it was migrated to standalone repository' (#98) from uncoupleFE into main
Reviewed-on: #98
2022-10-19 18:31:05 +00:00
156b09fd4e
added execute permission to webgate-cron.py 2022-10-19 09:35:52 +02:00
2ebd090d6c
uncoupled web frontend (lacre-webgate) from gpg-lacre; moved cron.py from frontend to backend dir and changed name (webgate-cron.py); 2022-10-12 16:29:09 +02:00
pfm
002e150805 Merge pull request 'Move core logic from gpg-mailgate.py to lacre.mailgate module' (#91) from 90-core-module into master
Reviewed-on: #91
2022-06-11 19:10:36 +00:00
5ffbbec5f0 Rename sort_recipients to deliver_message, remove unused imports 2022-06-11 21:05:27 +02:00
b627fde510 Move gpg-mailgate.py logic to lacre.mailgate module
gpg-mailgate.py script keeps its role, but only needs to call code defined in
lacre.mailgate.
2022-06-11 21:00:42 +02:00
pfm
8a366f2f17 Merge pull request 'Handle addresses with delimiters' (#89) from 87-handle-delimiters into master
Reviewed-on: #89
2022-06-08 19:32:27 +00:00
881a8d1756 Add GnuPG encryption support for addresses with delimiters
If a user registers their key for address alice@example.com but receives a
message sent to alice+something@example.com, this message should be encrypted
as well.

- Implement delimiter support for GnuPG encryption.

- Add E2E test case for a clear text message delivered to an address with
delimiter.

- Fix minor bug: wrong configuration parameter was retrieved when logging
information about enc_domain_keymap being active.
2022-06-08 21:20:58 +02:00
c86c620668 Extract delimiter support, add unit tests
Also: fix recursive call to get_cert_for_email.
2022-06-07 22:14:32 +02:00
pfm
c4781f2ac8 Merge pull request 'Record execution time and log it' (#86) from 84-measure-time into master
Reviewed-on: #86
2022-06-02 21:44:56 +00:00
251e6d1270 Record execution time and log it
After each execution, log an entry with information about total seconds from
the start to the end of execution and the value returned by
time.process_time() function, which returns:

	sum of the kernel and user-space CPU time

according to the documentation.

This feature can be used to collect stats about Lacre performance.
2022-06-02 23:41:14 +02:00
pfm
cb219799d2 Merge pull request 'Use CRLF for line-endings' (#83) from 78-fix-encryption into master
Reviewed-on: #83
2022-06-02 18:00:17 +00:00
937046eb17 Use CRLF for line-endings
Mail RFCs use CRLF for line endings and it turns out things may break in
strange ways if only LF is used.
2022-06-02 19:56:32 +02:00
65d2a77486 Don't break Content-Type header with LF - part 2 2022-06-02 19:43:27 +02:00
06abbc0edd Don't break Content-Type header with LF 2022-06-02 19:37:06 +02:00
pfm
9820e42457 Merge pull request 'Handle text data carefully' (#82) from 75-unify-types into master
Reviewed-on: #82
2022-06-01 21:59:52 +00:00
46be24670c Fix charset resolution in Content-Type parser 2022-06-01 23:44:41 +02:00
55b58d25bc Use literal separator '@' in sanitize_case_sense 2022-06-01 23:23:51 +02:00
d3b1717290 Extract PGP/INLINE checks, remove unnecessary byte-check 2022-06-01 23:00:05 +02:00
4c6fdc52ec Check mandatory config early, add tests
Also: extend failover logging configuration with file-based handler to make
sure that the user gets _some_ logs even if they do not configure Lacre at
all.
2022-05-31 22:09:10 +02: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
707fc96234
Add more contract tests
- Verify that Message.get_payload() returns str, unless passed decode=True,
when it returns bytes.

- Verify that RawConfigParser returns str.
2022-05-25 22:13:40 +02:00
558872d9d0 Start documenting dependency contracts with unit tests
Implement some unit tests for 'email' package so we know precisely how this
package behaves.
2022-05-16 20:57:12 +02:00
pfm
35987a6654 Merge pull request 'Clean-up' (#70) from 69-cleanup into master
Reviewed-on: #70
2022-05-14 09:49:14 +00:00
d27eef911a Update sample config
- Include helpful information about webpanel_url.
- Remove unused database settings.
- Add a hint about MySQL url to the database section.
2022-05-14 11:40:20 +02:00
92f3cedc51 Remove leftover .read() call 2022-05-14 11:26:49 +02:00
pfm
5639d8e5b6 Merge pull request 'Improve logging and configuration' (#65) from logging-and-config into master
- Replace custom logging code with "logging" package.
- Unify access to configuration and extract to "lacre.config" package.
- Introduce a new configuration file (with a sample included) to control how and where Lacre writes diagnostic output.
- Update sample configuration.

Reviewed-on: #65
2022-05-13 20:01:10 +00:00
d8bef9cdb0 Explain syslog logging better in sample logging config 2022-05-13 21:57:29 +02:00
11b78ce0fb Adjust log entry levels for severe conditions
When Lacre is misconfigured or can't proceed, report WARNING or even ERROR
level messages.
2022-05-13 21:27:50 +02:00
acdb2dd5c8 Log cron-job inner workings 2022-05-11 19:57:26 +02:00
7a8720c142 Update installation instructions, add sample logging config 2022-05-11 19:15:59 +02:00
8f0d8f4933 Add newlines to key material 2022-05-06 20:40:16 +02:00
617a208fe9 Fix indentation and names after rebase 2022-05-06 20:25:22 +02:00
9dfc447169 Use Lacre logging and configuration in register-handler 2022-05-06 20:13:23 +02:00
af5a5b4176 Use Lacre logging and configuration in cron.py 2022-05-06 20:13:19 +02:00
75ccfb0850 Use logging module
- Replace custom logging code with calls to logging module.
- Use logging.config to provide configuration parameters.

To make Lacre's logging more flexible, use fileConfig from logging.config to
set up all parameters.  If the configuration file is missing, use dictConfig
with hardcoded reasonable defaults.
2022-05-06 19:39:56 +02:00
baf7954270 Use list booleanness instead of comparing with empty list 2022-05-06 19:39:56 +02:00
031c7234f6 Reorder top-level expressions 2022-05-06 19:39:56 +02:00