aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/phishing.lua
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2016-11-01 11:01:52 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2016-11-01 11:01:52 +0300
commitad2f7cfc300e44eadaa9fdfb7e102e61c44a9748 (patch)
tree6ebd45afd1faf29c39595283d4a24f01b8d0e226 /src/plugins/lua/phishing.lua
parentbffb84c0bdcc3307c6681d506ae2b6977297281e (diff)
downloadrspamd-ad2f7cfc300e44eadaa9fdfb7e102e61c44a9748.tar.gz
rspamd-ad2f7cfc300e44eadaa9fdfb7e102e61c44a9748.zip
[Minor] phishing: rework map checks
- organize map checks into a function - use as symbol option actually matched domain name part (eSLD or hostname)
Diffstat (limited to 'src/plugins/lua/phishing.lua')
-rw-r--r--src/plugins/lua/phishing.lua36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/plugins/lua/phishing.lua b/src/plugins/lua/phishing.lua
index adddce255..4314d7930 100644
--- a/src/plugins/lua/phishing.lua
+++ b/src/plugins/lua/phishing.lua
@@ -119,7 +119,6 @@ local function phishing_cb(task)
end
if url:is_phished() and not url:is_redirected() then
- local found = false
local purl = url:get_phished()
local tld = url:get_tld()
local ptld = purl:get_tld()
@@ -138,29 +137,28 @@ local function phishing_cb(task)
end
rspamd_logger.debugx(task, "distance: %1 -> %2: %3", tld, ptld, dist)
- if #redirector_domains > 0 then
- for _,rule in ipairs(redirector_domains) do
- if rule['map']:get_key(tld) or rule['map']:get_key(url:get_host()) then
- task:insert_result(rule['symbol'], weight, ptld .. '->' .. tld)
- found = true
+ local function found_in_map(map, url, weight)
+ if #map > 0 then
+ for _,rule in ipairs(map) do
+ for _,dn in ipairs({url:get_tld(), url:get_host()}) do
+ if rule['map']:get_key(dn) then
+ task:insert_result(rule['symbol'], weight, ptld .. '->' .. dn)
+ return true
+ end
+ end
end
end
end
- if not found and #strict_domains > 0 then
- for _,rule in ipairs(strict_domains) do
- if rule['map']:get_key(ptld) or rule['map']:get_key(purl:get_host()) then
- task:insert_result(rule['symbol'], 1.0, ptld .. '->' .. tld)
- found = true
- end
- end
- end
- if not found then
- if domains then
- if domains:get_key(ptld) then
+
+ if not found_in_map(redirector_domains, url, weight) then
+ if not found_in_map(strict_domains, purl, 1.0) then
+ if domains then
+ if domains:get_key(ptld) then
+ task:insert_result(symbol, weight, ptld .. '->' .. tld)
+ end
+ else
task:insert_result(symbol, weight, ptld .. '->' .. tld)
end
- else
- task:insert_result(symbol, weight, ptld .. '->' .. tld)
end
end
end