aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conf/composites.conf89
-rw-r--r--src/libserver/cfg_rcl.c33
2 files changed, 78 insertions, 44 deletions
diff --git a/conf/composites.conf b/conf/composites.conf
index 7c81fff35..288b08d58 100644
--- a/conf/composites.conf
+++ b/conf/composites.conf
@@ -14,47 +14,50 @@
#
# See https://rspamd.com/doc/tutorials/writing_rules.html for details
-composite "FORGED_RECIPIENTS_MAILLIST" {
- expression = "FORGED_RECIPIENTS & -MAILLIST";
-}
-composite "FORGED_SENDER_MAILLIST" {
- expression = "FORGED_SENDER & -MAILLIST";
-}
-composite "FORGED_SENDER_FORWARDING" {
- expression = "FORGED_SENDER & g:forwarding";
-}
-composite "SPF_FAIL_FORWARDING" {
- expression = "g:forwarding & (R_SPF_SOFTFAIL | R_SPF_FAIL)";
- policy = "remove_weight";
-}
-composite "DMARC_POLICY_ALLOW_WITH_FAILURES" {
- expression = "DMARC_POLICY_ALLOW & (R_SPF_SOFTFAIL | R_SPF_FAIL | R_DKIM_REJECT)";
- policy = "remove_weight";
-}
-composite "FORGED_RECIPIENTS_FORWARDING" {
- expression = "FORGED_RECIPIENTS & g:forwarding";
-}
-composite "FORGED_SENDER_VERP_SRS" {
- expression = "FORGED_SENDER & (ENVFROM_PRVS | ENVFROM_VERP)";
-}
-composite "FORGED_MUA_MAILLIST" {
- expression = "g:mua and -MAILLIST";
-}
-composite "RBL_SPAMHAUS_XBL_ANY" {
- expression = "RBL_SPAMHAUS_XBL & RECEIVED_SPAMHAUS_XBL";
-}
-composite "AUTH_NA" {
- expression = "R_DKIM_NA & R_SPF_NA & DMARC_NA";
- score = 1.0;
- policy = "remove_weight";
-}
-composite "DKIM_MIXED" {
- expression = "-R_DKIM_ALLOW & (R_DKIM_DNSFAIL | R_DKIM_PERMFAIL | R_DKIM_REJECT)"
- policy = "remove_weight";
-}
-composite "MAIL_RU_MAILER_BASE64" {
- expression = "MAIL_RU_MAILER & (FROM_EXCESS_BASE64 | REPLYTO_EXCESS_BASE64 | SUBJ_EXCESS_BASE64 | TO_EXCESS_BASE64)";
-}
+composites {
+
+ FORGED_RECIPIENTS_MAILLIST {
+ expression = "FORGED_RECIPIENTS & -MAILLIST";
+ }
+ FORGED_SENDER_MAILLIST {
+ expression = "FORGED_SENDER & -MAILLIST";
+ }
+ FORGED_SENDER_FORWARDING {
+ expression = "FORGED_SENDER & g:forwarding";
+ }
+ SPF_FAIL_FORWARDING {
+ expression = "g:forwarding & (R_SPF_SOFTFAIL | R_SPF_FAIL)";
+ policy = "remove_weight";
+ }
+ DMARC_POLICY_ALLOW_WITH_FAILURES {
+ expression = "DMARC_POLICY_ALLOW & (R_SPF_SOFTFAIL | R_SPF_FAIL | R_DKIM_REJECT)";
+ policy = "remove_weight";
+ }
+ FORGED_RECIPIENTS_FORWARDING {
+ expression = "FORGED_RECIPIENTS & g:forwarding";
+ }
+ FORGED_SENDER_VERP_SRS {
+ expression = "FORGED_SENDER & (ENVFROM_PRVS | ENVFROM_VERP)";
+ }
+ FORGED_MUA_MAILLIST {
+ expression = "g:mua and -MAILLIST";
+ }
+ RBL_SPAMHAUS_XBL_ANY {
+ expression = "RBL_SPAMHAUS_XBL & RECEIVED_SPAMHAUS_XBL";
+ }
+ AUTH_NA {
+ expression = "R_DKIM_NA & R_SPF_NA & DMARC_NA";
+ score = 1.0;
+ policy = "remove_weight";
+ }
+ DKIM_MIXED {
+ expression = "-R_DKIM_ALLOW & (R_DKIM_DNSFAIL | R_DKIM_PERMFAIL | R_DKIM_REJECT)"
+ policy = "remove_weight";
+ }
+ MAIL_RU_MAILER_BASE64 {
+ expression = "MAIL_RU_MAILER & (FROM_EXCESS_BASE64 | REPLYTO_EXCESS_BASE64 | SUBJ_EXCESS_BASE64 | TO_EXCESS_BASE64)";
+ }
-.include(try=true; priority=1; duplicate=merge) "$LOCAL_CONFDIR/local.d/composites.conf"
-.include(try=true; priority=10) "$LOCAL_CONFDIR/override.d/composites.conf"
+ .include(try=true; priority=1; duplicate=merge) "$LOCAL_CONFDIR/local.d/composites.conf"
+ .include(try=true; priority=10) "$LOCAL_CONFDIR/override.d/composites.conf"
+}
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index b8423bb5d..6f9e66d5c 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1505,6 +1505,29 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
return TRUE;
}
+static gboolean
+rspamd_rcl_composites_handler (rspamd_mempool_t *pool,
+ const ucl_object_t *obj,
+ const gchar *key,
+ gpointer ud,
+ struct rspamd_rcl_section *section,
+ GError **err)
+{
+ ucl_object_iter_t it = NULL;
+ const ucl_object_t *cur;
+ gboolean success = TRUE;
+
+ while ((cur = ucl_iterate_object (obj, &it, true))) {
+ success = rspamd_rcl_composite_handler(pool, cur, ucl_object_key(cur), ud, section, err);
+ if (!success) {
+ break;
+ }
+ }
+
+ return success;
+}
+
+
struct rspamd_rcl_section *
rspamd_rcl_add_section (struct rspamd_rcl_section **top,
const gchar *name, const gchar *key_attr, rspamd_rcl_handler_t handler,
@@ -2317,7 +2340,7 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
"Sets if this statfile contains spam samples");
/**
- * Composites handler
+ * Composites handlers
*/
sub = rspamd_rcl_add_section_doc (&new,
"composite", "name",
@@ -2327,6 +2350,14 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
TRUE,
cfg->doc_strings,
"Rspamd composite symbols");
+ sub = rspamd_rcl_add_section_doc (&new,
+ "composites", NULL,
+ rspamd_rcl_composites_handler,
+ UCL_OBJECT,
+ FALSE,
+ TRUE,
+ cfg->doc_strings,
+ "Rspamd composite symbols");
/**
* Lua handler