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
-- 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
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
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
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
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
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
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