diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-02 12:11:12 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-02 12:11:12 +0000 |
commit | 634ae20ef109cd0416cc8ec392b4aaf7c585b4ef (patch) | |
tree | 352faf77b816b1ff277e3d856b4d8b9f971c06ab /src/plugins/lua/spamassassin.lua | |
parent | 704e0c8ca783cb6db31b09fe1c4ffc24cc3487fb (diff) | |
download | rspamd-634ae20ef109cd0416cc8ec392b4aaf7c585b4ef.tar.gz rspamd-634ae20ef109cd0416cc8ec392b4aaf7c585b4ef.zip |
[Feature] SA plugin can now set missing scores for rspamd
Diffstat (limited to 'src/plugins/lua/spamassassin.lua')
-rw-r--r-- | src/plugins/lua/spamassassin.lua | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index cbee2c90e..ef351c52e 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -86,6 +86,7 @@ local rules = {} local atoms = {} local metas = {} local scores = {} +local scores_added = {} local external_deps = {} local freemail_domains = {} local pcre_only_regexps = {} @@ -800,7 +801,7 @@ local function process_sa_conf(f) if cur_rule['meta'] and cur_rule['symbol'] then valid_rule = true end elseif words[1] == "describe" and valid_rule then cur_rule['description'] = words_to_re(words, 2) - elseif words[1] == "score" and valid_rule then + elseif words[1] == "score" then scores[words[2]] = parse_score(words) elseif words[1] == 'freemail_domains' then _.each(function(dom) @@ -1151,10 +1152,10 @@ local function post_process() --rspamd_config:register_symbol(k, calculate_score(k), f) atoms[k] = f end, - _.filter(function(k, r) + _.filter(function(k, r) return r['type'] == 'header' and r['header'] - end, - rules)) + end, + rules)) -- Custom function rules _.each(function(k, r) @@ -1293,7 +1294,9 @@ local function post_process() rspamd_config:set_metric_symbol({ name = k, score = r['score'], description = r['description'], + priority = 1, one_shot = true }) + scores_added[k] = 1 end rspamd_config:register_symbol(k, calculate_score(k, r), meta_cb) r['expression'] = expression @@ -1343,8 +1346,16 @@ local function post_process() _.filter(function(k, r) return r['type'] == 'meta' end, - rules)) + rules)) + -- Set missing symbols + _.each(function(key, score) + if not scores_added[key] then + rspamd_config:set_metric_symbol({ + name = key, score = score, + priority = 1}) + end + end, scores) if freemail_domains then freemail_trie = rspamd_trie.create(freemail_domains) rspamd_logger.infox(rspamd_config, 'loaded %1 freemail domains definitions', |