Subject: Working with the CMU Sieve code base

From: Aaron Stone <[email-masked]>
Date: Sun, 23 Feb 2003 22:55:13 -0800 (PST)

Hi,

I've been wrestling with the CMU Sieve code base for the past few weeks
and months, cleaning it up and making it useable as a generic Sieve
library without external dependencies.

Many of the folks on this list are also in the source as principal authors
of that code base... so this may be off-topic for the list, but is there
interest in discussing the finer points of wrestling with the code here?

Specifically: sieve_script_parse() takes a FILE argument. Many modern
MDA's use databases, LDAP, and other such storage mechanisms for their
user information, such that it would be much easier to present a buffer.

Thanks,
Aaron

---

From: Rob Siemborski <[email-masked]>
Date: Mon, 24 Feb 2003 09:13:26 -0500 (EST)

I'd suggest the Cyrus Development list ([email-masked])
for this thread.

-Rob

> user information, such that it would be much easier to present a buffer.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rob Siemborski | Andrew Systems Group * Research Systems Programmer
PGP:0x5CE32FCC | Cyert Hall 207 * [email-masked] * 412.268.7456
-----BEGIN GEEK CODE BLOCK----
Version: 3.12
GCS/IT/CM/PA d- s+: a-- C++++$ ULS++++$ P+++$ L+++(++++) E W+ N o? K-
w O- M-- V-- PS+ PE++ Y+ PGP+ t+@ 5+++ R@ tv-@ b+ DI+++ G e h r- y?
------END GEEK CODE BLOCK-----

Date: Mon, 24 Feb 2003 09:13:26 -0500 (EST)
From: Rob Siemborski <[email-masked]>
To: Aaron Stone <[email-masked]>
cc: [email-masked]
Subject: Re: Working with the CMU Sieve code base
Sender: [email-masked]

I'd suggest the Cyrus Development list ([email-masked])
for this thread.

-Rob

> user information, such that it would be much easier to present a buffer.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rob Siemborski | Andrew Systems Group * Research Systems Programmer
PGP:0x5CE32FCC | Cyert Hall 207 * [email-masked] * 412.268.7456
-----BEGIN GEEK CODE BLOCK----
Version: 3.12
GCS/IT/CM/PA d- s+: a-- C++++$ ULS++++$ P+++$ L+++(++++) E W+ N o? K-
w O- M-- V-- PS+ PE++ Y+ PGP+ t+@ 5+++ R@ tv-@ b+ DI+++ G e h r- y?
------END GEEK CODE BLOCK-----

Date: Sun, 23 Feb 2003 22:55:13 -0800 (PST)
From: Aaron Stone <[email-masked]>
To: [email-masked]
Subject: Working with the CMU Sieve code base
Sender: [email-masked]

Hi,

Thanks,
Aaron

Date: Tue, 4 Feb 2003 16:16:09 -0500
From: Lawrence Greenfield <[email-masked]>
To: [email-masked], Marc Mutz <[email-masked]>
Subject: Re: [managesieve] setactive "" semantics questions
Sender: [email-masked]

   Date: Tue, 04 Feb 2003 15:10:26 +0100
   From: Marc Mutz <[email-masked]>

   from draft-martin-managesieve-04:
   2.8.  SETACTIVE Command
       This command sets a script active. If the script name is the empty
       string (i.e. "") then any active script is disabled. If the script
       does not exist on the server then the server MUST reply with a NO
       response.
   <snip>

   What does that mean for
     setactive ""
   when no script is active? Should it fail or succeed? (The latter would 
   be a PITA for client implementors, since I need to LISTSCRIPTS before 
   any SETACTIVE "").

Our server repsonds with a "No" when there is no active script. I
don't think a server that responds with an "Ok" would be that far out
of line.

   And:
   Do I need to issue
    setactive ""
   between
     setactive "foo"
     setactive "bar"
   or will the second command implicitely set "foo" to inactive?

You can send

     setactive "foo"
     setactive "bar"

without any intervening commands.

Larry

Date: Tue, 04 Feb 2003 15:10:26 +0100
From: Marc Mutz <[email-masked]>
Subject: [managesieve] setactive "" semantics questions
To: [email-masked]
Organization: KDE
Sender: [email-masked]

--Boundary-02=_Tn8P+smFRSRbI15
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Description: signed data
Content-Disposition: inline

Hi!

from draft-martin-managesieve-04:
2.8.  SETACTIVE Command
    This command sets a script active. If the script name is the empty
    string (i.e. "") then any active script is disabled. If the script
    does not exist on the server then the server MUST reply with a NO
    response.
<snip>

What does that mean for
  setactive ""
when no script is active? Should it fail or succeed? (The latter would=20
be a PITA for client implementors, since I need to LISTSCRIPTS before=20
any SETACTIVE "").

And:
Do I need to issue
 setactive ""
between
  setactive "foo"
  setactive "bar"
