if ip and ip:is_valid() then return tostring(ip) end
return nil
end,
+ ['description'] = 'Get source IP address',
},
-- Get SMTP from
['smtp_from'] = {
end
return nil
end,
+ ['description'] = 'Get SMTP from',
},
-- Get MIME from
['mime_from'] = {
end
return nil
end,
+ ['description'] = 'Get MIME from',
},
-- Get country (ASN module must be executed first)
['country'] = {
return asn
end
end,
+ ['description'] = 'Get country (ASN module must be executed first)',
},
-- Get ASN number
['asn'] = {
return asn
end
end,
+ ['description'] = 'Get ASN number',
},
-- Get authenticated username
['user'] = {
return auser
end
end,
+ ['description'] = 'Get authenticated username',
},
-- Get principal recipient
['to'] = {
['get_value'] = function(task)
return task:get_principal_recipient()
end,
+ ['description'] = 'Get principal recipient',
},
-- Get content digest
['digest'] = {
['get_value'] = function(task)
return task:get_digest()
end,
+ ['description'] = 'Get content digest',
},
-- Get list of all attachments digests
['attachments'] = {
return nil
end,
+ ['description'] = 'Get list of all attachments digests',
},
-- Get all attachments files
['files'] = {
return nil
end,
+ ['description'] = 'Get all attachments files',
},
-- Get helo value
['helo'] = {
['get_value'] = function(task)
return task:get_helo()
end,
+ ['description'] = 'Get helo value',
},
-- Get header with the name that is expected as an argument. Returns list of
-- headers with this name
['get_value'] = function(task, args)
return task:get_header_full(args[1])
end,
+ ['description'] = 'Get header with the name that is expected as an argument. Returns list of headers with this name',
},
-- Get list of received headers (returns list of tables)
['received'] = {
['get_value'] = function(task)
return task:get_received_headers()
end,
+ ['description'] = 'Get list of received headers (returns list of tables)',
},
-- Get all urls
['urls'] = {
['get_value'] = function(task)
return task:get_urls()
end,
+ ['description'] = 'Get all urls',
},
-- Get all emails
['emails'] = {
['get_value'] = function(task)
return task:get_emails()
end,
+ ['description'] = 'Get all emails',
},
-- Get specific pool var. The first argument must be variable name,
-- the second argument is optional and defines the type (string by default)
['get_value'] = function(task, args)
return task:get_mempool():get_variable(args[1], args[2])
end,
+ ['description'] = [[Get specific pool var. The first argument must be variable name,
+ the second argument is optional and defines the type (string by default)]],
},
-- Get specific HTTP request header. The first argument must be header name.
['request_header'] = {
end
return nil
- end
+ end,
+ ['description'] = 'Get specific HTTP request header. The first argument must be header name.',
},
-- Get task date, optionally formatted
['time'] = {
end
return nil
- end
+ end,
+ ['description'] = 'Get task date, optionally formatted (see os.date)',
}
}
+local function pure_type(ltype)
+ return ltype:match('^(.*)_list$')
+end
+
local transform_function = {
-- Get hostname from url or a list of urls
['get_host'] = {
['map_type'] = 'string',
['process'] = function(inp, t)
return inp:get_host(),'string'
- end
+ end,
+ ['description'] = 'Get hostname from url or a list of urls',
},
-- Get tld from url or a list of urls
['get_tld'] = {
['map_type'] = 'string',
['process'] = function(inp, t)
return inp:get_tld()
- end
+ end,
+ ['description'] = 'Get tld from url or a list of urls',
},
-- Get address
['get_addr'] = {
['map_type'] = 'string',
['process'] = function(inp, _)
return inp:get_addr()
- end
+ end,
+ ['description'] = 'Get email address as a string',
},
-- Returns the lowercased string
['lower'] = {
['map_type'] = 'string',
['process'] = function(inp, _)
return inp:lower(),'string'
- end
+ end,
+ ['description'] = 'Returns the lowercased string',
},
-- Returns the first element
['first'] = {
['string_list'] = true
},
['process'] = function(inp, t)
- local pure_type = t:match('^(.*)_list$')
- return inp[1],pure_type
- end
+ return inp[1],pure_type(t)
+ end,
+ ['description'] = 'Returns the first element',
},
-- Returns the last element
['last'] = {
['string_list'] = true
},
['process'] = function(inp, t)
- local pure_type = t:match('^(.*)_list$')
- return inp[#inp],pure_type
- end
+ return inp[#inp],pure_type(t)
+ end,
+ ['description'] = 'Returns the last element',
},
-- Returns the nth element
['nth'] = {
['string_list'] = true
},
['process'] = function(inp, t, args)
- local pure_type = t:match('^(.*)_list$')
- return inp[tonumber(args[1])],pure_type
- end
+ return inp[tonumber(args[1] or 1)],pure_type(t)
+ end,
+ ['description'] = 'Returns the nth element',
},
-- Joins strings into a single string using separator in the argument
['join'] = {
},
['process'] = function(inp, _, args)
return table.concat(inp, args[1] or ''), 'string'
- end
+ end,
+ ['description'] = 'Joins strings into a single string using separator in the argument',
},
-- Create a digest from string or a list of strings
['digest'] = {
local hash = require 'rspamd_cryptobox_hash'
local ht = args[1] or 'blake2'
return hash:create_specific(ht):update(inp), 'hash'
- end
+ end,
+ ['description'] = 'Create a digest from string or a list of strings',
},
-- Encode hash to string (using hex encoding by default)
['encode'] = {
elseif how == 'base64' then
return inp:base64()
end
- end
+ end,
+ ['description'] = 'Encode hash to string (using hex encoding by default)',
},
-- Extracts substring
['substring'] = {
local end_pos = args[2] or -1
return inp:sub(start_pos, end_pos), 'string'
- end
+ end,
+ ['description'] = 'Extracts substring',
},
-- Drops input value and return values from function's arguments or an empty string
['id'] = {
end
return ''
- end
+ end,
+ ['description'] = 'Drops input value and return values from function\'s arguments or an empty string',
},
-- Extracts table value from key-value list
['elt'] = {
['map_type'] = 'string',
['process'] = function(inp, t, args)
return inp[args[1]],'string'
- end
+ end,
+ ['description'] = 'Extracts table value from key-value list',
},
-- Call specific userdata method
['method'] = {
['map_type'] = 'string',
['process'] = function(inp, _, args)
return inp[args[1]](inp)
- end
+ end,
+ ['description'] = 'Call specific userdata method',
},
-- Boolean function in, returns either nil or its input if input is in args list
['in'] = {
['process'] = function(inp, t, args)
for _,a in ipairs(args) do if a == inp then return inp,t end end
return nil
- end
+ end,
+ ['description'] = 'Boolean function in, returns either nil or its input if input is in args list',
},
['not_in'] = {
['types'] = {
['process'] = function(inp, t, args)
for _,a in ipairs(args) do if a == inp then return nil end end
return inp,t
- end
+ end,
+ ['description'] = 'Boolean function in, returns either nil or its input if input is not in args list',
},
}
if not x.types[t] then
-- Additional case for map
- local pure_type = t:match('^(.*)_list$')
- if pure_type and x.map_type and x.types[pure_type] then
+ local pt = pure_type(t, '^(.*)_list$')
+ if pt and x.map_type and x.types[pt] then
return {fun.map(function(list_elt)
- local ret, _ = x.process(list_elt, pure_type, x.args)
+ local ret, _ = x.process(list_elt, pt, x.args)
return ret
end, value), x.map_type}
end