From 7dc21e036d0f5286d06136632c69a06499b6c63b Mon Sep 17 00:00:00 2001 From: andryyy Date: Tue, 3 Nov 2020 10:27:46 +0100 Subject: [PATCH] [Rspamd] Fixes #3837 by setting correct data type for mails without fuzzy hashes, also implements actions --- data/conf/rspamd/meta_exporter/pipe.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/data/conf/rspamd/meta_exporter/pipe.php b/data/conf/rspamd/meta_exporter/pipe.php index 485a7b3c..63d0f7fd 100644 --- a/data/conf/rspamd/meta_exporter/pipe.php +++ b/data/conf/rspamd/meta_exporter/pipe.php @@ -68,6 +68,10 @@ if (empty($sender)) { $sender = 'empty-env-from@localhost'; } +if ($fuzzy == 'unknown') { + $fuzzy = '[]'; +} + try { $max_size = (int)$redis->Get('Q_MAX_SIZE'); if (($max_size * 1048576) < $raw_size) { @@ -216,8 +220,15 @@ foreach (json_decode($rcpts, true) as $rcpt) { foreach ($rcpt_final_mailboxes as $rcpt_final) { error_log("QUARANTINE: quarantine pipe: processing quarantine message for rcpt " . $rcpt_final . PHP_EOL); try { - $stmt = $pdo->prepare("INSERT INTO `quarantine` (`qid`, `subject`, `score`, `sender`, `rcpt`, `symbols`, `user`, `ip`, `msg`, `action`, `fuzzy_hashes`) - VALUES (:qid, :subject, :score, :sender, :rcpt, :symbols, :user, :ip, :msg, :action, :fuzzy_hashes)"); + // Fall back to reject + if ($action == "add header") { + $action = "header"; + } + else { + $action = "reject"; + } + $stmt = $pdo->prepare("INSERT INTO `quarantine` (`qid`, `subject`, `score`, `sender`, `rcpt`, `symbols`, `user`, `ip`, `msg`, `action`, `fuzzy_hashes`, `type`) + VALUES (:qid, :subject, :score, :sender, :rcpt, :symbols, :user, :ip, :msg, :action, :fuzzy_hashes, :type)"); $stmt->execute(array( ':qid' => $qid, ':subject' => $subject, @@ -229,7 +240,8 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) { ':ip' => $ip, ':msg' => $raw_data, ':action' => $action, - ':fuzzy_hashes' => $fuzzy + ':fuzzy_hashes' => $fuzzy, + ':type' => $action )); $stmt = $pdo->prepare('DELETE FROM `quarantine` WHERE `rcpt` = :rcpt AND `id` NOT IN ( SELECT `id`