From a849d15b0ff3c90e1847f91114bbfadcee5f4bd5 Mon Sep 17 00:00:00 2001 From: iglocska Date: Fri, 14 Mar 2014 09:19:35 +0100 Subject: [PATCH] Event description in alert e-mail subject made optional, fixes #231 --- app/Config/bootstrap.default.php | 2 ++ app/Model/Event.php | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Config/bootstrap.default.php b/app/Config/bootstrap.default.php index 319f8c3be..86e8b0284 100755 --- a/app/Config/bootstrap.default.php +++ b/app/Config/bootstrap.default.php @@ -141,6 +141,8 @@ Configure::write('MISP.default_attribute_distribution', 'event'); // Enable the tagging feature, it shou Configure::write('MISP.tagging', true); +// enabling this flag will allow the event description to be transmitted in the alert e-mail's subject. Be aware that this is not encrypted by PGP, so only enable it if you accept that part of the event description will be sent out in clear-text +Configure::write('MISP.extended_alert_subject', false); /** * The settings below can be used to set additional paths to models, views and controllers. diff --git a/app/Model/Event.php b/app/Model/Event.php index 8ee0f6ce3..f153a6958 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -1119,9 +1119,16 @@ class Event extends AppModel { if (!empty($bodyTempOther)) { $body .= "\n"; } - $subject = preg_replace( "/\r|\n/", "", $event['Event']['info']); - if (strlen($subject) > 55) { - $subject = substr($subject, 0, 55) . '...'; + + if (Configure::read('MISP.extended_alert_subject')) { + $subject = preg_replace( "/\r|\n/", "", $event['Event']['info']); + if (strlen($subject) > 55) { + $subject = substr($subject, 0, 55) . '... - '; + } else { + $subject .= " - "; + } + } else { + $subject = ''; } $body .= $bodyTempOther; // append the 'other' attribute types to the bottom. $body .= '==============================================' . "\n"; @@ -1157,7 +1164,7 @@ class Event extends AppModel { $Email = new CakeEmail(); $Email->from(Configure::read('MISP.email')); $Email->to($user['User']['email']); - $Email->subject("[" . Configure::read('MISP.org') . " " . Configure::read('MISP.name') . "] Event " . $id . " - " . $subject . " - " . $event['ThreatLevel']['name'] . " - TLP Amber"); + $Email->subject("[" . Configure::read('MISP.org') . " " . Configure::read('MISP.name') . "] Event " . $id . " - " . $subject . $event['ThreatLevel']['name'] . " - TLP Amber"); $Email->emailFormat('text'); // both text or html // send it $Email->send($bodySigned);