mirror of https://github.com/MISP/MISP
fix: Fixed an issue that incorrectly reported a feed update to have failed when not using delta-merge mode
- the issue was that in the case of a feed update to a fixed event without delta merge, MISP tried to insert all parsed attributes, which correctly automatically blocked duplicates - however, since these attributes were blocked by the validator, the feed fetcher reported that the fetch didn't succeed as it contained validation errors - this fix simply runs non-delta merge mode updates through the comparisons to the existing event, removing duplicates in advancepull/1709/head
parent
6e52070f48
commit
a637542a56
|
@ -488,7 +488,7 @@ class Feed extends AppModel {
|
|||
$this->save($feed);
|
||||
}
|
||||
}
|
||||
if ($feed['Feed']['fixed_event'] && $feed['Feed']['delta_merge']) {
|
||||
if ($feed['Feed']['fixed_event']) {
|
||||
$event = $this->Event->find('first', array('conditions' => array('Event.id' => $event['Event']['id']), 'recursive' => -1, 'contain' => array('Attribute' => array('conditions' => array('Attribute.deleted' => 0)))));
|
||||
$to_delete = array();
|
||||
foreach ($data as $k => $dataPoint) {
|
||||
|
@ -499,14 +499,19 @@ class Feed extends AppModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
foreach ($event['Attribute'] as $attribute) {
|
||||
$to_delete[] = $attribute['id'];
|
||||
}
|
||||
if (!empty($to_delete)) {
|
||||
$this->Event->Attribute->deleteAll(array('Attribute.id' => $to_delete));
|
||||
if ($feed['Feed']['delta_merge']) {
|
||||
foreach ($event['Attribute'] as $attribute) {
|
||||
$to_delete[] = $attribute['id'];
|
||||
}
|
||||
if (!empty($to_delete)) {
|
||||
$this->Event->Attribute->deleteAll(array('Attribute.id' => $to_delete));
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = array_values($data);
|
||||
if (empty($data)) {
|
||||
return true;
|
||||
}
|
||||
foreach ($data as $key => $value) {
|
||||
$data[$key]['event_id'] = $event['Event']['id'];
|
||||
$data[$key]['distribution'] = $feed['Feed']['distribution'];
|
||||
|
|
Loading…
Reference in New Issue