aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-07 18:34:36 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-07 18:34:36 +0100
commitace1f3025421e5a785a36cce6ef504eea608e980 (patch)
treed442f89fb35698b59f2ba481bbffec4cc4a6ff4d /src
parente4e44044ccca11143e5baccaca44a81592605042 (diff)
downloadrspamd-ace1f3025421e5a785a36cce6ef504eea608e980.tar.gz
rspamd-ace1f3025421e5a785a36cce6ef504eea608e980.zip
Properly deal with negative scores and nice symbols.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/spamassassin.lua32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua
index e55cd5429..a5d4c0c33 100644
--- a/src/plugins/lua/spamassassin.lua
+++ b/src/plugins/lua/spamassassin.lua
@@ -277,6 +277,8 @@ local function process_tflags(rule, flags)
rule['multiple'] = true
elseif string.match(flag, '^maxhits=(%d+)$') then
rule['maxhits'] = tonumber(string.match(flag, '^maxhits=(%d+)$'))
+ elseif flag == 'nice' then
+ rule['nice'] = true
end
end, _.drop_n(1, flags))
end
@@ -493,11 +495,15 @@ end
-- Now check all valid rules and add the according rspamd rules
-local function calculate_score(sym)
+local function calculate_score(sym, rule)
if _.all(function(c) return c == '_' end, _.take_n(2, _.iter(sym))) then
return 0.0
end
-
+
+ if rule['nice'] or (r['score'] and r['score'] < 0.0) then
+ return -1.0
+ end
+
return 1.0
end
@@ -676,8 +682,8 @@ _.each(function(k, r)
return 0
end
if r['score'] then
- local real_score = r['score'] * calculate_score(k)
- if real_score > meta_score_alpha then
+ local real_score = r['score'] * calculate_score(k, r)
+ if math.abs(real_score) > meta_score_alpha then
add_sole_meta(k, r)
end
end
@@ -699,8 +705,8 @@ _.each(function(k, r)
return 0
end
if r['score'] then
- local real_score = r['score'] * calculate_score(k)
- if real_score > meta_score_alpha then
+ local real_score = r['score'] * calculate_score(k, r)
+ if math.abs(real_score) > meta_score_alpha then
add_sole_meta(k, r)
end
end
@@ -733,8 +739,8 @@ _.each(function(k, r)
return 0
end
if r['score'] then
- local real_score = r['score'] * calculate_score(k)
- if real_score > meta_score_alpha then
+ local real_score = r['score'] * calculate_score(k, r)
+ if math.abs(real_score) > meta_score_alpha then
add_sole_meta(k, r)
end
end
@@ -752,8 +758,8 @@ _.each(function(k, r)
return sa_regexp_match(task:get_content(), r['re'], true, r)
end
if r['score'] then
- local real_score = r['score'] * calculate_score(k)
- if real_score > meta_score_alpha then
+ local real_score = r['score'] * calculate_score(k, r)
+ if math.abs(real_score) > meta_score_alpha then
add_sole_meta(k, r)
end
end
@@ -778,8 +784,8 @@ _.each(function(k, r)
return 0
end
if r['score'] then
- local real_score = r['score'] * calculate_score(k)
- if real_score > meta_score_alpha then
+ local real_score = r['score'] * calculate_score(k, r)
+ if math.abs(real_score) > meta_score_alpha then
add_sole_meta(k, r)
end
end
@@ -853,7 +859,7 @@ _.each(function(k, r)
if r['score'] then
rspamd_config:set_metric_symbol(k, r['score'], r['description'])
end
- rspamd_config:register_symbol(k, calculate_score(k), meta_cb)
+ rspamd_config:register_symbol(k, calculate_score(k, r), meta_cb)
if not atoms[k] then
atoms[k] = meta_cb
end