View | Details | Raw Unified | Return to bug 208226
Collapse All | Expand All

(-)lib/Mail/SpamAssassin/Plugin/TxRep.pm (-18 / +59 lines)
Lines 1326-1353 Link Here
1326
  my $totalweight      = 0;
1326
  my $totalweight      = 0;
1327
  $self->{totalweight} = $totalweight;
1327
  $self->{totalweight} = $totalweight;
1328
1328
1329
                     $delta += $self->check_reputations($pms, 'EMAIL_IP', $from,   $ip,   $signedby, $msgscore);
1329
  $delta += $self->check_reputations($pms, 'EMAIL_IP', $from, $ip, $signedby, $msgscore);
1330
  if ($domain)      {$delta += $self->check_reputations($pms, 'DOMAIN',   $domain, $ip,   $signedby, $msgscore);}
1330
1331
  if ($helo)        {$delta += $self->check_reputations($pms, 'HELO',     $helo,   undef, 'HELO',    $msgscore);}
1331
  if ($domain) {
1332
    $delta += $self->check_reputations($pms, 'DOMAIN', $domain, $ip, $signedby, $msgscore);
1333
  }
1334
  if ($helo) {
1335
    $delta += $self->check_reputations($pms, 'HELO', $helo, undef, 'HELO', $msgscore);
1336
  }
1332
  if ($origip) {
1337
  if ($origip) {
1333
    if (!$signedby) {$delta += $self->check_reputations($pms, 'EMAIL',    $from,   undef, undef,     $msgscore);}
1338
    if (!$signedby) {
1334
                     $delta += $self->check_reputations($pms, 'IP',       $origip, undef, undef,     $msgscore);
1339
      $delta += $self->check_reputations($pms, 'EMAIL', $from, undef, undef, $msgscore);
1340
    }
1341
    $delta += $self->check_reputations($pms, 'IP', $origip, undef, undef, $msgscore);
1335
  }
1342
  }
1336
1343
1337
  if (!defined $self->{learning}) {
1344
  if (!defined $self->{learning}) {
1338
    $delta = ($self->{totalweight})? $self->{conf}->{txrep_factor} * $delta / $self->{totalweight}  :  0;
1345
    $delta = ($self->{totalweight})? $self->{conf}->{txrep_factor} * $delta / $self->{totalweight}  :  0;
1339
    if ($delta) {
1346
    if ($delta) {
1340
        $pms->got_hit("TXREP", "TXREP: ", ruletype => 'eval', score => sprintf("%0.3f", $delta));
1347
      $pms->got_hit("TXREP", "TXREP: ", ruletype => 'eval', score => sprintf("%0.3f", $delta));
1341
    }
1348
    }
1342
    $msgscore += $delta;
1349
    $msgscore += $delta;
1343
    if (defined $pms->{score}) {
1350
    if (defined $pms->{score}) {
1344
        dbg("TxRep: post-TxRep score: %.3f", $pms->{score});
1351
      dbg("TxRep: post-TxRep score: %.3f", $pms->{score});
1345
    }
1352
    }
1346
  }
1353
  }
1347
  if ($self->{conf}->{txrep_track_messages} && $msg_id) {
1354
  if ($self->{conf}->{txrep_track_messages} && $msg_id) {
1348
    $self->check_reputations($pms, 'MSG_ID', $msg_id, undef, $date, $msgscore);
1355
    $self->check_reputations($pms, 'MSG_ID', $msg_id, undef, $date, $msgscore);
1349
  }
1356
  }
1350
  if (!defined $self->{txKeepStoreTied}) {$self->finish();}
1357
  if (!defined $self->{txKeepStoreTied}) {
1358
    $self->finish();
1359
  }
1351
1360
1352
  return 0;
1361
  return 0;
1353
}
1362
}
Lines 1361-1374 Link Here
1361
1370
1362
  if ($self->open_storages()) {
1371
  if ($self->open_storages()) {
1363
    if ($self->{conf}->{txrep_user2global_ratio} && $self->{user_storage} != $self->{global_storage}) {
1372
    if ($self->{conf}->{txrep_user2global_ratio} && $self->{user_storage} != $self->{global_storage}) {
1364
        my $user   = $self->check_reputation('user_storage',  @_);
1373
      my $user   = $self->check_reputation('user_storage',  @_);
1365
        my $global = $self->check_reputation('global_storage',@_);
1374
      my $global = $self->check_reputation('global_storage',@_);
1366
1375
1367
        $delta = (defined $user && $user==$user) ?
1376
      if (defined $user and $user == $user) {
1368
            ( $self->{conf}->{txrep_user2global_ratio} * $user + $global ) / ( 1 + $self->{conf}->{txrep_user2global_ratio} ) :
1377
        $delta = ( $self->{conf}->{txrep_user2global_ratio} * $user + $global ) / ( 1 + $self->{conf}->{txrep_user2global_ratio} );
1369
            $global;
1378
      } else {
1379
        $delta = $global;
1380
      }
1370
    } else {
1381
    } else {
1371
        $delta = $self->check_reputation(undef,@_);
1382
      $delta = $self->check_reputation(undef,@_);
1372
    }
1383
    }
1373
  }
1384
  }
