You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@issues.apache.org on 2010/09/02 04:23:02 UTC

[Bug 6485] New: Certain variables from plugins not available to report function (e.g. _ASN_)

https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6485

           Summary: Certain variables from plugins not available to report
                    function (e.g. _ASN_)
           Product: Spamassassin
           Version: 3.3.1
          Platform: PC
        OS/Version: Windows ME
            Status: NEW
          Severity: trivial
          Priority: P5
         Component: Plugins
        AssignedTo: dev@spamassassin.apache.org
        ReportedBy: kd6lvw+software@kd6lvw.ampr.org


This bug/enhancement request is similar to but different from these other two:

https://issues.apache.org/SpamAssassin/show_bug.cgi?id=5655
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6484

Could we alter the report generating function so that variables from the
Mail::SpamAssassin::Plugin::ASN plugin are available for substitution in the
"report" template?  Currently, "Report ... _ASN_ ..." does not work.

I am not sufficiently familiar with SA to know where report generation and
substitution is done in the code, else I would have attempted or suggested a
possible patch.  However, I know these (pseudo-)code snippets are on the right
track:

$label =  Desired label to substitute
$data  =  Resulting information to substitute

push @{$self->{main}->{conf}->{asnlookups}},
     { zone=>$zone, asn_tag=>$asn_tag, route_tag=>$route_tag };

foreach my $entry (@{$self->{main}->{conf}->{asnlookups}}) {
     $data = $scanner->{tag_data}->{$entry->{asn_tag}}
         if $label = $entry->{asn_tag};
     $data = $scanner->{tag_data}->{$entry->{route_tag}}
         if $label = $entry->{route_tag};
}

-- 
Configure bugmail: https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

[Bug 6485] Certain variables from plugins not available to report function (e.g. _ASN_)

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6485

software+spamassassin@kd6lvw.ampr.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |software+spamassassin@kd6lv
                   |                            |w.ampr.org

--- Comment #2 from software+spamassassin@kd6lvw.ampr.org 2010-11-30 20:12:19 UTC ---
Doesn't work for me.  The variables are not set - a null string is substituted.

SpamAssassin Version:  3.3.1 (2010-03-16)

Generating line:  "report ASN: _ASN_ (_ASNCIDR_) _RELAYCOUNTRY_"
Resulting  line:  "ASN:  () US **"
(Sample taken from the bug report e-mail I got for your followup.)
  US <= thor.apache.org.  (relaycountry string)
  ** <= localhost.        (as expected. RC works.  ASN doesn't.)

My report line is bracketed by "ifplugin Mail::SpamAssassin::Plugin::ASN" and
"endif" - so it would only inject into the report if the plugin module were in
fact loaded.  Full context:

ifplugin Mail::SpamAssassin::Plugin::ASN
report ASN: _ASN_ (_ASNCIDR_) _RELAYCOUNTRY_
asn_lookup origin.asn.spameatingmonkey.net _ASNCIDR_ _ASN_
asn_lookup origin.asn.cymru.com
asn_lookup ip2asn.sasm4.net
endif

...

It's in my pre file:
!cat /etc/mail/spamassassin/local.pre
tryplugin Mail::SpamAssassin::Plugin::ASN  <- Here it is.
tryplugin Mail::SpamAssassin::Plugin::AWL
tryplugin Mail::SpamAssassin::Plugin::DCC
...


Debugging log says it's there:
!spamassassin -D all --lint
Dec  1 00:51:58.694 [11558] dbg: logger: adding facilities: all
...
Dec  1 00:52:01.614 [11558] dbg: config: read file
/etc/mail/spamassassin/local.pre
...
Dec  1 00:52:02.030 [11558] dbg: plugin: loading
Mail::SpamAssassin::Plugin::SPF from @INC
Dec  1 00:52:02.076 [11558] dbg: plugin: loading
Mail::SpamAssassin::Plugin::ASN from @INC    <-- Here it is.
Dec  1 00:52:02.109 [11558] dbg: plugin: loading
Mail::SpamAssassin::Plugin::AWL from @INC
...
Dec  1 00:54:32.075 [11558] dbg: plugin:
Mail::SpamAssassin::Plugin::ASN=HASH(0xb0d9fd8) implements 'parsed_metadata',
priority 0  (Referenced/used too.)

DNS cache has these entries (1800 seconds later):
22.11.211.140.origin.asn.cymru.com. 13133 TXT
                              "3701 | 140.211.0.0/16 | US | arin | 1990-06-11"
22.11.211.140.ip2asn.sasm4.net. 2334 TXT "as3701"
22.11.211.140.asn.routeviews.org. 56589 TXT "3701" "140.211.0.0" "16"

The entry from spameatingmonkey.net timed out (300 seconds).  Therefore, the
module is loaded, fetched the data, but the variables were NOT set for
substitution into the report function.  That's the bug.

I am using the patch in 6484.  It does set the variables correctly per the
debugging statements.

-- 
Configure bugmail: https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

[Bug 6485] Certain variables from plugins not available to report function (e.g. _ASN_)

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6485

Mark Martinec <Ma...@ijs.si> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #3 from Mark Martinec <Ma...@ijs.si> 2011-01-06 14:03:37 UTC ---
> Doesn't work for me. The variables are not set - a null string is substituted.

Yes, your patch broke it. It stores tag data into wrong location,
and moreover it splits fields into individual characters.

The stock ASN.pm from 3.3.1 works as intended, including the report
substitutions.  Also the 3.4.0 (SVN trunk) that I uploaded today
(Bug 6484) works correctly while offering the new functionality
as you suggested.

I'm closing this now as 'resolved invalid'.

-- 
Configure bugmail: https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

[Bug 6485] Certain variables from plugins not available to report function (e.g. _ASN_)

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6485

--- Comment #1 from Mark Martinec <Ma...@ijs.si> 2010-11-30 19:30:59 UTC ---
> Could we alter the report generating function so that variables from the
> Mail::SpamAssassin::Plugin::ASN plugin are available for substitution in the
> "report" template?  Currently, "Report ... _ASN_ ..." does not work.

But they do work, I just tried it with stock 3.3.1.
Perhaps you forgot to 'loadplugin' the ASN plugin,
e.g. in your local.pre.  Check the debug log.

clear_report_template
report Spam detection software, running on the system "_HOSTNAME_", ...
report test: awl: _AWL_
report test: languages: _LANGUAGES_
report test: relaycountry: _RELAYCOUNTRY_
report test: asn: _ASN_, _ASNCIDR_
report 
report Content preview:  _PREVIEW_

-- 
Configure bugmail: https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

[Bug 6485] Certain variables from plugins not available to report function (e.g. _ASN_)

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6485

--- Comment #4 from software+spamassassin@kd6lvw.ampr.org 2011-01-06 17:14:25 UTC ---
Upon testing your revised patch from 6484, I agree.  Thanks.

-- 
Configure bugmail: https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.