commit f1d0657: [Fix] Fix group based composites

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Sep 14 12:49:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-09-14 13:46:01 +0100
URL: https://github.com/rspamd/rspamd/commit/f1d0657f3922da9ae88eb4a3b84cce8fc3444ad9 (HEAD -> master)

[Fix] Fix group based composites

---
 src/libserver/composites.c                 |  2 +-
 test/functional/cases/109_composites.robot | 30 +++---------------------------
 2 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/src/libserver/composites.c b/src/libserver/composites.c
index 7dff93802..c1ee471f8 100644
--- a/src/libserver/composites.c
+++ b/src/libserver/composites.c
@@ -394,7 +394,7 @@ rspamd_composite_expr_process (void *ud,
 	struct rspamd_task *task = cd->task;
 	GHashTableIter it;
 	gpointer k, v;
-	gdouble rc = epsilon, max = epsilon;
+	gdouble rc = 0, max = 0;
 
 	if (isset (cd->checked, cd->composite->id * 2)) {
 		/* We have already checked this composite, so just return its value */
diff --git a/test/functional/cases/109_composites.robot b/test/functional/cases/109_composites.robot
index 47fc0c28e..8da18fe97 100644
--- a/test/functional/cases/109_composites.robot
+++ b/test/functional/cases/109_composites.robot
@@ -12,59 +12,35 @@ ${MESSAGE}      ${TESTDIR}/messages/spam_message.eml
 ${RSPAMD_SCOPE}  Suite
 
 *** Test Cases ***
-Composites - Score
-  Scan File  ${MESSAGE}
-  Expect Score  50
-  Expect Required Score To Be Null
-
-Composites - Expressions
+Composites - All in One
   Scan File  ${MESSAGE}
   Expect Symbol With Score  EXPRESSIONS  5
   Expect Symbol With Score  EXPRESSIONS_B  0
-
-Composites - Policy: remove_weight
-  Scan File  ${MESSAGE}
   Expect Symbol With Score  POLICY_REMOVE_WEIGHT  5
   Expect Symbol With Score  POLICY_REMOVE_WEIGHT_B  0
   Do Not Expect Symbol  POLICY_REMOVE_WEIGHT_A
-
-Composites - Policy: force removing
-  Scan File  ${MESSAGE}
   Expect Symbol With Score  POLICY_FORCE_REMOVE  5.00
   Expect Symbol With Score  POLICY_FORCE_REMOVE_A  1.00
   Do Not Expect Symbol  POLICY_FORCE_REMOVE_B
-
-Composites - Policy: leave
-  Scan File  ${MESSAGE}
   Expect Symbol With Score  POLICY_LEAVE  5.00
   Do Not Expect Symbol  POLICY_LEAVE_A
   Expect Symbol With Score  POLICY_LEAVE_B  1.00
-
-Composites - Default policy: remove_weight
-  Scan File  ${MESSAGE}
   Expect Symbol With Score  DEFAULT_POLICY_REMOVE_WEIGHT  5.00
   Expect Symbol With Score  DEFAULT_POLICY_REMOVE_WEIGHT_A  0.00
   Expect Symbol With Score  DEFAULT_POLICY_REMOVE_WEIGHT_B  0.00
-
-Composites - Default policy: remove_symbol
-  Scan File  ${MESSAGE}
   Expect Symbol With Score  DEFAULT_POLICY_REMOVE_SYMBOL  5.00
   Do Not Expect Symbol  DEFAULT_POLICY_REMOVE_SYMBOL_A
   Do Not Expect Symbol  DEFAULT_POLICY_REMOVE_SYMBOL_B
-
-Composites - Default policy: leave
-  Scan File  ${MESSAGE}
   Expect Symbol With Score  DEFAULT_POLICY_LEAVE  5.00
   Expect Symbol With Score  DEFAULT_POLICY_LEAVE_A  1.00
   Expect Symbol With Score  DEFAULT_POLICY_LEAVE_B  1.00
-
-Composites - Symbol groups
-  Scan File  ${MESSAGE}
   Expect Symbol With Score  SYMBOL_GROUPS  5.00
   Expect Symbol With Score  POSITIVE_A  -1.00
   Expect Symbol With Score  ANY_A  -1.00
   Expect Symbol With Score  NEGATIVE_B  1.00
   Do Not Expect Symbol  NEGATIVE_A
+  Expect Score  50
+  Expect Required Score To Be Null
 
 Composites - Opts Plain
   Scan File  ${MESSAGE}  opts=sym1


More information about the Commits mailing list