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)
|
||||
{
|
||||
if ($mock) {
|
||||
if ($mock || !Configure::read('MISP.background_jobs')) {
|
||||
if ($this->request->is('post')) {
|
||||
$this->loadModel('Log');
|
||||
$result = $this->Log->recoverDeletedEvent($id, $mock);
|
||||
|
@ -5648,6 +5648,9 @@ class EventsController extends AppController
|
|||
return $this->RestResponse->viewData($results, $this->response->type());
|
||||
} else {
|
||||
$this->Flash->success($message);
|
||||
if (!$mock) {
|
||||
$this->redirect(['action' => 'restoreDeletedEvents']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = __('This action is only accessible via POST requests.');
|
||||
|
@ -5660,9 +5663,6 @@ class EventsController extends AppController
|
|||
}
|
||||
$this->set('data', $this->Log->mockLog);
|
||||
} else {
|
||||
if (!Configure::read('MISP.background_jobs')) {
|
||||
throw new MethodNotAllowedException(__('Workers must be enabled to use this feature'));
|
||||
}
|
||||
if ($this->request->is('post')) {
|
||||
$job_type = 'recover_event';
|
||||
$function = 'recoverEvent';
|
||||
|
|
|
@ -848,10 +848,14 @@ class Log extends AppModel
|
|||
switch($logEntry['action']) {
|
||||
case 'add':
|
||||
$logEntry['data'] = $this->Attribute->UTCToISODatetime(['Attribute' => $logEntry['data']], 'Attribute');
|
||||
$logEntry['data'] = $logEntry['data']['Attribute'];
|
||||
if (!empty($this->mockRecovery)) {
|
||||
$this->mockLog[] = ['model' => 'Attribute', 'action' => 'add', 'data' => $logEntry['data']];
|
||||
} else {
|
||||
$this->Attribute->create();
|
||||
if (!isset($logEntry['data']['to_ids'])) {
|
||||
$logEntry['data']['to_ids'] = 0;
|
||||
}
|
||||
$this->Attribute->save($logEntry['data']);
|
||||
}
|
||||
break;
|
||||
|
@ -862,6 +866,7 @@ class Log extends AppModel
|
|||
]);
|
||||
if (!empty($attribute)) {
|
||||
$logEntry['data'] = $this->Attribute->UTCToISODatetime(['Attribute' => $logEntry['data']], 'Attribute');
|
||||
$logEntry['data'] = $logEntry['data']['Attribute'];
|
||||
foreach ($logEntry['data'] as $field => $value) {
|
||||
$attribute['Attribute'][$field] = $value;
|
||||
}
|
||||
|
@ -1057,6 +1062,8 @@ class Log extends AppModel
|
|||
}
|
||||
switch($logEntry['action']) {
|
||||
case 'add':
|
||||
$logEntry['data'] = $this->MispObject->Attribute->UTCToISODatetime(['Object' => $logEntry['data']], 'Object');
|
||||
$logEntry['data'] = $logEntry['data']['Object'];
|
||||
if (!empty($this->mockRecovery)) {
|
||||
$this->mockLog[] = ['model' => 'MispObject', 'action' => 'add', 'data' => $logEntry['data']];
|
||||
} else {
|
||||
|
@ -1065,6 +1072,8 @@ class Log extends AppModel
|
|||
}
|
||||
break;
|
||||
case 'edit':
|
||||
$logEntry['data'] = $this->MispObject->Attribute->UTCToISODatetime(['Object' => $logEntry['data']], 'Object');
|
||||
$logEntry['data'] = $logEntry['data']['Object'];
|
||||
$object = $this->MispObject->find('first', [
|
||||
'recursive' => -1,
|
||||
'conditions' => ['Object.id' => $logEntry['model_id']]
|
||||
|
|
Loading…
Reference in New Issue