Skip to content

Commit

Permalink
[Rework] Migrate from ip_score to reputation
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Jul 17, 2019
1 parent a767535 commit 48d68b1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conf/composites.conf
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ composites {

IP_SCORE_FREEMAIL {
description = "Negate IP_SCORE when message comes from FreeMail";
expression = "FREEMAIL_FROM & IP_SCORE";
expression = "FREEMAIL_FROM & SENDER_REP_SPAM";
score = 0.0;
policy = "remove_weight";
}
Expand Down
38 changes: 38 additions & 0 deletions lualib/lua_cfg_transform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
local logger = require "rspamd_logger"
local lua_util = require "lua_util"
local rspamd_util = require "rspamd_util"
local fun = require "fun"

local function is_implicit(t)
local mt = getmetatable(t)
Expand Down Expand Up @@ -358,5 +359,42 @@ return function(cfg)
end
end

-- Deal with IP_SCORE
if cfg.ip_score then
logger.warnx(rspamd_config, 'ip_score module is deprecated in honor of reputation module!')

if not cfg.reputation then
cfg.reputation = {
rules = {}
}
end

if not fun.any(function(_, v) return v.selector and v.selector.ip end,
cfg.reputation.rules) then
logger.infox(rspamd_config, 'attach ip reputation element to use it')

cfg.reputation.rules.ip_score = {
selector = {
ip = {},
},
backend = {
redis = {},
}
}

if cfg.symbols['IP_SCORE'] then
local t = cfg.symbols['IP_SCORE']

if not cfg.symbols['SENDER_REP_SPAM'] then
cfg.symbols['SENDER_REP_SPAM'] = t
cfg.symbols['SENDER_REP_HAM'] = t
cfg.symbols['SENDER_REP_HAM'].weight = -(t.weight or 0)
end
end
else
logger.infox(rspamd_config, 'ip reputation already exists, do not do any IP_SCORE transforms')
end
end

return ret, cfg
end
4 changes: 4 additions & 0 deletions src/plugins/lua/ip_score.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This module is deprecated and must not be used.
-- This file serves as a tombstone to prevent old ip_score to be loaded

return

0 comments on commit 48d68b1

Please sign in to comment.