new: [alerting] Block the alerting of events based on the date field as an alternative to the timestamp, fixes #4937

pull/4939/head
iglocska 2019-07-30 10:58:15 +02:00
parent c87af6751f
commit 90191be3cd
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 21 additions and 4 deletions

View File

@ -2804,18 +2804,26 @@ class Event extends AppModel
public function sendAlertEmailRouter($id, $user, $oldpublish = null)
{
if (Configure::read('MISP.block_old_event_alert') && !empty(Configure::read('MISP.block_old_event_alert_age') && is_numeric(Configure::read('MISP.block_old_event_alert_age')))) {
if (Configure::read('MISP.block_old_event_alert')) {
$oldest = time() - (Configure::read('MISP.block_old_event_alert_age') * 86400);
$oldest_date = time() - (Configure::read('MISP.block_old_event_alert_by_date') * 86400);
$event = $this->find('first', array(
'conditions' => array('Event.id' => $id),
'recursive' => -1,
'fields' => array('Event.timestamp')
'fields' => array('Event.timestamp', 'Event.date')
));
if (empty($event)) {
return false;
}
if (intval($event['Event']['timestamp']) < $oldest) {
return true;
if (!empty(Configure::read('MISP.block_old_event_alert_age')) && is_numeric(Configure::read('MISP.block_old_event_alert_age'))) {
if (intval($event['Event']['timestamp']) < $oldest) {
return true;
}
}
if (!empty(Configure::read('MISP.block_old_event_alert_by_date')) && is_numeric(Configure::read('MISP.block_old_event_alert_by_date'))) {
if (strtotime($event['Event']['date']) < $oldest_date) {
return true;
}
}
}
if (Configure::read('MISP.block_event_alert') && Configure::read('MISP.block_event_alert_tag') && !empty(Configure::read('MISP.block_event_alert_tag'))) {

View File

@ -855,6 +855,15 @@ class Server extends AppModel
'type' => 'numeric',
'null' => false,
),
'block_old_event_alert_by_date' => array(
'level' => 1,
'description' => __('If the MISP.block_old_event_alert setting is set, this setting will control the threshold for the event.date field, indicating how old an event can be for it to be alerted on. The "date" field of the event is used. Expected format: integer, in days'),
'value' => false,
'errorMessage' => '',
'test' => 'testForNumeric',
'type' => 'numeric',
'null' => false,
),
'tmpdir' => array(
'level' => 1,
'description' => __('Please indicate the temp directory you wish to use for certain functionalities in MISP. By default this is set to /tmp and will be used among others to store certain temporary files extracted from imports during the import process.'),