]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix several issues with flag propagation
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 18 Jul 2024 12:26:26 +0000 (13:26 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 18 Jul 2024 12:26:26 +0000 (13:26 +0100)
src/libserver/spf.c
src/libserver/spf.h
src/lua/lua_spf.c
src/plugins/lua/spf.lua

index afd77294badc636d1943656c6324bccf83cb05ea..562222042469ca9dcf50f7460e6003d1841d4f93 100644 (file)
@@ -451,6 +451,9 @@ rspamd_spf_process_reference(struct spf_resolved *target,
                        target->flags |= RSPAMD_SPF_RESOLVED_NA;
                        continue;
                }
+               if (cur->flags & RSPAMD_SPF_FLAG_PLUSALL) {
+                       target->flags |= RSPAMD_SPF_RESOLVED_PLUSALL;
+               }
                if (cur->flags & RSPAMD_SPF_FLAG_INVALID) {
                        /* Ignore invalid elements */
                        continue;
@@ -1418,7 +1421,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 | RSPAMD_SPF_FLAG_PLUSALL;
+               addr->flags |= RSPAMD_SPF_FLAG_PLUSALL;
                msg_notice_spf("domain %s allows any SPF (+all), ignore SPF record completely",
                                           rec->sender_domain);
        }
index 2487b6d574f0237f18978b6c02638247d4a8d321..b89dc4d0e34e04b80c489a92bee0654af5b99269 100644 (file)
@@ -105,6 +105,7 @@ enum rspamd_spf_resolved_flags {
        RSPAMD_SPF_RESOLVED_TEMP_FAILED = (1u << 0u),
        RSPAMD_SPF_RESOLVED_PERM_FAILED = (1u << 1u),
        RSPAMD_SPF_RESOLVED_NA = (1u << 2u),
+       RSPAMD_SPF_RESOLVED_PLUSALL = (1u << 3u),
 };
 
 struct spf_resolved {
index a9bcfc80c5cdea397bb43f325c88b5e46da0208b..850ce21204110db8120286e3e559690066d31f19 100644 (file)
@@ -89,7 +89,7 @@ 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_pushinteger(L, RSPAMD_SPF_RESOLVED_PLUSALL);
        lua_setfield(L, -2, "plusall");
 
        lua_setfield(L, -2, "flags");
@@ -370,6 +370,11 @@ spf_check_element(lua_State *L, struct spf_resolved *rec, struct spf_addr *addr,
                                lua_pushinteger(L, RSPAMD_SPF_RESOLVED_TEMP_FAILED);
                                lua_pushfstring(L, "%cany", spf_mech_char(addr->mech));
                        }
+                       else if (rec->flags & RSPAMD_SPF_RESOLVED_PLUSALL) {
+                               lua_pushboolean(L, false);
+                               lua_pushinteger(L, RSPAMD_SPF_RESOLVED_PLUSALL);
+                               lua_pushfstring(L, "%cany", spf_mech_char(addr->mech));
+                       }
                        else {
                                lua_pushboolean(L, true);
                                lua_pushinteger(L, addr->mech);
index b9add61a6b34e44f3e2f227399c43d97fe220f9a..35650725069763a4035796d7cc90cfa432c4b5a1 100644 (file)
@@ -119,6 +119,8 @@ local function spf_check_callback(task)
   local function flag_to_symbol(fl)
     if bit.band(fl, rspamd_spf.flags.temp_fail) ~= 0 then
       return local_config.symbols.dnsfail
+    elseif bit.band(fl, rspamd_spf.flags.plusall) ~= 0 then
+      return local_config.symbols.plusall
     elseif bit.band(fl, rspamd_spf.flags.perm_fail) ~= 0 then
       return local_config.symbols.permfail
     elseif bit.band(fl, rspamd_spf.flags.na) ~= 0 then