draft-ietf-sieve-include-07.txt   draft-ietf-sieve-include-08.txt 
Network Working Group C. Daboo Network Working Group C. Daboo
Internet-Draft A. Stone Internet-Draft A. Stone
Intended status: Standards Track July 5, 2011 Intended status: Standards Track July 8, 2011
Expires: January 6, 2012 Expires: January 9, 2012
Sieve Email Filtering: Include Extension Sieve Email Filtering: Include Extension
draft-ietf-sieve-include-07 draft-ietf-sieve-include-08
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, and allows a large scripts or multiple sets of scripts much easier, and allows a
site and its users to build up libraries of scripts. Users are able site and its users to build up libraries of scripts. Users are able
to include their own personal scripts or site-wide scripts. to include their own personal scripts or site-wide scripts.
Status of this Memo Status of this Memo
skipping to change at page 1, line 34 skipping to change at page 1, line 34
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
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."
This Internet-Draft will expire on January 6, 2012. This Internet-Draft will expire on January 9, 2012.
Copyright Notice Copyright Notice
Copyright (c) 2011 IETF Trust and the persons identified as the Copyright (c) 2011 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 Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction and Overview . . . . . . . . . . . . . . . . . . 5 1. Introduction and Overview . . . . . . . . . . . . . . . . . . 3
2. Conventions Used in This Document . . . . . . . . . . . . . . 5 2. Conventions Used in This Document . . . . . . . . . . . . . . 3
3. Include Extension . . . . . . . . . . . . . . . . . . . . . . 6 3. Include Extension . . . . . . . . . . . . . . . . . . . . . . 3
3.1. General Considerations . . . . . . . . . . . . . . . . . . 6 3.1. General Considerations . . . . . . . . . . . . . . . . . . 3
3.2. Control Structure include . . . . . . . . . . . . . . . . 7 3.2. Control Structure include . . . . . . . . . . . . . . . . 5
3.3. Control Structure return . . . . . . . . . . . . . . . . . 10 3.3. Control Structure return . . . . . . . . . . . . . . . . . 8
3.4. Interaction with Variables . . . . . . . . . . . . . . . . 10 3.4. Interaction with Variables . . . . . . . . . . . . . . . . 8
3.4.1. Control Structure global . . . . . . . . . . . . . . . 10 3.4.1. Control Structure global . . . . . . . . . . . . . . . 8
3.4.2. Variables Namespace global . . . . . . . . . . . . . . 12 3.4.2. Variables Namespace global . . . . . . . . . . . . . . 10
4. Security Considerations . . . . . . . . . . . . . . . . . . . 13 4. Security Considerations . . . . . . . . . . . . . . . . . . . 10
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11
5.1. "include" Extension Registration . . . . . . . . . . . . . 13 5.1. "include" Extension Registration . . . . . . . . . . . . . 11
6. References . . . . . . . . . . . . . . . . . . . . . . . . . . 14 6. References . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.1. Normative References . . . . . . . . . . . . . . . . . . . 14 6.1. Normative References . . . . . . . . . . . . . . . . . . . 11
6.2. Informative References . . . . . . . . . . . . . . . . . . 14 6.2. Informative References . . . . . . . . . . . . . . . . . . 11
Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 14 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 12
Appendix B. Change History (to be removed prior to
publication as an RFC) . . . . . . . . . . . . . . . 12
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 14 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 14
Change History (to be removed prior to publication as an RFC)
Changes from ietf-06 to ietf-07:
a. Nits from Stephan Bosch.
Changes from ietf-05 to ietf-06:
a. Nits from Barry Leiba.
Changes from ietf-04 to ietf-05:
a. Integrate review from Barry Leiba.
Changes from ietf-03 to ietf-04:
a. No changes.
Changes from ietf-02 to ietf-03:
a. Setting a variable then calling global on it is an error
(something like 'use strict').
b. Specify that the 'global' keyword is only available when
'variables' has also been required.
c. Uploading a script that includes a nonexistent script is not an
error at upload time.
Changes from ietf-01 to ietf-02:
a. Require that script names must be constant strings, not subject
to variable expansion.
b. Try the phrase immediate script instead of current script.
c. Clarify that "global 'varname'" and "global.varname" refer to the
same variable.
d. Drop the requirement the global keywords come after require and
before anything else.
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:
a. None
Changes from -05 to -06:
a. Aaron Stone joins as author.
b. Removed | characters from the script examples.
c. Updated draft references to published RFCs.
Changes from -04 to -05:
a. Fixed examples.
b. Relaxed requirement that imported/exported variables be set
before being used.
Changes from -03 to -04:
a. Fixed missing 2119 definitions.
b. Defined interaction with variables through use of import and
export commands.
Changes from -02 to -03:
a. Refreshing expired draft (updated for nits).
b. Syntax -> Usage.
c. Updated to 3028bis reference.
Changes from -01 to -02:
a. Minor formatting changes only - refreshing expired draft.
Changes from -00 to -01:
a. Added IPR boiler plate.
b. Re-ordered sections at start to conform to RFC style.
c. Moved recursion comment into General Considerations section.
d. Switched to using optional parameter to indicate personal vs
global.
e. Explicitly state that an error occurs when a missing script is
included.
1. Introduction and Overview 1. Introduction and Overview
It's 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 latter 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
skipping to change at page 6, line 28 skipping to change at page 4, line 20
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 NOT allow recursive script inclusion. An
possible. For example, if script "A" includes script "B", and script error MUST be generated when such a script is executed. An error
"B" includes script "A" an error MUST be generated either when the SHOULD be generated when such a script is marked active with
script is uploaded to the Sieve repository, or when the script is MANAGESIEVE [RFC5804] or similar mechanisms. Implementations MUST
executed. If such an error is detected whilst processing a Sieve NOT generate errors for recursive inclusions at upload time, as this
script, an implicit "keep" action MUST be executed to prevent loss of would force an upload ordering requirement upon script authors /
any messages. generators. However, if an active script is replaced with a faulty
script and would remain the active script, an error MUST be generated
and the upload MUST fail. If an include recursion error is detected
during script execution, an implicit "keep" action MUST be executed
to prevent loss of any messages.
Sieve implementations MUST generate an error at execution time if an Sieve implementations MUST generate an error at execution time if an
included script does not exist. Implementations MUST NOT generate included script does not exist. Implementations MUST NOT generate
errors for scripts missing at upload time, as this would force an errors for scripts missing at upload time, as this would force an
upload ordering requirement upon script authors / generators. upload ordering requirement upon script authors / generators.
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 "global" command defined rules defined in Section 3.4 and support the "global" command defined
there. there.
3.2. Control Structure include 3.2. Control Structure include
Usage: include [LOCATION] [ONCE] <value: string> Usage: include [LOCATION] [ONCE] <value: string>
LOCATION = ":personal" / ":global" LOCATION = ":personal" / ":global"
ONCE = ":once" ONCE = ":once"
The "include" command takes an optional "location" parameter, an The "include" command takes an optional "location" parameter, an
optional ":once" parameter, and a single string argument representing optional ":once" parameter, and a single string argument representing
the name of the script to include for processing at that point. It the name of the script to include for processing at that point. It
is RECOMMENDED that implementations restrict script names according is RECOMMENDED that implementations restrict script names according
to MANAGESIEVE [RFC5804] Section 1.7. Implementations MUST NOT allow to MANAGESIEVE [RFC5804] Section 1.7. Implementations MUST NOT allow
skipping to change at page 7, line 47 skipping to change at page 5, line 47
Implementations MUST NOT generate an error if an "include :once" Implementations MUST NOT generate an error if an "include :once"
command names a script whose inclusion would be recursive; in this command names a script whose inclusion would be recursive; in this
case, the script MUST be considered previously included and therefore case, the script MUST be considered previously included and therefore
"include :once" will not include it again. "include :once" will not include it again.
Note: It is RECOMMENDED that script authors / generators use this Note: It is RECOMMENDED that script authors / generators use this
parameter only when including a script that performs general duties parameter only when including a script that performs general duties
such as declaring global variables and making sanity checks of the such as declaring global variables and making sanity checks of the
environment. environment.
The included script MUST be a valid Sieve script, including having The included script MUST be a valid Sieve script. Each script MUST
necessary "require" statements for all optional capabilities used by have its own "require" statements for all optional capabilities used
the script. The scope of a "require" statement in an included script by that script. The scope of a "require" statement is the script in
is for the immediate script only, not the including script. For which it immediately appears, and neither inherits nor passes on
example, if script "A" includes script "B", and script "B" uses the capabilities to other scripts during the course of execution.
"fileinto" extension, script "B" must have a "require" statement for
"fileinto", irrespective of whether script "A" has one. In addition,
if script "A" does not have a "require" statement for "fileinto",
"fileinto" cannot be used anywhere in script "A", even after
inclusion of script "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
immediate one. The "return" command (described below) stops immediate one. The "return" command (described below) stops
processing of the immediate script only, and allows the scripts that processing of the immediate script only, and allows the scripts that
include it to continue. include it to continue.
The "include" command MAY appear anywhere in a script where a control
structure is legal, and MAY be used within another control structure,
e.g., within an "if" or "foreverypart" block (MIME [RFC5703]).
Examples: Examples:
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"];
skipping to change at page 9, line 45 skipping to change at page 7, line 45
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")
{ {
reject; reject "No thank you.";
}
The "include" command may appear anywhere in the script where a
control structure is legal.
Example:
require ["include"];
if anyof (header :contains "Subject" "$$",
header :contains "Subject" "Make money")
{
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 immediately included The "return" command stops processing of the immediately 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
skipping to change at page 11, line 34 skipping to change at page 9, line 24
unknown variable, as specified in VARIABLES [RFC5229], Section 3 unknown variable, as specified in VARIABLES [RFC5229], Section 3
(i.e., evaluates to an empty string). (i.e., evaluates to an empty string).
Example: Example:
The active script The active script
The included script may contain repetitive code that is The included script may contain repetitive code that is
effectively a subroutine that can be factored out. In this effectively a subroutine that can be factored out. In this
script, the test which matches last will leave its value in the script, the test which matches last will leave its value in the
test-mailbox variable and the top-level script will file the test_mailbox variable and the top-level script will file the
message into that mailbox. If no tests matched, the message will message into that mailbox. If no tests matched, the message will
be implicitly kept in the INBOX. be implicitly kept in the INBOX.
require ["include", "variables", "relational"]; require ["fileinto", "include", "variables", "relational"];
global "test"; global "test";
global "test-mailbox"; global "test_mailbox";
set "test" "$$" set "test" "$$";
include "spam_checks"; include "spam_checks";
set "test" "Make money" set "test" "Make money";
include "spam_checks"; include "spam_checks";
if string :count "eq" "${test-mailbox}" "1" if string :count "eq" "${test_mailbox}" "1"
{ {
fileinto "${test-mailbox}"; fileinto "${test_mailbox}";
stop; stop;
} }
Personal script "spam_checks" Personal script "spam_checks"
This script is makes a number of tests against the message, This script is makes a number of tests against the message,
falling through back to the top-level script having set the global falling through back to the top-level script having set the global
test-mailbox variable with a target folder to file the message test_mailbox variable with a target folder to file the message
into. into.
require ["include", "variables"]; require ["include", "variables"];
global ["test", "test-mailbox"]; global ["test", "test_mailbox"];
if header :contains "Subject" "${test}" if header :contains "Subject" "${test}"
{ {
set "test-mailbox" "spam-${test}"; set "test_mailbox" "spam-${test}";
} }
3.4.2. Variables Namespace global 3.4.2. Variables Namespace global
In addition to the "global" command, this document defines the In addition to the "global" command, this document defines the
variables namespace "global", as specified in VARIABLES [RFC5229], variables namespace "global", as specified in VARIABLES [RFC5229],
Section 3. Section 3.
Example: Example:
skipping to change at page 13, line 15 skipping to change at page 10, line 40
Example: Example:
require ["variables", "include"]; require ["variables", "include"];
global "i_am_on_vacation"; global "i_am_on_vacation";
set "global.i_am_on_vacation" "1"; set "global.i_am_on_vacation" "1";
if string :is "${i_am_on_vacation}" "1" if string :is "${i_am_on_vacation}" "1"
{ {
vacation "It's true, I am on vacation." vacation "It's true, I am on vacation.";
} }
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.
For example, a site policy might enable only certain users with
administrative privileges to modify the global scripts. Site are
advised against allowing all users to have write access to the site's
global scripts.
Sieve implementations MUST ensure that script names are checked for Sieve implementations MUST ensure that script names are checked for
validity and proper permissions prior to inclusion, in order to validity and proper permissions prior to inclusion, in order to
prevent a malicious user from gaining acess to files accessible to prevent a malicious user from gaining acess to files accessible to
the mail server software that should not be accessible to the user. the mail server software that should not be accessible to the user.
Beyond these, the "include" extension does not raise any security Beyond these, the "include" extension does not raise any security
considerations that are not present in the base SIEVE [RFC5228] considerations that are not present in the base SIEVE [RFC5228]
document and the VARIABLES [RFC5229] extension. document and the VARIABLES [RFC5229] extension.
skipping to change at page 14, line 17 skipping to change at page 11, line 44
Requirement Levels", BCP 14, RFC 2119, March 1997. Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC5228] Guenther, P. and T. Showalter, "Sieve: An Email Filtering [RFC5228] Guenther, P. and T. Showalter, "Sieve: An Email Filtering
Language", RFC 5228, January 2008. Language", RFC 5228, January 2008.
[RFC5229] Homme, K., "Sieve Email Filtering: Variables Extension", [RFC5229] Homme, K., "Sieve Email Filtering: Variables Extension",
RFC 5229, January 2008. RFC 5229, January 2008.
6.2. Informative References 6.2. Informative References
[RFC5429] Stone, A., "Sieve Email Filtering: Reject and Extended
Reject Extensions", RFC 5429, March 2009.
[RFC5703] Hansen, T. and C. Daboo, "Sieve Email Filtering: MIME Part
Tests, Iteration, Extraction, Replacement, and Enclosure",
RFC 5703, October 2009.
[RFC5804] Melnikov, A. and T. Martin, "A Protocol for Remotely [RFC5804] Melnikov, A. and T. Martin, "A Protocol for Remotely
Managing Sieve Scripts", RFC 5804, July 2010. Managing Sieve Scripts", RFC 5804, July 2010.
Appendix A. Acknowledgments Appendix A. Acknowledgments
Thanks to Ken Murchison, Rob Siemborski, Alexey Melnikov, Marc Mutz, Thanks to Ken Murchison, Rob Siemborski, Alexey Melnikov, Marc Mutz,
Kjetil Torgrim Homme, Stephan Bosch, Arnt Gulbrandsen, Barry Leiba, Kjetil Torgrim Homme, Stephan Bosch, Arnt Gulbrandsen, Barry Leiba,
and Jeffrey Hutzelman for comments and corrections. and Jeffrey Hutzelman for comments and corrections.
Appendix B. Change History (to be removed prior to publication as an
RFC)
Changes from ietf-07 to ietf-08:
a. Nits from Stephan Bosch.
b. Nits from Barry Leiba.
c. Wordsmithing and layout wrangling.
Changes from ietf-06 to ietf-07:
a. Nits from Stephan Bosch.
Changes from ietf-05 to ietf-06:
a. Nits from Barry Leiba.
Changes from ietf-04 to ietf-05:
a. Integrate review from Barry Leiba.
Changes from ietf-03 to ietf-04:
a. No changes.
Changes from ietf-02 to ietf-03:
a. Setting a variable then calling global on it is an error
(something like 'use strict').
b. Specify that the 'global' keyword is only available when
'variables' has also been required.
c. Uploading a script that includes a nonexistent script is not an
error at upload time.
Changes from ietf-01 to ietf-02:
a. Require that script names must be constant strings, not subject
to variable expansion.
b. Try the phrase immediate script instead of current script.
c. Clarify that "global 'varname'" and "global.varname" refer to the
same variable.
d. Drop the requirement the global keywords come after require and
before anything else.
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:
a. None
Changes from -05 to -06:
a. Aaron Stone joins as author.
b. Removed | characters from the script examples.
c. Updated draft references to published RFCs.
Changes from -04 to -05:
a. Fixed examples.
b. Relaxed requirement that imported/exported variables be set
before being used.
Changes from -03 to -04:
a. Fixed missing 2119 definitions.
b. Defined interaction with variables through use of import and
export commands.
Changes from -02 to -03:
a. Refreshing expired draft (updated for nits).
b. Syntax -> Usage.
c. Updated to 3028bis reference.
Changes from -01 to -02:
a. Minor formatting changes only - refreshing expired draft.
Changes from -00 to -01:
a. Added IPR boiler plate.
b. Re-ordered sections at start to conform to RFC style.
c. Moved recursion comment into General Considerations section.
d. Switched to using optional parameter to indicate personal vs
global.
e. Explicitly state that an error occurs when a missing script is
included.
Authors' Addresses Authors' Addresses
Cyrus Daboo Cyrus Daboo
Email: cyrus@daboo.name Email: cyrus@daboo.name
Aaron Stone Aaron Stone
Email: aaron@serendipity.cx Email: aaron@serendipity.cx
 End of changes. 24 change blocks. 
165 lines changed or deleted 177 lines changed or added

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