diff options
author | Andrew Lewis <nerf@judo.za.org> | 2015-02-13 11:23:06 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2015-02-13 11:23:06 +0200 |
commit | a7540e1dc1975ce43e20366cdf5d205409782277 (patch) | |
tree | 4599f00ceda52c77e81deba4b9753cfe0e7c56cd /src/plugins | |
parent | 1d7e4cbd19287af3decfc8a0adb293120b802cab (diff) | |
download | rspamd-a7540e1dc1975ce43e20366cdf5d205409782277.tar.gz rspamd-a7540e1dc1975ce43e20366cdf5d205409782277.zip |
rbl.lua: Try harder to avoid invalid DNS lookups
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/rbl.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index 9abac0067..bb0732820 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -1,7 +1,19 @@ local rbls = {} local rspamd_logger = require "rspamd_logger" -local rspamd_ip = require "rspamd_ip" + +local function validate_dns(lstr, rstr) + if (lstr:len() + rstr:len()) > 252 then + return false + end + for v in lstr:gmatch("[^%.]+") do + if not v:match("^[%w%.-]+$") or v:len() > 63 + or v:match("^-") or v:match("-$") then + return false + end + end + return true +end local function ip_to_rbl(ip, rbl) return table.concat(ip:inversed_str_octets(), ".") .. '.' .. rbl @@ -83,7 +95,8 @@ local function rbl_cb (task) end if not havegot['helo'] then havegot['helo'] = task:get_helo() - if not havegot['helo'] or string.sub(havegot['helo'],1,1) == '[' or rspamd_ip.from_string(havegot['helo']):is_valid() then + if havegot['helo'] == nil or + not validate_dns(havegot['helo'], rbl['rbl']) then notgot['helo'] = true return end |