diff --git a/TODO b/TODO index df4b7d2ab6d07cc79e9e34eaf886d0d5b99dc3df..d1931f65261ecf7ee5484b0be799c2bc60c415f7 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,6 @@ Next (in order of descending priority/precedence): MUST win. - 'If an address is not syntactically valid, then it will not be matched by tests specifying ":localpart" or ":domain"'. -* Code cleanup * Full security review. Enforce limits on number of created objects, script size, execution time, etc... - Make (configurable) limit on the number of redirects diff --git a/src/testsuite/cmd-test-fail.c b/src/testsuite/cmd-test-fail.c index 8eefab67b86c628acfe71b17228cfd2338af281d..b4632695449ff716b38dc6ba86dc87573fe754a2 100644 --- a/src/testsuite/cmd-test-fail.c +++ b/src/testsuite/cmd-test-fail.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "sieve-common.h" #include "sieve-commands.h" #include "sieve-validator.h" diff --git a/src/testsuite/cmd-test-set.c b/src/testsuite/cmd-test-set.c index d0dd1dfe3f60a46b460892ebe98a3659cb939058..ee4e7a9776329736bd351b9c763fa8202d515598 100644 --- a/src/testsuite/cmd-test-set.c +++ b/src/testsuite/cmd-test-set.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "ioloop.h" #include "str-sanitize.h" diff --git a/src/testsuite/cmd-test.c b/src/testsuite/cmd-test.c index f41c55ab186871bf6e3b1109223e226ff7339ec2..15041ddd1700b667a1811ffb948c434dc9e7e678 100644 --- a/src/testsuite/cmd-test.c +++ b/src/testsuite/cmd-test.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "sieve-common.h" #include "sieve-commands.h" #include "sieve-validator.h" diff --git a/src/testsuite/ext-testsuite.c b/src/testsuite/ext-testsuite.c index fc240ddd0edfb67a7ff83bc702fcf18ec1c9326c..8978d862008707259ee7166f7909e75beb6df6cb 100644 --- a/src/testsuite/ext-testsuite.c +++ b/src/testsuite/ext-testsuite.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + /* Extension testsuite * ------------------- * @@ -43,25 +46,9 @@ #include "testsuite-common.h" -/* Forward declarations */ - -static bool ext_testsuite_load(int ext_id); -static bool ext_testsuite_validator_load(struct sieve_validator *valdtr); -static bool ext_testsuite_generator_load(const struct sieve_codegen_env *cgenv); -static bool ext_testsuite_binary_load(struct sieve_binary *sbin); - -/* Commands */ - -extern const struct sieve_command cmd_test; -extern const struct sieve_command cmd_test_fail; -extern const struct sieve_command cmd_test_set; - -/* Tests */ - -extern const struct sieve_command tst_test_compile; -extern const struct sieve_command tst_test_error; - -/* Operations */ +/* + * Operations + */ const struct sieve_operation *testsuite_operations[] = { &test_operation, @@ -72,18 +59,31 @@ const struct sieve_operation *testsuite_operations[] = { &test_error_operation }; -/* Operands */ +/* + * Operands + */ const struct sieve_operand *testsuite_operands[] = { &testsuite_object_operand }; -/* Extension definitions */ +/* + * Extension + */ + +/* Forward declarations */ + +static bool ext_testsuite_load(int ext_id); +static bool ext_testsuite_validator_load(struct sieve_validator *valdtr); +static bool ext_testsuite_generator_load(const struct sieve_codegen_env *cgenv); +static bool ext_testsuite_binary_load(struct sieve_binary *sbin); -int ext_testsuite_my_id; +/* Extension object */ + +static int ext_my_id; const struct sieve_extension testsuite_extension = { "vnd.dovecot.testsuite", - &ext_testsuite_my_id, + &ext_my_id, ext_testsuite_load, ext_testsuite_validator_load, ext_testsuite_generator_load, @@ -94,15 +94,15 @@ const struct sieve_extension testsuite_extension = { SIEVE_EXT_DEFINE_OPERAND(testsuite_object_operand) }; +/* Extension implementation */ + static bool ext_testsuite_load(int ext_id) { - ext_testsuite_my_id = ext_id; + ext_my_id = ext_id; return TRUE; } -/* Load extension into validator */ - static bool ext_testsuite_validator_load(struct sieve_validator *valdtr) { sieve_validator_register_command(valdtr, &cmd_test); @@ -115,15 +115,11 @@ static bool ext_testsuite_validator_load(struct sieve_validator *valdtr) return testsuite_validator_context_initialize(valdtr); } -/* Load extension into generator */ - static bool ext_testsuite_generator_load(const struct sieve_codegen_env *cgenv) { return testsuite_generator_context_initialize(cgenv->gentr); } -/* Load extension into binary */ - static bool ext_testsuite_binary_load(struct sieve_binary *sbin ATTR_UNUSED) { return TRUE; diff --git a/src/testsuite/mail-raw.c b/src/testsuite/mail-raw.c index 50c1689c7710497f6608102e7f800dceaf215bd7..a1ed1ec56a5deda35e7a5c1787a948f3aa8df229 100644 --- a/src/testsuite/mail-raw.c +++ b/src/testsuite/mail-raw.c @@ -1,10 +1,10 @@ -/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ /* This file was gratefully stolen from dovecot/src/deliver/deliver.c and altered * to suit our needs. So, this contains lots and lots of duplicated code. - * The sieve_test program needs to read an email message from stdin and it needs - * to build a struct mail (to be fed to the sieve library). Deliver does something - * similar already, so that source was a basis for this test binary. + * FIXME: As a matter of fact a similar file is located at src/sieve-bin/mail-raw.c + * These must be merged. */ #include "lib.h" @@ -27,12 +27,20 @@ #include <fcntl.h> #include <pwd.h> +/* + * Configuration + */ + #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" /* After buffer grows larger than this, create a temporary file to /tmp where to read the mail. */ #define MAIL_MAX_MEMORY_BUFFER (1024*128) +/* + * Implementation + */ + static struct mail_namespace *raw_ns; void mail_raw_init(const char *user) diff --git a/src/testsuite/mail-raw.h b/src/testsuite/mail-raw.h index 73ed48b919952c9c263950a3b8081157db00262d..c401208e5cf36e711c2d1e75bc00e592ac9ce93e 100644 --- a/src/testsuite/mail-raw.h +++ b/src/testsuite/mail-raw.h @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __MAIL_RAW_H #define __MAIL_RAW_H diff --git a/src/testsuite/namespaces.c b/src/testsuite/namespaces.c index f032b3e85c6c0186d788c323ad31686059ce2394..e1565c4599ade118ddccf7203399d0ada29defee 100644 --- a/src/testsuite/namespaces.c +++ b/src/testsuite/namespaces.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ #include "lib.h" #include "istream.h" diff --git a/src/testsuite/namespaces.h b/src/testsuite/namespaces.h index 81e9fc030b602c2c08f45647209fd297e1947f51..c8901671267247d594d9fe2f18bd832c4d640692 100644 --- a/src/testsuite/namespaces.h +++ b/src/testsuite/namespaces.h @@ -1,7 +1,12 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + +/* FIXME: Duplicated */ + #ifndef __NAMESPACES_H #define __NAMESPACES_H void namespaces_init(void); void namespaces_deinit(void); -#endif /* __MAIL_RAW_H */ +#endif /* __NAMESPACES_H */ diff --git a/src/testsuite/testsuite-common.c b/src/testsuite/testsuite-common.c index d14cf8fad6c6d237cd9dfb21ce680d4cb420cbcc..0b670f4dd8fe6e988d4da8a953777a163e348713 100644 --- a/src/testsuite/testsuite-common.c +++ b/src/testsuite/testsuite-common.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "str.h" #include "string.h" diff --git a/src/testsuite/testsuite-common.h b/src/testsuite/testsuite-common.h index c371e5c8324bb0081fc0add99ae9f1dbe2fc9d44..16eee76c6c06ec893c77fb327ad90519a9b745aa 100644 --- a/src/testsuite/testsuite-common.h +++ b/src/testsuite/testsuite-common.h @@ -1,11 +1,18 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __TESTSUITE_COMMON_H #define __TESTSUITE_COMMON_H -extern const struct sieve_extension testsuite_extension; +/* + * Extension + */ -extern int ext_testsuite_my_id; +extern const struct sieve_extension testsuite_extension; -/* Testsuite message environment */ +/* + * Testsuite message environment + */ extern struct sieve_message_data testsuite_msgdata; @@ -19,7 +26,9 @@ void testsuite_envelope_set_sender(const char *value); void testsuite_envelope_set_recipient(const char *value); void testsuite_envelope_set_auth_user(const char *value); -/* Testsuite validator context */ +/* + * Validator context + */ struct testsuite_validator_context { struct sieve_validator_object_registry *object_registrations; @@ -29,7 +38,9 @@ bool testsuite_validator_context_initialize(struct sieve_validator *valdtr); struct testsuite_validator_context *testsuite_validator_context_get (struct sieve_validator *valdtr); -/* Testsuite generator context */ +/* + * Generator context + */ struct testsuite_generator_context { struct sieve_jumplist *exit_jumps; @@ -37,7 +48,24 @@ struct testsuite_generator_context { bool testsuite_generator_context_initialize(struct sieve_generator *gentr); -/* Testsuite operations */ +/* + * Commands + */ + +extern const struct sieve_command cmd_test; +extern const struct sieve_command cmd_test_fail; +extern const struct sieve_command cmd_test_set; + +/* + * Tests + */ + +extern const struct sieve_command tst_test_compile; +extern const struct sieve_command tst_test_error; + +/* + * Operations + */ enum testsuite_operation_code { TESTSUITE_OPERATION_TEST, @@ -55,7 +83,9 @@ extern const struct sieve_operation test_set_operation; extern const struct sieve_operation test_compile_operation; extern const struct sieve_operation test_error_operation; -/* Testsuite operands */ +/* + * Operands + */ extern const struct sieve_operand testsuite_object_operand; @@ -63,7 +93,9 @@ enum testsuite_operand_code { TESTSUITE_OPERAND_OBJECT }; -/* Test context */ +/* + * Test context + */ void testsuite_test_start(string_t *name); void testsuite_test_fail(string_t *reason); @@ -72,14 +104,18 @@ void testsuite_test_succeed(string_t *reason); void testsuite_testcase_fail(const char *reason); int testsuite_testcase_result(void); -/* Tested script environment */ +/* + * Tested script environment + */ bool testsuite_script_compile(const char *script_path); void testsuite_script_get_error_init(void); const char *testsuite_script_get_error_next(bool location); -/* Testsuite init/deinit */ +/* + * Testsuite init/deinit + */ void testsuite_init(void); void testsuite_deinit(void); diff --git a/src/testsuite/testsuite-objects.c b/src/testsuite/testsuite-objects.c index 4e002603fec2cf02e782d8de765e4371d6668bbb..eb91d09663a7e834e1f4746c9b6457e5a856b2eb 100644 --- a/src/testsuite/testsuite-objects.c +++ b/src/testsuite/testsuite-objects.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "string.h" #include "ostream.h" diff --git a/src/testsuite/testsuite-objects.h b/src/testsuite/testsuite-objects.h index 0512ea370c2037d5089f1c0554108dac4b6a84fb..6a0fc122e2f6459bf1079b8fbe9cb0e9bfecda78 100644 --- a/src/testsuite/testsuite-objects.h +++ b/src/testsuite/testsuite-objects.h @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __TESTSUITE_OBJECTS_H #define __TESTSUITE_OBJECTS_H @@ -6,7 +9,9 @@ #include "testsuite-common.h" -/* Testsuite object operand */ +/* + * Testsuite object operand + */ struct testsuite_object_operand_interface { struct sieve_extension_obj_registry testsuite_objects; @@ -14,7 +19,9 @@ struct testsuite_object_operand_interface { extern const struct sieve_operand_class testsuite_object_oprclass; -/* Testsuite object access */ +/* + * Testsuite object access + */ struct testsuite_object { struct sieve_object object; @@ -26,7 +33,9 @@ struct testsuite_object { string_t *(*get_member)(const struct sieve_runtime_env *renv, int id); }; -/* Testsuite object registration */ +/* + * Testsuite object registration + */ const struct testsuite_object *testsuite_object_find (struct sieve_validator *valdtr, const char *identifier); @@ -35,13 +44,17 @@ void testsuite_object_register void testsuite_register_core_objects (struct testsuite_validator_context *ctx); -/* Testsuite object argument */ +/* + * Testsuite object argument + */ bool testsuite_object_argument_activate (struct sieve_validator *valdtr, struct sieve_ast_argument *arg, struct sieve_command_context *cmd); -/* Testsuite object code */ +/* + * Testsuite object code + */ const struct testsuite_object *testsuite_object_read (struct sieve_binary *sbin, sieve_size_t *address); @@ -52,7 +65,9 @@ const char *testsuite_object_member_name bool testsuite_object_dump (const struct sieve_dumptime_env *denv, sieve_size_t *address); -/* Testsuite core objects */ +/* + * Testsuite core objects + */ extern const struct testsuite_object message_testsuite_object; extern const struct testsuite_object envelope_testsuite_object; diff --git a/src/testsuite/testsuite.c b/src/testsuite/testsuite.c index 20e055573572af2ef703ff4c9e169e649d3ee03d..eb12d91a62683a8b69b47e1e18f38580a8e174ff 100644 --- a/src/testsuite/testsuite.c +++ b/src/testsuite/testsuite.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ #include "lib.h" #include "lib-signals.h" @@ -26,6 +27,10 @@ #include <fcntl.h> #include <pwd.h> +/* + * Configuration + */ + #define DEFAULT_SENDMAIL_PATH "/usr/lib/sendmail" #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" diff --git a/src/testsuite/tst-test-compile.c b/src/testsuite/tst-test-compile.c index 9dbcbb4ae3df613737f621c9e4ee30c22e5242a7..ae9f72108a1551e3b363a0c60c7749ce5dbb9a2d 100644 --- a/src/testsuite/tst-test-compile.c +++ b/src/testsuite/tst-test-compile.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "sieve-common.h" #include "sieve-script.h" #include "sieve-commands.h" @@ -33,7 +36,9 @@ const struct sieve_command tst_test_compile = { NULL }; -/* Test_compile operation */ +/* + * Operation + */ static bool tst_test_compile_operation_dump (const struct sieve_operation *op, @@ -50,7 +55,9 @@ const struct sieve_operation test_compile_operation = { tst_test_compile_operation_execute }; -/* Validation */ +/* + * Validation + */ static bool tst_test_compile_validate (struct sieve_validator *valdtr ATTR_UNUSED, struct sieve_command_context *tst) @@ -65,7 +72,9 @@ static bool tst_test_compile_validate return sieve_validator_argument_activate(valdtr, tst, arg, FALSE); } -/* Code generation */ +/* + * Code generation + */ static inline struct testsuite_generator_context * _get_generator_context(struct sieve_generator *gentr) diff --git a/src/testsuite/tst-test-error.c b/src/testsuite/tst-test-error.c index 8dbce7352442f8097a3f90f261131b5ab79b97b6..bf842a6a7118e9829c76f1fb0e47836168927e48 100644 --- a/src/testsuite/tst-test-error.c +++ b/src/testsuite/tst-test-error.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "sieve-common.h" #include "sieve-error.h" #include "sieve-script.h" @@ -39,7 +42,9 @@ const struct sieve_command tst_test_error = { NULL }; -/* Test_error operation */ +/* + * Operation + */ static bool tst_test_error_operation_dump (const struct sieve_operation *op,