mirror of https://github.com/MISP/MISP
fix: [recovery] various fixes
- to_ids fixed - background processing made optional - first/last seen format conversion altering the data's format for the recovery script fixed - added capture of object first/last seen to the recovery scriptpull/6327/head
parent
18097f05db
commit
94c37871da
|
@ -5630,7 +5630,7 @@ class EventsController extends AppController
|
||||||
|
|
||||||
public function recoverEvent($id, $mock = false)
|
public function recoverEvent($id, $mock = false)
|
||||||
{
|
{
|
||||||
if ($mock) {
|
if ($mock || !Configure::read('MISP.background_jobs')) {
|
||||||
if ($this->request->is('post')) {
|
if ($this->request->is('post')) {
|
||||||
$this->loadModel('Log');
|
$this->loadModel('Log');
|
||||||
$result = $this->Log->recoverDeletedEvent($id, $mock);
|
$result = $this->Log->recoverDeletedEvent($id, $mock);
|
||||||
|
@ -5648,6 +5648,9 @@ class EventsController extends AppController
|
||||||
return $this->RestResponse->viewData($results, $this->response->type());
|
return $this->RestResponse->viewData($results, $this->response->type());
|
||||||
} else {
|
} else {
|
||||||
$this->Flash->success($message);
|
$this->Flash->success($message);
|
||||||
|
if (!$mock) {
|
||||||
|
$this->redirect(['action' => 'restoreDeletedEvents']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message = __('This action is only accessible via POST requests.');
|
$message = __('This action is only accessible via POST requests.');
|
||||||
|
@ -5660,9 +5663,6 @@ class EventsController extends AppController
|
||||||
}
|
}
|
||||||
$this->set('data', $this->Log->mockLog);
|
$this->set('data', $this->Log->mockLog);
|
||||||
} else {
|
} else {
|
||||||
if (!Configure::read('MISP.background_jobs')) {
|
|
||||||
throw new MethodNotAllowedException(__('Workers must be enabled to use this feature'));
|
|
||||||
}
|
|
||||||
if ($this->request->is('post')) {
|
if ($this->request->is('post')) {
|
||||||
$job_type = 'recover_event';
|
$job_type = 'recover_event';
|
||||||
$function = 'recoverEvent';
|
$function = 'recoverEvent';
|
||||||
|
|
|
@ -848,10 +848,14 @@ class Log extends AppModel
|
||||||
switch($logEntry['action']) {
|
switch($logEntry['action']) {
|
||||||
case 'add':
|
case 'add':
|
||||||
$logEntry['data'] = $this->Attribute->UTCToISODatetime(['Attribute' => $logEntry['data']], 'Attribute');
|
$logEntry['data'] = $this->Attribute->UTCToISODatetime(['Attribute' => $logEntry['data']], 'Attribute');
|
||||||
|
$logEntry['data'] = $logEntry['data']['Attribute'];
|
||||||
if (!empty($this->mockRecovery)) {
|
if (!empty($this->mockRecovery)) {
|
||||||
$this->mockLog[] = ['model' => 'Attribute', 'action' => 'add', 'data' => $logEntry['data']];
|
$this->mockLog[] = ['model' => 'Attribute', 'action' => 'add', 'data' => $logEntry['data']];
|
||||||
} else {
|
} else {
|
||||||
$this->Attribute->create();
|
$this->Attribute->create();
|
||||||
|
if (!isset($logEntry['data']['to_ids'])) {
|
||||||
|
$logEntry['data']['to_ids'] = 0;
|
||||||
|
}
|
||||||
$this->Attribute->save($logEntry['data']);
|
$this->Attribute->save($logEntry['data']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -862,6 +866,7 @@ class Log extends AppModel
|
||||||
]);
|
]);
|
||||||
if (!empty($attribute)) {
|
if (!empty($attribute)) {
|
||||||
$logEntry['data'] = $this->Attribute->UTCToISODatetime(['Attribute' => $logEntry['data']], 'Attribute');
|
$logEntry['data'] = $this->Attribute->UTCToISODatetime(['Attribute' => $logEntry['data']], 'Attribute');
|
||||||
|
$logEntry['data'] = $logEntry['data']['Attribute'];
|
||||||
foreach ($logEntry['data'] as $field => $value) {
|
foreach ($logEntry['data'] as $field => $value) {
|
||||||
$attribute['Attribute'][$field] = $value;
|
$attribute['Attribute'][$field] = $value;
|
||||||
}
|
}
|
||||||
|
@ -1057,6 +1062,8 @@ class Log extends AppModel
|
||||||
}
|
}
|
||||||
switch($logEntry['action']) {
|
switch($logEntry['action']) {
|
||||||
case 'add':
|
case 'add':
|
||||||
|
$logEntry['data'] = $this->MispObject->Attribute->UTCToISODatetime(['Object' => $logEntry['data']], 'Object');
|
||||||
|
$logEntry['data'] = $logEntry['data']['Object'];
|
||||||
if (!empty($this->mockRecovery)) {
|
if (!empty($this->mockRecovery)) {
|
||||||
$this->mockLog[] = ['model' => 'MispObject', 'action' => 'add', 'data' => $logEntry['data']];
|
$this->mockLog[] = ['model' => 'MispObject', 'action' => 'add', 'data' => $logEntry['data']];
|
||||||
} else {
|
} else {
|
||||||
|
@ -1065,6 +1072,8 @@ class Log extends AppModel
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
|
$logEntry['data'] = $this->MispObject->Attribute->UTCToISODatetime(['Object' => $logEntry['data']], 'Object');
|
||||||
|
$logEntry['data'] = $logEntry['data']['Object'];
|
||||||
$object = $this->MispObject->find('first', [
|
$object = $this->MispObject->find('first', [
|
||||||
'recursive' => -1,
|
'recursive' => -1,
|
||||||
'conditions' => ['Object.id' => $logEntry['model_id']]
|
'conditions' => ['Object.id' => $logEntry['model_id']]
|
||||||
|
|
Loading…
Reference in New Issue