-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow limiting Sieve :regex execution time
- Loading branch information
1 parent
72b106f
commit 414d6f7
Showing
5 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!perl | ||
use Cassandane::Tiny; | ||
use Cassandane::Util::Slurp; | ||
use Cwd qw(abs_path); | ||
|
||
sub test_regex_timeout | ||
:min_version_3_9 :needs_component_sieve :NoAltNameSpace :NoStartInstances | ||
{ | ||
my ($self) = @_; | ||
|
||
$self->{instance}->{config}->set('sieve_regex_timeout' => '0.000001'); | ||
$self->_start_instances(); | ||
|
||
xlog, $self, "Create manifold user and make it readable by cassandane"; | ||
my $admintalk = $self->{adminstore}->get_client(); | ||
$admintalk->create("user.manifold"); | ||
$admintalk->setacl("user.manifold", cassandane => 'lrs'); | ||
|
||
xlog $self, "Install a script for cassandane"; | ||
$self->{instance}->install_sieve_script(<<EOF | ||
require ["regex", "imap4flags"]; | ||
if header :regex "Subject" "Message" { | ||
addflag "\\\\Flagged"; | ||
keep; | ||
} | ||
EOF | ||
); | ||
|
||
my $msg = $self->{gen}->generate(subject => 'Message 1'); | ||
$self->{instance}->deliver($msg, users => [ 'cassandane', 'manifold' ]); | ||
|
||
xlog $self, "Check that the message made it to INBOX due to Sieve failure"; | ||
$self->{store}->set_folder('INBOX'); | ||
$self->{store}->set_fetch_attributes(qw(uid flags)); | ||
$msg->set_attribute(uid => 1); | ||
$msg->set_attribute(flags => [ '\\Recent', '$SieveFailed' ]); | ||
$self->check_messages({ 1 => $msg }, check_guid => 0); | ||
|
||
xlog $self, "Check that the message made it to manifold INBOX"; | ||
$self->{store}->set_folder('user.manifold'); | ||
$self->{store}->set_fetch_attributes(qw(uid flags)); | ||
$msg->set_attribute(uid => 1); | ||
$msg->set_attribute(flags => [ '\\Recent' ]); | ||
$self->check_messages({ 1 => $msg }, check_guid => 0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
Description: | ||
|
||
Allow a timeout to be set on the execution of Sieve regular expression matches. | ||
|
||
|
||
Config changes: | ||
|
||
Adds 'sieve_regex_timeout' option. | ||
|
||
|
||
Upgrade instructions: | ||
|
||
None. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters