Browse Source

[Fix] Fix rules setup

pull/5617/head
Vsevolod Stakhov 3 weeks ago
parent
commit
f39430660d
No known key found for this signature in database GPG Key ID: 7647B6790081437
  1. 35
      rules/headers_checks.lua

35
rules/headers_checks.lua

@ -12,7 +12,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]--
]] --
local util = require "rspamd_util"
local ipairs = ipairs
@ -238,7 +238,7 @@ local check_replyto_id = rspamd_config:register_symbol({
end
-- See if the Display Names match
if (from[1].name and rt[1].name and
util.strequal_caseless(from[1].name, rt[1].name)) then
util.strequal_caseless(from[1].name, rt[1].name)) then
task:insert_result('REPLYTO_DN_EQ_FROM_DN', 1.0)
end
end
@ -248,9 +248,9 @@ local check_replyto_id = rspamd_config:register_symbol({
if (to and to[1] and to[1].addr:lower() == rt[1].addr:lower()) then
-- Ignore this for mailing-lists and automatic submissions
if (not (task:get_header('List-Unsubscribe') or
task:get_header('X-To-Get-Off-This-List') or
task:get_header('X-List') or
task:get_header('Auto-Submitted')))
task:get_header('X-To-Get-Off-This-List') or
task:get_header('X-List') or
task:get_header('Auto-Submitted')))
then
task:insert_result('REPLYTO_EQ_TO_ADDR', 1.0)
end
@ -471,9 +471,9 @@ rspamd_config.BROKEN_HEADERS = {
rspamd_config.BROKEN_CONTENT_TYPE = {
callback = function(task)
return fun.any(function(p)
return p:is_broken()
end,
task:get_parts())
return p:is_broken()
end,
task:get_parts())
end,
score = 1.5,
group = 'headers',
@ -667,7 +667,7 @@ local check_from_id = rspamd_config:register_symbol {
if (from[1].name == nil or from[1].name == '') then
task:insert_result('FROM_NO_DN', 1.0)
elseif (from[1].name and
util.strequal_caseless(from[1].name, from[1].addr)) then
util.strequal_caseless(from[1].name, from[1].addr)) then
task:insert_result('FROM_DN_EQ_ADDR', 1.0)
elseif (from[1].name and from[1].name ~= '') then
task:insert_result('FROM_HAS_DN', 1.0)
@ -705,7 +705,7 @@ local check_from_id = rspamd_config:register_symbol {
if (util.strequal_caseless(to[1].addr, from[1].addr)) then
task:insert_result('TO_EQ_FROM', 1.0)
elseif (to[1].domain and from[1].domain and
util.strequal_caseless(to[1].domain, from[1].domain))
util.strequal_caseless(to[1].domain, from[1].domain))
then
task:insert_result('TO_DOM_EQ_FROM_DOM', 1.0)
end
@ -837,7 +837,7 @@ local check_to_cc_id = rspamd_config:register_symbol {
for _, toa in ipairs(to) do
-- To: Recipients <noreply@dropbox.com>
if (toa['name'] and (toa['name']:lower() == 'recipient'
or toa['name']:lower() == 'recipients')) then
or toa['name']:lower() == 'recipients')) then
task:insert_result('TO_DN_RECIPIENTS', 1.0)
end
if (toa['name'] and util.strequal_caseless(toa['name'], toa['addr'])) then
@ -849,7 +849,7 @@ local check_to_cc_id = rspamd_config:register_symbol {
if (rcpts) then
for _, rcpt in ipairs(rcpts) do
if (toa and toa['addr'] and rcpt and rcpt['addr'] and
util.strequal_caseless(rcpt['addr'], toa['addr']))
util.strequal_caseless(rcpt['addr'], toa['addr']))
then
to_match_envrcpt = to_match_envrcpt + 1
end
@ -1158,7 +1158,7 @@ local function is_8bit_addr(addr)
return false;
end
rspamd_config.INVALID_FROM_8BIT = {
local invalid_from_8bit = {
callback = function(task)
local from = (task:get_from('mime') or {})[1] or {}
if is_8bit_addr(from) then
@ -1171,7 +1171,7 @@ rspamd_config.INVALID_FROM_8BIT = {
group = 'headers'
}
rspamd_config.INVALID_RCPT_8BIT = {
local invalid_rcpt_8bit = {
callback = function(task)
local rcpts = task:get_recipients('mime') or {}
return fun.any(function(rcpt)
@ -1188,14 +1188,17 @@ rspamd_config.INVALID_RCPT_8BIT = {
if rspamd_config:is_mime_utf8() then
-- Disable some of the rules preserving the underlying logic
rspamd_config.INVALID_FROM_8BIT.condition = function()
invalid_from_8bit.condition = function()
return false
end
rspamd_config.INVALID_RCPT_8BIT.condition = function()
invalid_rcpt_8bit.condition = function()
return false
end
end
rspamd_config.INVALID_FROM_8BIT = invalid_from_8bit
rspamd_config.INVALID_RCPT_8BIT = invalid_rcpt_8bit
rspamd_config.XM_CASE = {
callback = function(task)
return task:has_header('X-mailer', true)

Loading…
Cancel
Save