summaryrefslogtreecommitdiffstats
path: root/lualib/lua_selectors.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-21 12:39:33 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-21 12:39:33 +0100
commitaa95595931bf1ad08c1ee20f144074e31222acd8 (patch)
treea491e7460749b098548b0f763b8fbc8d8a879322 /lualib/lua_selectors.lua
parentfec55830a7ebf7030d801a883743da84a05eea75 (diff)
downloadrspamd-aa95595931bf1ad08c1ee20f144074e31222acd8.tar.gz
rspamd-aa95595931bf1ad08c1ee20f144074e31222acd8.zip
[Minor] Add `in` and `not_in` transformations
Diffstat (limited to 'lualib/lua_selectors.lua')
-rw-r--r--lualib/lua_selectors.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 69a20b9c4..5f2f3564a 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -382,6 +382,27 @@ local transform_function = {
return inp[args[1]](inp)
end
},
+ -- Boolean function in, returns either nil or its input if input is in args list
+ ['in'] = {
+ ['types'] = {
+ ['string'] = true,
+ },
+ ['map_type'] = 'string',
+ ['process'] = function(inp, _, args)
+ for _,a in ipairs(args) do if a == inp then return inp end end
+ return nil
+ end
+ },
+ ['not_in'] = {
+ ['types'] = {
+ ['string'] = true,
+ },
+ ['map_type'] = 'string',
+ ['process'] = function(inp, _, args)
+ for _,a in ipairs(args) do if a == inp then return nil end end
+ return inp
+ end
+ },
}
local function process_selector(task, sel)