local rspamd_logger = require 'rspamd_logger'
local rspamd_http = require "rspamd_http"
+local E = {}
+
local rows = {}
local attachment_rows = {}
local urls_rows = {}
if settings['from_map'] and dkim == 'allow' then
-- Use dkim
local das = task:get_symbol(settings['dkim_allow_symbols'][1])
- if das and das[1] and das[1]['options'] then
+ if ((das or E)[1] or E).options then
for _,dkim_domain in ipairs(das[1]['options']) do
local specific = settings.from_map:get_key(dkim_domain)
if specific then
local dmarc_reporting = false
local dmarc_actions = {}
+local E = {}
+
local function gen_dmarc_grammar()
local lpeg = require "lpeg"
lpeg.locale(lpeg)
rspamd_logger.infox(task, "skip DMARC checks for local networks and authorized users");
return
end
- if from and from[1] and from[1]['domain'] and not from[2] then
+ if ((from or E)[1] or E).domain and not (from or E)[2] then
dmarc_domain = rspamd_util.get_tld(from[1]['domain'])
else
task:insert_result(dmarc_symbols['na'], 1.0, 'No From header')
local dkim_ok = false
if task:has_symbol(symbols['spf_allow_symbol']) then
local efrom = task:get_from(1)
- if efrom and efrom[1] and efrom[1]['domain'] then
+ if ((efrom or E)[1] or E).domain then
if strict_spf and rspamd_util.strequal_caseless(efrom[1]['domain'], from[1]['domain']) then
spf_ok = true
elseif strict_spf then
table.insert(reason, "No valid SPF")
end
local das = task:get_symbol(symbols['dkim_allow_symbol'])
- if das and das[1] and das[1]['options'] then
+ if ((das or E)[1] or E).options then
for _,dkim_domain in ipairs(das[1]['options']) do
if strict_dkim and rspamd_util.strequal_caseless(from[1]['domain'], dkim_domain) then
dkim_ok = true
local symbol_rcpt = 'FORGED_RECIPIENTS'
local symbol_sender = 'FORGED_SENDER'
+local E = {}
+
local function check_forged_headers(task)
local auser = task:get_user()
local smtp_rcpt = task:get_recipients(1)
-- allow user to BCC themselves
res = true
break
- elseif smtp_from and smtp_from[1] and smtp_from[1]['addr'] and
+ elseif ((smtp_from or E)[1] or E).addr and
smtp_from[1]['addr'] == sr['addr'] then
-- allow sender to BCC themselves
res = true
local map = {}
+local E = {}
+
local function known_mid_cb(task)
local re = {}
local header = task:get_header('Message-Id')
local das = task:get_symbol(settings['symbol_dkim_allow'])
- if das and das[1] and das[1]['options'] then
+ if ((das or E)[1] or E).options then
for _,dkim_domain in ipairs(das[1]['options']) do
local v = map:get_key(dkim_domain)
if v then
}
local redis_params
+local E = {}
+
local function mx_check(task)
local ip_addr = task:get_ip()
if task:get_user() or (ip_addr and ip_addr:is_local()) then
local from = task:get_from('smtp')
local mx_domain
- if from and from[1] and from[1]['domain'] and not from[2] then
+ if ((from or E)[1] or E).domain and not from[2] then
mx_domain = from[1]['domain']
else
mx_domain = task:get_helo()
-- A plugin that implements ratelimits using redis or kvstorage server
+local E = {}
+
-- Default settings for limits, 1-st member is burst, second is rate and the third is numeric type
local settings = {
}
['from'] = {
['get_value'] = function(task)
local from = task:get_from(0)
- if from and from[1] and from[1]['addr'] then
+ if ((from or E)[1] or E).addr then
return from[1]['addr']
end
return nil
['bounce'] = {
['get_value'] = function(task)
local from = task:get_from(0)
- if not from or not from[1] or not from[1]['user'] then
+ if not ((from or E)[1] or E).user then
return '_'
end
if check_bounce(from[1]['user']) then return '_' else return nil end
else
local rate_keys = {}
local rcpts = task:get_recipients(0)
- if not rcpts or not rcpts[1] or not rcpts[1]['addr'] then
+ if not ((rcpts or E)[1] or E).addr then
return nil
end
local key_s = table.concat(key_t, ":")
-- Documentation can be found here:
-- https://rspamd.com/doc/modules/rbl.html
+local E = {}
local N = 'rbl'
+
local rbls = {}
local local_exclusions = nil
end
if not havegot['dkim'] then
local das = task:get_symbol(symbols['dkim_allow_symbol'])
- if das and das[1] and das[1]['options'] then
+ if ((das or E)[1] or E).options then
havegot['dkim'] = das[1]['options']
else
notgot['dkim'] = true
-- This plugin is intended to read and parse spamassassin rules with regexp
-- rules. SA plugins or statistics are not supported
+local E = {}
local N = 'spamassassin'
+
local rspamd_logger = require "rspamd_logger"
local rspamd_regexp = require "rspamd_regexp"
local rspamd_expression = require "rspamd_expression"
'check_from_in_blacklist',
function(task)
local from = task:get_from('mime')
- if from and from[1] and from[1]['addr'] then
+ if ((from or E)[1] or E).addr then
if sa_lists['from_blacklist'][string.lower(from[1]['addr'])] then
return 1
end
'check_from_in_whitelist',
function(task)
local from = task:get_from('mime')
- if from and from[1] and from[1]['addr'] then
+ if ((from or E)[1] or E).addr then
if sa_lists['from_whitelist'][string.lower(from[1]['addr'])] then
return 1
end
'check_from_in_default_whitelist',
function(task)
local from = task:get_from('mime')
- if from and from[1] and from[1]['addr'] then
+ if ((from or E)[1] or E).addr then
if sa_lists['from_def_whitelist'][string.lower(from[1]['addr'])] then
return 1
end
rules = {}
}
+local E = {}
+
local function whitelist_cb(symbol, rule, task)
local domains = {}
-- Now we can check from domain or helo
local from = task:get_from(1)
- if from and from[1] and from[1]['domain'] then
+ if ((from or E)[1] or E).domain then
local tld = rspamd_util.get_tld(from[1]['domain'])
if tld then
end
local from = task:get_from(2)
- if from and from[1] and from[1]['domain'] then
+ if ((from or E)[1] or E).domain then
local tld = rspamd_util.get_tld(from[1]['domain'])
if tld then