diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-13 23:29:02 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-13 23:29:02 +0100 |
commit | 58c0ecaa2e171681c25462d29ed1acb609ba40b2 (patch) | |
tree | 604bb6b51fa14ffb1f084099fd28b001fa03881f /lualib/lua_selectors | |
parent | 4241a6d65d2ffa7f18763129472a94666fb55d1c (diff) | |
download | rspamd-58c0ecaa2e171681c25462d29ed1acb609ba40b2.tar.gz rspamd-58c0ecaa2e171681c25462d29ed1acb609ba40b2.zip |
[Minor] Selectors: Add `get_tld` transform
Diffstat (limited to 'lualib/lua_selectors')
-rw-r--r-- | lualib/lua_selectors/transforms.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lualib/lua_selectors/transforms.lua b/lualib/lua_selectors/transforms.lua index 6f5ed7027..e5987a216 100644 --- a/lualib/lua_selectors/transforms.lua +++ b/lualib/lua_selectors/transforms.lua @@ -16,6 +16,7 @@ limitations under the License. local fun = require 'fun' local lua_util = require "lua_util" +local rspamd_util = require "rspamd_util" local ts = require("tableshape").types local logger = require 'rspamd_logger' local common = require "lua_selectors/common" @@ -428,7 +429,18 @@ Empty string comes the first argument or 'true', non-empty string comes nil]], 'given as second argument or `?`', ['args_schema'] = {ts.string:is_optional()} }, - + -- Extracts tld from a hostname + ['get_tld'] = { + ['types'] = { + ['string'] = true + }, + ['map_type'] = 'string', + ['process'] = function(inp, _, _) + return rspamd_util.get_tld(inp) + end, + ['description'] = 'Extracts tld from a hostname represented as a string', + ['args_schema'] = {} + }, } transform_function.match = transform_function.regexp |