diff options
Diffstat (limited to 'conf')
-rw-r--r-- | conf/lua/hfilter.lua | 32 | ||||
-rw-r--r-- | conf/metrics.conf | 2 | ||||
-rw-r--r-- | conf/modules.conf | 1 |
3 files changed, 33 insertions, 2 deletions
diff --git a/conf/lua/hfilter.lua b/conf/lua/hfilter.lua index ed3a346e5..e81986826 100644 --- a/conf/lua/hfilter.lua +++ b/conf/lua/hfilter.lua @@ -102,6 +102,7 @@ local config = { ['helo_enabled'] = false, ['hostname_enabled'] = false, ['from_enabled'] = false, + ['rcpt_enabled'] = false, ['mid_enabled'] = false, ['url_enabled'] = false } @@ -345,8 +346,9 @@ local function hfilter(task) task:insert_result('HFILTER_HOSTNAME_' .. weight_hostname, 1.0) end + -- MAILFROM checks -- + local frombounce = false if config['from_enabled'] then - -- MAILFROM checks -- local from = task:get_from(1) if from then --FROM host check @@ -354,6 +356,25 @@ local function hfilter(task) local fr_split = split(fr['addr'], '@', 0) if table.maxn(fr_split) == 2 then check_host(task, fr_split[2], 'FROMHOST', '', '') + if fr_split[1] == 'postmaster' then + frombounce = true + end + end + end + else + task:insert_result('HFILTER_FROM_BOUNCE', 1.00) + frombounce = true + end + end + + -- Recipients checks -- + if config['rcpt_enabled'] then + local rcpt = task:get_recipients() + if rcpt then + local count_rcpt = table.maxn(rcpt) + if frombounce then + if count_rcpt > 1 then + task:insert_result('HFILTER_RCPT_BOUNCEMOREONE', 1.00) end end end @@ -397,6 +418,9 @@ local symbols_hostname = { "HFILTER_HOSTNAME_5", "HFILTER_HOSTNAME_UNKNOWN" } +local symbols_rcpt = { + "HFILTER_RCPT_BOUNCEMOREONE" +} local symbols_mid = { "HFILTER_MID_NORESOLVE_MX", "HFILTER_MID_NORES_A_OR_MX", @@ -410,7 +434,8 @@ local symbols_url = { local symbols_from = { "HFILTER_FROMHOST_NORESOLVE_MX", "HFILTER_FROMHOST_NORES_A_OR_MX", - "HFILTER_FROMHOST_NOT_FQDN" + "HFILTER_FROMHOST_NOT_FQDN", + "HFILTER_FROM_BOUNCE" } local opts = rspamd_config:get_all_opt('hfilter') @@ -432,6 +457,9 @@ end if config['from_enabled'] then append_t(symbols_enabled, symbols_from) end +if config['rcpt_enabled'] then + append_t(symbols_enabled, symbols_rcpt) +end if config['mid_enabled'] then append_t(symbols_enabled, symbols_mid) end diff --git a/conf/metrics.conf b/conf/metrics.conf index f4697c43d..49266e7ae 100644 --- a/conf/metrics.conf +++ b/conf/metrics.conf @@ -780,10 +780,12 @@ metric { symbol { weight = 1.50; name = "HFILTER_FROMHOST_NORESOLVE_MX"; description = "MX found in FROM host and no resolve"; } symbol { weight = 3.50; name = "HFILTER_FROMHOST_NORES_A_OR_MX"; description = "FROM host no resolve to A or MX"; } symbol { weight = 4.00; name = "HFILTER_FROMHOST_NOT_FQDN"; description = "FROM host not FQDN"; } + symbol { weight = 0.00; name = "HFILTER_FROM_BOUNCE"; description = "Bounce message"; } symbol { weight = 0.50; name = "HFILTER_MID_NORESOLVE_MX"; description = "MX found in Message-id host and no resolve"; } symbol { weight = 0.50; name = "HFILTER_MID_NORES_A_OR_MX"; description = "Message-id host no resolve to A or MX"; } symbol { weight = 0.50; name = "HFILTER_MID_NOT_FQDN"; description = "Message-id host not FQDN"; } symbol { weight = 4.00; name = "HFILTER_HOSTNAME_UNKNOWN"; description = "Unknown hostname (no PTR or no resolve PTR to hostname)"; } + symbol { weight = 1.50; name = "HFILTER_RCPT_BOUNCEMOREONE"; description = "Message from bounce and over 1 recepient"; } symbol { weight = 3.50; name = "HFILTER_URL_ONLY"; description = "URL only in body"; } symbol { weight = 2.20; name = "HFILTER_URL_ONELINE"; description = "One line URL and text in body"; } } diff --git a/conf/modules.conf b/conf/modules.conf index 6310f4326..582ca5204 100644 --- a/conf/modules.conf +++ b/conf/modules.conf @@ -265,5 +265,6 @@ hfilter { hostname_enabled = true; url_enabled = true; from_enabled = true; + rcpt_enabled = true; mid_enabled = true; } |