mirror of https://github.com/MISP/MISP
fix: [test] Show debug output for warninglist
parent
39395ce69b
commit
ad9bb42441
|
@ -181,7 +181,7 @@ jobs:
|
|||
run: sudo -E su $USER -c 'app/Console/cake Admin updateTaxonomies'
|
||||
|
||||
- name: Update Warninglists
|
||||
run: sudo -E su $USER -c 'app/Console/cake Admin updateWarningLists'
|
||||
run: sudo -E su $USER -c 'app/Console/cake Admin updateWarningLists --verbose'
|
||||
|
||||
- name: Update Noticelists
|
||||
run: sudo -E su $USER -c 'app/Console/cake Admin updateNoticeLists'
|
||||
|
|
|
@ -32,6 +32,15 @@ class AdminShell extends AppShell
|
|||
));
|
||||
$parser->addSubcommand('updateWarningLists', array(
|
||||
'help' => __('Update the JSON definition of warninglists.'),
|
||||
'parser' => [
|
||||
'options' => [
|
||||
'verbose' => [
|
||||
'help' => 'Show verbose output.',
|
||||
'default' => false,
|
||||
'boolean' => true
|
||||
]
|
||||
]
|
||||
]
|
||||
));
|
||||
$parser->addSubcommand('updateTaxonomies', array(
|
||||
'help' => __('Update the JSON definition of taxonomies.'),
|
||||
|
@ -324,13 +333,19 @@ class AdminShell extends AppShell
|
|||
public function updateWarningLists()
|
||||
{
|
||||
$result = $this->Warninglist->update();
|
||||
$success = count($result['success']);
|
||||
$fails = count($result['fails']);
|
||||
$this->out("$success warninglists updated, $fails fails");
|
||||
if ($fails) {
|
||||
$this->out(__('Fails:'));
|
||||
foreach ($result['fails'] as $fail) {
|
||||
$this->out("{$fail['name']}: {$fail['fail']}");
|
||||
|
||||
if ($this->params['verbose']) {
|
||||
$this->out($this->json($result));
|
||||
} else {
|
||||
$success = count($result['success']);
|
||||
$fails = count($result['fails']);
|
||||
$this->out("$success warninglists updated, $fails fails");
|
||||
if ($fails) {
|
||||
$this->out(__('Fails:'));
|
||||
foreach ($result['fails'] as $fail) {
|
||||
$this->out("{$fail['name']}: {$fail['fail']}");
|
||||
}
|
||||
$this->_stop(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ abstract class AppShell extends Shell
|
|||
*/
|
||||
protected function json($data)
|
||||
{
|
||||
return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
|
||||
return JsonTool::encode($data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -288,7 +288,7 @@ class Warninglist extends AppModel
|
|||
$list['type'] = $list['type'][0];
|
||||
}
|
||||
if (!isset($existingWarninglist[$list['name']]) || $list['version'] > $existingWarninglist[$list['name']]['version']) {
|
||||
$current = isset($existingWarninglist[$list['name']]) ? $existingWarninglist[$list['name']] : [];
|
||||
$current = $existingWarninglist[$list['name']] ?? [];
|
||||
try {
|
||||
$id = $this->__updateList($list, $current);
|
||||
$result['success'][$id] = ['name' => $list['name'], 'new' => $list['version']];
|
||||
|
|
Loading…
Reference in New Issue