aboutsummaryrefslogtreecommitdiffstats
path: root/rules
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2016-06-29 22:49:56 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2016-06-29 22:49:56 +0300
commitc7c75954d2f5389300de6dca55ef8b180743cce9 (patch)
tree9a6e16b3b3403f4dd9d982e74b2d296a6966b707 /rules
parent8c58447646bb27b357aed9c0f88db467dee233f3 (diff)
downloadrspamd-c7c75954d2f5389300de6dca55ef8b180743cce9.tar.gz
rspamd-c7c75954d2f5389300de6dca55ef8b180743cce9.zip
[Feature] Add support for non-standard BATV signatures
Diffstat (limited to 'rules')
-rw-r--r--rules/misc.lua28
1 files changed, 24 insertions, 4 deletions
diff --git a/rules/misc.lua b/rules/misc.lua
index 2ea175a80..e51b0435a 100644
--- a/rules/misc.lua
+++ b/rules/misc.lua
@@ -277,19 +277,39 @@ rspamd_config.MULTIPLE_UNIQUE_HEADERS = {
rspamd_config.ENVFROM_PRVS = {
callback = function (task)
- -- Detect PRVS/BATV addresses to avoid FORGED_SENDER
- -- https://en.wikipedia.org/wiki/Bounce_Address_Tag_Validation
+ --[[
+ Detect PRVS/BATV addresses to avoid FORGED_SENDER
+ https://en.wikipedia.org/wiki/Bounce_Address_Tag_Validation
+
+ Signature syntax:
+
+ prvs=TAG=USER@example.com BATV draft (https://tools.ietf.org/html/draft-levine-smtp-batv-01)
+ prvs=USER=TAG@example.com
+ btv1==TAG==USER@example.com Barracuda appliance
+ msprvs1=TAG=USER@example.com Sparkpost email delivery service
+ ]]--
if not (task:has_from(1) and task:has_from(2)) then
return false
end
local envfrom = task:get_from(1)
- local tag,ef = envfrom[1].addr:lower():match("^prvs=([^=]+)=(.+)$")
- if not ef then return false end
+ local re_text = '^(?:(prvs|msprvs1)=([^=]+)=|btv1==[^=]+==)(.+@(.+))$'
+ local re = rspamd_regexp.create_cached(re_text)
+ local c = re:search(envfrom[1].addr:lower(), false, true)
+ if not c then return false end
+ local ef = c[1][4]
-- See if it matches the From header
local from = task:get_from(2)
if ef == from[1].addr:lower() then
return true
end
+ -- Check for prvs=USER=TAG@example.com
+ local t = c[1][2]
+ if t == 'prvs' then
+ local efr = c[1][3] .. '@' .. c[1][5]
+ if efr == from[1].addr:lower() then
+ return true
+ end
+ end
return false
end,
score = 0.01,