From 05118ba2bc6477912a3679456918d4d9977d6705 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Sun, 5 Jul 2020 14:08:42 +0200 Subject: [PATCH] chg: [mail] TLP in subject should be uppercase --- app/Model/Event.php | 14 +++++++------- app/Model/Post.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Model/Event.php b/app/Model/Event.php index 1ddb36dfb..a7b04f7ee 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -3027,11 +3027,11 @@ class Event extends AppModel } else { $subject = ''; } - $subjMarkingString = !empty(Configure::read('MISP.email_subject_TLP_string')) ? Configure::read('MISP.email_subject_TLP_string') : "tlp:amber"; - $subjTag = !empty(Configure::read('MISP.email_subject_tag')) ? Configure::read('MISP.email_subject_tag') : "tlp"; + $subjMarkingString = Configure::read('MISP.email_subject_TLP_string') ?: "tlp:amber"; + $subjTag = Configure::read('MISP.email_subject_tag') ?: "tlp"; $tagLen = strlen($subjTag); foreach ($event[0]['EventTag'] as $k => $tag) { - $tagName=$tag['Tag']['name']; + $tagName = $tag['Tag']['name']; if (strncasecmp($subjTag, $tagName, $tagLen) == 0 && strlen($tagName) > $tagLen && ($tagName[$tagLen] == ':' || $tagName[$tagLen] == '=')) { if (Configure::read('MISP.email_subject_include_tag_name') === false) { $subjMarkingString = trim(substr($tagName, $tagLen+1), '"'); @@ -3045,7 +3045,7 @@ class Event extends AppModel if (Configure::read('MISP.threatlevel_in_email_subject') === false) { $threatLevel = ''; } - $subject = "[" . Configure::read('MISP.org') . " MISP] Event " . $id . " - " . $subject . $threatLevel . $subjMarkingString; + $subject = "[" . Configure::read('MISP.org') . " MISP] Event " . $id . " - " . $subject . $threatLevel . strtoupper($subjMarkingString); // Initialise the Job class if we have a background process ID // This will keep updating the process's progress bar @@ -3250,13 +3250,13 @@ class Event extends AppModel if (empty($orgMembers)) { return false; } + $tplColorString = Configure::read('MISP.email_subject_TLP_string') ?: "tlp:amber"; + $subject = "[" . Configure::read('MISP.org') . " MISP] Need info about event " . $id . " - " . strtoupper($tplColorString); + $result = true; foreach ($orgMembers as $reporter) { $temp = $this->__buildContactEventEmailBody($user, $message, $event, $reporter, $id); $bodyevent = $temp[0]; $body = $temp[1]; - $result = true; - $tplColorString = !empty(Configure::read('MISP.email_subject_TLP_string')) ? Configure::read('MISP.email_subject_TLP_string') : "tlp:amber"; - $subject = "[" . Configure::read('MISP.org') . " MISP] Need info about event " . $id . " - ".$tplColorString; $result = $this->User->sendEmail($reporter, $bodyevent, $body, $subject, $user) && $result; } return $result; diff --git a/app/Model/Post.php b/app/Model/Post.php index 199450eec..ea3315a57 100644 --- a/app/Model/Post.php +++ b/app/Model/Post.php @@ -118,8 +118,8 @@ class Post extends AppModel $bodyDetail .= "The following message was added: \n"; $bodyDetail .= "\n"; $bodyDetail .= $message . "\n"; - $tplColorString = !empty(Configure::read('MISP.email_subject_TLP_string')) ? Configure::read('MISP.email_subject_TLP_string') : "tlp:amber"; - $subject = "[" . Configure::read('MISP.org') . " MISP] New post in discussion " . $post['Post']['thread_id'] . " - ".$tplColorString; + $tplColorString = Configure::read('MISP.email_subject_TLP_string') ?: "tlp:amber"; + $subject = "[" . Configure::read('MISP.org') . " MISP] New post in discussion " . $post['Post']['thread_id'] . " - " . strtoupper($tplColorString); foreach ($orgMembers as $recipient) { $this->User->sendEmail($recipient, $bodyDetail, $body, $subject); }