1374
  return $delta;
1385
  return $delta;
Lines 1383-1388 Link Here
1383
  my $delta  = 0;
1394
  my $delta  = 0;
1384
  my $weight = ($key eq 'MSG_ID')? 1 : eval('$pms->{main}->{conf}->{txrep_weight_'.lc($key).'}');
1395
  my $weight = ($key eq 'MSG_ID')? 1 : eval('$pms->{main}->{conf}->{txrep_weight_'.lc($key).'}');
1385
1396
1397
#  {
1398
#    #Bug 7164, trying to find out reason for these: _WARN: Use of uninitialized value $msgscore in addition (+) at /usr/share/perl5/vendor_perl/Mail/SpamAssassin/Plugin/TxRep.pm line 1415.
1399
#    no warnings;
1400
#
1401
#    unless (defined $msgscore) {
1402
#      #Output some params and the calling function so we can identify more about this bug
1403
#      dbg("TxRep: MsgScore Undefined (bug 7164) - check_reputation Parameters: self: $self storage: $storage pms: $pms, key: $key, id: $id, ip: $ip, signedby: $signedby, msgscore: $msgscore");
1404
#      dbg("TxRep: MsgScore Undefined (bug 7164) - weight: $weight");
1405
#
1406
#      my ($package, $filename, $line) = caller();
1407
#
1408
#      chomp($package);
1409
#      chomp($filename);
1410
#      chomp($line);
1411
#
1412
#      dbg("TxRep: MsgScore Undefined (bug 7164) - Caller Info: Package: $package - Filename: $filename - Line: $line");
1413
#
1414
#      #Define $msgscore as a triage to hide warnings while we find the root cause
1415
#      #$msgscore = 0;
1416
#    }
1417
#  }
1418
1419
1386
  if (defined $weight && $weight) {
1420
  if (defined $weight && $weight) {
1387
    my $meanrep;
1421
    my $meanrep;
1388
    my $timer = $self->{main}->time_method('check_txrep_'.lc($key));
1422
    my $timer = $self->{main}->time_method('check_txrep_'.lc($key));
Lines 1410-1420 Link Here
1410
        $self->{totalweight} += $weight;
1444
        $self->{totalweight} += $weight;
1411
        if ($key eq 'MSG_ID' && $self->count() > 0) {
1445
        if ($key eq 'MSG_ID' && $self->count() > 0) {
1412
            $delta = $self->total() / $self->count();
1446
            $delta = $self->total() / $self->count();
1413
	    $pms->set_tag('TXREP'.$tag_id,              sprintf("%2.1f",$delta));
1447
	    $pms->set_tag('TXREP'.$tag_id,              sprintf("%2.1f", $delta));
1414
        } elsif (defined $self->total()) {
1448
        } elsif (defined $self->total()) {
1415
            $delta = ($self->total() + $msgscore) / (1 + $self->count()) - $msgscore;
1449
            #Bug 7164 - $msgscore undefined
1450
            if (defined $msgscore) {
1451
              $delta = ($self->total() + $msgscore) / (1 + $self->count()) - $msgscore;
1452
            } else {
1453
              $delta = ($self->total()) / (1 + $self->count());
1454
            }
1416
1455
1417
            $pms->set_tag('TXREP_'.$tag_id,             sprintf("%2.1f",$delta));
1456
            $pms->set_tag('TXREP_'.$tag_id,             sprintf("%2.1f", $delta));
1418
            if (defined $meanrep) {
1457
            if (defined $meanrep) {
1419
                $pms->set_tag('TXREP_'.$tag_id.'_MEAN', sprintf("%2.1f", $meanrep));
1458
                $pms->set_tag('TXREP_'.$tag_id.'_MEAN', sprintf("%2.1f", $meanrep));
1420
            }
1459
            }
Lines 1448-1454 Link Here
1448
        $self->{checker}->remove_entry($self->{entry}); #forgetting the message ID
1487
        $self->{checker}->remove_entry($self->{entry}); #forgetting the message ID
1449
    }
1488
    }
1450
  }
1489
  }
1451
  if (defined $storage) {$self->{checker} = $self->{default_storage};}
1490
  if (defined $storage) {
1491
    $self->{checker} = $self->{default_storage};
1492
  }
1452
1493
1453
  return ($weight || 0) * ($delta || 0);
1494
  return ($weight || 0) * ($delta || 0);
1454
}
1495
}

Return to bug 208226