aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-01 14:27:02 +0000
committerGitHub <noreply@github.com>2016-11-01 14:27:02 +0000
commit88653d479196615886b5aaaf355b01c91714743a (patch)
treefb7ff0783b808d5b12b30efd372ef286a6101d94 /src
parentf809803e8ed239d6f9242c9837333414e077b620 (diff)
parentad2f7cfc300e44eadaa9fdfb7e102e61c44a9748 (diff)
downloadrspamd-88653d479196615886b5aaaf355b01c91714743a.tar.gz
rspamd-88653d479196615886b5aaaf355b01c91714743a.zip
Merge pull request #1083 from moisseev/phishing
[Minor] phishing: rework map checks
Diffstat (limited to 'src')
-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