You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Paul Stead <pa...@zeninternet.co.uk> on 2014/11/03 11:51:25 UTC

Adding tag SENDERDOMAIN

I think a tag of SENDERDOMAIN would be handy to have so it can be used
with askdns and other rules which can make use of tags.

This would help address the following bug, which could be implemented
with a simple rule:

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

As well as the following mailing list posts:

http://spamassassin.1065346.n5.nabble.com/DMARC-policy-check-with-AskDNS-posible-td109426.html
http://spamassassin.1065346.n5.nabble.com/dnssec-dane-td110982.html#a112729
- My post

I'd suggest the following diff - is this in the best place and method to
accomplish this?

Index: lib/Mail/SpamAssassin/PerMsgStatus.pm
===================================================================
--- lib/Mail/SpamAssassin/PerMsgStatus.pm    (revision 1636308)
+++ lib/Mail/SpamAssassin/PerMsgStatus.pm    (working copy)
@@ -2864,6 +2864,9 @@
  ok:
    $envf =~ s/^<*//gs;                # remove <
    $envf =~ s/>*\s*$//gs;        # remove >, whitespace, newlines
+  my $fromdom = $envf;
+  $fromdom =~ s/.*\@//;
+  $self->set_tag('SENDERDOMAIN', $fromdom);
    return $envf;
  }

--
Paul Stead
Systems Engineer
Zen Internet

Re: Adding tag SENDERDOMAIN

Posted by Mark Martinec <Ma...@ijs.si>.
Paul Stead wrote:
> Awesome,
> 
> Might it be useful to have other tags set as well?
> 
> LASTEXTERNALHELO - similar to the common tag in PerMsgStatus
> LASTEXTERNALIP - as above
> 
> Anything else that could be handy?


Indeed, the LASTEXTERNALIP, LASTEXTERNALRDNS, and LASTEXTERNALHELO
could just as well be made into tags. To make LASTEXTERNALIP useful
as a tag the fields of an IP address would probably need to be
reversed.


We already have tags RELAYSTRUSTEDREVIP, RELAYSUNTRUSTEDREVIP,
RELAYSINTERNALREVIP, RELAYSEXTERNALREVIP :

Mail/SpamAssassin/Message/Metadata.pm :

   foreach my $tuple (
       [$self->{relays_trusted},   'RELAYSTRUSTEDREVIP'  ],
       [$self->{relays_untrusted}, 'RELAYSUNTRUSTEDREVIP'],
       [$self->{relays_internal},  'RELAYSINTERNALREVIP' ],
       [$self->{relays_external},  'RELAYSEXTERNALREVIP' ])
   { my($rly, $tag) = @$tuple;
     my @revips;
     @revips = map {
       my($ip,$revip);
       $ip = $_->{ip}  if ref $_ && !$_->{ip_private};
       $revip = reverse_ip_address($ip)  if defined $ip && $ip ne '';
       defined $revip && $revip ne '' ? $revip : ();
     } @$rly  if $rly;
     $permsgstatus->set_tag($tag,
                            @revips == 1 ? $revips[0] : \@revips) if 
@revips;

These last four are currently undocumented, as they are not (yet)
a full substitute for the more complicated logic in a plugin DNSEval,
although the idea behind these was to provide data to askdns rules
that could eventually complement or replace check_rbl* eval calls
with their lastexternal, firsttrusted, notfirsthop, and untrusted
modifiers.

   Mark

Re: Adding tag SENDERDOMAIN

Posted by Paul Stead <pa...@zeninternet.co.uk>.
Awesome,

Might it be useful to have other tags set as well?

LASTEXTERNALHELO - similar to the common tag in PerMsgStatus
LASTEXTERNALIP - as above

Anything else that could be handy?

Paul

On 04/11/14 16:51, Mark Martinec wrote:
> me wrote:
>> I agree that would make a trivial yet useful addition to functionality.
>> It probably does not help with PR #7080, but may be useful with other
>> mentioned applications. Will add something along these lines, thanks!
>
> Done:
>    https://issues.apache.org/SpamAssassin/show_bug.cgi?id=7099
>
>
> Mark
--
Paul Stead
Systems Engineer
Zen Internet

Re: Adding tag SENDERDOMAIN

Posted by Mark Martinec <Ma...@ijs.si>.
me wrote:
> I agree that would make a trivial yet useful addition to functionality.
> It probably does not help with PR #7080, but may be useful with other
> mentioned applications. Will add something along these lines, thanks!

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


Mark

Re: Adding tag SENDERDOMAIN

Posted by Mark Martinec <Ma...@ijs.si>.
2014-11-03 11:51, Paul Stead wrote:
> I think a tag of SENDERDOMAIN would be handy to have so it can be used
> with askdns and other rules which can make use of tags.
> 
> This would help address the following bug, which could be implemented
> with a simple rule:
> 
> https://issues.apache.org/SpamAssassin/show_bug.cgi?id=7080
> 
> As well as the following mailing list posts:
> 
> http://spamassassin.1065346.n5.nabble.com/DMARC-policy-check-with-AskDNS-posible-td109426.html
> http://spamassassin.1065346.n5.nabble.com/dnssec-dane-td110982.html#a112729
> - My post
> 
> I'd suggest the following diff - is this in the best place and method 
> to
> accomplish this?
> 
> --- lib/Mail/SpamAssassin/PerMsgStatus.pm    (revision 1636308)
> +++ lib/Mail/SpamAssassin/PerMsgStatus.pm    (working copy)
> @@ -2864,6 +2864,9 @@
>  ok:
>    $envf =~ s/^<*//gs;                # remove <
>    $envf =~ s/>*\s*$//gs;        # remove >, whitespace, newlines
> +  my $fromdom = $envf;
> +  $fromdom =~ s/.*\@//;
> +  $self->set_tag('SENDERDOMAIN', $fromdom);
>    return $envf;
>  }

I agree that would make a trivial yet useful addition to functionality.
It probably does not help with PR #7080, but may be useful with other
mentioned applications. Will add something along these lines, thanks!

   Mark