diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-07-13 13:07:45 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-07-13 13:07:45 +0400 |
commit | 091e84951a2b032bb2930b300ffe43eaf01a304e (patch) | |
tree | 5d5992bb7de97fdb20c04bda9fff013fbe134c82 /src/cfg_utils.c | |
parent | c6d62c095bc27aebd6c5f8dc9716467ae147fb68 (diff) | |
download | rspamd-091e84951a2b032bb2930b300ffe43eaf01a304e.tar.gz rspamd-091e84951a2b032bb2930b300ffe43eaf01a304e.zip |
Add validity detector for statfiles inside classifier.
Add euristic to detect spam/ham classes based on statfile symbol.
Diffstat (limited to 'src/cfg_utils.c')
-rw-r--r-- | src/cfg_utils.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 6bd16d620..56202d4f1 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -1044,6 +1044,62 @@ find_classifier_conf (struct config_file *cfg, const gchar *name) return NULL; } +gboolean +check_classifier_statfiles (struct classifier_config *cf) +{ + struct statfile *st; + gboolean has_other = FALSE, cur_class; + GList *cur; + + /* First check classes directly */ + cur = cf->statfiles; + while (cur) { + st = cur->data; + if (!has_other) { + cur_class = st->is_spam; + has_other = TRUE; + } + else { + if (cur_class != st->is_spam) { + return TRUE; + } + } + + cur = g_list_next (cur); + } + + if (!has_other) { + /* We have only one statfile */ + return FALSE; + } + /* We have not detected any statfile that has different class, so turn on euristic based on symbol's name */ + has_other = FALSE; + cur = cf->statfiles; + while (cur) { + st = cur->data; + if (rspamd_strncasestr (st->symbol, "spam", -1) != NULL) { + st->is_spam = TRUE; + } + else if (rspamd_strncasestr (st->symbol, "ham", -1) != NULL) { + st->is_spam = FALSE; + } + + if (!has_other) { + cur_class = st->is_spam; + has_other = TRUE; + } + else { + if (cur_class != st->is_spam) { + return TRUE; + } + } + + cur = g_list_next (cur); + } + + return FALSE; +} + /* * vi:ts=4 */ |