[Web] Show fuzzy hash of rejected mail, if any
parent
6d1c0041f4
commit
0165c9d26b
|
@ -51,6 +51,7 @@ $raw_data = mb_convert_encoding($raw_data_content, 'HTML-ENTITIES', "UTF-8");
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
|
|
||||||
$qid = $headers['X-Rspamd-Qid'];
|
$qid = $headers['X-Rspamd-Qid'];
|
||||||
|
$fuzzy = $headers['X-Rspamd-Fuzzy'];
|
||||||
$subject = $headers['X-Rspamd-Subject'];
|
$subject = $headers['X-Rspamd-Subject'];
|
||||||
$score = $headers['X-Rspamd-Score'];
|
$score = $headers['X-Rspamd-Score'];
|
||||||
$rcpts = $headers['X-Rspamd-Rcpt'];
|
$rcpts = $headers['X-Rspamd-Rcpt'];
|
||||||
|
@ -215,8 +216,8 @@ 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`)
|
$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)");
|
VALUES (:qid, :subject, :score, :sender, :rcpt, :symbols, :user, :ip, :msg, :action, :fuzzy_hashes)");
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
':qid' => $qid,
|
':qid' => $qid,
|
||||||
':subject' => $subject,
|
':subject' => $subject,
|
||||||
|
@ -227,7 +228,8 @@ foreach ($rcpt_final_mailboxes as $rcpt_final) {
|
||||||
':user' => $user,
|
':user' => $user,
|
||||||
':ip' => $ip,
|
':ip' => $ip,
|
||||||
':msg' => $raw_data,
|
':msg' => $raw_data,
|
||||||
':action' => $action
|
':action' => $action,
|
||||||
|
':fuzzy_hashes' => $fuzzy
|
||||||
));
|
));
|
||||||
$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`
|
||||||
|
|
|
@ -63,6 +63,8 @@ if (!empty($_GET['hash']) && ctype_alnum($_GET['hash'])) {
|
||||||
$data['score'] = $mailc['score'];
|
$data['score'] = $mailc['score'];
|
||||||
// Get rspamd symbols
|
// Get rspamd symbols
|
||||||
$data['symbols'] = json_decode($mailc['symbols']);
|
$data['symbols'] = json_decode($mailc['symbols']);
|
||||||
|
// Get fuzzy hashes
|
||||||
|
$data['fuzzy_hashes'] = json_decode($mailc['fuzzy_hashes']);
|
||||||
$data['subject'] = $mail_parser->getHeader('subject');
|
$data['subject'] = $mail_parser->getHeader('subject');
|
||||||
(empty($data['subject'])) ? $data['subject'] = '-' : null;
|
(empty($data['subject'])) ? $data['subject'] = '-' : null;
|
||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
|
@ -118,6 +120,8 @@ elseif (!empty($_GET['id']) && ctype_alnum($_GET['id'])) {
|
||||||
$data['score'] = $mailc['score'];
|
$data['score'] = $mailc['score'];
|
||||||
// Get rspamd symbols
|
// Get rspamd symbols
|
||||||
$data['symbols'] = json_decode($mailc['symbols']);
|
$data['symbols'] = json_decode($mailc['symbols']);
|
||||||
|
// Get fuzzy hashes
|
||||||
|
$data['fuzzy_hashes'] = json_decode($mailc['fuzzy_hashes']);
|
||||||
// Get text/plain content
|
// Get text/plain content
|
||||||
$data['text_plain'] = $mail_parser->getMessageBody('text');
|
$data['text_plain'] = $mail_parser->getMessageBody('text');
|
||||||
// Get html content and convert to text
|
// Get html content and convert to text
|
||||||
|
|
|
@ -3,7 +3,7 @@ function init_db_schema() {
|
||||||
try {
|
try {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
|
|
||||||
$db_version = "26092020_2000";
|
$db_version = "24102020_0900";
|
||||||
|
|
||||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||||
|
@ -260,6 +260,7 @@ function init_db_schema() {
|
||||||
"ip" => "VARCHAR(50)",
|
"ip" => "VARCHAR(50)",
|
||||||
"action" => "CHAR(20) NOT NULL DEFAULT 'unknown'",
|
"action" => "CHAR(20) NOT NULL DEFAULT 'unknown'",
|
||||||
"symbols" => "JSON",
|
"symbols" => "JSON",
|
||||||
|
"fuzzy_hashes" => "JSON",
|
||||||
"sender" => "VARCHAR(255) NOT NULL DEFAULT 'unknown'",
|
"sender" => "VARCHAR(255) NOT NULL DEFAULT 'unknown'",
|
||||||
"rcpt" => "VARCHAR(255)",
|
"rcpt" => "VARCHAR(255)",
|
||||||
"msg" => "LONGTEXT",
|
"msg" => "LONGTEXT",
|
||||||
|
|
|
@ -18,6 +18,14 @@ jQuery(function($){
|
||||||
$('#qid_detail_efrom').text(data.env_from);
|
$('#qid_detail_efrom').text(data.env_from);
|
||||||
$('#qid_detail_score').text(data.score);
|
$('#qid_detail_score').text(data.score);
|
||||||
$('#qid_detail_symbols').html('');
|
$('#qid_detail_symbols').html('');
|
||||||
|
$('#qid_detail_fuzzy').html('');
|
||||||
|
if (data.fuzzy_hashes !== null) {
|
||||||
|
$.each(data.fuzzy_hashes, function (index, value) {
|
||||||
|
$('#qid_detail_fuzzy').append('<p style="font-family:monospace">' + value + '</p>');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#qid_detail_fuzzy').append('-');
|
||||||
|
}
|
||||||
if (typeof data.symbols !== 'undefined') {
|
if (typeof data.symbols !== 'undefined') {
|
||||||
data.symbols.sort(function (a, b) {
|
data.symbols.sort(function (a, b) {
|
||||||
if (a.score === 0) return 1
|
if (a.score === 0) return 1
|
||||||
|
|
|
@ -148,6 +148,7 @@ jQuery(function($){
|
||||||
$('#qid_detail_efrom').text(data.env_from);
|
$('#qid_detail_efrom').text(data.env_from);
|
||||||
$('#qid_detail_score').text(data.score);
|
$('#qid_detail_score').text(data.score);
|
||||||
$('#qid_detail_symbols').html('');
|
$('#qid_detail_symbols').html('');
|
||||||
|
$('#qid_detail_fuzzy').html('');
|
||||||
if (typeof data.symbols !== 'undefined') {
|
if (typeof data.symbols !== 'undefined') {
|
||||||
data.symbols.sort(function (a, b) {
|
data.symbols.sort(function (a, b) {
|
||||||
if (a.score === 0) return 1
|
if (a.score === 0) return 1
|
||||||
|
@ -169,7 +170,13 @@ jQuery(function($){
|
||||||
});
|
});
|
||||||
$('[data-toggle="tooltip"]').tooltip()
|
$('[data-toggle="tooltip"]').tooltip()
|
||||||
}
|
}
|
||||||
|
if (data.fuzzy_hashes !== null) {
|
||||||
|
$.each(data.fuzzy_hashes, function (index, value) {
|
||||||
|
$('#qid_detail_fuzzy').append('<p style="font-family:monospace">' + value + '</p>');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#qid_detail_fuzzy').append('-');
|
||||||
|
}
|
||||||
$('#qid_detail_recipients').html('');
|
$('#qid_detail_recipients').html('');
|
||||||
if (typeof data.recipients !== 'undefined') {
|
if (typeof data.recipients !== 'undefined') {
|
||||||
$.each(data.recipients, function(index, value) {
|
$.each(data.recipients, function(index, value) {
|
||||||
|
|
|
@ -26,6 +26,10 @@ if (!isset($_SESSION['mailcow_cc_role'])) {
|
||||||
<label for="qid_detail_recipients"><h4><?=$lang['quarantine']['recipients'];?>:</h4></label>
|
<label for="qid_detail_recipients"><h4><?=$lang['quarantine']['recipients'];?>:</h4></label>
|
||||||
<p id="qid_detail_recipients"></p>
|
<p id="qid_detail_recipients"></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="qid_detail_fuzzy"><h4>Fuzzy Hashes:</h4></label>
|
||||||
|
<p id="qid_detail_fuzzy"></p>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="qid_detail_hfrom"><h4><?=$lang['quarantine']['sender_header'];?>:</h4></label>
|
<label for="qid_detail_hfrom"><h4><?=$lang['quarantine']['sender_header'];?>:</h4></label>
|
||||||
<p><span class="mail-address-item" id="qid_detail_hfrom"></span></p>
|
<p><span class="mail-address-item" id="qid_detail_hfrom"></span></p>
|
||||||
|
|
|
@ -56,6 +56,10 @@ elseif (in_array($_GET['action'], array('release', 'delete'))) {
|
||||||
<label for="qid_detail_recipients"><h4><?=$lang['quarantine']['recipients'];?>:</h4></label>
|
<label for="qid_detail_recipients"><h4><?=$lang['quarantine']['recipients'];?>:</h4></label>
|
||||||
<p id="qid_detail_recipients"></p>
|
<p id="qid_detail_recipients"></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="qid_detail_fuzzy"><h4>Fuzzy Hashes:</h4></label>
|
||||||
|
<p id="qid_detail_fuzzy"></p>
|
||||||
|
</div>
|
||||||
<form method="post" autofill="off">
|
<form method="post" autofill="off">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-success" name="quick_release" value="<?=$_GET['hash'];?>"><?= $lang['tfa']['confirm']; ?></button>
|
<button type="submit" class="btn btn-success" name="quick_release" value="<?=$_GET['hash'];?>"><?= $lang['tfa']['confirm']; ?></button>
|
||||||
|
|
Loading…
Reference in New Issue