end
local function clusterting_idempotent_cb(task, rule)
- local action = task:get_action()
+ local verdict = lua_util.get_task_verdict(task)
local score
- if action == 'no action' then
+ if verdict == 'ham' then
score = rule.ham_mult
- elseif action == 'reject' then
+ elseif verdict == 'spam' then
score = rule.spam_mult
- elseif action == 'add header' or action == 'rewrite subject' then
+ elseif verdict == 'junk' then
score = rule.junk_mult
else
- rspamd_logger.debugm(N, task, 'skip rule %s, action=%s',
- rule.name, action)
+ rspamd_logger.debugm(N, task, 'skip rule %s, verdict=%s',
+ rule.name, verdict)
return
end
return
end
- local is_spam = not (task:get_metric_action() == 'no action')
+ local verdict = lua_util.get_task_verdict(task)
-- Update each bucket
for k, v in pairs(prefixes) do
end
local now = rspamd_util.get_time()
now = lua_util.round(now * 1000.0) -- Get milliseconds
- local mult_burst = bucket.ham_factor_burst or 1.0
- local mult_rate = bucket.ham_factor_burst or 1.0
+ local mult_burst = 1.0
+ local mult_rate = 1.0
- if is_spam then
+ if verdict == 'spam' or verdict == 'junk' then
mult_burst = bucket.spam_factor_burst or 1.0
mult_rate = bucket.spam_factor_rate or 1.0
+ elseif verdict == 'ham' then
+ mult_burst = bucket.ham_factor_burst or 1.0
+ mult_rate = bucket.ham_factor_rate or 1.0
end
lua_redis.exec_redis_script(bucket_update_id,
local default_expiry = 864000 -- 10 day by default
local keymap_schema = ts.shape{
- ['reject'] = ts.string,
- ['add header'] = ts.string,
- ['rewrite subject'] = ts.string,
- ['no action'] = ts.string
+ ['spam'] = ts.string,
+ ['junk'] = ts.string,
+ ['ham'] = ts.string,
}
-- Get reputation from ham/spam/probable hits
end
local function dkim_reputation_idempotent(task, rule)
- local action = task:get_metric_action()
+ local verdict = lua_util.get_task_verdict()
local token = {
}
local cfg = rule.selector.config
local need_set = false
-- TODO: take metric score into consideration
- local k = cfg.keys_map[action]
+ local k = cfg.keys_map[verdict]
if k then
token[k] = 1.0
-- s is for spam,
-- p is for probable spam
keys_map = {
- ['reject'] = 's',
- ['add header'] = 'p',
- ['rewrite subject'] = 'p',
- ['no action'] = 'h'
+ ['spam'] = 's',
+ ['junk'] = 'p',
+ ['ham'] = 'h'
},
symbol = 'DKIM_SCORE', -- symbol to be inserted
lower_bound = 10, -- minimum number of messages to be scored
end
local function url_reputation_idempotent(task, rule)
- local action = task:get_metric_action()
+ local verdict = lua_util.get_task_verdict(task)
local token = {
}
local cfg = rule.selector.config
local need_set = false
-- TODO: take metric score into consideration
- local k = cfg.keys_map[action]
+ local k = cfg.keys_map[verdict]
if k then
token[k] = 1.0
-- s is for spam,
-- p is for probable spam
keys_map = {
- ['reject'] = 's',
- ['add header'] = 'p',
- ['rewrite subject'] = 'p',
- ['no action'] = 'h'
+ ['spam'] = 's',
+ ['junk'] = 'p',
+ ['ham'] = 'h'
},
symbol = 'URL_SCORE', -- symbol to be inserted
lower_bound = 10, -- minimum number of messages to be scored
end
end
- local action = task:get_metric_action()
+ local verdict = lua_util.get_task_verdict(task)
local token = {
}
local need_set = false
-- TODO: take metric score into consideration
- local k = cfg.keys_map[action]
+ local k = cfg.keys_map[verdict]
if k then
token[k] = 1.0
-- s is for spam,
-- p is for probable spam
keys_map = {
- ['reject'] = 's',
- ['add header'] = 'p',
- ['rewrite subject'] = 'p',
- ['no action'] = 'h'
+ ['spam'] = 's',
+ ['junk'] = 'p',
+ ['ham'] = 'h'
},
scores = { -- how each component is evaluated
['asn'] = 0.4,
end
local function spf_reputation_idempotent(task, rule)
- local action = task:get_metric_action()
+ local verdict = lua_util.get_task_verdict(task)
local spf_record = task:get_mempool():get_variable('spf_record')
local spf_allow = task:has_symbol('R_SPF_ALLOW')
local token = {
if not spf_record or not spf_allow then return end
-- TODO: take metric score into consideration
- local k = cfg.keys_map[action]
+ local k = cfg.keys_map[verdict]
if k then
token[k] = 1.0
-- s is for spam,
-- p is for probable spam
keys_map = {
- ['reject'] = 's',
- ['add header'] = 'p',
- ['rewrite subject'] = 'p',
- ['no action'] = 'h'
+ ['spam'] = 's',
+ ['junk'] = 'p',
+ ['ham'] = 'h'
},
symbol = 'SPF_SCORE', -- symbol to be inserted
lower_bound = 10, -- minimum number of messages to be scored
end
local function generic_reputation_idempotent(task, rule)
- local action = task:get_metric_action()
+ local verdict = lua_util.get_task_verdict(task)
local cfg = rule.selector.config
local need_set = false
local token = {}
local selector_res = cfg.selector(task)
if not selector_res then return end
- local k = cfg.keys_map[action]
+ local k = cfg.keys_map[verdict]
if k then
token[k] = 1.0
-- s is for spam,
-- p is for probable spam
keys_map = {
- ['reject'] = 's',
- ['add header'] = 'p',
- ['rewrite subject'] = 'p',
- ['no action'] = 'h'
+ ['spam'] = 's',
+ ['junk'] = 'p',
+ ['ham'] = 'h'
},
lower_bound = 10, -- minimum number of messages to be scored
min_score = nil,