]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] Implement two-phase composite evaluation for postfilter dependencies
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 14 Oct 2025 13:59:01 +0000 (14:59 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 14 Oct 2025 13:59:01 +0000 (14:59 +0100)
commitac8d5173cce870872aec7c54a42a2f379d3f6719
tree92bf0b0c02a8eeba28f7a0ddb9a6d8053da31da0
parentf9d1b2323b2caac110ce32450beadf8e68b2e085
[Fix] Implement two-phase composite evaluation for postfilter dependencies

Fixes #5674 where composite rules combining postfilter/statistics symbols
with regular filter symbols failed to trigger. Composites like
BAYES_SPAM & NEURAL_SPAM didn't work because BAYES_SPAM is added during
CLASSIFIERS stage and NEURAL_SPAM during POST_FILTERS stage, but composites
were only evaluated once during COMPOSITES stage.

Solution:
- Analyze composite dependencies at configuration time
- Split composites into first-pass (depend only on filters) and second-pass
  (depend on postfilters/stats or other second-pass composites)
- Evaluate first-pass composites during COMPOSITES stage via symcache
- Evaluate second-pass composites during COMPOSITES_POST stage by directly
  iterating the second_pass_composites vector
- Skip symcache checks for second-pass composites during second pass to
  force re-evaluation despite being marked as checked in first pass
- Add functional test demonstrating the fix

The dependency analysis uses transitive closure: if composite A depends on
composite B, and B needs second pass, then A also needs second pass.
src/libserver/cfg_utils.cxx
src/libserver/composites/composites.cxx
src/libserver/composites/composites.h
src/libserver/composites/composites_internal.hxx
src/libserver/composites/composites_manager.cxx
src/libserver/task.c
test/functional/cases/001_merged/109_composites_postfilter.robot [new file with mode: 0644]
test/functional/configs/merged-local.conf
test/functional/configs/merged.conf
test/functional/lua/composites_postfilter.lua [new file with mode: 0644]