From f8b0fd41a3b6335d86e9fa3ee25e1e5b12df1c7b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 17 Jul 2024 15:35:18 +0100 Subject: [PATCH] [Feature] Treat SPF +all in a special way Issue: #4996 --- src/libserver/spf.c | 2 +- src/libserver/spf.h | 1 + src/lua/lua_spf.c | 2 ++ src/plugins/lua/spf.lua | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libserver/spf.c b/src/libserver/spf.c index 32c020bf3..afd77294b 100644 --- a/src/libserver/spf.c +++ b/src/libserver/spf.c @@ -1418,7 +1418,7 @@ parse_spf_all(struct spf_record *rec, struct spf_addr *addr) /* Disallow +all */ if (addr->mech == SPF_PASS) { - addr->flags |= RSPAMD_SPF_FLAG_INVALID; + addr->flags |= RSPAMD_SPF_FLAG_INVALID | RSPAMD_SPF_FLAG_PLUSALL; msg_notice_spf("domain %s allows any SPF (+all), ignore SPF record completely", rec->sender_domain); } diff --git a/src/libserver/spf.h b/src/libserver/spf.h index cc0ee4c05..2487b6d57 100644 --- a/src/libserver/spf.h +++ b/src/libserver/spf.h @@ -77,6 +77,7 @@ typedef enum spf_action_e { #define RSPAMD_SPF_FLAG_PERMFAIL (1u << 10u) #define RSPAMD_SPF_FLAG_RESOLVED (1u << 11u) #define RSPAMD_SPF_FLAG_CACHED (1u << 12u) +#define RSPAMD_SPF_FLAG_PLUSALL (1u << 13u) /** Default SPF limits for avoiding abuse **/ #define SPF_MAX_NESTING 10 diff --git a/src/lua/lua_spf.c b/src/lua/lua_spf.c index 46e72202f..a9bcfc80c 100644 --- a/src/lua/lua_spf.c +++ b/src/lua/lua_spf.c @@ -89,6 +89,8 @@ lua_load_spf(lua_State *L) lua_setfield(L, -2, "perm_fail"); lua_pushinteger(L, RSPAMD_SPF_FLAG_CACHED); lua_setfield(L, -2, "cached"); + lua_pushinteger(L, RSPAMD_SPF_FLAG_PLUSALL); + lua_setfield(L, -2, "plusall"); lua_setfield(L, -2, "flags"); diff --git a/src/plugins/lua/spf.lua b/src/plugins/lua/spf.lua index 48f3c17be..b9add61a6 100644 --- a/src/plugins/lua/spf.lua +++ b/src/plugins/lua/spf.lua @@ -56,6 +56,7 @@ local symbols = { dnsfail = "R_SPF_DNSFAIL", permfail = "R_SPF_PERMFAIL", na = "R_SPF_NA", + plusall = "R_SPF_PLUSALL", } local default_config = { -- 2.39.5