summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-09 17:07:18 +0000
committerGitHub <noreply@github.com>2017-03-09 17:07:18 +0000
commit6d85b9ad383ee57d24457b12231aede3f3d88e80 (patch)
treef9b1467abf2b5db7a3cbdf907f9a06f371ed0c11 /src
parent0acbff09302ad7f246c1acb487d6129ad504db18 (diff)
parent6a0b76c33a36810f566d0ec8282bd77cff19c833 (diff)
downloadrspamd-6d85b9ad383ee57d24457b12231aede3f3d88e80.tar.gz
rspamd-6d85b9ad383ee57d24457b12231aede3f3d88e80.zip
Merge pull request #1507 from fatalbanana/mt
[Feature] Support using request headers in settings
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/settings.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index a3a41440a..758bc9b94 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -225,6 +225,19 @@ local function check_settings(task)
end
end
+ if rule['request_header'] then
+ for k, v in pairs(rule['request_header']) do
+ local h = task:get_request_header(k)
+ res = (h and v:match(h))
+ if res then
+ break
+ end
+ end
+ if not res then
+ return nil
+ end
+ end
+
if res then
if rule['whitelist'] then
rule['apply'] = {whitelist = true}
@@ -445,6 +458,19 @@ local function process_settings_table(tbl)
if elt['authenticated'] then
out['authenticated'] = true
end
+ if elt['request_header'] then
+ local rho = {}
+ for k, v in pairs(elt['request_header']) do
+ local re = rspamd_regexp.get_cached(v)
+ if not re then
+ re = rspamd_regexp.create_cached(v)
+ end
+ if re then
+ rho[k] = re
+ end
+ end
+ out['request_header'] = rho
+ end
-- Now we must process actions
if elt['symbols'] then out['symbols'] = elt['symbols'] end