Updated spamfilter rules

This commit is contained in:
mdecimus 2024-04-05 15:27:16 +02:00
parent 3a5ca70365
commit 89433f3f06
6 changed files with 37 additions and 75 deletions

View file

@ -45,7 +45,8 @@ script_names = {
"greylist" : "Greylisting" "greylist" : "Greylisting"
} }
maps = ["scores.map", maps = ["spam_config.map",
"scores.map",
"allow_dmarc.list", "allow_dmarc.list",
"allow_domains.list", "allow_domains.list",
"allow_spf_dkim.list", "allow_spf_dkim.list",
@ -68,7 +69,7 @@ def read_file(file):
return f.read() + "\n" return f.read() + "\n"
def build_spam_filters(scripts): def build_spam_filters(scripts):
spam_filter = read_file("./spamfilter/settings.toml") spam_filter = "[version]\nspam-filter = \"1.0\"\n\n"
for script_name, file_list in scripts.items(): for script_name, file_list in scripts.items():
script_content = read_and_concatenate(file_list).replace("'''", "\\'\\'\\'") script_content = read_and_concatenate(file_list).replace("'''", "\\'\\'\\'")
script_description = script_names[script_name] script_description = script_names[script_name]
@ -85,9 +86,6 @@ def main():
spam_filter = build_spam_filters(scripts) spam_filter = build_spam_filters(scripts)
with open("spamfilter.toml", "w", encoding="utf-8") as toml_file: with open("spamfilter.toml", "w", encoding="utf-8") as toml_file:
toml_file.write(spam_filter) toml_file.write(spam_filter)
config = read_file("./minimal.toml") + read_file("./security.toml") + spam_filter
with open("config.toml", "w", encoding="utf-8") as toml_file:
toml_file.write(config)
print("Stalwart TOML configuration files have been generated.") print("Stalwart TOML configuration files have been generated.")
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -49,13 +49,6 @@ compression = "lz4"
type = "internal" type = "internal"
store = "rocksdb" store = "rocksdb"
[lookup.default]
domain = "%{env:DOMAIN}%"
hostname = "%{env:HOSTNAME}%"
[oauth]
key = "%{env:OAUTH_KEY}%"
[tracer."stdout"] [tracer."stdout"]
type = "stdout" type = "stdout"
level = "info" level = "info"
@ -66,7 +59,6 @@ enable = true
#user = "stalwart-mail" #user = "stalwart-mail"
#group = "stalwart-mail" #group = "stalwart-mail"
[server.http] [authentication.fallback-admin]
headers = ["Access-Control-Allow-Origin: *", user = "admin"
"Access-Control-Allow-Methods: POST, GET, PATCH, PUT, DELETE, HEAD, OPTIONS", secret = "%{env:ADMIN_SECRET}%"
"Access-Control-Allow-Headers: Authorization, Content-Type, Accept, X-Requested-With"]

View file

@ -1,19 +0,0 @@
[queue.quota.queue-max-size]
messages = 100000
size = 10737418240 # 10gb
enable = true
[queue.throttle.recipient-limit]
key = ["rcpt_domain"]
concurrency = 5
enable = true
[session.throttle.concurrency-by-remote-ip]
key = ["remote_ip"]
concurrency = 5
enable = true
[session.throttle.rate-by-sender]
key = ["sender_domain", "rcpt"]
rate = "25/1h"
enable = true

View file

@ -1,23 +1,5 @@
[spam.header] [version]
is-spam = "X-Spam-Status: Yes" spam-filter = "1.0"
[lookup.spam-config]
add-spam = true
add-spam-result = true
learn-enable = true
learn-balance = "0.9"
learn-ham-replies = true
learn-ham-threshold = "-0.5"
learn-spam-threshold = "6.0"
threshold-spam = "5.0"
threshold-discard = "0.0"
threshold-reject = "0.0"
directory = ""
lookup = ""
[session.data]
script = [ { if = "is_empty(authenticated_as)", then = "'spam-filter'"},
{ else = "'track-replies'" } ]
[sieve.trusted.scripts.spam-filter] [sieve.trusted.scripts.spam-filter]
name = "Spam Filter" name = "Spam Filter"
@ -2464,6 +2446,21 @@ if eval "!key_exists(SPAM_DB, triplet)" {
[lookup] [lookup]
spam-config = {
"add-spam" = true,
"add-spam-result" = true,
"learn-enable" = true,
"learn-balance" = "0.9",
"learn-ham-replies" = true,
"learn-ham-threshold" = "-0.5",
"learn-spam-threshold" = "6.0",
"threshold-spam" = "5.0",
"threshold-discard" = "0.0",
"threshold-reject" = "0.0",
"directory" = "",
"lookup" = ""
}
spam-scores = {"ABUSE_SURBL" = "5.0", spam-scores = {"ABUSE_SURBL" = "5.0",
"ALLOWLIST_DKIM" = "-1.0", "ALLOWLIST_DKIM" = "-1.0",
"ALLOWLIST_DMARC" = "-7.0", "ALLOWLIST_DMARC" = "-7.0",

View file

@ -0,0 +1,14 @@
spam-config = {
"add-spam" = true,
"add-spam-result" = true,
"learn-enable" = true,
"learn-balance" = "0.9",
"learn-ham-replies" = true,
"learn-ham-threshold" = "-0.5",
"learn-spam-threshold" = "6.0",
"threshold-spam" = "5.0",
"threshold-discard" = "0.0",
"threshold-reject" = "0.0",
"directory" = "",
"lookup" = ""
}

View file

@ -1,20 +0,0 @@
[spam.header]
is-spam = "X-Spam-Status: Yes"
[lookup.spam-config]
add-spam = true
add-spam-result = true
learn-enable = true
learn-balance = "0.9"
learn-ham-replies = true
learn-ham-threshold = "-0.5"
learn-spam-threshold = "6.0"
threshold-spam = "5.0"
threshold-discard = "0.0"
threshold-reject = "0.0"
directory = ""
lookup = ""
[session.data]
script = [ { if = "is_empty(authenticated_as)", then = "'spam-filter'"},
{ else = "'track-replies'" } ]