or will the second command implicitely set "foo" to inactive?

Marc

=2D-=20
They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety.      -- Benjamin Franklin

--Boundary-02=_Tn8P+smFRSRbI15
Content-Type: application/pgp-signature
Content-Description: signature

--Boundary-02=_Tn8P+smFRSRbI15--

Date: Tue, 04 Feb 2003 00:53:51 +0100
From: Marc Mutz <[email-masked]>
Subject: Re: extensions and sieve
To: [email-masked]
Organization: KDE
Sender: [email-masked]

--Boundary-02=_PEwP+fRpHixpUT3
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Description: signed data
Content-Disposition: inline

On Tuesday 04 February 2003 00:13, Jutta Degener wrote:
<snip :param>
>   But maybe this is overkill.

It isn't, but this is:

> - RFC 2047 prohibits RFC 2047-encoding of filenames.
>   (They're not the right kind of token.)
>
>   In reality, many clients do RFC 2047-encode and -decode names,
>   and I think sieve code matching against file names in order
>   to prevent use of certain extensions needs to, ironically,
>   RFC 2047-decode the wrong tokens in spite of what the RFC itself
> says.
<snip>

They should decode rfc2231, of course, but leave rfc2047 alone in=20
parameters. The only client I am aware of that is so broken to produce=20
rfc2047 in parameter values is - guess what - Outlook (I think mutt had=20
this bug in one or two minor revisions, too, but I don't know, so I=20
won't claim it).

As a general note, this mimeheader searching is of course failing for=20
encrypted content, so if you try to filter out .vbs (which, I suppose,=20
are VisualBasic scripts), you're better off hooking up a custom=20
solution (read: ADKs, bah!) into your Sieve engine's spamtest/virustest=20
framework.

Marc

=2D-=20
History teaches that grave threats to liberty often come in times of
urgency, when constitutional rights seem too extravagant to endure.
                                  -- Justice Thurgood Marshall, 1989

--Boundary-02=_PEwP+fRpHixpUT3
Content-Type: application/pgp-signature
Content-Description: signature

--Boundary-02=_PEwP+fRpHixpUT3--

Date: Mon, 3 Feb 2003 15:13:30 -0800
From: Jutta Degener <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Subject: Re: extensions and sieve
Sender: [email-masked]

Seems a lot of people have asked for this.
So, here's a bit of wording to play with.

Two issues I can think of:

- I really don't like applying regexes to something with
  a comment and quote syntax.

  Therefore, I'd like a :param parameter that can be used
  to select a Content-Disposition or Content-Type parameter
  (so you'd check for :param "filename" in the example)
  rather than trying to just match them with :contains
  or worse.  (The grammar describing what :param means
  can probably be done better.)

  But maybe this is overkill.

- RFC 2047 prohibits RFC 2047-encoding of filenames.
  (They're not the right kind of token.)

  In reality, many clients do RFC 2047-encode and -decode names,
  and I think sieve code matching against file names in order
  to prevent use of certain extensions needs to, ironically,
  RFC 2047-decode the wrong tokens in spite of what the RFC itself says.

  I'm not sure about the right wording there.

Here's a hasty first draft:

Test mimeheader

   Syntax: mimeheader [:param <params:string-list>] [COMPARATOR] [MATCH-TYPE]
        	     <header-names: string-list> <key-list: string-list>

   The "mimeheader" test evaluates to true if any of the values of
   the named MIME headers match any of the keys.  The type of match
   is specified by the optional [MATCH-TYPE] argument, which defaults
   to ":is", as specified in section 2.6 of [SIEVE].

   Like the "header" test, this test returns true if any combination of the
   string-list and key-list arguments match.  Also like "header", a
   MIME header listed in the header-names argument contains the
   empty string key if and only if it exists.

   Unlike the "header" test, the headers matching the "mimeheader" test
   can occur either in the outermost RFC2822 header or in any of the 
   contained MIME parts.  (They must occur in the header section of
   a MIME part; the matching algorithm MUST disregard the text contained
   in MIME bodies.)

   If the optional :param keyword is present, all matching headers
   are interpreted as if they had the syntax

   	*(token / <tspecial other than ;>) *(; name=value)

   similar of the Content-Type and Content-Disposition header, and the
   value used for the sake of comparison is that of the parameter whose
   name case-insensitively matches any of the specified names.

Jutta <[email-masked]>

Date: Mon, 03 Feb 2003 17:08:45 -0500
From: Cyrus Daboo <[email-masked]>
To: [email-masked]
cc: [email-masked]
Subject: Re: extensions and sieve
Sender: [email-masked]

Hi [email-masked],

--On Monday, February 03, 2003 1:20 PM -0800 [email-masked] wrote:

| In the meantime, note that for a message that is in MIME format, you can
| hope that perhaps the filename will show up in a MIME header line.  For
| instance, filenames are sometimes in a NAME parameter on a Content-type:
| header line, or in a FILENAME parameter on the Content-disposition:
| header line, or occasionally filenames will even get put on the
| Content-description: header line.  So you could try doing something like:
|
| if header :contains
|  ["Content-type", "Content-disposition", "Content-description"] ".vbs" {
|  ...some action... }
|
| but of course note that that's only going to apply in cases where incoming
| messages are in MIME format, and happen to have the filename explicitly
| advertised on one of the listed MIME header lines.  So depending upon what
| sorts of incoming messages you're dealing with, this may or may not be
| useful.

That won't work in general. The 'header' test is done only over the 
top-level rfc2822 headers and not on any MIME headers embedded in the 
message when it is a multipart. Thus any multiparts will not be caught by 
this and I think that will be the majority of cases.

-- 
Cyrus Daboo

From: [email-masked]
Date: Mon, 03 Feb 2003 13:20:31 -0800 (PST)
Subject: Re: extensions and sieve
To: Paulo Sousa <[email-masked]>
Cc: Nigel Swinson <[email-masked]>, [email-masked]
Sender: [email-masked]

In addition to what Nigel Swinson <[email-masked]> wrote:

> > Anyone could help me? I need filter mails by extensions (.exe .vbs ....).
> > How i can do a rule to this?

> The Sieve spec doesn't natively support any kind of test on the content of
> the message, only the headers, envelope and size of the message.  Sieve is
> currently not MIME aware at all.

> However some implementation have some kind of X_body test that allows you to
> search against the body of the message, but it's all a bit of kludge.  It's
> only really worthwhile if it's available in conjunction with the regex
> extension, and even then it becomes extremely CPU intensive, and a problem
> for the server.

> The better solution is to wait for us to knock together some kind of mime
> aware syntax that allows us to say "emails that contain attachments of type
> X"...

In the meantime, note that for a message that is in MIME format, you can hope
that perhaps the filename will show up in a MIME header line.  For instance,
filenames are sometimes in a NAME parameter on a Content-type: header line, or
in a FILENAME parameter on the Content-disposition: header line, or
occasionally filenames will even get put on the Content-description: header
line.  So you could try doing something like:

if header :contains
 ["Content-type", "Content-disposition", "Content-description"] ".vbs" { 
 ...some action... }

but of course note that that's only going to apply in cases where incoming
messages are in MIME format, and happen to have the filename explicitly
advertised on one of the listed MIME header lines.  So depending upon what
sorts of incoming messages you're dealing with, this may or may not be useful.

Regards,

Kristin

> Doing this with MailSite for example, involves following the advice found in
> the following KB articles:
> http://www.rockliffe.com/support/docs/html/1/00/10039.asp
> http://www.rockliffe.com/support/docs/html/1/00/10078.asp

> The KB articles describe how to enter the filters into the gui, but if you
> click the "advanced" button then you get to see the Sieve it produces in all
> it's glory.

> BTW, this list is NOT designed to answer this kind of query... it's for
> discussion and creation of new Sieve standards/specs.  Advice on this kind
> of thing should be solicited from your mail server provider.

> Cheers

> Nigel

From: "Nigel Swinson" <[email-masked]>
To: "Paulo Sousa" <[email-masked]>
Cc: <[email-masked]>
Subject: Re: extensions and sieve
Date: Mon, 3 Feb 2003 20:57:12 -0000
Sender: [email-masked]

> Anyone could help me? I need filter mails by extensions (.exe .vbs ....).
> How i can do a rule to this?

The Sieve spec doesn't natively support any kind of test on the content of
the message, only the headers, envelope and size of the message.  Sieve is
currently not MIME aware at all.

However some implementation have some kind of X_body test that allows you to
search against the body of the message, but it's all a bit of kludge.  It's
only really worthwhile if it's available in conjunction with the regex
extension, and even then it becomes extremely CPU intensive, and a problem
for the server.

The better solution is to wait for us to knock together some kind of mime
aware syntax that allows us to say "emails that contain attachments of type
X"...

Doing this with MailSite for example, involves following the advice found in
the following KB articles:
http://www.rockliffe.com/support/docs/html/1/00/10039.asp
http://www.rockliffe.com/support/docs/html/1/00/10078.asp

The KB articles describe how to enter the filters into the gui, but if you
click the "advanced" button then you get to see the Sieve it produces in all
it's glory.

BTW, this list is NOT designed to answer this kind of query... it's for
discussion and creation of new Sieve standards/specs.  Advice on this kind
of thing should be solicited from your mail server provider.

Cheers

Nigel

Date: Mon, 3 Feb 2003 12:31:51 -0200 (BRST)
From: Paulo Sousa <[email-masked]>
To: [email-masked]
Subject: extensions and sieve
Sender: [email-masked]

Hi

Anyone could help me? I need filter mails by extensions (.exe .vbs ....).
How i can do a rule to this?

Thanks

Paulo Sousa