From 8d09cadc77bc100d7e522c4649d50dac63af710a Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 29 Sep 2023 10:35:33 +0200 Subject: [PATCH 1/3] fix: [console:EventShell] Fixed parameter parsing and typo --- app/Console/Command/EventShell.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Command/EventShell.php b/app/Console/Command/EventShell.php index 9fb01fd45..42a8e7ce2 100644 --- a/app/Console/Command/EventShell.php +++ b/app/Console/Command/EventShell.php @@ -91,8 +91,8 @@ class EventShell extends AppShell } $isXml = $extension === 'xml'; - $takeOwnership = $this->param('take_ownership'); - $publish = $this->param('publish'); + $takeOwnership = $this->params['take-ownership']; + $publish = $this->params['publish']; $results = $this->Event->addMISPExportFile($user, $content, $isXml, $takeOwnership, $publish); foreach ($results as $result) { From 4ddf3b41f3d5b68419f76b194e1287f1084b0566 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 29 Sep 2023 11:55:35 +0200 Subject: [PATCH 2/3] fix: [Console:EventShell] Correctly interpret returned data --- app/Console/Command/EventShell.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Console/Command/EventShell.php b/app/Console/Command/EventShell.php index 42a8e7ce2..8940673d8 100644 --- a/app/Console/Command/EventShell.php +++ b/app/Console/Command/EventShell.php @@ -97,6 +97,8 @@ class EventShell extends AppShell foreach ($results as $result) { if (is_numeric($result['result'])) { + $this->out("Event `{$result['info']}` already exists at ({$result['result']})."); + } else if ($result['result'] === true) { $this->out("Event #{$result['id']}: {$result['info']} imported."); } else { $this->out("Could not import event because of validation errors: " . json_encode($result['validationIssues'])); From 7bd64bc23f5e780709d8a60dd37d2cefb1e7d671 Mon Sep 17 00:00:00 2001 From: iglocska Date: Mon, 2 Oct 2023 15:30:17 +0200 Subject: [PATCH 3/3] fix: [search] pagination fix --- app/Controller/LogsController.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Controller/LogsController.php b/app/Controller/LogsController.php index 1d540ae48..c58461ff6 100644 --- a/app/Controller/LogsController.php +++ b/app/Controller/LogsController.php @@ -273,7 +273,7 @@ class LogsController extends AppController $this->set('actionDefinitions', $this->{$this->defaultModel}->actionDefinitions); // reset the paginate_conditions - $this->Session->write('paginate_conditions_log', array()); + //$this->Session->write('paginate_conditions_log', array()); if ($this->request->is('post')) { $filters['email'] = $this->request->data['Log']['email']; if (!$orgRestriction) { @@ -337,12 +337,11 @@ class LogsController extends AppController $this->Session->write('paginate_conditions_log_model_id', $filters['model_id']); $this->Session->write('paginate_conditions_log_title', $filters['title']); $this->Session->write('paginate_conditions_log_change', $filters['change']); - $this->Session->write('paginate_conditions_log_change', $filters['from'] ?? null); - $this->Session->write('paginate_conditions_log_change', $filters['to'] ?? null); + $this->Session->write('paginate_conditions_log_from', $filters['from'] ?? null); + $this->Session->write('paginate_conditions_log_to', $filters['to'] ?? null); if (Configure::read('MISP.log_client_ip')) { $this->Session->write('paginate_conditions_log_ip', $filters['ip']); } - // set the same view as the index page $this->render('index'); } @@ -355,12 +354,11 @@ class LogsController extends AppController $filters['model_id'] = $this->Session->read('paginate_conditions_log_model_id'); $filters['title'] = $this->Session->read('paginate_conditions_log_title'); $filters['change'] = $this->Session->read('paginate_conditions_log_change'); - $filters['change'] = $this->Session->read('paginate_conditions_log_from') ?? null; - $filters['change'] = $this->Session->read('paginate_conditions_log_to') ?? null; + $filters['from'] = $this->Session->read('paginate_conditions_log_from') ?? null; + $filters['to'] = $this->Session->read('paginate_conditions_log_to') ?? null; if (Configure::read('MISP.log_client_ip')) { $filters['ip'] = $this->Session->read('paginate_conditions_log_ip'); } - // for info on what was searched for $this->set('emailSearch', $filters['email']); $this->set('orgSearch', $filters['org']); @@ -378,7 +376,7 @@ class LogsController extends AppController // re-get pagination $this->{$this->defaultModel}->recursive = 0; - $this->paginate = array_merge_recursive($this->Session->read('paginate_conditions_log'), $this->paginate); + $this->paginate = array_replace_recursive($this->paginate, $this->Session->read('paginate_conditions_log')); if (!isset($this->paginate['order'])) { $this->paginate['order'] = array('Log.id' => 'DESC'); }