Rspamd: more features#3159
Conversation
|
@hanscees @alexanderadam you could really help me here: do you know how to trigger Sieve locally by moving a mail into the "Junk" folder with a command executed inside the container? I want to complete the last test for |
Sadly I don't 😬 |
|
I have to think about that. Will come back to it this evening. |
Thanks!
Indeed. I don't know how to do that actually, I have never done that before. |
|
@polarathene @casperklein would you be fine if this PR got included into v12.0.0? I marked it for v12.1.0, but if you're okay with it, I'd take care of this ASAP so we can merge this for v12.0.0. |
a3767e8 to
7a89471
Compare
Why shouldn't it be fine to include it in v12? I see no reason against it. |
Hi, A test that simulates an email copy from commandline to dovecot is possible, but wouldnt recommend it since its very complex. However, the notes to do copy's with imap are here: see https://www.atmail.com/blog/advanced-imap/ Perhaps more manageable is to run and parse the command doveconf and look for the plugin section and check a couple of things : By the way a similar command for rspamd is rspamd configdump Does this help a bit? |
That's what we do :)
Thanks for the link, will have a look.
The Rspamd test sends 4 emails actually: 1 normal, 1 Gtube rejection, one virus rejection, and one that Rspamds adds a header to. The part that moves the mail does not trigger Sieve for me though.
Don't worry, our test suite (BATS) plus our helpers are rather comprehensive.
Test is already doing that.
To will have a look at the link you provided. The rest is already all implemented :) |
👍🏼 |
|
@casperklein @polarathene you can already go ahead and review changes. The only additions I will try to implement is for the last test to be more comprehensive. |
This is probably going to be low on my priority to get to. Or if @casperklein reviews before me and approves, that's fine to merge without waiting on my review input 👍 I am probably going to need a day or so before I could make time for it so by all means if that suits you go for it. |
|
Generally, "move_spam_to_junk" isn't a spamassassin/rspamd specific thing. I think there is no need for a separate docker-mailserver/target/scripts/startup/setup.d/dovecot.sh Lines 77 to 85 in dab7070 Just remove the PS: Your (rspamd) sieve solution looks a bit more advanced, than what currently is used: I think this can be updated safely 👍 |
|
@casperklein you are right! I went ahead and implemented your approach, then rewrote history to have cleanly separated commits again; suggestions are incorporated :) I will force-push my changes now. |
7a89471 to
9a84ded
Compare
9a84ded to
cbd43c5
Compare
|
FYI: I'd like to merge this at the very latest on Friday, 12 o'clock UTC+1 because thereafter I will be unavailable to merge/adjust for 2 weeks straight. |
12 hours to go 😅 I'll try to review before then, but if another maintainer approves that's fine by me too for merging. |
polarathene
left a comment
There was a problem hiding this comment.
Light review as short on time and Dovecot sieve + rspamd aren't anything I am too knowledgeable about.
I've left some notes, but if they're not a concern in your opinion that's fine, go ahead and merge 👍 Happy vacation! 😀
I wasn't able to review yesterday :-\ Tonight/tomorrow I can review. |
I won't be able to properly respond to feedback then; I got about 3 hours left for that, as I said. |
|
I was able to feedback from @polarathene now; I hope you like the PR @casperklein :)
Thank's a lot! :D |
polarathene
left a comment
There was a problem hiding this comment.
I suppose we merge this after your feedback @casperklein as @georglauterbach is no longer able to respond for 2 weeks.
Feel free to merge after your review or make any changes 👍
| cat >/usr/lib/dovecot/sieve-global/after/spam_to_junk.sieve << EOF | ||
| require ["fileinto","mailbox"]; | ||
|
|
||
| if anyof (header :contains "X-Spam-Flag" "YES", | ||
| header :contains "X-Spam" "Yes") { | ||
| fileinto "Junk"; | ||
| } | ||
| EOF |
There was a problem hiding this comment.
Honestly not a fan of EOF like this vs separate files, but I've said this before with cron jobs and looked the other way in the PR where this was also done 😅
Separate config files have better observability in my opinion.
- Far more visible in the file tree as distinct content from scripts. Also beneficial for tasks like
grepon content that isn't.shwhen searching / filtering the entire project for something, less noise to wade through. git blamefar more useful as they don't tend to go through as much churn as scripts have been (each year it seems they get refactored heavily).
I don't think there's much gain from inlining content like this, but I know it's preferred by you and casper 😅
There was a problem hiding this comment.
I know you're not a fan, but from my perspective, the gains (reduced complexity in the file tree, Dockerfile and removal of the uncanny rm in the else branch) outweigh the disadvantages in this case for such a small file :)
With larger files, I agree with you!
There was a problem hiding this comment.
I don't think there's much gain from inlining content like this, but I know it's preferred by you and casper 😅
It depends on 😆 For static content, I generally prefer plain files. For small snippets (with variables), a heredoc may better suited.
If there is consent, we can in a separate PR move some (not only rspam related) heredocs to files.
There was a problem hiding this comment.
If there is consent, we can in a separate PR move some (not only rspam related) heredocs to files.
I can live with it 😅
There's some merit for the co-location to that extent perhaps, but those less familiar where everything is and wanting to contribute or troubleshoot something may first expect files in the container that we add to exist as files in our project, rather than embedded into scripts 🤷♂️ (I know this was a bit of a pain-point for me with the cron jobs, which I think existed in several locations in the container, some from packages beyond what DMS added)
It probably won't make much of a difference to getting new maintainers onboard though, so if it's easier for those actively maintaining the project to leverage heredocs, go for it 😎
Very quick feedback I can give, will be on GH for 1 minute a day :) Flight hasn't yet started :D I just can't edit or adjust anything
Yes - go ahead! :) |
ping :) |
|
Documentation preview for this PR is ready! 🎉 Built with commit: 3ab664b |
|
| cat >/usr/lib/dovecot/sieve-global/after/spam_to_junk.sieve << EOF | ||
| require ["fileinto","mailbox"]; | ||
|
|
||
| if anyof (header :contains "X-Spam-Flag" "YES", | ||
| header :contains "X-Spam" "Yes") { | ||
| fileinto "Junk"; | ||
| } | ||
| EOF |
There was a problem hiding this comment.
I don't think there's much gain from inlining content like this, but I know it's preferred by you and casper 😅
It depends on 😆 For static content, I generally prefer plain files. For small snippets (with variables), a heredoc may better suited.
If there is consent, we can in a separate PR move some (not only rspam related) heredocs to files.
|
@georglauterbach Commit b918de1 introduced a breaking change:
Having the rules as "before" rules allowed users to manually "whitelist" a sender whose e-mails could be wrongly flagged as spam (with a May I ask what was the reasoning behind this change? I'm asking because I might be missing the point. Thanks in advance! |
Truth be told, I'm just not a Sieve expert 😅 I didn't know that this could be breaking.
So if I understand you correctly, it's not really about the before/after, but about the global/user order? I will look into this again; if you could help me a bit and provide information about your setup so I can see where your configuration files are, that'd help a lot! Thanks :) |
It's alright 😄 There are so many things that can go wrong, and collaborating helps figuring all of this out!
This docker image exposes ManageSieve on the port 4190, which is used to let each user set up their own filters. I manage a mailserver where a few users have genuine e-mails getting wrongly caught by SpamAssassin. As a result, some users have custom rules where if an e-mail comes from a trusted e-mail address, to I'm not a Sieve expert either, but from my understanding, the last User filters are located in Hopefully that makes sense! In regards to my specific setup, I'm providing SnappyMail (active fork of Rainloop) as our webmail, which lets users interface with ManageSieve and make their own filters. One user in particular has filters like this in place: if header :contains ["From"] "twitch"
{
fileinto "INBOX.Twitch";
}
if header :contains ["From"] "bandcamp"
{
fileinto "INBOX.Bandcamp";
}However, with your global "after" filter, spam mails would still be filed into the "Junk" folder, with no way of overriding it. |
|
I genuinly didn't think the last Thanks a lot for the explanation! |
|
.....Actually I think I just got hit with the syndrome of "asking for help / telling someone something, to then find an answer by yourself" 😅 Apologies! It might be worth trying to keep the Junk filter as an "after" filter just like you did, and attempt using I'm just not sure if a I'll go test this ASAP |
|
Haha, I know this "syndrom" very well :D What I found about your question: https://dovecot.org/list/dovecot/2018-March/111384.html so it seems to be possible. I am uncertain which route to go down. Your idea using I will adjust the release notes though to make users aware of this unintended change. It is, after all, somehow breaking... |
|
Please reach back to me whether you think the |
Hi @georglauterbach, I can now confirm after a while that this has been working flawlessly! 😄 |
Description
Add new features to our Rspamd integration:
MOVE_SPAM_TO_JUNK=1, we will now move messages marked with theX-Spam: Yesheader to the "Junk" folderRSPAMD_LEARN=1, we enableI tried to separate commits as cleanly as possible to make reviews easier.
Closes #3145
Closes #3156
Type of change
Checklist:
docs/)