Skip to content

rspamd: add neural module config#3833

Merged
georglauterbach merged 14 commits intodocker-mailserver:masterfrom
hanscees:master
Feb 1, 2024
Merged

rspamd: add neural module config#3833
georglauterbach merged 14 commits intodocker-mailserver:masterfrom
hanscees:master

Conversation

@hanscees
Copy link
Copy Markdown
Contributor

@hanscees hanscees commented Jan 25, 2024

Description

Added config to use neural networks to make spam detection better

Fixes #3816

Type of change

  • New feature (non-breaking change which adds functionality)
  • Improvement (non-breaking change that does improve existing functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added information about changes made in this PR to CHANGELOG.md

@polarathene
Copy link
Copy Markdown
Member

Without good justification, this looks like something @georglauterbach already added support for with rspamd integration. You can provide these configs yourself rather than upstream into DMS for everyone.

I don't have much opinion on rspamd config, so I'll leave this up to @georglauterbach to decide if the configuration being contributed is really appropriate (not just the rspamd feature itself).

Generally this is something we defer to as a docs contribution, and if there is enough interest from DMS users we look into bringing it into DMS. A PR that just provides a static config preset isn't really something I care much for.


The neural module itself is still documented as experimental and has WIP tags.

@georglauterbach
Copy link
Copy Markdown
Member

I actually asked for a PR in the corresponding issue #3816. This PR need more work, though: we need a ENV RSPAMD_ENABLE_NEURAL that conditionally enabled this feature. The configs seem okay; when RSPAMD_ENABLE_NEURAL=0 we can just rm them. @hanscees how well are you versed in Bash? This requires not a very elaborate Bash knowledge, because I can help.

@hanscees
Copy link
Copy Markdown
Contributor Author

hanscees commented Jan 26, 2024

I actually asked for a PR in the corresponding issue #3816. This PR need more work, though: we need a ENV RSPAMD_ENABLE_NEURAL that conditionally enabled this feature. The configs seem okay; when RSPAMD_ENABLE_NEURAL=0 we can just rm them. @hanscees how well are you versed in Bash? This requires not a very elaborate Bash knowledge, because I can help.

I have adjusted the files

vi scripts/startup/variables-stack.sh

vi scripts/startup/setup.d/security/rspamd.sh

vi mailserver.env

But do I know make a completely new PR? Hmm, I think the changes are already added. Can you check ?
I have mentioned a new help neural.html page that does not exist yet by the way

Copy link
Copy Markdown
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks already very good. I added two comments, one has a suggestion. When you're on GitHub, you can commit my suggestion so you don't have to apply it manually.

What is left to do is to basically copy the information from mailserver.env to our documentation, specifically docs/content/config/environment.md.

Then I think we're good to go! 🚀

Comment thread mailserver.env Outdated
Comment thread target/scripts/startup/setup.d/security/rspamd.sh Outdated
Comment thread mailserver.env Outdated
@polarathene polarathene changed the title add neural config feat: rspamd - Add neural module config Jan 28, 2024
Comment thread target/scripts/startup/setup.d/security/rspamd.sh Outdated
Comment thread target/scripts/startup/setup.d/security/rspamd.sh Outdated
Comment thread mailserver.env Outdated
@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Jan 29, 2024

Okay, last tasks @hanscees:

  • "copy" the information from mailserver.env to our documentation, specifically docs/content/config/environment.md.
  • Add an entry to CHANGELOG.md

I have applied my latest review feedback myself, so you'll need to pull before working on the branch again.

Then we can update this branch and merge.

Comment thread target/scripts/startup/setup.d/security/rspamd.sh Outdated
@georglauterbach georglauterbach changed the title feat: rspamd - Add neural module config rspamd: add neural module config Jan 29, 2024
@georglauterbach georglauterbach added this to the v14.0.0 milestone Jan 29, 2024
@georglauterbach georglauterbach added kind/new feature A new feature is requested in this issue or implemeted with this PR area/features service/security/rspamd labels Jan 29, 2024
@hanscees
Copy link
Copy Markdown
Contributor Author

Okay, last tasks @hanscees:

  • "copy" the information from mailserver.env to our documentation, specifically docs/content/config/environment.md.
  • Add an entry to CHANGELOG.md

I have applied my latest review feedback myself, so you'll need to pull before working on the branch again.

Then we can update this branch and merge.

done. Please check for errors.

@georglauterbach
Copy link
Copy Markdown
Member

Okay, last tasks @hanscees:

  • "copy" the information from mailserver.env to our documentation, specifically docs/content/config/environment.md.
  • Add an entry to CHANGELOG.md

I have applied my latest review feedback myself, so you'll need to pull before working on the branch again.
Then we can update this branch and merge.

done. Please check for errors.

I don't see the corresponding changes here on GitHub. Did you push the changes?

@hanscees
Copy link
Copy Markdown
Contributor Author

hanscees commented Jan 30, 2024

I have no idea what to do. The base branch keeps changing (ie your branch).

then I do locally
git fetch upstream
git merge upstream/master

I commit and it says
git push origin master

To https://github.com/hanscees/docker-mailserver
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/hanscees/docker-mailserver'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

No clue what to do now. Teh code changes are sitting nicely on my disk and refuse to move ...

After some fiddling with rebase no and what not it seems to work now ..........

@polarathene
Copy link
Copy Markdown
Member

I have no idea what to do. The base branch keeps changing (ie your branch).

Just for future reference, it's usually best to have your master branch unmodified, just sync it with ours, then branch off that when you're making a contribution and send a PR of that branch.

No merging or rebasing is needed with us, we can update the branch from Github here and we merge PRs via squash commit so we're not that concerned with commit history in a PR. We just review it until we're happy with the final diff.

I am forgetful with the git CLI personally and find it much easier to manage operations via software like GitKraken. I rewrite history with interactive rebase feature there, manage my branches, commit messages and merge conflicts all through that. It avoids a lot of the headaches I had when using only CLI.

@polarathene
Copy link
Copy Markdown
Member

Current test failure:

not ok 81 [Rspamd] (full) service log exist and contains proper content in 340ms
# (from function `assert_success' in file test/test_helper/bats-assert/src/assert_success.bash, line 42,
#  from function `_service_log_should_contain_string' in file test/helper/log_and_filtering.bash, line 50,
#  in test file test/tests/parallel/set1/spam_virus/rspamd_full.bats, line 111)
#   `_service_log_should_contain_string 'rspamd' 'lua module neural is disabled in the configuration'' failed
#
# -- command failed --
# status : 1
# output :
# --
#

Comment thread target/scripts/startup/setup.d/security/rspamd.sh
@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Jan 31, 2024

I have no idea what to do. The base branch keeps changing (ie your branch).

then I do locally git fetch upstream git merge upstream/master

I commit and it says git push origin master

To https://github.com/hanscees/docker-mailserver ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://github.com/hanscees/docker-mailserver' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

No clue what to do now. Teh code changes are sitting nicely on my disk and refuse to move ...

After some fiddling with rebase no and what not it seems to work now ..........

I'd strongly advise checking out another branch before working on features (as it makes syncing to upstream way easier). This is my workflow:

[master] $ git pull
[master] $ git checkout -b feature-branch
[feature-branch] $ # do some work
[feature-branch] $ git commit ...
[feature-branch] $ git push -u origin feature-branch
# then create a PR

# later, when changes / suggestions were applied
[feature-branch] $ git pull
[feature-branch] $ # do some work
[feature-branch] $ git commit ...

# in case you already commited something and forgot to pull earlier, try
[feature-branch] $ # do some work
[feature-branch] $ git commit ...
[feature-branch] $ git pull --rebase

For feature branches on forked repositories, we can manage syncing with our upstream master here on GitHub, so you need not worry about this.


Okay, so I am not 100% sure why the test did not fail earlier. One last change needs to happen:

  1. Apply my last suggestion and then make sure to git pull on your local branch
  2. In target/scripts/startup/setup.d/security/rspamd.sh, you need to remove neural in line 190 (I hope) (on your branch) from the array called DISABLE_MODULES inside the function __rspamd__setup_default_modules. Just remove the line.

@georglauterbach
Copy link
Copy Markdown
Member

georglauterbach commented Jan 31, 2024

We have a ton of changes now that warrant v14 IMO. This PR should go into v14, though. @casperklein @polarathene what are your thoughts on going for a release PR and a feature freeze after this PR has been merged?

@polarathene
Copy link
Copy Markdown
Member

@polarathene what are your thoughts on going for a release PR and a feature freeze after this PR has been merged?

I have a docs PR to complete that I'd like to get in for v14. A week freeze should be enough time to get that in. Other than that I'm fine with a release 👍

@hanscees
Copy link
Copy Markdown
Contributor Author

I have no idea what to do. The base branch keeps changing (ie your branch).

Just for future reference, it's usually best to have your master branch unmodified, just sync it with ours, then branch off that when you're making a contribution and send a PR of that branch.

No merging or rebasing is needed with us, we can update the branch from Github here and we merge PRs via squash commit so we're not that concerned with commit history in a PR. We just review it until we're happy with the final diff.

I am forgetful with the git CLI personally and find it much easier to manage operations via software like GitKraken. I rewrite history with interactive rebase feature there, manage my branches, commit messages and merge conflicts all through that. It avoids a lot of the headaches I had when using only CLI.

As I said, this git stuff PR is first time for me. I didnt know offbranching existed until 2 minutes ago. Will try that for sure :).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 1, 2024

Documentation preview for this PR is ready! 🎉

Built with commit: b89c4a7

@georglauterbach georglauterbach merged commit 45935f5 into docker-mailserver:master Feb 1, 2024
@hanscees
Copy link
Copy Markdown
Contributor Author

hanscees commented Feb 1, 2024

thanks for all your help! Great to see this fly!

@georglauterbach
Copy link
Copy Markdown
Member

Thanks for the contribution 🚀 Always nice to see community contributions!

AlMaVizca added a commit to AlMaVizca/docker-mailserver-helm that referenced this pull request Jun 19, 2024
AlMaVizca added a commit to AlMaVizca/docker-mailserver-helm that referenced this pull request Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/features kind/new feature A new feature is requested in this issue or implemeted with this PR service/security/rspamd

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

feature request: adding neural module for rspamd

4 participants