draft-ietf-sieve-include-00.txt   draft-ietf-sieve-include-01.txt 
Network Working Group C. Daboo Network Working Group C. Daboo
Internet-Draft A. Stone Internet-Draft A. Stone
Expires: September 24, 2009 March 23, 2009 Expires: September 30, 2009 March 29, 2009
Sieve Email Filtering: Include Extension Sieve Email Filtering: Include Extension
draft-ietf-sieve-include-00 draft-ietf-sieve-include-01
Status of this Memo Status of this Memo
This Internet-Draft is submitted to IETF in full conformance with the This Internet-Draft is submitted to IETF in full conformance with the
provisions of BCP 78 and BCP 79. This document may contain material provisions of BCP 78 and BCP 79. This document may contain material
from IETF Documents or IETF Contributions published or made publicly from IETF Documents or IETF Contributions published or made publicly
available before November 10, 2008. The person(s) controlling the available before November 10, 2008. The person(s) controlling the
copyright in some of this material may not have granted the IETF copyright in some of this material may not have granted the IETF
Trust the right to allow modifications of such material outside the Trust the right to allow modifications of such material outside the
IETF Standards Process. Without obtaining an adequate license from IETF Standards Process. Without obtaining an adequate license from
skipping to change at page 1, line 41 skipping to change at page 1, line 41
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
The list of current Internet-Drafts can be accessed at The list of current Internet-Drafts can be accessed at
http://www.ietf.org/ietf/1id-abstracts.txt. http://www.ietf.org/ietf/1id-abstracts.txt.
The list of Internet-Draft Shadow Directories can be accessed at The list of Internet-Draft Shadow Directories can be accessed at
http://www.ietf.org/shadow.html. http://www.ietf.org/shadow.html.
This Internet-Draft will expire on September 24, 2009. This Internet-Draft will expire on September 30, 2009.
Copyright Notice Copyright Notice
Copyright (c) 2009 IETF Trust and the persons identified as the Copyright (c) 2009 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents in effect on the date of Provisions Relating to IETF Documents in effect on the date of
publication of this document (http://trustee.ietf.org/license-info). publication of this document (http://trustee.ietf.org/license-info).
Please review these documents carefully, as they describe your rights Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. and restrictions with respect to this document.
Abstract Abstract
The Sieve Email Filtering "include" extension permits users to The Sieve Email Filtering "include" extension permits users to
include one Sieve script inside another. This can make managing include one Sieve script inside another. This can make managing
large scripts or multiple sets of scripts much easier, as well as large scripts or multiple sets of scripts much easier, and allows a
supporting common 'libraries' of scripts. Users are able to include site and its users to build up libraries of scripts. Users are able
their own personal scripts or site-wide scripts provided by the local to include their own personal scripts or site-wide scripts.
Sieve implementation.
Change History (to be removed prior to publication as an RFC) Change History (to be removed prior to publication as an RFC)
Changes from ietf-00 to ietf-01:
a. Replaced import/export with global.
b. Added :once modifier to include.
c. Added global namespace to see if it holds water.
Changes from daboo-06 to ietf-00: Changes from daboo-06 to ietf-00:
a. None a. None
Changes from -05 to -06: Changes from -05 to -06:
a. Aaron Stone joins as author. a. Aaron Stone joins as author.
b. Removed | characters from the script examples. b. Removed | characters from the script examples.
c. Updated draft references to published RFCs. c. Updated draft references to published RFCs.
Changes from -04 to -05: Changes from -04 to -05:
a. Fixed examples. a. Fixed examples.
skipping to change at page 2, line 46 skipping to change at page 3, line 4
Changes from -02 to -03: Changes from -02 to -03:
a. Refreshing expired draft (updated for nits). a. Refreshing expired draft (updated for nits).
b. Syntax -> Usage. b. Syntax -> Usage.
c. Updated to 3028bis reference. c. Updated to 3028bis reference.
Changes from -01 to -02: Changes from -01 to -02:
a. Minor formatting changes only - refreshing expired draft. a. Minor formatting changes only - refreshing expired draft.
Changes from -00 to -01: Changes from -00 to -01:
a. Added IPR boiler plate. a. Added IPR boiler plate.
b. Re-ordered sections at start to conform to RFC style. b. Re-ordered sections at start to conform to RFC style.
c. Moved recursion comment into General Considerations section. c. Moved recursion comment into General Considerations section.
d. Switched to using optional parameter to indicate personal vs d. Switched to using optional parameter to indicate personal vs
global. global.
e. Explicitly state that an error occurs when a missing script is e. Explicitly state that an error occurs when a missing script is
included. included.
Open Issues (to be resolved prior to publication as an RFC) Open Issues (to be resolved prior to publication as an RFC)
a. Interaction with variables (scoping). Should variables be a. Interaction with variables (scoping). Idea 1: use a "global"
carried over between scripts that are included? Or should command to make a variable shared between scripts. Idea 2: use a
variables defined in an included script be local to that script "global" variable namespace and no additional commands.
only?
Table of Contents Table of Contents
1. Introduction and Overview . . . . . . . . . . . . . . . . . . 4 1. Introduction and Overview . . . . . . . . . . . . . . . . . . 4
2. Conventions Used in This Document . . . . . . . . . . . . . . 4 2. Conventions Used in This Document . . . . . . . . . . . . . . 4
3. Include Extension . . . . . . . . . . . . . . . . . . . . . . 4 3. Include Extension . . . . . . . . . . . . . . . . . . . . . . 4
3.1. General Considerations . . . . . . . . . . . . . . . . . . 4 3.1. General Considerations . . . . . . . . . . . . . . . . . . 4
3.2. Control Structure Include . . . . . . . . . . . . . . . . 5 3.2. Control Structure include . . . . . . . . . . . . . . . . 5
3.3. Control Structure Return . . . . . . . . . . . . . . . . . 8 3.3. Control Structure return . . . . . . . . . . . . . . . . . 8
3.4. Interaction with Variables . . . . . . . . . . . . . . . . 8 3.4. Interaction with Variables . . . . . . . . . . . . . . . . 8
3.4.1. Control Structure Import . . . . . . . . . . . . . . . 8 3.4.1. Control Structure global . . . . . . . . . . . . . . . 9
3.4.2. Control Structure Export . . . . . . . . . . . . . . . 9 3.4.2. Variables Namespace global . . . . . . . . . . . . . . 10
4. Security Considerations . . . . . . . . . . . . . . . . . . . 10 4. Security Considerations . . . . . . . . . . . . . . . . . . . 10
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11
5.1. "include" Extension Registration . . . . . . . . . . . . . 10 5.1. "include" Extension Registration . . . . . . . . . . . . . 11
6. Normative References . . . . . . . . . . . . . . . . . . . . . 11 6. Normative References . . . . . . . . . . . . . . . . . . . . . 11
Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 11 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 11
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 11 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 11
1. Introduction and Overview 1. Introduction and Overview
Its convenient to be able to break SIEVE [RFC5228] scripts down into It's convenient to be able to break SIEVE [RFC5228] scripts down into
smaller components which can be reused in a variety of different smaller components which can be reused in a variety of different
circumstances. For example, users may want to have a default script circumstances. For example, users may want to have a default script
and a special 'vacation' script, the later being activated when the and a special 'vacation' script, the latter being activated when the
user goes on vacation. In that case the default actions should user goes on vacation. In that case the default actions should
continue to be run, but a vacation command should be executed first. continue to be run, but a vacation command should be executed first.
One option is to edit the default script to add or remove the One option is to edit the default script to add or remove the
vacation command as needed. Another is to have a vacation script vacation command as needed. Another is to have a vacation script
that simply has a vacation command and then includes the default that simply has a vacation command and then includes the default
script. script.
2. Conventions Used in This Document 2. Conventions Used in This Document
Conventions for notations are as in SIEVE [RFC5228] Section 1.1.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119]. document are to be interpreted as described in [RFC2119].
Conventions for notations are as in SIEVE [RFC5228] Section 1.1.
3. Include Extension 3. Include Extension
3.1. General Considerations 3.1. General Considerations
Sieve implementations that implement the "include", "return", Sieve implementations that implement the "include", "return", and
"export" and "import" commands described below have an identifier of "global" commands described below have an identifier of "include" for
"include" for use with the capability mechanism. If any of the use with the capability mechanism. If any of the "include",
"include", "return", "export" or "import" commands are used in a "return", or "global" commands are used in a script, the "include"
script, the "include" capability MUST be listed in the "require" capability MUST be listed in the "require" statement in that script.
statement in that script.
Sieve implementations must track the use of actions in included Sieve implementations must track the use of actions in included
scripts so that implicit "keep" behavior can be properly determined scripts so that implicit "keep" behavior can be properly determined
based on whether any actions have executed in any script. based on whether any actions have executed in any script.
Sieve implementations are allowed to limit the total number of nested Sieve implementations are allowed to limit the total number of nested
included scripts, but MUST provide for a total of at least three included scripts, but MUST provide for a total of at least three
levels of nested scripts including the top-level script. An error levels of nested scripts including the top-level script. An error
MUST be generated either when the script is uploaded to the Sieve MUST be generated either when the script is uploaded to the Sieve
repository, or when the script is executed, if any nesting limit is repository, or when the script is executed, if any nesting limit is
exceeded. If such an error is detected whilst processing a Sieve exceeded. If such an error is detected whilst processing a Sieve
script, an implicit "keep" action MUST be executed to prevent loss of script, an implicit "keep" action MUST be executed to prevent loss of
any messages. any messages.
Sieve implementations MUST ensure that recursive includes are not Sieve implementations MUST ensure that recursive includes are not
possible. i.e. if script "A" includes script "B", and script "B" possible. For example, if script "A" includes script "B", and script
includes script "A" an error MUST be generated either when the script "B" includes script "A" an error MUST be generated either when the
is uploaded to the Sieve repository, or when the script is executed. script is uploaded to the Sieve repository, or when the script is
If such an error is detected whilst processing a Sieve script, an executed. If such an error is detected whilst processing a Sieve
implicit "keep" action MUST be executed to prevent loss of any script, an implicit "keep" action MUST be executed to prevent loss of
messages. any messages.
Sieve implementations MUST handle missing scripts being referenced Sieve implementations MUST handle missing scripts being referenced
via an includes in an existing script. An error MUST be generated via an includes in an existing script. An error MUST be generated
when a missing included script is discovered during execution. If when a missing included script is discovered during execution. If
such an error is detected an implicit "keep" action MUST be executed such an error is detected an implicit "keep" action MUST be executed
to prevent loss of any messages. to prevent loss of any messages.
If the Sieve "variables" extension [RFC5229] is present, an issue If the Sieve "variables" extension [RFC5229] is present, an issue
arises with the "scope" of variables defined in scripts that may arises with the "scope" of variables defined in scripts that may
include each other. For example, if a script defines the variable include each other. For example, if a script defines the variable
"${status}" with one particular meaning or usage, and another defines "${status}" with one particular meaning or usage, and another defines
"${status}" with a different meaning, then if one script includes the "${status}" with a different meaning, then if one script includes the
other there is an issue as to which "${status}" is being referenced. other there is an issue as to which "${status}" is being referenced.
To solve this problem, Sieve implementations MUST follow the scoping To solve this problem, Sieve implementations MUST follow the scoping
rules defined in Section 3.4 and support the "import" and "export" rules defined in Section 3.4 and support the "global" command defined
commands defined there. there.
3.2. Control Structure Include 3.2. Control Structure include
Usage: include [<location: LOCATION>] <value: string> Usage: include [LOCATION] [ONCE] <value: string>
LOCATION = ":personal" / ":global" LOCATION = ":personal" / ":global"
The "include" command includes an optional "location" parameter, and ONCE = ":once"
a single string argument representing the name of the script to
include in the main script at that point.
The "location" parameter defaults to ":personal" if not specified. The "include" command takes an optional "location" parameter, an
The "location" has the following meanings: optional ":once" parameter, and a single string argument representing
the name of the script to include for processing at that point.
:personal The "location" parameter MUST default to ":personal" if not
specified. The "location" has the following meanings:
:personal
Indicates that the named script is stored in the user's own Indicates that the named script is stored in the user's own
personal (private) Sieve repository. personal (private) Sieve repository.
:global :global
Indicates that the named script is stored in a site-wide Sieve Indicates that the named script is stored in a site-wide Sieve
repository, accessible to all users of the Sieve system. repository, accessible to all users of the Sieve system.
The ":once" parameter tells the interpreter only to include the Sieve
script if it has not already been included at any other point during
the script execution. If the script has already been included,
processing continues immediately following the include command.
Implementations MUST NOT generate an error if an "include :once"
command names a script whose inclusion would be recursive; in this
case, the script MUST be considered previously included and therefore
"include :once" will not include it again.
Note: It is RECOMMENDED that script authors / generators use this
parameter only when including a script that performs general duties
such as declaring global variables and making sanity checks of the
environment.
The included script MUST be a valid Sieve script, including having The included script MUST be a valid Sieve script, including having
necessary "require" statements for all optional capabilities used by necessary "require" statements for all optional capabilities used by
the script. The scope of a "require" statement in an included script the script. The scope of a "require" statement in an included script
is for that script only, not the including script. e.g. if script "A" is for that script only, not the including script. For example, if
includes script "B", and script "B" uses the "fileinto" extension, script "A" includes script "B", and script "B" uses the "fileinto"
script "B" must have a "require" statement for "fileinto", extension, script "B" must have a "require" statement for "fileinto",
irrespective of whether script "A" has one. In addition, if script irrespective of whether script "A" has one. In addition, if script
"A" does not have a "require" statement for "fileinto", "fileinto" "A" does not have a "require" statement for "fileinto", "fileinto"
cannot be used anywhere in script "A", even after inclusion of script cannot be used anywhere in script "A", even after inclusion of script
"B". "B".
A "stop" command in an included script MUST stop all script A "stop" command in an included script MUST stop all script
processing, including the processing of the scripts that include the processing, including the processing of the scripts that include the
current one. The "return" command (described below) stops processing current one. The "return" command (described below) stops processing
of the current script only, and allows the scripts that include it to of the current script only, and allows the scripts that include it to
continue. continue.
skipping to change at page 6, line 31 skipping to change at page 6, line 44
The user has four scripts stored in their personal repository: The user has four scripts stored in their personal repository:
"default" "default"
This is the default active script that includes several others. This is the default active script that includes several others.
require ["include"]; require ["include"];
include :personal "always_allow"; include :personal "always_allow";
include :global "spam_tests"; include :global "spam_tests";
include :personal "my_spam_tests"; include :personal "spam_tests";
include :personal "mailing_lists"; include :personal "mailing_lists";
"always_allow" Personal script "always_allow"
This script special cases some correspondent email addresses and This script special cases some correspondent email addresses and
makes sure any message containing those addresses are always kept. makes sure any message containing those addresses are always kept.
if header :is "From" "boss@example.com" if header :is "From" "boss@example.com"
{ {
keep; keep;
} }
elsif header :is "From" "ceo@example.com" elsif header :is "From" "ceo@example.com"
{ {
keep; keep;
} }
"my_spam_tests" Personal script "spam_tests"
This script does some user-specific spam tests to catch spam This script does some user-specific spam tests to catch spam
messages not caught by the site-wide spam tests. messages not caught by the site-wide spam tests.
require ["reject"]; require ["reject"];
if header :contains "Subject" "XXXX" if header :contains "Subject" "XXXX"
{ {
reject; reject;
} }
elsif header :is "From" "money@example.com" elsif header :is "From" "money@example.com"
{ {
reject; reject;
} }
"mailing_lists" Personal script "mailing_lists"
This script looks for messages from different mailing lists and This script looks for messages from different mailing lists and
files each into a mailbox specific to the mailing list. files each into a mailbox specific to the mailing list.
require ["fileinto"]; require ["fileinto"];
if header :is "Sender" "owner-ietf-mta-filters@imc.org" if header :is "Sender" "owner-ietf-mta-filters@imc.org"
{ {
fileinto "lists.sieve"; fileinto "lists.sieve";
} }
elsif header :is "Sender" "owner-ietf-imapext@imc.org" elsif header :is "Sender" "owner-ietf-imapext@imc.org"
{ {
fileinto "lists.imapext"; fileinto "lists.imapext";
} }
There is one script stored in the global repository: There is one script stored in the global repository:
"spam_tests" Site script "spam_tests"
This script does some site-wide spam tests which any user at the This script does some site-wide spam tests which any user at the
site can include in their own scripts at a suitable point. The site can include in their own scripts at a suitable point. The
script content is kept up to date by the site administrator. script content is kept up to date by the site administrator.
require ["reject"]; require ["reject"];
if anyof (header :contains "Subject" "$$", if anyof (header :contains "Subject" "$$",
header :contains "Subject" "Make money") header :contains "Subject" "Make money")
{ {
skipping to change at page 8, line 15 skipping to change at page 8, line 26
Example: Example:
require ["include"]; require ["include"];
if anyof (header :contains "Subject" "$$", if anyof (header :contains "Subject" "$$",
header :contains "Subject" "Make money") header :contains "Subject" "Make money")
{ {
include "my_reject_script"; include "my_reject_script";
} }
3.3. Control Structure Return 3.3. Control Structure return
Usage: return Usage: return
The "return" command stops processing of the currently included The "return" command stops processing of the currently included
script only and returns processing control to the script which script only and returns processing control to the script which
includes it. If used in the main script (i.e. not in an included includes it. If used in the main script (i.e. not in an included
script), it has the same effect as the "stop" command, including the script), it has the same effect as the "stop" command, including the
appropriate "keep" action if no other actions have been executed up appropriate "keep" action if no other actions have been executed up
to that point. to that point.
skipping to change at page 8, line 38 skipping to change at page 8, line 49
In order to avoid problems of variables in an included script In order to avoid problems of variables in an included script
"overwriting" those from the script that includes it, this "overwriting" those from the script that includes it, this
specification requires that all variables defined in a script MUST be specification requires that all variables defined in a script MUST be
kept "private" to that script by default - i.e. they are not kept "private" to that script by default - i.e. they are not
"visible" to other scripts. This ensures that two script authors "visible" to other scripts. This ensures that two script authors
cannot inadvertently cause problems by choosing the same name for a cannot inadvertently cause problems by choosing the same name for a
variable. variable.
However, sometimes there is a need to make a variable defined in one However, sometimes there is a need to make a variable defined in one
script available to others. This specification defines the new script available to others. This specification defines the new
commands "export" and "import" to alter the default behavior of command "global" to declare that a variable is shared among scripts.
variable scoping to allow variables to be "seen" by other scripts. Effectively, two namespaces are defined: one local to the current
The "export" command takes a list of variable names defined in a script, and another shared among all scripts. Implementations MUST
script and makes those available to any script that explicitly wants allow a non-global variable to have the same name as a global
to use them. The "import" command allows a script to gain access to variable but have no interaction between them.
variables that have been explicitly made available by other scripts.
The explicit use of "export and "import", coupled with the default
behavior of variables only having local scope, ensures that multiple
scripts cannot inadvertently overwrite each others variables.
3.4.1. Control Structure Import 3.4.1. Control Structure global
Usage: import <value: string-list> Usage: global <value: string-list>
The "import" command contains a string list argument that defines one The "global" command contains a string list argument that defines one
or more names of variables exported by other scripts which should be or more names of variables to be stored in the global variable space.
made available to the current script.
The "import" command, if present, MUST be used immediately after any The "global" command, if present, MUST be used immediately after any
"require" commands (at least one of which will be present listing the "require" commands (at least one of which will be present listing the
"include" extension). Multiple "import" commands are allowed. An "include" extension). Multiple "global" commands are allowed. An
error occurs if an "import" command appears after a command other error occurs if an "global" command appears after a command other
than "require" or "import". Use of the "import" command makes the than "require" or "global". Use of the "global" command makes the
listed variables immediately available for use in the body of the listed variables immediately available for use in the body of the
script that uses it. script that uses it.
If an "import" command lists a variable that has not been exported by If a "global" command lists a variable that has not been defined in
any other script at that point during the Sieve execution process, the global namespace, the name of the variable is nonetheless marked
then an error MUST occur. as global, and any subsequent "set" command will set the value of the
variable in global scope.
Interpretation of a string containing a variable marked as global,
but without any value set, SHALL behave as any other access to an
unknown variable, as specified in Section 3 of [RFC5229] (that is,
the unknown variable reference evaltuates to an empty string).
Example: Example:
require ["variables", "fileinto", "include"]; require ["variables", "include"];
import "test"; global "test";
global "test-mailbox";
if header :contains "Subject" "${test}" # The included script may contain repetitive code that is
# effectively a subroutine that can be factored out.
set "test" "$$"
include "spam_filter_script";
set "test" "Make money"
include "spam_filter_script";
# Message will be filed according to the test that matched last.
if string :count "${test-mailbox}" "1"
{ {
fileinto "INBOX.spam-${test}; fileinto "INBOX${test-mailbox}";
stop;
} }
# If nothing matched, the message is implicitly kept.
3.4.2. Control Structure Export Active script
Usage: export <value: string-list> require ["variables", "include"];
global ["test", "test-mailbox"];
The "export" command contains a string list argument that defines one if header :contains "Subject" "${test}"
or more names of variables defined in the current script which should {
be made available to any scripts that run during the current Sieve set "test-mailbox" "spam-${test};
script execution process. }
The "export" command, if present, MUST be used immediately after any spam_filter_script
"require" or "import" commands. Multiple "export" commands are
allowed. An error occurs if an "export" command appears after a
command other than "require", "import" or "export".
An error occurs if an "export" command lists a variable that is 3.4.2. Variables Namespace global
listed in an "import" command preceding it in the current script.
In addition to the "global" command, this document defines the
variables namespace "global", per [RFC5229], Section 3.
Example: Example:
require ["variables", "include"]; require ["variables", "include"];
export "test";
set "test" "$$" set "global.i_am_on_vacation" "1";
include "spam_filter_script";
set "test" "Make money"
include "spam_filter_script";
Example: [[[ Does it make sense to have this form instead of the "global"
command? Does it make sense to have both? If both, it would make
sense that the two syntaxes reference the same set of variables. By
way of example:
require ["variables", "include"]; require ["variables", "include"];
import "test"; global "i_am_on_vacation";
export "test-mailbox";
if header :contains "Subject" "${test}" set "global.i_am_on_vacation" "1";
if string :is "${i_am_on_vacation}" "1"
{ {
set "test-mailbox" "INBOX.spam-${test}; vacation "It's true, I am on vacation."
include "fileinto-script"
} }
]]]
4. Security Considerations 4. Security Considerations
Sieve implementations MUST ensure adequate security for the global Sieve implementations MUST ensure adequate security for the global
script repository to prevent unauthorized changes to global scripts. script repository to prevent unauthorized changes to global scripts.
Beyond that, the "include" extension does not raise any security Beyond that, the "include" extension does not raise any security
considerations that are not present in the base Sieve protocol, and considerations that are not present in the base Sieve protocol, and
these issues are discussed in Sieve. these issues are discussed in Sieve.
5. IANA Considerations 5. IANA Considerations
 End of changes. 57 change blocks. 
104 lines changed or deleted 134 lines changed or added

This html diff was produced by rfcdiff 1.35. The latest version is available from http://tools.ietf.org/tools/rfcdiff/