aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-10-10 10:41:43 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-10-10 10:41:43 +0200
commitf0a0160c9f0fb7b5a2f6fe691671df31933af1d1 (patch)
treea6233e32c459fd4c9ff641b187222e3c5d7c67b5 /src/plugins/lua
parentba01e88c8520cc09be7c2f0a387d76c6be04b08f (diff)
downloadrspamd-f0a0160c9f0fb7b5a2f6fe691671df31933af1d1.tar.gz
rspamd-f0a0160c9f0fb7b5a2f6fe691671df31933af1d1.zip
[Minor] Use human-readable policy in DMARC plugin
Diffstat (limited to 'src/plugins/lua')
-rw-r--r--src/plugins/lua/dmarc.lua30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index da5837d2b..112865939 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -132,8 +132,7 @@ local function dmarc_callback(task)
local reason = {}
local strict_spf = false
local strict_dkim = false
- local strict_policy = false
- local quarantine_policy = false
+ local dmarc_policy = 'none'
local found_policy = false
local failed_policy
local rua
@@ -176,10 +175,9 @@ local function dmarc_callback(task)
policy = string.match(e, '^p=(.+)$')
if policy then
if (policy == 'reject') then
- strict_policy = true
+ dmarc_policy = 'reject'
elseif (policy == 'quarantine') then
- strict_policy = true
- quarantine_policy = true
+ dmarc_policy = 'quarantine'
elseif (policy ~= 'none') then
failed_policy = 'p tag has invalid value: ' .. policy
return
@@ -189,19 +187,17 @@ local function dmarc_callback(task)
if subdomain_policy and lookup_domain == dmarc_domain then
if (subdomain_policy == 'reject') then
if dmarc_domain ~= from[1]['domain'] then
- strict_policy = true
+ dmarc_policy = 'reject'
end
elseif (subdomain_policy == 'quarantine') then
if dmarc_domain ~= from[1]['domain'] then
- strict_policy = true
- quarantine_policy = true
+ dmarc_policy = 'quarantine'
end
elseif (subdomain_policy == 'none') then
if dmarc_domain ~= from[1]['domain'] then
- strict_policy = false
- quarantine_policy = false
+ dmarc_policy = 'none'
end
- else
+ elseif (subdomain_policy ~= 'none') then
failed_policy = 'sp tag has invalid value: ' .. subdomain_policy
return
end
@@ -295,12 +291,12 @@ local function dmarc_callback(task)
task:insert_result(dmarc_symbols['dnsfail'], 1.0, lookup_domain .. ' : ' .. 'SPF/DKIM temp error')
return maybe_force_action('dnsfail')
end
- if quarantine_policy then
+ if dmarc_policy == 'quarantine' then
if not pct or pct == 100 or (math.random(100) <= pct) then
task:insert_result(dmarc_symbols['quarantine'], res, lookup_domain .. ' : ' .. reason_str)
disposition = "quarantine"
end
- elseif strict_policy then
+ elseif dmarc_policy == 'reject' then
if not pct or pct == 100 or (math.random(100) <= pct) then
task:insert_result(dmarc_symbols['reject'], res, lookup_domain .. ' : ' .. reason_str)
disposition = "reject"
@@ -309,13 +305,7 @@ local function dmarc_callback(task)
task:insert_result(dmarc_symbols['softfail'], res, lookup_domain .. ' : ' .. reason_str)
end
else
- local real_policy = 'none'
- if strict_policy then
- real_policy = 'reject'
- elseif quarantine_policy then
- real_policy = 'quarantine'
- end
- task:insert_result(dmarc_symbols['allow'], res, lookup_domain, real_policy)
+ task:insert_result(dmarc_symbols['allow'], res, lookup_domain, dmarc_policy)
end
if rua and redis_params and dmarc_reporting then