commit 7329a9a: [Minor] rspamd_stats: support rescoring symbols

Andrew Lewis nerf at judo.za.org
Wed Sep 1 14:42:04 UTC 2021


Author: Andrew Lewis
Date: 2021-09-01 13:56:59 +0200
URL: https://github.com/rspamd/rspamd/commit/7329a9a149edda7de45c5d7d4b290055ab2969ef (refs/pull/3874/head)

[Minor] rspamd_stats: support rescoring symbols

---
 utils/rspamd_stats.pl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl
index b0084c93a..e90524d20 100755
--- a/utils/rspamd_stats.pl
+++ b/utils/rspamd_stats.pl
@@ -14,6 +14,7 @@ my @symbols_exclude;
 my @symbols_bidirectional;
 my @symbols_groups;
 my @symbols_ignored;
+my %symbols_mult;
 my %groups;
 my $reject_score   = 15.0;
 my $junk_score     = 6.0;
@@ -47,6 +48,7 @@ GetOptions(
     "ignore=s@"             => \@symbols_ignored,
     "group|g=s@"            => \@symbols_groups,
     "log|l=s"               => \$log_file,
+    "mult=s"                => \%symbols_mult,
     "alpha-score|alpha|a=f" => \$diff_alpha,
     "correlations|c"        => \$correlations,
     "nrelated=i"            => \$nrelated,
@@ -427,7 +429,7 @@ sub ProcessRelated {
         next if IsIgnored($sym_name);
 
         if ($2) {
-            $sym_score = $3 * 1.0;
+            $sym_score = $3 * ($symbols_mult{$sym_name} or 1.0);
 
             if ( abs($sym_score) < $diff_alpha ) {
                 next;
@@ -549,7 +551,7 @@ sub ProcessLog {
                         my $orig_name = $sym_name;
 
                         if ($2) {
-                            $sym_score = $3 * 1.0;
+                            $sym_score = $3 * ($symbols_mult{$sym_name} or 1.0);
 
                             if ( abs($sym_score) < $diff_alpha ) {
                                 next;
@@ -868,6 +870,7 @@ rspamd_stats [options] [--symbol=SYM1 [--symbol=SYM2...]] [--log file]
    --exclude-logs=integer number of latest logs to exclude (0 by default)
    --json                 print json output instead of human readable
    --help                 brief help message
+   --mult=sym=number      multiply symbol score
    --man                  full documentation
 
 =head1 OPTIONS
@@ -932,6 +935,10 @@ Select log entries before this time. Format: C<YYYY-MM-DD HH:MM:SS> (can be trun
 with B<--start> select entries between B<--start> and B<--end>. The omitted date defaults to the current date if you
 supply the time.
 
+=item B<--mult=symbol=number>
+
+Multiplies score for the named symbol by the provided multiplier.
+
 =item B<--help>
 
 Print a brief help message and exits.


More information about the Commits mailing list