mirror of https://github.com/MISP/MISP
chg: [CLI] Simplify updating JSON structures
parent
8ecb50a492
commit
2dd74ed79b
|
@ -184,20 +184,8 @@ jobs:
|
|||
app/Console/cake Admin setSetting "Plugin.ZeroMQ_enable" 1
|
||||
app/Console/cake Admin setSetting "Plugin.ZeroMQ_audit_notifications_enable" 1
|
||||
|
||||
- name: Update Galaxies
|
||||
run: app/Console/cake Admin updateGalaxies
|
||||
|
||||
- name: Update Taxonomies
|
||||
run: app/Console/cake Admin updateTaxonomies
|
||||
|
||||
- name: Update Warninglists
|
||||
run: app/Console/cake Admin updateWarningLists --verbose
|
||||
|
||||
- name: Update Noticelists
|
||||
run: app/Console/cake Admin updateNoticeLists
|
||||
|
||||
- name: Update Object Templates
|
||||
run: app/Console/cake Admin updateObjectTemplates 1
|
||||
- name: Update JSON
|
||||
run: app/Console/cake Admin updateJSON
|
||||
|
||||
- name: Turn MISP live
|
||||
run: app/Console/cake Admin live 1
|
||||
|
|
|
@ -302,16 +302,22 @@ class AdminShell extends AppShell
|
|||
public function updateJSON()
|
||||
{
|
||||
$this->out('Updating all JSON structures.');
|
||||
$results = $this->Server->updateJSON();
|
||||
foreach ($results as $type => $result) {
|
||||
$overallSuccess = true;
|
||||
foreach ($this->Server->updateJSON() as $type => $result) {
|
||||
$type = Inflector::pluralize(Inflector::humanize($type));
|
||||
if ($result !== false) {
|
||||
$this->out(__('%s updated.', $type));
|
||||
if ($result['success']) {
|
||||
$this->out(__('%s updated in %.2f seconds.', $type, $result['duration']));
|
||||
} else {
|
||||
$this->out(__('Could not update %s.', $type));
|
||||
$this->out($result['result']);
|
||||
$overallSuccess = false;
|
||||
}
|
||||
}
|
||||
$this->out('All JSON structures updated. Thank you and have a very safe and productive day.');
|
||||
if ($overallSuccess) {
|
||||
$this->out('All JSON structures updated. Thank you and have a very safe and productive day.');
|
||||
} else {
|
||||
$this->error('Some structure could no be updated');
|
||||
}
|
||||
}
|
||||
|
||||
public function updateGalaxies()
|
||||
|
|
|
@ -2084,7 +2084,10 @@ class ServersController extends AppController
|
|||
|
||||
public function updateJSON()
|
||||
{
|
||||
$results = $this->Server->updateJSON();
|
||||
$results = [];
|
||||
foreach ($this->Server->updateJSON() as $type => $result) {
|
||||
$results[$type] = $results['success'];
|
||||
}
|
||||
return $this->RestResponse->viewData($results, $this->response->type());
|
||||
}
|
||||
|
||||
|
|
|
@ -4746,15 +4746,18 @@ class Server extends AppModel
|
|||
return $servers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generator[string, array]
|
||||
*/
|
||||
public function updateJSON()
|
||||
{
|
||||
$results = array();
|
||||
foreach (['Galaxy', 'Noticelist', 'Warninglist', 'Taxonomy', 'ObjectTemplate', 'ObjectRelationship'] as $target) {
|
||||
$model = ClassRegistry::init($target);
|
||||
$start = microtime(true);
|
||||
$result = $model->update();
|
||||
$results[$target] = $result === false ? false : true;
|
||||
$duration = microtime(true) - $start;
|
||||
yield $target => ['success' => $result !== false, 'result' => $result, 'duration' => $duration];
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function resetRemoteAuthKey($id)
|
||||
|
|
Loading…
Reference in New Issue