diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-15 17:35:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-15 17:35:16 +0100 |
commit | 3262b2b175bb5de9eb3dbd68279f177a1b8b3e29 (patch) | |
tree | facf99da63cd2ffd0ece9ddbac545d84dd2945a8 /src/libserver/composites.c | |
parent | 9e7c70034a91b90f09dd507b43214f84c05532ca (diff) | |
download | rspamd-3262b2b175bb5de9eb3dbd68279f177a1b8b3e29.tar.gz rspamd-3262b2b175bb5de9eb3dbd68279f177a1b8b3e29.zip |
[Feature] Implement composites policies
Diffstat (limited to 'src/libserver/composites.c')
-rw-r--r-- | src/libserver/composites.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/libserver/composites.c b/src/libserver/composites.c index 917d1d0c3..bca87d23a 100644 --- a/src/libserver/composites.c +++ b/src/libserver/composites.c @@ -194,7 +194,21 @@ rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom) nrd->ms = ms; /* By default remove symbols */ - nrd->action = (RSPAMD_COMPOSITE_REMOVE_SYMBOL|RSPAMD_COMPOSITE_REMOVE_WEIGHT); + switch (cd->composite->policy) { + case RSPAMD_COMPOSITE_POLICY_REMOVE_ALL: + default: + nrd->action = (RSPAMD_COMPOSITE_REMOVE_SYMBOL|RSPAMD_COMPOSITE_REMOVE_WEIGHT); + break; + case RSPAMD_COMPOSITE_POLICY_REMOVE_SYMBOL: + nrd->action = RSPAMD_COMPOSITE_REMOVE_SYMBOL; + break; + case RSPAMD_COMPOSITE_POLICY_REMOVE_WEIGHT: + nrd->action = RSPAMD_COMPOSITE_REMOVE_WEIGHT; + break; + case RSPAMD_COMPOSITE_POLICY_LEAVE: + nrd->action = 0; + break; + } for (;;) { t = *beg; @@ -381,3 +395,26 @@ rspamd_make_composites (struct rspamd_task *task) { g_hash_table_foreach (task->results, composites_metric_callback, task); } + + +enum rspamd_composite_policy +rspamd_composite_policy_from_str (const gchar *string) +{ + enum rspamd_composite_policy ret = RSPAMD_COMPOSITE_POLICY_UNKNOWN; + + if (strcmp (string, "remove") == 0 || strcmp (string, "remove_all") == 0 || + strcmp (string, "default") == 0) { + ret = RSPAMD_COMPOSITE_POLICY_REMOVE_ALL; + } + else if (strcmp (string, "remove_symbol") == 0) { + ret = RSPAMD_COMPOSITE_POLICY_REMOVE_SYMBOL; + } + else if (strcmp (string, "remove_weight") == 0) { + ret = RSPAMD_COMPOSITE_POLICY_REMOVE_WEIGHT; + } + else if (strcmp (string, "leave") == 0 || strcmp (string, "remove_none") == 0) { + ret = RSPAMD_COMPOSITE_POLICY_LEAVE; + } + + return ret; +} |