From 71499b6811fdd2df0ecc7581120b83a0935b1370 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 28 Nov 2018 12:39:48 +0000 Subject: [Test] Add tests for pct=0 case --- src/plugins/lua/dmarc.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins/lua/dmarc.lua') diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index b55c5d41f..af43a5b8c 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -415,12 +415,15 @@ local function dmarc_validate_policy(task, policy, hdrfromdom, dmarc_esld) policy.domain .. ' : ' .. reason_str, policy.dmarc_policy) disposition = what else - if (math.random(100) > policy.pct) then + local coin = math.random(100) + if (coin > policy.pct) then if (not no_sampling_domains or not no_sampling_domains:get_key(policy.domain)) then task:insert_result(dmarc_symbols['softfail'], 1.0, policy.domain .. ' : ' .. reason_str, policy.dmarc_policy, "sampled_out") sampled_out = true + lua_util.debugm(N, task, 'changed dmarc policy from %s to %s, sampled out: %s < %s', + what, 'softfail', coin, policy.pct) else task:insert_result(dmarc_symbols[what], 1.0, policy.domain .. ' : ' .. reason_str, policy.dmarc_policy, "local_policy") -- cgit v1.2.3