Rspamd使用通用配置语言(UCL)进行配置。Rspamd定义了几个变量和宏来扩展UCL功能。
C模块启动项在options.inc文件中配置。
# Included from top-level .conf file
filters = "chartable,dkim,spf,surbl,regexp,fuzzy_check";
在filters定义加载模块。
Lua模块启动项在common.conf文件中配置
# A common rspamd configuration file
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
# You can modify '$LOCAL_CONFDIR/rspamd.conf.local.override' to redefine
# parameters defined on the top level
#
# You can modify '$LOCAL_CONFDIR/rspamd.conf.local' to add
# parameters defined on the top level
#
# For specific modules or configuration you can also modify
# '$LOCAL_CONFDIR/local.d/file.conf' - to add your options or rewrite defaults
# '$LOCAL_CONFDIR/override.d/file.conf' - to override the defaults
#
# See https://rspamd.com/doc/tutorials/writing_rules.html for details
...
modules {
path = "$PLUGINSDIR/lua/"
}
在modules里定义需要加载的模块。
该模块允许从消息文本部分的不同Unicode脚本中查找字符数。如果消息无法转换为UTF-8(例如,当它包含无法识别的字符集定义)时,该模块只检查ASCII和非ASCII字符之间的转换次数。
在modules.d/chartable.conf中配置该模块
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
# You can modify '$LOCAL_CONFDIR/rspamd.conf.local.override' to redefine
# parameters defined on the top level
#
# You can modify '$LOCAL_CONFDIR/rspamd.conf.local' to add
# parameters defined on the top level
#
# For specific modules or configuration you can also modify
# '$LOCAL_CONFDIR/local.d/file.conf' - to add your options or rewrite defaults
# '$LOCAL_CONFDIR/override.d/file.conf' - to override the defaults
#
# See https://rspamd.com/doc/tutorials/writing_rules.html for details
chartable {
threshold = 0.300000;
symbol = "R_MIXED_CHARSET";
.include(try=true,priority=5) "${DBDIR}/dynamic/chartable.conf"
.include(try=true,priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/chartable.conf"
.include(try=true,priority=10) "$LOCAL_CONFDIR/override.d/chartable.conf"
}
默认情况下Rspamd将扫描结果与阈值threshold进行比较。
另外,可以通过定义lua脚本完成其他功能。例如,可以使用某些密钥来签出出站邮件。
要使用此功能,可以使用一个选项sign_condition来定义Lua脚本,用于分析任务对象并返回签名参数(如果需要签名)
key:域的私钥路径
selector:DKIM选择器值
domain:用于签名的域名
如果不需要签名,那么这个函数应该返回nil或false。这是一个learn_condition脚本的示例,用于对来自example.com域的邮件进行签名:
#dkim.conf
sign_condition =<
该模块旨在检查存储在模糊存储工作者中的特定模糊模式的消息。同时,该模块负责用消息模式学习模糊存储。
模糊规则被定义为一组规则定义。每个规则都必须有服务器列表来检查或学习,以及一组标记和可选参数。下面是规则设置的一个例子:
#fuzzy_check.conf
rule "FUZZY_CUSTOM" {
# List of servers, can be an array or multi-value item
servers = "127.0.0.1:11335";
# List of additional mime types to be checked in this fuzzy ("*" for any)
mime_types = ["application/*", "*/octet-stream"];
# Maximum global score for all maps
max_score = 20.0;
# Ignore flags that are not listed in maps for this rule
skip_unknown = yes;
# If this value is false, then allow learning for this fuzzy rule
read_only = no;
# Fast hash type
algorithm = "mumhash";
}
SURBL该模块根据一个DNS列表扫描消息中的URL
下面是禁用SURBL配置:
#surbl.conf
rules {
"RAMBLER_URIBL" {
enabled = false;#enabled = true
}
}
该模块提供与病毒扫描程序的集成,目前支持ClamAV等。配置在antivirus.conf中
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
# You can modify '$LOCAL_CONFDIR/rspamd.conf.local.override' to redefine
# parameters defined on the top level
#
# You can modify '$LOCAL_CONFDIR/rspamd.conf.local' to add
# parameters defined on the top level
#
# For specific modules or configuration you can also modify
# '$LOCAL_CONFDIR/local.d/file.conf' - to add your options or rewrite defaults
# '$LOCAL_CONFDIR/override.d/file.conf' - to override the defaults
#
# See https://rspamd.com/doc/tutorials/writing_rules.html for details
antivirus {
# multiple scanners could be checked, for each we create a configuration block with an arbitrary name
clamav {
# If set force this action if any virus is found (default unset: no action is forced)
# action = "reject";
# if `true` only messages with non-image attachments will be checked (default true)
attachments_only = true;
# If `max_size` is set, messages > n bytes in size are not scanned
#max_size = 20000000;
# symbol to add (add it to metric if you want non-zero weight)
symbol = "CLAM_VIRUS";
# type of scanner: "clamav", "fprot", "sophos" or "savapi"
type = "clamav";
# For "savapi" you must also specify the following variable
#product_id = 12345;
# You can enable logging for clean messages
#log_clean = true;
# servers to query (if port is unspecified, scanner-specific default is used)
# can be specified multiple times to pool servers
# can be set to a path to a unix socket
# Enable this in local.d/antivirus.conf
#servers = "127.0.0.1:3310";
# if `patterns` is specified virus name will be matched against provided regexes and the related
# symbol will be yielded if a match is found. If no match is found, default symbol is yielded.
patterns {
# symbol_name = "pattern";
JUST_EICAR = "^Eicar-Test-Signature$";
}
# `whitelist` points to a map of IP addresses. Mail from these addresses is not scanned.
whitelist = "/etc/rspamd/antivirus.wl";
}
.include(try=true,priority=5) "${DBDIR}/dynamic/antivirus.conf"
.include(try=true,priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/antivirus.conf"
.include(try=true,priority=10) "$LOCAL_CONFDIR/override.d/antivirus.conf"
}
该模块检查扫描的电子邮件的ARC签名和密封。
配置示例如下:
#arc.conf
# If false, messages with empty envelope from are not signed
allow_envfrom_empty = true;
# If true, envelope/header domain mismatch is ignored
allow_hdrfrom_mismatch = false;
# If true, multiple from headers are allowed (but only first is used)
allow_hdrfrom_multiple = false;
# If true, username does not need to contain matching domain
allow_username_mismatch = false;
# If false, messages from authenticated users are not selected for signing
auth_only = true;
# Default path to key, can include '$domain' and '$selector' variables
path = "/var/lib/rspamd/arc/$domain.$selector.key";
# Default selector to use
selector = "arc";
# If false, messages from local networks are not selected for signing
sign_local = true;
# Symbol to add when message is signed
symbol_signed = "ARC_SIGNED";
# Whether to fallback to global config
try_fallback = true;
# Domain to use for ARC signing: can be "header" or "envelope"
use_domain = "header";
# Whether to normalise domains to eSLD
use_esld = true;
# Whether to get keys from Redis
use_redis = false;
# Hash for ARC keys in Redis
key_prefix = "ARC_KEYS";
# map of domains -> names of selectors (since rspamd 1.5.3)
#selector_map = "/etc/rspamd/arc_selectors.map";
# map of domains -> paths to keys (since rspamd 1.5.3)
#path_map = "/etc/rspamd/arc_paths.map";
# Domain specific settings
domain {
example.com {
# Private key path
path = "/var/lib/rspamd/arc/example.key";
# Selector
selector = "ds";
}
}
该模块可以收集:扫描邮件的发件人/收件人/分数和元数据,如DKIM / DMARC / bayes /模糊状态以及有关URL和附件的信息。配置示例如下:
clickhouse {
# Push update when 1000 records are collected (1000 if unset)
limit = 1000;
# IP:port of Clickhouse server ("localhost:8123" if unset)
server = "localhost:8123";
# Timeout to wait for response (5 seconds if unset)
timeout = 5;
# How many bits of sending IP to mask in logs for IPv4 (19 if unset)
ipmask = 19;
# How many bits of sending IP to mask in logs for IPv6 (48 if unset)
ipmask6 = 48;
# Record URL paths? (default false)
full_urls = false;
# This parameter points to a map of domain names
# If a message has a domain in this map in From: header and DKIM signature,
# record general metadata in a table named after the domain
#from_tables = "/etc/rspamd/clickhouse_from.map";
# These are tables used to store data in Clickhouse
# Table used to store ASN information (default unset: not collected)
#asn_table = "rspamd_asn"; # default unset
# The following table names are set by default
# Set these if you use want to use different table names
#table = "rspamd"; # general metadata
#attachments_table = "rspamd_attachments"; # attachment metadata
#urls_table = "rspamd_urls"; # url metadata
# These are symbols of other checks in Rspamd
# Set these if you use non-default symbol names (unlikely)
#bayes_spam_symbols = ["BAYES_SPAM"];
#bayes_ham_symbols = ["BAYES_HAM"];
#fann_symbols = ["FANN_SCORE"];
#fuzzy_symbols = ["FUZZY_DENIED"];
#whitelist_symbols = ["WHITELIST_DKIM", "WHITELIST_SPF_DKIM", "WHITELIST_DMARC"];
#dkim_allow_symbols = ["R_DKIM_ALLOW"];
#dkim_reject_symbols = ["R_DKIM_REJECT"];
#dmarc_allow_symbols = ["DMARC_POLICY_ALLOW"];
#dmarc_reject_symbols = ["DMARC_POLICY_REJECT", "DMARC_POLICY_QUARANTINE"];
}
该模块执行DCC查找以确定消息是否为批量接收。
该模块提供了一种相对简单的配置DKIM签名的方法。DKIM签名模块根据可以用各种设置修改的预定义策略选择签名域和选择器。该政策的描述如下:
配置如下:
# dkim_signing.conf
# If false, messages with empty envelope from are not signed
allow_envfrom_empty = true;
# If true, envelope/header domain mismatch is ignored
allow_hdrfrom_mismatch = false;
# If true, multiple from headers are allowed (but only first is used)
allow_hdrfrom_multiple = false;
# If true, username does not need to contain matching domain
allow_username_mismatch = false;
# If false, messages from authenticated users are not selected for signing
auth_only = true;
# Default path to key, can include '$domain' and '$selector' variables
path = "/var/lib/rspamd/dkim/$domain.$selector.key";
# Default selector to use
selector = "dkim";
# If false, messages from local networks are not selected for signing
sign_local = true;
# Map file of IP addresses/subnets to consider for signing
# sign_networks = "/some/file"; # or url
# Symbol to add when message is signed
symbol = "DKIM_SIGNED";
# Whether to fallback to global config
try_fallback = true;
# Domain to use for DKIM signing: can be "header" (MIME From), "envelope" (SMTP From) or "auth" (SMTP username)
use_domain = "header";
# Domain to use for DKIM signing when sender is in sign_networks ("header"/"envelope"/"auth")
#use_domain_sign_networks = "header";
# Domain to use for DKIM signing when sender is a local IP ("header"/"envelope"/"auth")
#use_domain_sign_local = "header";
# Whether to normalise domains to eSLD
use_esld = true;
# Whether to get keys from Redis
use_redis = false;
# Hash for DKIM keys in Redis
key_prefix = "DKIM_KEYS";
# map of domains -> names of selectors (since rspamd 1.5.3)
#selector_map = "/etc/rspamd/dkim_selectors.map";
# map of domains -> paths to keys (since rspamd 1.5.3)
#path_map = "/etc/rspamd/dkim_paths.map";
# Domain specific settings
domain {
example.com {
# Private key path
path = "/var/lib/rspamd/dkim/example.key";
# Selector
selector = "ds";
}
}
该模块实现基于DNS或静态列表的电子邮件过滤。模块的配置是很常见的surbl模块。您可以定义多个rule部分,可以定义静态地图或DNS列表:
# emails.conf
rule "EMAILS_DNSBL" {
dnsbl = "emailbl.rambler.ru";
domain_only = true;
}
rule "EMAILS_STATIC" {
map = "/etc/rspamd/bad_emails.list";
}
该模块的目的是强制执行一个操作元素在本单元规则中有效:
配置示例如下:
#force_actions.conf
rules {
# For each condition we want to force an action on we define a rule
# Rule is given a descriptive name
MY_WHITELIST {
# This is the action we want to force
action = "no action";
# If the following combination of symbols is present:
expression = "IS_IN_WHITELIST & !CLAM_VIRUS & !FPROT_VIRUS";
}
WHITELIST_EXCEPTION {
action = "reject";
expression = "IS_IN_WHITELIST & (CLAM_VIRUS | FPROT_VIRUS)";
# message setting sets SMTP message returned by mailer
message = "Rejected due to suspicion of virus";
}
DCC_BULK {
action = "rewrite subject";
# Here expression is just one symbol
expression = "DCC_BULK";
# subject setting sets metric subject for rewrite subject action
subject = "[BULK] %s";
# honor_action setting define actions we don't want to override
honor_action = ["reject", "soft reject", "add header"];
}
BAYES_SPAM_UPGRADE {
action = "add header";
expression = "BAYES_SPAM";
# require_action setting defines actions that will be overridden
require_action = ["no action", "greylist"];
}
}
该模块旨在从一些孤立的垃圾邮件收集中收集模糊散列,并将其发布到使用复制协议的本地模糊存储。
要启用收集,您需要在垃圾邮件捕获器上设置Rspamd实例,其工作在仅收集模式。最基本配置如下:
# We skip common section and leave only relevant configuration
worker "fuzzy" {
bind_socket = "*:11335";
count = 1;
# Important to enable this
collection_only = true;
# This is needed to sign collections (will discuss later)
collection_signkey = "utenidt7xdkys5ite89w4gntrdgbsd9gp9rzjjtzzzwx693cei8y";
# This is needed to encrypt communication between collector and this storage
collection_keypair = {
pubkey = "ffg1m6rqi3doy7qggqbr4qjwxw6ahy56nr4zs47doz3nn6euhsty";
privkey = "y6qjkr4htunjwm7i9cxzzu413tnobe8cjmgmo916i1hdy4yh1s4y";
id = "eg6ccqr91bt7bkfspufk5kgrejr8sriypkixo5a5xje83nhd58jnjnusr9ppcjtkgyqc7x1fyqpqkazxk6wnnf9buuxbguspyme7trn";
encoding = "base32";
algorithm = "curve25519";
type = "kex";
}
# Allow local updates
allow_update = ["localhost"];
# Collection should be performed once per minute
sync = 1m;
}
# Needed for `rspamc fuzzy_add`
worker "controller" {
bind_socket = "localhost:11334";
secure_ips = "127.0.0.1";
}
# Needed to send hashes to local storage
fuzzy_check {
min_bytes = 100;
rule "main" {
timeout = 1s;
retransmits = 7;
servers = "localhost:11335";
symbol = "FUZZY_UNKNOWN";
mime_types = "*";
max_score = 20.0;
read_only = no;
skip_unknown = yes;
algorithm = "mumhash";
fuzzy_map = {
FUZZY_DENIED {
max_score = 20.0;
flag = 1;
}
FUZZY_PROB {
max_score = 10.0;
flag = 2;
}
FUZZY_WHITE {
max_score = 2.0;
flag = 3;
}
}
learn_condition =<
该模块的目的是延迟垃圾邮件得分高于灰名单动作阈值的消息。
Greylisting模块为Redis中的每个消息保存2个哈希值:
存储应用了某个掩码的IP地址:它是/19针对IPv4和/64IPv6的。每个散列都有自己的时间戳,Rspamd会检查以下时间:
配置项在greylist.conf中:
要使用默认设置启用模块,您需要至少定义redis服务器来存储灰名单数据:
#greylist.conf
servers = "127.0.0.1:6379";
该模块旨在将历史记录存储在Redis列表中,对字段进行更细粒度的控制,可选压缩和开箱即用的群集支持。配置如下:
#history_redis.conf
servers = 127.0.0.1:6379; # Redis server to store history
key_prefix = "rs_history"; # Default key name
nrows = 2000; # Default rows limit
compress = true; # Use zstd compression when storing data in redis
IP分数在Redis中存储记录,IP Score需要ASN模块的查询信息。默认配置如下:
#ip_score.conf
# how each action is treated in scoring
actions {
reject = 1.0;
"add header" = 0.25;
"rewrite subject" = 0.25;
"no action" = 1.0;
}
# how each component is evaluated
scores {
asn = 0.5;
country = 0.1;
ipnet = 0.8;
ip = 1.0;
}
# prefix for asn hashes
asn_prefix = "a:";
# prefix for country hashes
country_prefix = "c:";
# hash table in redis used for storing scores
hash = "ip_score";
# prefix for subnet hashes
ipnet_prefix = "n:";
# minimum number of messages to be scored
lower_bound = 10;
# the metric to score (usually "default")
metric = "default";
# upper and lower bounds at which to cap total score
#max_score = 10;
#min_score = -5;
# Amount to divide subscores by before applying tanh
score_divisor = 10;
# list of servers (or configure redis globally)
#servers = "localhost";
# symbol to be inserted
symbol = "IP_SCORE";
您还必须为公制注册一些权重。例如,您可以将以下内容添加到metrics.conf:
symbol "IP_SCORE" {
weight = 2.0;
description = "IP reputation";
}
元数据导出器处理一组规则,它们识别有趣的消息,并将信息推送到外部服务(目前支持的是Redis Pub / Sub,HTTP POST&SMTP;用户定义的后端也可以使用)。可能的应用程序包括隔离,记录,警报和反馈回路。对于配置中定义的每个规则:
默认配置如下:
metadata_exporter {
# Each rule defines some export process
rules {
# The following rule posts JSON-formatted metadata at the defined URL
# when it sees a rejected mail from an authenticated user
MY_HTTP_ALERT_1 {
backend = "http";
url = "http://127.0.0.1:8080/foo";
# More about selectors and formatters later
selector = "is_reject_authed";
formatter = "json";
}
# This rule posts all messages to a Redis Pub/Sub channel
MY_REDIS_PUBSUB_1 {
backend = "redis_pubsub";
channel = "foo";
# Default formatter and selector is used
}
# This rule sends an e-Mail alert over SMTP containing message metadata
# when it sees a rejected mail from an authenticated user
MY_EMAIL_1 {
backend = "send_mail";
smtp = "127.0.0.1";
mail_to = "[email protected]";
selector = "is_reject_authed";
formatter = "email_alert";
}
}
}
该模块从rspamd手机统局数据,并将其提供到外部系统。Non-backend-specific配置如下
#metric_exporter.conf
# Backend: just "graphite" for now - MUST be set
backend = "graphite";
# List of metrics to export - MUST be set.
# See next section for list of metrics
metrics = [
"ham_count",
"spam_count",
];
# Below settings are optional and values shown will be used as defaults if these are unset:
# Statefile: Path to file at which to persist last run information
statefile = "$DBDIR/metric_exporter_last_push";
# Timeout in seconds for pushing stats to backend
timeout = 15;
# Interval in seconds at which stats should be pushed
interval = 120;
另外,backend-specific配置如下
# Hostname for Carbon: "localhost" if unset
host = "localhost";
# Port for Carbon: 2003 if unset
port = 2003;
# Prefix for metric names: "rspamd" if unset
metric_prefix = "rspamd";
该模块是抑制某些特定域的DKIM签名的INVALID_MSGID消息的(格式错误消息id)和MISSING_MID(缺少消息id)规则。默认配置如下:
#mid.conf
mid = {
url = [
"${CONFDIR}/mid.inc",
];
}
该模块提供一种比较简单的方法来配置通过Rmilter来添加/删除头文件。默认配置如下:
# milter_headers.conf:
# Options
# Rmilter compatibility option (default false) (enables x-spamd-result, x-rspamd-server & x-rspamd-queue-id)
# extended_spam_headers = true;
# List of headers to be enabled for authenticated users (default empty)
# authenticated_headers = ["authentication-results"];
# List of headers to be enabled for local IPs (default empty)
# local_headers = ["x-spamd-bar"];
# Set false to always add headers for local IPs (default true)
# skip_local = true;
# Set false to always add headers for authenticated users (default true)
# skip_authenticated = true;
# Routines to use- this is the only required setting (may be omitted if using extended_spam_headers)
use = ["x-spamd-bar", "authentication-results"];
# this is where we may configure our selected routines
routines {
# settings for x-spamd-bar routine
x-spamd-bar {
# effectively disables negative spambar
negative = "";
}
# other routines...
}
custom {
# user-defined routines: more on these later
}
Multmap
该模块处理基于由Rspamd动态更新并被调用的不同类型的列表的规则maps。对于通过文件进行组织的白名单,黑名单和其他列表很有用。配置:
# multimap.conf
symbol {
type = "type";
map = "url";
# [optional params...]
}
symbol1 {
type = "type";
map = "from";
# [optional params...]
}
强制属性有:
可选属性:
该模块报告潜在的被钓鱼网址。默认配置如下
# Phishing.conf
phishing {
symbol = "R_PHISHING"; # Default symbol
# Check only domains from this list
domains = "file:///path/to/map";
# Make exclusions for known redirectors
# Entry format: URL/path for map, colon, name of symbol
redirector_domains = [
"${CONFDIR}/redirectors.map:REDIRECTOR_FALSE"
];
# For certain domains from the specified strict maps
# use another symbol for phishing plugin
strict_domains = [
"${CONFDIR}/paypal.map:PAYPAL_PHISHING"
];
}
该模块限制来自某些发件人的邮件,将某些IP地址的某些收件人从这些参数中分离出来,将这些参数组合到一个单独的限制内。在默认配置中,没有指定缓存服务器,因此,除非将该选项添加到配置中,否则该模块将无法正常工作。
Ratelimit 模块支持以下配置选项:
rates - 表格中允许的利率表格:
type = [burst,leak];
type可以是下面的一种:
该模块支持检查消息的发送方的IPv4 / IPv6源地址与一组RBL以及各种不太常规的使用RBL的方法:对于接收头中的地址; 针对发件人的反向DNS名称和SMTP时间下用于HELO / EHLO的参数。配置结构如下:
# rbl.conf
# default settings defined here
rbls {
# 'rbls' subsection under which the RBL definitions are nested
an_rbl {
# rbl-specific subsection
}
# ...
}
默认设置定义了使用RBL的方式,除非在特定于RBL的子节中被覆盖。
可以为以下参数设置默认值(如果未设置这些参数,则使用默认值),请注意,这些参数可能会在默认配置中重新定义):
RBL特定小节的结构如下:
# Descriptive name of RBL or symbol if symbol is not defined.
an_rbl {
# Explicitly defined symbol
symbol = "SOME_SYMBOL";
# RBL-specific defaults (where different from global defaults)
#The global defaults may be overridden using 'helo' to override 'default_helo' and so on.
ipv6 = true;
ipv4 = false;
# Address used for RBL-testing
rbl = "v6bl.example.net";
# Possible responses from RBL and symbols to yield
returncodes {
# Name_of_symbol = "address";
EXAMPLE_ONE = "127.0.0.1";
EXAMPLE_TWO = "127.0.0.2";
}
}
该模块的目的是对一个Received header的邮件进行简单的检查。这些检查背后的想法是,合法邮件可能不止一个header,还有一些糟糕的模式,比如动态或宽带,这些都是被黑客入侵的用户机器的垃圾邮件所常见的。配置示例如下:
once_received {
# lines are used to negate this module for certain hosts
good_host = "^mail";
# lines are used to specify certain bad patterns
bad_host = "static";
bad_host = "dynamic";
# for emails with bad patterns or with unresolvable hostnames
symbol_strict = "ONCE_RECEIVED_STRICT";
# for generic one received mail
symbol = "ONCE_RECEIVED";
# define a list of networks for which once_received checks should be excluded.
whitelist = "/tmp/ip.map";
}
该模块收集经过身份验证的用户发送的消息的message-id头,并将相应的散列存储到Redis中,后者将在可配置的时间之后过期(默认为1天)。此外,它还将所有接收到的消息和检查的头信息都进行了散列(即。消息发送到我们的系统发出的消息的响应中)-并产生一个符号,可以用来调整评分或强制采取行动(很可能是“不采取行动”)根据配置。
符号(REPLY)符号在标识为回复的消息上产生。
# replies.conf
# This setting is non-default & may be desirable
#action = "no action";
# These are default settings you may want to change
expire = 86400;
key_prefix = "rr";
message = "Message is reply to one we originated";
symbol = "REPLY";
# Module specific redis configuration
#servers = "localhost";
模块允许加载rspamd规则,调整符号分数和操作,而不需要完全守护程序重新启动。 rspamd_update提供了在不更新rspamd本身的情况下更新新规则和分数更改的方法。
更新结构:
rules- 将加载到rspamd中的lua代码片段列表,可以使用rspamd_config全局注册新的规则
示例如下:
rules = {
test =<
该模块旨在为rspamd读取和采用spamassassin规则。该插件的目标是在rspamd内本地重用现有的spamassassin规则。此插件的配置非常简单:只需将所有SA规则粘贴到单个文件中,并将其提供给spamassassin模块:
spamassassin {
ruleset = "/path/to/file";
# Limit search size to 100 kilobytes for all regular expressions
match_limit = 100k;
# Those regexp atoms will not be passed through hyperscan:
pcre_only = ["RULE1", "__RULE2"];
}
使用spamtrap模块,您可以捕获垃圾邮件陷阱的电子邮件,甚至捕获所有的域。配置参数如下:
map:您可以定义一个正则表达式映射,该映射将自动禁用此模块的Redis
action = "no action";
score = 1.0;
learn_fuzzy = true;
learn_spam = true;
map = file://$LOCAL_CONFDIR/maps.d/spamtrap.map;
enabled = true;
这个模块为SURBL模块提供了一个连接到引用或参照重定向。要启用它,redirector_hosts_map必须在SURBL配置中设置:
# surbl.conf
redirector_hosts_map = "/etc/rspamd/redirectors.inc";
可以设置以下配置来控制URL重定向器模块的行为:
# url_redirector.conf
# How long to cache dereferenced links in Redis (default 1 day)
expire = 1d;
# Timeout for HTTP requests (10 seconds by default)
timeout = 10; # 10 seconds by default
# How many nested redirects to follow (default 1)
nested_limit = 1;
# Prefix for keys in redis (default "rdr:")
key_prefix = "rdr:";
# Check SSL certificates (default false)
check_ssl = false;
max_size = 10k; # maximum body to process
URL信誉插件过滤URL的相关性,并为持久存在于Redis中的所选TLD分配动态声誉(有关配置redis的信息,请参阅此处)。要启用它,应在以下位置设置以下内容/etc/rspamd/local.d/url_reputation.conf:
# url_reputation.conf
enabled = true;
配置示例如下:
# url_reputation.conf
# Key prefix for redis - default "Ur."
key_prefix = "Ur.";
# Symbols to insert - defaults as shown
symbols {
white = "URL_REPUTATION_WHITE";
black = "URL_REPUTATION_BLACK";
grey = "URL_REPUTATION_GREY";
neutral = "URL_REPUTATION_NEUTRAL";
}
# DKIM/DMARC/SPF allow symbols - defaults as shown
foreign_symbols {
dmarc = "DMARC_POLICY_ALLOW";
dkim = "R_DKIM_ALLOW";
spf = "R_SPF_ALLOW";
}
# SURBL metatags to ignore - default as shown
ignore_surbl = ["URIBL_BLOCKED", "DBL_PROHIBIT", "SURBL_BLOCKED"];
# Amount of samples required for scoring - default 5
threshold = 5;
# Maximum number of TLDs to update reputation on (default 1)
update_limit = 1;
# Maximum number of TLDs to query reputation on (default 100)
query_limit = 100;
# If true, try to find most 'relevant' URL (default true)
relevance = true;
白名单模块旨在否定或增加已知来自受信任来源的某些消息的分数。白名单配置非常简单。您可以在rules段内定义一组规则 。每个规则必须具有domains指定域的映射(如果指定为字符串)或域的直接列表(如果指定为数组)的属性。
允许以下约束:
三种工作模式:
可选设置:
配置示例如下:
# whitelist.conf
whitelist {
rules {
WHITELIST_SPF = {
valid_spf = true;
domains = [
"github.com",
];
score = -1.0;
}
WHITELIST_DKIM = {
valid_dkim = true;
domains = [
"github.com",
];
score = -2.0;
}
WHITELIST_SPF_DKIM = {
valid_spf = true;
valid_dkim = true;
domains = [
["github.com", 2.0],
];
score = -3.0;
}
STRICT_SPF_DKIM = {
valid_spf = true;
valid_dkim = true;
strict = true;
domains = [
["paypal.com", 2.0],
];
score = -3.0; # For strict rules negative score should be defined
}
BLACKLIST_DKIM = {
valid_spf = true;
valid_dkim = true;
blacklist = true;
domains = "/some/file/blacklist_dkim.map";
score = 3.0; # Note positive score here
}
WHITELIST_DMARC_DKIM = {
valid_dkim = true;
valid_dmarc = true;
domains = [
"github.com",
];
score = -7.0;
}
}
}