From 4f7f493490b573badc62e7d543952d9a94f23db1 Mon Sep 17 00:00:00 2001 From: andryyy Date: Mon, 12 Nov 2018 09:56:54 +0100 Subject: [PATCH] [Rspamd] Add SOGo contacts to whitelist --- data/conf/rspamd/dynmaps/settings.php | 89 ++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/data/conf/rspamd/dynmaps/settings.php b/data/conf/rspamd/dynmaps/settings.php index 9799c712..3af3245a 100644 --- a/data/conf/rspamd/dynmaps/settings.php +++ b/data/conf/rspamd/dynmaps/settings.php @@ -26,13 +26,32 @@ catch (PDOException $e) { } function parse_email($email) { - if(!filter_var($email, FILTER_VALIDATE_EMAIL)) return false; + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return false; $a = strrpos($email, '@'); return array('local' => substr($email, 0, $a), 'domain' => substr($email, $a)); } +function wl_by_sogo() { + global $pdo; + $rcpt = array(); + $stmt = $pdo->query("SELECT DISTINCT(`sogo_folder_info`.`c_path2`) AS `user`, GROUP_CONCAT(`sogo_quick_contact`.`c_mail`) AS `contacts` FROM `sogo_folder_info` + INNER JOIN `sogo_quick_contact` ON `sogo_quick_contact`.`c_folder_id` = `sogo_folder_info`.`c_folder_id` + GROUP BY `c_path2`"); + $sogo_contacts = $stmt->fetchAll(PDO::FETCH_ASSOC); + while ($row = array_shift($sogo_contacts)) { + foreach (explode(',', $row['contacts']) as $contact) { + if (!filter_var($contact, FILTER_VALIDATE_EMAIL)) { + continue; + } + $rcpt[$row['user']][] = '/^' . str_replace('/', '\/', $contact) . '$/i'; + } + } + return $rcpt; +} + function ucl_rcpts($object, $type) { global $pdo; + $rcpt = array(); if ($type == 'mailbox') { // Standard aliases $stmt = $pdo->prepare("SELECT `address` FROM `alias` @@ -82,10 +101,7 @@ function ucl_rcpts($object, $type) { $rcpt[] = '/.*@' . $row['alias_domain'] . '/i'; } } - if (!empty($rcpt)) { - return $rcpt; - } - return false; + return $rcpt; } ?> settings { @@ -138,6 +154,65 @@ while ($row = array_shift($rows)) { $contacts) { + $username_sane = preg_replace("/[^a-zA-Z0-9]+/", "", $user); +?> + whitelist_sogo_ { + + from = ; + + priority = 4; + + rcpt = ; + + apply "default" { + SOGO_CONTACT = -999.0; + } + symbols [ + "SOGO_CONTACT" + ] + } + whitelist_sogo__header { + header = { + + "From" = ; + + } + priority = 4; + + rcpt = ; + + apply "default" { + SOGO_CONTACT = -999.0; + } + symbols [ + "SOGO_CONTACT" + ] + } + -} - +} \ No newline at end of file