[Rspamd] Fixes #3837 by setting correct data type for mails without fuzzy hashes, also implements actions

master
andryyy 2020-11-03 10:27:46 +01:00
parent fd462f67e1
commit 7dc21e036d
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
1 changed files with 15 additions and 3 deletions

View File

@ -68,6 +68,10 @@ if (empty($sender)) {
$sender = 'empty-env-from@localhost'; $sender = 'empty-env-from@localhost';
} }
if ($fuzzy == 'unknown') {
$fuzzy = '[]';
}
try { try {
$max_size = (int)$redis->Get('Q_MAX_SIZE'); $max_size = (int)$redis->Get('Q_MAX_SIZE');
if (($max_size * 1048576) < $raw_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) { foreach ($rcpt_final_mailboxes as $rcpt_final) {
error_log("QUARANTINE: quarantine pipe: processing quarantine message for rcpt " . $rcpt_final . PHP_EOL); error_log("QUARANTINE: quarantine pipe: processing quarantine message for rcpt " . $rcpt_final . PHP_EOL);
try { try {
$stmt = $pdo->prepare("INSERT INTO `quarantine` (`qid`, `subject`, `score`, `sender`, `rcpt`, `symbols`, `user`, `ip`, `msg`, `action`, `fuzzy_hashes`) // Fall back to reject
VALUES (:qid, :subject, :score, :sender, :rcpt, :symbols, :user, :ip, :msg, :action, :fuzzy_hashes)"); 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( $stmt->execute(array(
':qid' => $qid, ':qid' => $qid,
':subject' => $subject, ':subject' => $subject,
@ -229,7 +240,8 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) {
':ip' => $ip, ':ip' => $ip,
':msg' => $raw_data, ':msg' => $raw_data,
':action' => $action, ':action' => $action,
':fuzzy_hashes' => $fuzzy ':fuzzy_hashes' => $fuzzy,
':type' => $action
)); ));
$stmt = $pdo->prepare('DELETE FROM `quarantine` WHERE `rcpt` = :rcpt AND `id` NOT IN ( $stmt = $pdo->prepare('DELETE FROM `quarantine` WHERE `rcpt` = :rcpt AND `id` NOT IN (
SELECT `id` SELECT `id`