Opened 12 years ago

Last modified 12 years ago

#504 testing enhancement (fixed)

Automatically insert new rules

Reported by: mortonda@… Owned by: mortonda@…
Priority: normal Milestone: 1.0.3
Component: amavisd-maia Version: 1.0.2
Severity: normal Keywords:


Similar to #320 which just updates scores, we should be able to insert new rules as they are triggered, thus solving for all time this FAQ

All that is needed is a else clause in maia_record_tests()

Also, a web interface for the admin to edit the text description of missing rules would be handy.

Change History (3)

comment:1 Changed 12 years ago by rjl@…

It should be noted that this feature will not render the script obsolete, since there will always be a need for a tool that reads rule descriptions from existing *.cf files. This feature only adds the rule name and score, leaving the description field null, so if it were used in place of, all the rules in your database would show up as "(No description provided)", which is less than ideal when we're talking about thousands of rules--no one is going to want to edit all of those descriptions by hand.

What this feature does do, though, is catch the rules that currently fails to pick up (because they lack 'describe' lines). It adds these rules with null descriptions which can be edited later by the superadmin. Ticket #357 still needs to be resolved, at which point the problems with will be eliminated and this new feature won't offer much, apart from catching new rules that have been added by admins who don't automatically run whenever rules are updated.

comment:2 Changed 12 years ago by mortonda@…

  • Owner changed from rjl to mortonda@…
  • Status changed from new to accepted

implemented in [1300] and [1301]

one bug has been reported:

Column 'rule_name' cannot be null at /usr/sbin/amavisd-new line 4331.

I think it is related to SA returning "none" when no rules are hit.

Here's a potential patch:

diff --git a/amavisd-maia b/amavisd-maia
index 589056a..234be5c 100755
--- a/amavisd-maia
+++ b/amavisd-maia
@@ -4277,7 +4277,7 @@ sub maia_record_tests($$$$) {
     my @rules_to_insert = ();
     my @rules_to_update = ();
-    if (@tests) {
+    if (@tests && $tests[0] ne 'none') { #sometimes the rule is "none" which probably means no rules triggered; skip it
         $select = "SELECT id, rule_count, rule_score_3 FROM maia_sa_rules WHERE rule_name LIKE ? LIMIT 1";
         $sth = $dbh->prepare_cached($select)
@@ -4292,6 +4292,9 @@ sub maia_record_tests($$$$) {
                 $test_score = $2;
                 $test_name = untaint($test_name);
                 $test_score = untaint($test_score);
+            } else { #something funny with the rule name, log it but keep moving
+                do_log(0, sprintf("Maia: [record_tests] Cannot parse improper rule: %s", $t));
+                next;
             # look up the test by name in the maia_sa_rules table

comment:3 Changed 12 years ago by mortonda@…

  • Resolution set to fixed
  • Status changed from accepted to testing

applied in [1364] and [1365]

Note: See TracTickets for help on using tickets.