You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Martin Gregorie <ma...@gregorie.org> on 2018/09/30 17:44:07 UTC

Unexpected error spotted by --lint check

I was just now link checking a modified local rule (SA 3.4.2 on Fedora
28, fully patched as on last Friday night (28Sep2018) when I got the
error:

Sep 30 18:06:54.602 [18545] warn: config: Strange rule token: 1.5
Sep 30 18:06:55.316 [18545] warn: lint: 1 issues detected, please rerun
with debug enabled for more information

Rerunning with -D --lint gets this:
Sep 30 18:09:33.134 [18587] dbg: plugin: loading
Mail::SpamAssassin::Plugin::MimeMagic from
/etc/mail/spamassassin/MimeMagic.pm
Sep 30 18:09:33.140 [18587] dbg: config: header eval rule name is
IMAGE_MISMATCH function is
mimemagic_mismatch_contenttype('jpe?g','gif','png','bmp','svg')
Sep 30 18:09:33.141 [18587] dbg: config: header eval rule name is
MG_IMISMATCH function is mimemagic_mismatch_datatype('image/')
Sep 30 18:09:33.164 [18587] warn: config: Strange rule token: 1.5

which fairly obviously points to a fault in a pair of local rules:

describe IMAGE_MISMATCH Image doesn't match content type
header   IMAGE_MISMATCH eval:mimemagic_mismatch_contenttype('jpe?g',
'gif','png','bmp','svg')
score    IMAGE_MISMATCH 1.5

describe MG_IMISMATCH Another way of scanning all 
header   MG_IMISMATCH eval:mimemagic_mismatch_datatype('image/')
score    MG_IMISMATCH 0.01

But there's nothing obviously wrong, to me anyway, in the first rule
and in any case nothing in this file has been modified since 09Jan2017
according to its datestamp - which was when I installed Fedora on what
was then a new machine, so the file was last modified some time before
then.

Last Friday's upgrade made three Perl changes:

Upgraded: perl-File-Path-2.16-1.fc28.noarch
Installed: perl-BSD-Resource-1.291.100-5.fc28.x86_64
Upgraded: perl-Archive-Zip-1.64-1.fc28.noarch

Does this raise any warnings I should beware of?

SA 3.4.2 seems to be running OK apart from this.


Martin
 


Re: Unexpected error spotted by --lint check

Posted by John Hardin <jh...@impsec.org>.
On Tue, 2 Oct 2018, Martin Gregorie wrote:

> On Mon, 2018-10-01 at 22:45 +0100, RW wrote:
>> It seems to be related to the use decimal numeric literals
>>
>> meta     __YYY          1/2
>> meta     __XXX          0.2 * __YYY  + 0.1
>>
>> $ spamassassin --lint
>> ...
>> ... warn: config: Strange rule __XXX token: 0.2
>> ... warn: config: Strange rule __XXX token: 1.1
>>
> Interesting. I have only one local rule with a literal '1.5' in a meta
> rule body. Here's that rule:
>
> describe MG_LOTTO  Fake lotto winner
> header   __MG_LOT1 From =~ /lotto/i
> body     __MG_LOT2 /(lotto|loterie)/i
> meta     MG_LOTTO  ( ( __MG_LOT1 + __MG_LOT2 ) > 1.5 )
> score    MG_LOTTO  2.0
>
> This rule has been around and working as expected for several years.

Looks like the lint got broken, then, and needs to accept decimal 
numbers...

-- 
  John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
  jhardin@impsec.org    FALaholic #11174     pgpk -a jhardin@impsec.org
  key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
  550 days since the first commercial re-flight of an orbital booster (SpaceX)

Re: Unexpected error spotted by --lint check

Posted by Martin Gregorie <ma...@gregorie.org>.
On Tue, 2018-10-02 at 12:20 +0300, Henrik K wrote:
> Are you talking about the .cf file and line that contains rule being
> warned about?  I don't see how it could be done, looking at how the
> cf and stuff are processed.
> 
Yes I was, but if it can';t be done, fair enough.

> I already patched the warning to mention rulename, so atleast that's
> more verbose.
>
Yes, that will be very helpful. Thanks.

Martin




Re: Unexpected error spotted by --lint check

Posted by Henrik K <he...@hege.li>.
On Tue, Oct 02, 2018 at 09:44:41AM +0100, Martin Gregorie wrote:
> On Tue, 2018-10-02 at 07:57 +0300, Henrik K wrote:
> > This is also nothing else than a warn, the rule works regardless.
> > 
> That makes warnings like this somewhat useless because this makes
> locating them rather difficult. Is there any possibility of showing the
> filename and line number in the --lint report? 

Are you talking about the .cf file and line that contains rule being warned
about?  I don't see how it could be done, looking at how the cf and stuff
are processed.

I already patched the warning to mention rulename, so atleast that's more
verbose.  Seems the warn itself is good, now we know decimal numbers were
missing from the check..  :-)


