Bladeren bron

[Feature] Descriptive options for DMARC failure symbols

tags/1.4.0
Andrew Lewis 7 jaren geleden
bovenliggende
commit
c77e967ea3
1 gewijzigde bestanden met toevoegingen van 23 en 7 verwijderingen
  1. 23
    7
      src/plugins/lua/dmarc.lua

+ 23
- 7
src/plugins/lua/dmarc.lua Bestand weergeven

return maybe_force_action('na') return maybe_force_action('na')
end end


local reason = {}
local strict_spf = false local strict_spf = false
local strict_dkim = false local strict_dkim = false
local strict_policy = false local strict_policy = false
if task:has_symbol(symbols['spf_allow_symbol']) then if task:has_symbol(symbols['spf_allow_symbol']) then
efrom = task:get_from(1) efrom = task:get_from(1)
if efrom and efrom[1] and efrom[1]['domain'] then if efrom and efrom[1] and efrom[1]['domain'] then
if rspamd_util.strequal_caseless(efrom[1]['domain'], from[1]['domain']) then
if strict_spf and rspamd_util.strequal_caseless(efrom[1]['domain'], from[1]['domain']) then
spf_ok = true spf_ok = true
elseif not strict_spf then
elseif strict_spf then
table.insert(reason, "SPF not aligned (strict)")
end
if not strict_spf then
local spf_tld = rspamd_util.get_tld(efrom[1]['domain']) local spf_tld = rspamd_util.get_tld(efrom[1]['domain'])
if rspamd_util.strequal_caseless(spf_tld, dmarc_domain) then if rspamd_util.strequal_caseless(spf_tld, dmarc_domain) then
spf_ok = true spf_ok = true
else
table.insert(reason, "SPF not aligned (relaxed)")
end end
end end
end end
else
table.insert(reason, "No SPF")
end end
local das = task:get_symbol(symbols['dkim_allow_symbol']) local das = task:get_symbol(symbols['dkim_allow_symbol'])
if das and das[1] and das[1]['options'] then if das and das[1] and das[1]['options'] then
for i,dkim_domain in ipairs(das[1]['options']) do for i,dkim_domain in ipairs(das[1]['options']) do
if rspamd_util.strequal_caseless(from[1]['domain'], dkim_domain) then
if strict_dkim and rspamd_util.strequal_caseless(from[1]['domain'], dkim_domain) then
dkim_ok = true dkim_ok = true
elseif not strict_dkim then
elseif strict_dkim then
table.insert(reason, "DKIM not aligned (strict)")
end
if not strict_dkim then
local dkim_tld = rspamd_util.get_tld(dkim_domain) local dkim_tld = rspamd_util.get_tld(dkim_domain)
if rspamd_util.strequal_caseless(dkim_tld, dmarc_domain) then if rspamd_util.strequal_caseless(dkim_tld, dmarc_domain) then
dkim_ok = true dkim_ok = true
else
table.insert(reason, "DKIM not aligned (relaxed)")
end end
end end
end end
else
table.insert(reason, "No DKIM")
end end


local disposition = 'none' local disposition = 'none'
if not (spf_ok or dkim_ok) then if not (spf_ok or dkim_ok) then
local reason_str = table.concat(reason, ", ")
res = 1.0 res = 1.0
local spf_tmpfail = task:get_symbol(symbols['spf_tempfail_symbol']) local spf_tmpfail = task:get_symbol(symbols['spf_tempfail_symbol'])
local dkim_tmpfail = task:get_symbol(symbols['dkim_tempfail_symbol']) local dkim_tmpfail = task:get_symbol(symbols['dkim_tempfail_symbol'])
end end
if quarantine_policy then if quarantine_policy then
if not pct or pct == 100 or (math.random(100) <= pct) then if not pct or pct == 100 or (math.random(100) <= pct) then
task:insert_result(dmarc_symbols['quarantine'], res, lookup_domain)
task:insert_result(dmarc_symbols['quarantine'], res, lookup_domain .. ' : ' .. reason_str)
disposition = "quarantine" disposition = "quarantine"
end end
elseif strict_policy then elseif strict_policy then
if not pct or pct == 100 or (math.random(100) <= pct) then if not pct or pct == 100 or (math.random(100) <= pct) then
task:insert_result(dmarc_symbols['reject'], res, lookup_domain)
task:insert_result(dmarc_symbols['reject'], res, lookup_domain .. ' : ' .. reason_str)
disposition = "reject" disposition = "reject"
end end
else else
task:insert_result(dmarc_symbols['softfail'], res, lookup_domain)
task:insert_result(dmarc_symbols['softfail'], res, lookup_domain .. ' : ' .. reason_str)
end end
else else
task:insert_result(dmarc_symbols['allow'], res, lookup_domain) task:insert_result(dmarc_symbols['allow'], res, lookup_domain)

Laden…
Annuleren
Opslaan