aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-04 09:41:09 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-04 09:41:09 +0000
commit5ebcabcff378c0c56ed187c60f941b33d06013d7 (patch)
tree83eb0727796428709b8172229bdb31818252e91b /src/libmime
parent626107bb0f5593506230940a7d9b53d1b5f06d99 (diff)
downloadrspamd-5ebcabcff378c0c56ed187c60f941b33d06013d7.tar.gz
rspamd-5ebcabcff378c0c56ed187c60f941b33d06013d7.zip
[Minor] Remove non-reject gtube patterns unless enable_test_patterns is enabled
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/message.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 95a1ab708..37ac0a223 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -46,11 +46,13 @@
#define SET_PART_UTF(part) ((part)->flags |= RSPAMD_MIME_TEXT_PART_FLAG_UTF)
static const gchar gtube_pattern_reject[] = "XJS*C4JDBQADN1.NSBN3*2IDNEN*"
- "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
+ "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
static const gchar gtube_pattern_add_header[] = "YJS*C4JDBQADN1.NSBN3*2IDNEN*"
- "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
+ "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
static const gchar gtube_pattern_rewrite_subject[] = "ZJS*C4JDBQADN1.NSBN3*2IDNEN*"
- "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
+ "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
+static const gchar gtube_pattern_no_action[] = "AJS*C4JDBQADN1.NSBN3*2IDNEN*"
+ "GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X";
struct rspamd_multipattern *gtube_matcher = NULL;
static const guint64 words_hash_seed = 0xdeadbabe;
@@ -616,6 +618,16 @@ rspamd_multipattern_gtube_cb (struct rspamd_multipattern *mp,
gsize len,
void *context)
{
+ struct rspamd_task *task = (struct rspamd_task *)context;
+
+ if (strnum > 0) {
+ if (task->cfg->enable_test_patterns) {
+ return strnum + 1;
+ }
+
+ return 0;
+ }
+
return strnum + 1; /* To distinguish from zero */
}
@@ -639,6 +651,9 @@ rspamd_check_gtube (struct rspamd_task *task, struct rspamd_mime_text_part *part
rspamd_multipattern_add_pattern (gtube_matcher,
gtube_pattern_rewrite_subject,
RSPAMD_MULTIPATTERN_DEFAULT);
+ rspamd_multipattern_add_pattern (gtube_matcher,
+ gtube_pattern_no_action,
+ RSPAMD_MULTIPATTERN_DEFAULT);
g_assert (rspamd_multipattern_compile (gtube_matcher, NULL));
}
@@ -647,21 +662,27 @@ rspamd_check_gtube (struct rspamd_task *task, struct rspamd_mime_text_part *part
part->utf_content->len <= max_check_size) {
if ((ret = rspamd_multipattern_lookup (gtube_matcher, part->utf_content->data,
part->utf_content->len,
- rspamd_multipattern_gtube_cb, NULL, NULL)) > 0) {
+ rspamd_multipattern_gtube_cb, task, NULL)) > 0) {
switch (ret) {
case 1:
act = METRIC_ACTION_REJECT;
break;
case 2:
+ g_assert (task->cfg->enable_test_patterns);
act = METRIC_ACTION_ADD_HEADER;
break;
case 3:
+ g_assert (task->cfg->enable_test_patterns);
act = METRIC_ACTION_REWRITE_SUBJECT;
break;
+ case 4:
+ g_assert (task->cfg->enable_test_patterns);
+ act = METRIC_ACTION_NOACTION;
+ break;
}
- if (act != METRIC_ACTION_NOACTION) {
+ if (ret != 0) {
task->flags |= RSPAMD_TASK_FLAG_SKIP;
task->flags |= RSPAMD_TASK_FLAG_GTUBE;
msg_info_task (