Nikita Koshikov wrote:
If X-Spam-Scan-Score have 6-9 digit after dot - the first one ignored, thus X-Spam-Scan-Score: 3.6 -> "ge" skips. #right X-Spam-Scan-Score: 3.8 -> "ge" works. #wrong X-Spam-Scan-Score: 5.9 -> "ge" works. #wrong X-Spam-Scan-Score: 6.0 -> "ge" works. #right X-Spam-Scan-Score: 6.9 -> "ge" works. #right X-Spam-Scan-Score: 7.3 -> "ge" works. #right
Note that the value '0' has a special meaning for the spamtest test. The 'definitely not spam' value is '1'. Therefore, values ranging from 0.0 to 10.0 are calculated into a score as follows:
score = (header_value / 10.0) * 9 + 1
So, the 5.9 match is correct as it yields 6.3, matching against "6".
The 3.8 match, however, is not correct. Please run the attached testsuite script I composed from your e-mail as follows:
src/testsuite/testsuite nikita-spamtest.svtest
At my end, this test case succeeds fully, including the 3.8 match. The test suite script should be fairly easy to understand and modify. If you manage to trigger a bug somehow, please let me now.
If the rule modified to (spamtest :value "ge" :comparator "i;ascii-numeric" "6.0") everything works as expected.
Matching against "6.0" will end at the first non-digit character, which should normally be equal to matching against "6". Very strange that this somehow helps. What version are you using?
One more thing - sieve-test. I couldn't test my scripts with it:
# sieve-test -x +spamtest -t sieve spam.txt 00000007: SPAMTEST test 00000007: spamtest: extension not configured 00000013: JMPFALSE (false)
You need to set the configuration by setting the appropriate config values in the environment (e.g. SIEVE_SPAMTEST_MAX_VALUE) while calling sieve-test. (For Dovecot v2.0 the tools also still don't use the Dovecot configuration, which needs to be fixed before the first release).
Regards,
Stephan.
require "vnd.dovecot.testsuite"; require "spamtest"; require "relational"; require "comparator-i;ascii-numeric"; require "variables";
/*
- Value */
/* Value 3.6 */
test_set "message" text: X-Spam-Scan-Score: 3.6
Test! . ;
test_config :set "sieve_spamtest_status_type" "score"; test_config :set "sieve_spamtest_status_header" "X-Spam-Scan-Score: (-?[[:digit:]]+\.[[:digit:]])"; test_config :set "sieve_spamtest_max_value" "10"; test_config :reload "spamtest";
test "Value: 3.6" { if spamtest :is "0" { test_fail "spamtest not configured or test failed"; }
if anyof (spamtest :value "ge" :comparator "i;ascii-numeric" "6")
{
if spamtest :matches "*" { }
test_fail "wrong spam value produced: ${1}";
}
}
/* Value: 3.8 */
test_set "message" text: X-Spam-Scan-Score: 3.8
Test! . ;
test "Value: 3.8" { if spamtest :is "0" { test_fail "spamtest not configured or test failed"; }
if anyof (spamtest :value "ge" :comparator "i;ascii-numeric" "6")
{
if spamtest :matches "*" { }
test_fail "wrong spam value produced: ${1}";
}
}
/* Value: 5.9 */
test_set "message" text: X-Spam-Scan-Score: 5.9
Test! . ;
test "Value: 5.9" { if spamtest :is "0" { test_fail "spamtest not configured or test failed"; }
if not anyof (spamtest :value "ge" :comparator "i;ascii-numeric" "6")
{
if spamtest :matches "*" { }
test_fail "wrong spam value produced: ${1}";
}
}
/* Value: 6.0 */
test_set "message" text: X-Spam-Scan-Score: 6.0
Test! . ;
test "Value: 6.0" { if spamtest :is "0" { test_fail "spamtest not configured or test failed"; }
if not anyof (spamtest :value "ge" :comparator "i;ascii-numeric" "6")
{
if spamtest :matches "*" { }
test_fail "wrong spam value produced: ${1}";
}
}
/* Value: 6.9 */
test_set "message" text: X-Spam-Scan-Score: 6.9
Test! . ;
test "Value: 6.9" { if spamtest :is "0" { test_fail "spamtest not configured or test failed"; }
if not anyof (spamtest :value "ge" :comparator "i;ascii-numeric" "6")
{
if spamtest :matches "*" { }
test_fail "wrong spam value produced: ${1}";
}
}
/* Value: 7.3 */
test_set "message" text: X-Spam-Scan-Score: 7.3
Test! . ;
test "Value: 7.3" { if spamtest :is "0" { test_fail "spamtest not configured or test failed"; }
if not anyof (spamtest :value "ge" :comparator "i;ascii-numeric" "6")
{
if spamtest :matches "*" { }
test_fail "wrong spam value produced: ${1}";
}
}