Re: Unexpected error spotted by --lint check

Posted by Martin Gregorie <ma...@gregorie.org>.
On Tue, 2018-10-02 at 07:57 +0300, Henrik K wrote:
> This is also nothing else than a warn, the rule works regardless.
> 
That makes warnings like this somewhat useless because this makes
locating them rather difficult. Is there any possibility of showing the
filename and line number in the --lint report? 
 
> The warning is also fixed now:
> 
http://svn.apache.org/viewvc?view=revision&sortby=date&revision=1842593
> 
Many thanks for the fix.

Martin



Re: Unexpected error spotted by --lint check

Posted by Henrik K <he...@hege.li>.
On Tue, Oct 02, 2018 at 12:58:25AM +0100, Martin Gregorie wrote:
>
> That's read from and parsed from different file (local.cf) than the
> rule that's getting blamed for the problem

As I said the linearity of debug log cannot be taken granted.  Only
something written on the _same_ line is guaranteed to be be related to
itself.

This is also nothing else than a warn, the rule works regardless.

The warning is also fixed now:
http://svn.apache.org/viewvc?view=revision&sortby=date&revision=1842593


Re: Unexpected error spotted by --lint check

Posted by Martin Gregorie <ma...@gregorie.org>.
On Mon, 2018-10-01 at 22:45 +0100, RW wrote:
> It seems to be related to the use decimal numeric literals 
> 
> meta     __YYY          1/2
> meta     __XXX          0.2 * __YYY  + 0.1
> 
> $ spamassassin --lint
> ...
> ... warn: config: Strange rule __XXX token: 0.2
> ... warn: config: Strange rule __XXX token: 1.1
>
Interesting. I have only one local rule with a literal '1.5' in a meta
rule body. Here's that rule:

describe MG_LOTTO  Fake lotto winner
header   __MG_LOT1 From =~ /lotto/i
body     __MG_LOT2 /(lotto|loterie)/i
meta     MG_LOTTO  ( ( __MG_LOT1 + __MG_LOT2 ) > 1.5 )
score    MG_LOTTO  2.0

This rule has been around and working as expected for several years.

That's read from and parsed from different file (local.cf) than the
rule that's getting blamed for the problem (in MimeMagic.cf) and some
600 lines earlier if these files are read in collation sequence. 

MimeMagic.cf contains conditional code:

if (version >= 3.003)

loadplugin  Mail::SpamAssassin::Plugin::MimeMagic MimeMagic.pm
followed by defining two rules called MG_IMG_TYPE_WRONG and
MG_IMISMATCH

else

ifplugin Mail::SpamAssassin::Plugin::ImageInfo
followed by defining several rules, all with double underscore prefixes
to their names, either 
of the form: mimeheader .... Content-Type =~ /image\/xxx/i ...
or:          body ... eval:image_count('xxx',1)
then a bunch of metas, also with double underscore name prefixes, that
are combined into a final meta rule, IMAGE_MISMATCH, which has a score
of 1.5 

endif

The oddity here is that *both* IMAGE_MISMATCH and MG_IMISMATCH appear
in that order immediately before the 

  warn: config: Strange rule token: 1.5

warning but there "-D --lint" log does not mention the
MG_IMG_TYPE_WRONG rule at all.

This looks to me as if there might there be some problem with the
if...else...endif handling.

There was a second 'endif' in the file, which I've removed without,
apparently, any effect at all - and certainly no effect on this
problem.
 

Martin



Re: Unexpected error spotted by --lint check

Posted by RW <rw...@googlemail.com>.
On Mon, 1 Oct 2018 00:44:39 +0300
Henrik K wrote:

> On Sun, Sep 30, 2018 at 08:55:13PM +0100, Martin Gregorie wrote:
> > On Sun, 2018-09-30 at 21:13 +0300, Henrik K wrote:  
> > > On Sun, Sep 30, 2018 at 06:44:07PM +0100, Martin Gregorie wrote:  
> > > > 
> > > > Sep 30 18:06:54.602 [18545] warn: config: Strange rule token:
> > > > 1.5  
> > > 
> > > According to code this can only be seen with meta rules.  So
> > > check if you have "meta FOOBAR 1.5" somewhere.
> > >   
> > The -D debug trace seems to say pretty unambiguously that its
> > scanning my MG_IMISMATCH rule, which is a header... eval: rule, but
> > the only  
> 
> Debug log is not necessary linear. If you want to be _sure_, try this
> patch:

It seems to be related to the use decimal numeric literals 

