Commit Graph

2634 Commits

Author SHA1 Message Date
Georg Lauterbach 7c4857d7a4
Merge branch 'master' into rspamd/use-sieve-for-subject-rewrite 2024-01-28 11:13:04 +01:00
Georg Lauterbach 2c77e25d8b
Merge branch 'master' into rspamd/use-sieve-for-subject-rewrite 2024-01-28 11:11:36 +01:00
Brennan Kinney 204825fa5a
ci(fix): `docs-preview-deploy.yml` - Use the correct setting names (#3843) 2024-01-28 20:41:19 +13:00
Brennan Kinney 4a05d7bb7c
docs: Add Debian 12 breaking change for `opendmarc` package (#3841) 2024-01-28 10:23:49 +13:00
georglauterbach 17b475cf61
Merge branch 'master' into rspamd/use-sieve-for-subject-rewrite 2024-01-27 16:28:39 +01:00
georglauterbach ffe3370227
re-add test that checks Amavis' defaults 2024-01-27 16:27:49 +01:00
georglauterbach c593999da8
add `_file_does_not_exist_in_container`
- counterpart to `_file_exists_in_container`
- usage was adjusted in all Rspamd-related tests and in
  Amavis tests
2024-01-27 16:17:35 +01:00
Georg Lauterbach fb0fba9da7
Apply suggestions from code review
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-01-27 16:12:22 +01:00
Brennan Kinney f27629be4e
docs: Minor revisions to `README.md` (#3839) 2024-01-28 01:51:37 +13:00
Brennan Kinney a8ccd54da5
ci: `docs-preview-deploy.yml` - Switch to official `download-artifact` action (#3838)
v4 of the official action now supports this use-case.
2024-01-28 01:50:01 +13:00
georglauterbach d77c6a6741
Merge branch 'master' into rspamd/use-sieve-for-subject-rewrite 2024-01-26 14:45:59 +01:00
georglauterbach 12e3e8ff6d
Merge branch 'master' into rspamd/use-sieve-for-subject-rewrite 2024-01-26 14:45:04 +01:00
georglauterbach b74266c17b
adjust Rspamd tests to new implementation 2024-01-26 14:44:21 +01:00
georglauterbach c243a0ac9b
re-add entry to `mailserver.env` 2024-01-26 14:44:11 +01:00
georglauterbach 60bd9c9e58
adjust Amavis tests
The updated tests unifies checking ENVs related to Amavis, which have
previously lived in a separate test file.
2024-01-26 14:43:59 +01:00
georglauterbach f2dcb03e79
delete useless test
The functionality will be added to `amavis.bats`.
2024-01-26 14:43:59 +01:00
georglauterbach 8ea0ae2ff0
use Sieve for Rspamd and SA/Amavis
As mentioned by @polarathene, the previous changes included a mixture of
Dovecot Sieve (for Rspamd) and a native implementation for SA/Amavis.
Now, we handle everything through Sieve. This is really a breaking
change.
2024-01-26 14:43:58 +01:00
Georg Lauterbach 8d58e1565f
Apply suggestions from code review
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-01-26 14:43:42 +01:00
Andreas Perhab 9ac11021e1
setup-stack: fix error when RSPAMD_DMS_DKIM_D is not set (#3827)
* setup-stack: fix error when RSPAMD_DMS_DKIM_D is not set

prevent messages like this
  chown: cannot access '': No such file or directory
when RSPAMD_DMS_DKIM_D has no value

* Update target/scripts/startup/setup-stack.sh

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-01-26 14:40:29 +01:00
Georg Lauterbach ba27edc801
Rspamd: only declare Rspamd variables when not already declared (#3837)
* only declare Rspamd vars when not already declared

* update CHANGELOG

* Update CHANGELOG.md

---------

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-01-26 14:07:46 +01:00
Brennan Kinney 7d9eb1e4a7
docs: Add context to `sender-cleanup` in Postfix `master.cf` (#3834)
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-01-26 11:32:49 +01:00
Brennan Kinney 487867285b
docs: UX Improvement - Better distinguish side nav page categories (#3835) 2024-01-26 11:32:18 +01:00
Brennan Kinney 47f8d50beb
fix: Ensure configs are sanitized for parsing (#3819)
* chore: Detect missing final newline in configs read

These lines will be not be processed by `read`, emit a warning to raise awareness.

* fix: Ensure parsed config has final newline appended (when possible)

This functionality was handled in `accounts.sh` via a similar sed command (that the linked references also offer).

`printf` is better for this, no shellcheck comment required either.

We additionally don't attempt to modify files that are read-only.

* fix: Ensure parsed configs have CRLF to LF corrected (where possible)

Likewise, this runtime fix was only covering two config files. It now applies to all callers of this method.

* fix: Sanitize `postfix-master.cf` via helper

This feature should have been using the helper to avoid user error from their config updates accidentally introducing subtle breakage implicitly (due to CRLF or missing final newline).

* tests: Add test cases for new helpers

* tests:  `rm` is redundant when using `BATS_TEST_TMPDIR`

This temporary directory is created and removed implicitly. Even after a test failure.

* chore: Remove old `postfix-virtual.cf` migration logic

This was introduced in 2018, there should be no one needing to rely on this anymore?

* tests: Remove comment on sed failure concern

* chore: Add entry to `CHANGELOG.md`

* Apply suggestions from code review

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-01-26 10:28:26 +13:00
georglauterbach fc26674d65
correct remaining tests 2024-01-25 18:54:18 +01:00
georglauterbach 94d8f0fdb4
update `CHANGELOG.md` 2024-01-25 18:41:48 +01:00
georglauterbach a25aa8554b
notify users when they haven't adopted `SPAM_SUBJECT` 2024-01-25 18:34:32 +01:00
georglauterbach 4ff83bf254
update and extend Rspamd tests for `SPAM_SUBJECT` 2024-01-25 18:34:09 +01:00
georglauterbach 5a04813629
implement `SPAM_SUBJECT` for Rspamd 2024-01-25 18:24:09 +01:00
georglauterbach ab11d8e4a7
remove `rewrite_subject` action in Rspamd base config 2024-01-25 18:24:09 +01:00
georglauterbach d0eccd322f
introduce new helper `_file_exists_in_container`
This helper will be used in un upcoming commit that adds testing
functionality. In a follow-up PR, the helper will be applied in all
tests.
2024-01-25 18:24:09 +01:00
georglauterbach 7372fae786
setup a check to warn users about certain config
If I am not mistaken, the configuration I am checking for is the one we
should emit a warning about: in case junk mail is moved to the inbox and
no rewriting happens, we should check whether this is actually what the
user wants.
2024-01-25 18:24:08 +01:00
georglauterbach bc6786ec87
rename `SA_SPAM_SUBJECT` to `SPAM_SUBJECT` in code 2024-01-25 18:24:08 +01:00
georglauterbach 6a79f6124a
remove `SA_SPAM_SUBJECT` and define `SPAM_SUBJECT`
This commit is just altering the documentation and gives an impression
on the upcoming changes.
2024-01-25 18:24:07 +01:00
Brennan Kinney 22c6daee32
chore: Revise improper restart message (#3826)
Improved guidance.
2024-01-25 12:21:24 +00:00
Brennan Kinney 303ca82fb9
docs(fix): New external link icon workaround for mkdocs-material 9.5.5 (#3823)
This is the easiest to maintain workaround now available. Upstream continues to reject the value such a feature for accessibility.
2024-01-26 01:02:19 +13:00
Georg Lauterbach ed1e1ebbd3
tests: new sending and filtering functions (#3786)
* move log/filter functions into own file

* add ShellCheck global directives

* use new function for tracking logs

The new function, called `_send_email_with_mid`, aligns with suggestions
from @polarethene and is heavily simplified compared to its predecessor
`_send_email_and_get_id`. New helpers will be introduced to filter logs
according to the MID constructed in this function.

* new filters for searching logs with MID

* use new filters (and sending) functions

* add new helper for asserting non-existence of log message

* use new filters in tests

* Apply suggestions from code review

- `_mid` / `MID` => `_msgid` / `MSG_ID`
- Revised documentation / tooltip comments

* Apply suggestions from code review

* fix tests

* use more distinct names for MSG_ID headers

* update `_filter_service_log` to not use `-i -E`

Moreover, I added a function to print the whole mail log. Appropriate
comments were added to this function to indicate that one should only
use this function when necessary.

* adjust helpers to new helper filter

* follow-up of previous commit

* add CHANGELOG entry

* Apply suggestions from code review

* chore: Update OAuth2 to use new log helper

* Apply suggestions from code review

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>

* added explicit `_regexp` filters for logs

* Apply suggestions from code review

---------

Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-01-25 11:06:05 +13:00
Georg Lauterbach 00018e7e2b
general: update base image to Debian 12 ("Bookworm") (#3403)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Co-authored-by: Casper <casperklein@users.noreply.github.com>
2024-01-24 17:05:55 +01:00
Brennan Kinney 0c7e49e654
release: v13.3.1 (#3817)
* chore: Bump `VERSION`

* chore: Update `CHANGELOG.md`

---------

Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-01-24 14:25:13 +01:00
Brennan Kinney 2cf5856961
chore: Raise awareness of v13 breaking change better (#3818)
Several issues have been raised where this was not an obvious breaking change to the reader. Additional context on impact relevance has been included.
2024-01-25 00:46:56 +13:00
Brennan Kinney 9a53fb0463
docs: Minor revisions to Dovecot Sieve page (#3811)
- The old Dovecot wiki link needed to be updated to the new location.
- The new docs are not entirely compatible AFAIK, thus making the existing examples/docs a bit outdated / incompatible. A warning admonition has been added early on to raise awareness to the reader.
- Minor formatting revisions to the content.
2024-01-24 11:47:32 +13:00
Brennan Kinney 611a66bf98
fix: Correctly support multiple Dovecot PassDBs (#3812)
* fix: Dovecot PassDB should restrict allowed auth mechanisms

This prevents PassDBs incompatible with certain auth mechanisms from logging failures which accidentally triggers Fail2Ban.

Instead only allow the PassDB to be authenticated against when it's compatible with the auth mechanism used.

* tests: Use `curl` for OAuth2 login test-cases instead of netcat

`curl` provides this capability for both IMAP and SMTP authentication with a bearer token. It supports both `XOAUTH2` and `OAUTHBEARER` mechanisms, as these updated test-cases demonstrate.

* chore: Add entry to `CHANGELOG.md`
2024-01-23 19:11:05 +01:00
Brennan Kinney d40a17f7e0
fix: Ensure correct ownership for the Rspamd DKIM directory (#3813)
The UID / GID shifted during a new release. Until DKIM handling is refactored in a new major release, this fix ensures the content maintains the expected `_rspamd` ownership.
2024-01-23 11:51:10 +01:00
dependabot[bot] 315f33c9fe
chore(deps): Bump anchore/scan-action from 3.5.0 to 3.6.0 (#3808)
Bumps [anchore/scan-action](https://github.com/anchore/scan-action) from 3.5.0 to 3.6.0.
- [Release notes](https://github.com/anchore/scan-action/releases)
- [Changelog](https://github.com/anchore/scan-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/anchore/scan-action/compare/v3.5.0...v3.6.0)

---
updated-dependencies:
- dependency-name: anchore/scan-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
2024-01-23 15:36:53 +13:00
dependabot[bot] 37f4c853b2
chore(deps): Bump actions/cache from 3 to 4 (#3807) 2024-01-22 21:02:49 +01:00
github-actions[bot] 3cbcdb2d65
docs: update `CONTRIBUTORS.md` (#3798)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Casper <casperklein@users.noreply.github.com>
2024-01-21 12:31:10 +01:00
Jam Balaya 41b471fb14
fix(typo): comment on mailserver.env (#3799)
Thanks!
2024-01-21 12:21:29 +01:00
Georg Lauterbach b78978caed
release: v13.3.0 (#3781)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-01-20 12:33:05 +01:00
Brennan Kinney f3a7f08f96
tests: Revise OAuth2 tests (#3795)
* tests: OAuth2 - Replace Python `/userinfo` endpoint with Caddy

Better documented, easier flow and separation of concerns via Caddy.

The python code had additional noise related to setting up a basic API which is abstracted away via `Caddyfile` config that's dedicated to this task.

* tests: OAuth2 - Minimize noise + Improve test assertion

Caddyfile can use an Access Token instead of a JWT. Much smaller and correct for this OAuth2 configuration. This new value has been documented inline.

Likewise the `sub` field returned is not important to this test. `email_verified` is kept as it may be helpful for further coverage testing.

The actual test-case has better assertions for success and failure by checking for Dovecot logs we expect instead of netcat response.

`oauth2` to `auth` for the Caddy container hostname is not necessary, just a more generic subdomain choice.

* tests: OAuth2 - Caddyfile `imap/xoauth2` route dynamic via query string

This way is more flexible and doesn't require modifying the `Caddyfile` directly, while still easy to use.

Additionally simplifies understanding the Caddyfile to maintainers by removing the `route` directive that was required to ensure a deterministic order of vars.

* tests: OAuth2 - `/imap/xoauth2` respond with IMAP commands for netcat

Since this is the only intended usage, might as well have it respond with the full file content.

* tests: OAuth2 - Implement coverage for `OAUTHBEARER`

Caddyfile route for `/imap/` now accepts any subpath to support handling both `xoauth2` and `oauthbearer` subpaths.

Both SASL mechanisms represent the same information, with `XOAUTH2` being a common mechanism to encounter defined by Google, whilst `OAUTHBEARER` is the newer variant standardized by RFC 7628 but not yet as widely adopted.

The request to `/userinfo` endpoint will be the same, only the `credentials` value to be encoded differs.

Instead of repeating the block for a similar route, this difference is handled via the Caddyfile `map` directive.

We match the path context (_`/xoauth2` or `/oauthbearer`, the `/imap` prefix was stripped by `handle_path` earlier_), when there is a valid match, `sasl_mechanism` and `credentials` map vars are created and assigned to be referenced by the later `respond` directive.

---

Repeat the same test-case logic, DRY with log asserts extracted to a common function call. This should be fine as the auth method will be sufficient to match against or a common failure caught.

* tests: OAuth2 - Minor revisions

Separate test cases and additional comment on creating the same base64 encoded credentials via CLI as an alternative to running Caddy.

Added a simple `compose.yaml` for troubleshooting or running the container for the `/imap/xoauth2` / `/imap/oauthbearer` endpoints.

* tests: OAuth2 - Route endpoints in Caddyfile with snippets instead

`reverse_proxy` was a bit more convenient, but the additional internal ports weren't really relevant. It also added noise to logging when troubleshooting.

The `import` directive with Snippet blocks instead is a bit cleaner, but when used in a single file snippets must be defined prior to referencing them with the `import` directive.

---

`compose.yaml` inlines the examples, with slight modification to `localhost:80`, since the Caddyfile examples `auth.example.test` is more relevant to the tests which can use it, and not applicable to troubleshooting locally outside of tests.

* chore: Add entry to `CHANGELOG.md`

* chore: Additional context on access token
2024-01-20 10:49:09 +01:00
Brennan Kinney a5d536201b
docs: Add maintenance comment for `reject_unknown_sender_domain` (#3793)
I figured this was a useful comment to reference related to the setting if it's ever being changed or needs to be better understood (linked issue is a common failure that can be encountered related to this restriction).
2024-01-20 17:51:32 +13:00
Roy Sindre Norangshol deb0d2d09a
docs: Guidance for binding outbound SMTP with multiple interfaces available (#3465)
Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
2024-01-19 14:58:20 +13:00