Internet-Draft | Sieve Filter Rule Metadata | March 2023 |
Happel | Expires 14 September 2023 | [Page] |
This document describes current practices in managing Sieve scripts and proposes a standardized way for storing filter rule metadata in Sieve comments.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 14 September 2023.¶
Copyright (c) 2023 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
Sieve is a formal language for email filtering specified in (RFC5228). Filters are stored in so called "scripts", which are text files containing Sieve filtering expressions.¶
Users can edit Sieve scripts directly, in case they have access to the script files, or by using the ManageSieve protocol (RFC5804), if it is made available by their email service.¶
While experienced users may follow this approach, (RFC5228, section 1) anticipates that "GUI-based editors will be the preferred way of editing filters for a large number of users."¶
This likely describes current practice, given that typical end users rarely have direct access to their Sieve scripts, and given that most email services do not offer ManageSieve access. Furthermore, even for a popular email client such as Thunderbird, only very rough Script editors seem to exist [TBSieve].¶
Many Webmail and Groupware software features GUI-based email filter editors, which use Sieve as the underlying script language. When creating filters, the editor will create or update the user's Sieve script. When opening the editor, the script will be parsed and presented in a constrained set of UI widgets (such as dropdown-lists or input fields).¶
The vast majority (if not all) GUI-based editors follow a similar interaction paradigm, which is designed along the Sieve language design concepts. A user first needs to define a "test" (RFC5228, section 2.5), which defines filtering criteria (e.g., based on sender or size of a message). The second major component is the definition of one or more "actions" (RFC5228, section 4), such as to move an email matching the filtering criteria into a certain mailbox.¶
The design of existing editors affords users to modularize their email filters, so that multiple test/action style "fiter rules" are created. The "else" and "elseif" keywords, which are common in free-form Sieve scripts (RFC5228, section 9), are typically not used in those modularized filter rules.¶
Modularized filter rules often contain a "stop;" commend as their final action by default, which makes them widely independent of each other. GUI-based email filter editors typically allow users to label and to (re-)order filter rules.¶
Besides a dedicated GUI-based editor for email filters, many Webmail and Groupware software include additional ways to modify the Sieve script of a user. There are contextual interfaces, which create rules in the background or which launch a prefilled filter rule creation dialog.¶
Examples are:¶
The latter case is also an example for special purpose filters as described in the following.¶
Email filters are often used as a technology for realizing other features, such as blocklists, vacation messages [RFC5230], or email forwarding. In most of these cases, there will be a dedicated user interface specific to the feature. This user interface will still write to the user's Sieve script, but the corresponding email filter will either not be editable or hidden in the regular email filter editor.¶
This special handling in the filter editor (i.e., the recognition of a special purpose filter rule) is typically based on metadata which is captured in Sieve comments (see also Section 4).¶
Besides capturing rules based on user input, Sieve scripts are sometimes also used in other ways. E.g., some SPAM filtering systems use machine-generated Sieve scripts for their operations. Such scripts are typically hidden from end users and hence cannot be edited. They are out of the scope of this draft.¶
In order to manage modularized Sieve scripts, GUI-based script editors need to capture the following information.¶
In addition to this, some systems store further information:¶
Since none of this information is natively supported by the Sieve rule language, systems fall back to Sieve comments for storing. Various vendor-specific practices have emerged, as seen in Section 4.¶
Another aspect of informal standardization has been the deacativation of certain Sieve code. Based on the RFC, Sieve offers two means of deactivation:¶
While some vendors using type (b) scripts rely on commenting out for disabling individual modular rules, others came up with more formalized approaches such as wrapping disabled rules using a simple "if (false)" clause.¶
The following filtering rule is take from an OpenXChange-generated Sieve script:¶
Flag: |UniqueId:15|Rulename: testRuleCreate if true { discard ; }¶
Once "deactivated" in the user interface, this filtering rule will be represented in the Sieve script as follows:¶
## Flag: |UniqueId:15|Rulename: testRuleCreate #<!-->if true #<!-->{ #<!--> discard ; #<!-->}¶
The following filtering rule is take from an CriticalPath-generated Sieve script:¶
if allof (true, header :contains "X-Priority" "5") { discard; }¶
Once "deactivated" in the user interface, this filtering rule will be represented in the Sieve script as follows:¶
if allof (false, header :contains "X-Priority" "5") { discard; }¶
While the described informal workarounds helped vendors to cope within the boundaries of the Sieve language, we see a number of issues with this status quo:¶
The purpose of this section is to propose a normative reference for filtering rule comments and deactivation.¶
(TBD)¶
(TBD)¶
For the purpose of deactivating rules, the "wrapping" approach described in the previous section should be applied.¶
(TBD)¶
In this section, we will document Sieve script patterns used by the software of different vendors.¶
"(...)" stands for omitted code in example scripts.¶
# cp_filter_name: Test filter # cp_filter_description:¶
# Sieve Filter # Generated by Ingo (http://www.horde.org/apps/ingo/) (09/03/2021, 05:37:41 PM) require ["vacation", "regex", "fileinto", "imapflags", "body", "reject", "notify"]; # Whitelisted Addresses if address :all :comparator "i;ascii-casemap" :is ["From", "Sender", "Resent-From"] "whitelist@foo.com" { keep; stop; } # Vacation (...) # Blacklisted Addresses if address :all :comparator "i;ascii-casemap" :is ["From", "Sender", "Resent-From"] "non@foo.com" { discard; stop; } # Spamfilter if header :comparator "i;ascii-casemap" :matches "X-Spam-Status" "yes*" { fileinto "spamblock"; stop; } # Forwards if true { redirect "fws@foo.com"; } # userDefined Rule (Name: fileInto userDefinedFolder) if address :all :comparator "i;ascii-casemap" :contains "To" "x" { fileinto "userDefinedFolder"; stop; }¶
#RULE: $Name="Blocked senders" $Type="BLOCKED_ADDRESSES" $Version=1 $Lz=1 $Order=1 #BEGINFILTER (...) #ENDFILTER #RULE: $Name="Test Folder Bulkmail" $Type="DEFAULT_TYPE" $Version=1 $Lz=1 $Order=6 #require "fileinto"; (...) #ENDRULE¶
## Flag: vacation|UniqueId:1|Rulename: vacation notice ## Flag: autoforward|UniqueId:2|Rulename: autoforward ## Flag: |UniqueId:0|Rulename: MyTestFiler¶
This document has no IANA actions at this time.¶