meta     __YYY          1/2
meta     __XXX          0.2 * __YYY  + 0.1

$ spamassassin --lint
...
... warn: config: Strange rule __XXX token: 0.2
... warn: config: Strange rule __XXX token: 1.1

Re: Unexpected error spotted by --lint check

Posted by Henrik K <he...@hege.li>.
On Sun, Sep 30, 2018 at 08:55:13PM +0100, Martin Gregorie wrote:
> On Sun, 2018-09-30 at 21:13 +0300, Henrik K wrote:
> > On Sun, Sep 30, 2018 at 06:44:07PM +0100, Martin Gregorie wrote:
> > > 
> > > Sep 30 18:06:54.602 [18545] warn: config: Strange rule token: 1.5
> > 
> > According to code this can only be seen with meta rules.  So check if
> > you have "meta FOOBAR 1.5" somewhere.
> > 
> The -D debug trace seems to say pretty unambiguously that its scanning
> my MG_IMISMATCH rule, which is a header... eval: rule, but the only

Debug log is not necessary linear. If you want to be _sure_, try this patch:

--- lib/Mail/SpamAssassin/Conf/Parser.pm	2018/09/30 18:14:46	1842402
+++ lib/Mail/SpamAssassin/Conf/Parser.pm	2018/09/30 18:24:47	1842403
@@ -1318,7 +1318,7 @@
     }
     # WTF is it? Just warn, for now. Bug #7557
     else {
-      $self->lint_warn("config: Strange rule token: $token", $name);
+      $self->lint_warn("config: Strange rule $name token: $token", $name);
       $meta .= "$token ";
     }
   }


Re: Unexpected error spotted by --lint check

Posted by "Kevin A. McGrail" <km...@apache.org>.
Possibly related to https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7627
which says you have a rule issue to.  Post the rule you are working on
otherwise look for a syntax error.
--
Kevin A. McGrail
VP Fundraising, Apache Software Foundation
Chair Emeritus Apache SpamAssassin Project
https://www.linkedin.com/in/kmcgrail - 703.798.0171


On Sun, Sep 30, 2018 at 3:55 PM Martin Gregorie <ma...@gregorie.org> wrote:

> On Sun, 2018-09-30 at 21:13 +0300, Henrik K wrote:
> > On Sun, Sep 30, 2018 at 06:44:07PM +0100, Martin Gregorie wrote:
> > >
> > > Sep 30 18:06:54.602 [18545] warn: config: Strange rule token: 1.5
> >
> > According to code this can only be seen with meta rules.  So check if
> > you have "meta FOOBAR 1.5" somewhere.
> >
> The -D debug trace seems to say pretty unambiguously that its scanning
> my MG_IMISMATCH rule, which is a header... eval: rule, but the only
> nearby  occurrence of '1.5' is the score of the immediately preceding
> rule as you can see in my last post: the two rules are cut and pasted
> from the .cf file without any editing apart from neatening up the fold
> in the long header line in IMAGE_MISMATCH
>
> less also found 1.5 as a reported software version number (Geo::IP,
> version 1.51). These are only the two hits in the entire debugging
> output that match the less search term "/1\.5" in the entire debugging
> output (apart from 1.5% in the timing report line).
>
>
> Martin
>
>
>

Re: Unexpected error spotted by --lint check

Posted by Martin Gregorie <ma...@gregorie.org>.
On Sun, 2018-09-30 at 21:13 +0300, Henrik K wrote:
> On Sun, Sep 30, 2018 at 06:44:07PM +0100, Martin Gregorie wrote:
> > 
> > Sep 30 18:06:54.602 [18545] warn: config: Strange rule token: 1.5
> 
> According to code this can only be seen with meta rules.  So check if
> you have "meta FOOBAR 1.5" somewhere.
> 
The -D debug trace seems to say pretty unambiguously that its scanning
my MG_IMISMATCH rule, which is a header... eval: rule, but the only
nearby  occurrence of '1.5' is the score of the immediately preceding
rule as you can see in my last post: the two rules are cut and pasted
from the .cf file without any editing apart from neatening up the fold
in the long header line in IMAGE_MISMATCH

less also found 1.5 as a reported software version number (Geo::IP,
version 1.51). These are only the two hits in the entire debugging
output that match the less search term "/1\.5" in the entire debugging
output (apart from 1.5% in the timing report line).


Martin



Re: Unexpected error spotted by --lint check

Posted by Henrik K <he...@hege.li>.
On Sun, Sep 30, 2018 at 06:44:07PM +0100, Martin Gregorie wrote:
>
> Sep 30 18:06:54.602 [18545] warn: config: Strange rule token: 1.5

According to code this can only be seen with meta rules.  So check if you
have "meta FOOBAR 1.5" somewhere.