Re: [exim] Removing all headers with the same prefix

2017-04-19 Thread Stefan Unterweger
* Jeremy Harris on Tue, Apr 18, 2017 at 10:54:58PM +0100:
> It'll be a multistep process, probably.  Treat ACLs as a programming
> language.
> 
> […]
> 
> But start with doing it as a sequence of
> 
>  set acl_m_foo =   

I’m already doing something very similar to implement a home-grown
greylisting (with the heavy lifting coming from Postgres).  This is
indeed one of the best ways I found out to build ACLs from scratch.


* Heiko Schlittermann via Exim-users on Wed, Apr 19, 2017 at 09:23:10AM +0200:
> As part of my data acl I use:
> 
>warn  set acl_m_headers_remove \
>= ${filter {MESSAGE_HEADERS}{match{$item}{\N^x-(?:ius|hh)-\N}}}
> 
> to remember all headers matching /^x-(ius|hh)-/i in an ACL variable.
> The MESSAGE_HEADERS macro is:
> 
> MESSAGE_HEADERS  = \
>   ${lc:${sg\
>{${map\
>  { <\n ${sg {$message_headers_raw}{\N\n\s+\N}{ }} }\
>  {${extract{1}{:}{$item}}}\
>  }\
>}\
>{\N\n\N}\
>{:}\
>}}

Thanks for the pointer: This is exactly the direction I was looking for.
Now I know where to look, thanks!


Cheers,
Stefan

-- 
▪ Die Internetbleibe.  Schick, magisch, leistungsstark.  
https://internetbleibe.de/
▪ medoly media UG (haftungsbeschränkt) | Hausburgstraße 13, 10249 Berlin
▪ i...@medolymedia.de | https://medolymedia.de/ | Tel. 030 609 826‒560 | Fax 
…‒569
▪ Geschäftsführer: Matthias Nothhaft | HRB 131198 (Amtsgericht 
Berlin-Charlottenburg), Sitz: Berlin, USt-ID: DE275221203

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Re: [exim] Removing all headers with the same prefix

2017-04-19 Thread Heiko Schlittermann via Exim-users
Stefan Unterweger <28443.kr@8j1.enskribi.email> (Di 18 Apr 2017 20:07:33 CEST):
> I want to scrub certain kinds of headers for all incoming messages so
…
> I have tried to find some kind of string expansion which would give me a
> list of all message headers which start with my chosen prefix, or some
> other kind of trick to get similar results, but so far, I didn’t find
> anything.  Of course I could list all possible combinations of ‘Spam-…’
> that I can think of, but this is kind of a losing battle…

As part of my data acl I use:

 warn  set acl_m_headers_remove \
   = ${filter {MESSAGE_HEADERS}{match{$item}{\N^x-(?:ius|hh)-\N}}}

to remember all headers matching /^x-(ius|hh)-/i in an ACL variable.
The MESSAGE_HEADERS macro is:

MESSAGE_HEADERS  = \
  ${lc:${sg\
   {${map\
 { <\n ${sg {$message_headers_raw}{\N\n\s+\N}{ }} }\
 {${extract{1}{:}{$item}}}\
 }\
   }\
   {\N\n\N}\
   {:}\
   }}


The actual removal is done in the transport as follows:

begin transports

smtp:
driver = …
headers_remove = $acl_m_headers_remove
headers_add = $acl_m_headers_add


But, please note, this solution has not been reviewed for a long time, but
it is in use currently and seems to work. 


Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
-- 
 SCHLITTERMANN.de  internet & unix support -
 Heiko Schlittermann, Dipl.-Ing. (TU) - {fon,fax}: +49.351.802998{1,3} -
 gnupg encrypted messages are welcome --- key ID: F69376CE -
 ! key id 7CBF764A and 972EAC9F are revoked since 2015-01  -


signature.asc
Description: PGP signature
-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Re: [exim] Removing all headers with the same prefix

2017-04-19 Thread Jasen Betts
On 2017-04-18, Stefan Unterweger <28443.kr@8j1.enskribi.email> wrote:
> Hi,
>
> I want to scrub certain kinds of headers for all incoming messages so
> that I can use them for myself—and trust them.  In particular, I want to
> get rid of all headers which start with ‘Spam-’, no matter what comes
> after that prefix (be it ‘Spam-Score’, ‘Spam-Whitelisted’ or whatever my
> yet-to-be-designed antispam filters will come up with).
>
> The Exim Specification mentions in §43.25 that ‘wildcards are not
> permitted, nor is list expansion performed […] however, both connection
> and message variable expansions are performed.‘
>
> I have tried to find some kind of string expansion which would give me a
> list of all message headers which start with my chosen prefix, or some
> other kind of trick to get similar results, but so far, I didn’t find
> anything.  Of course I could list all possible combinations of ‘Spam-…’
> that I can think of, but this is kind of a losing battle…
>
> Any ideas are appreciated.

something using ${sg perhaps.

-- 
This email has not been checked by half-arsed antivirus software 

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Re: [exim] Removing all headers with the same prefix

2017-04-18 Thread Jeremy Harris
On 18/04/17 19:07, Stefan Unterweger wrote:
> I want to scrub certain kinds of headers for all incoming messages so
> that I can use them for myself—and trust them.  In particular, I want to
> get rid of all headers which start with ‘Spam-’, no matter what comes
> after that prefix (be it ‘Spam-Score’, ‘Spam-Whitelisted’ or whatever my
> yet-to-be-designed antispam filters will come up with).

It'll be a multistep process, probably.  Treat ACLs as a programming
language.

Start with all the headers.
Treating them as a list, strip the content leaving just the
header names.
Filter for only the names you're
interested in.
Then feed that variable to headers_remove.


You _might be able then, having constructed it sequentially,
be able to compress it into a one-liner nested expansion -
if you care.

But start with doing it as a sequence of

 set acl_m_foo =   

operations, it's the only way to stay sane.
-- 
Cheers,
  Jeremy

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

[exim] Removing all headers with the same prefix

2017-04-18 Thread Stefan Unterweger
Hi,

I want to scrub certain kinds of headers for all incoming messages so
that I can use them for myself—and trust them.  In particular, I want to
get rid of all headers which start with ‘Spam-’, no matter what comes
after that prefix (be it ‘Spam-Score’, ‘Spam-Whitelisted’ or whatever my
yet-to-be-designed antispam filters will come up with).

The Exim Specification mentions in §43.25 that ‘wildcards are not
permitted, nor is list expansion performed […] however, both connection
and message variable expansions are performed.‘

I have tried to find some kind of string expansion which would give me a
list of all message headers which start with my chosen prefix, or some
other kind of trick to get similar results, but so far, I didn’t find
anything.  Of course I could list all possible combinations of ‘Spam-…’
that I can think of, but this is kind of a losing battle…

Any ideas are appreciated.

Cheers,
Stefan

-- 
▪ Die Internetbleibe.  Schick, magisch, leistungsstark.  
https://internetbleibe.de/
▪ medoly media UG (haftungsbeschränkt) | Hausburgstraße 13, 10249 Berlin
▪ i...@medolymedia.de | https://medolymedia.de/ | Tel. 030 609 826‒560 | Fax 
…‒569
▪ Geschäftsführer: Matthias Nothhaft | HRB 131198 (Amtsgericht 
Berlin-Charlottenburg), Sitz: Berlin, USt-ID: DE275221203

-- 
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/