new: Update all the json structures in MISP via the API, fixes #2168

- Just post to the following APIs as a site admin:
  - /warninglists/update
  - /galaxies/update
  - /taxonomies/update
pull/2211/head
iglocska 2017-05-09 09:00:01 +02:00
parent a9ac025785
commit eb6a5e7000
3 changed files with 24 additions and 9 deletions

View File

@ -23,7 +23,13 @@ class GalaxiesController extends AppController {
public function update() {
if (!$this->request->is('post')) throw new MethodNotAllowedException('This action is only accessible via POST requests.');
$result = $this->Galaxy->update();
$this->redirect(array('controller' => 'galaxies', 'action' => 'index'));
$message = 'Galaxies updated.';
if ($this->_isRest()) {
return $this->RestResponse->saveSuccessResponse('Galaxy', 'update', false, $this->response->type(), $message);
} else {
$this->Session->setFlash($message);
$this->redirect(array('controller' => 'galaxies', 'action' => 'index'));
}
}
public function view($id) {

View File

@ -166,14 +166,19 @@ class TaxonomiesController extends AppController {
'change' => 'Executed an update of the taxonomy library, but there was nothing to update.',
));
}
if ($successes == 0 && $fails == 0) $this->Session->setFlash('All taxonomy libraries are up to date already.');
else if ($successes == 0) $this->Session->setFlash('Could not update any of the taxonomy libraries');
$message = '';
if ($successes == 0 && $fails == 0) $message = 'All taxonomy libraries are up to date already.';
else if ($successes == 0) $message = 'Could not update any of the taxonomy libraries';
else {
$message = 'Successfully updated ' . $successes . ' taxonomy libraries.';
if ($fails != 0) $message .= ' However, could not update ' . $fails . ' taxonomy libraries.';
$this->Session->setFlash($message);
}
$this->redirect(array('controller' => 'taxonomies', 'action' => 'index'));
if ($this->_isRest()) {
return $this->RestResponse->saveSuccessResponse('Taxonomy', 'update', false, $this->response->type(), $message);
} else {
$this->Session->setFlash($message);
$this->redirect(array('controller' => 'taxonomies', 'action' => 'index'));
}
}
public function addTag($taxonomy_id = false) {

View File

@ -86,14 +86,18 @@ class WarninglistsController extends AppController {
'change' => 'Executed an update of the warning lists, but there was nothing to update.',
));
}
if ($successes == 0 && $fails == 0) $this->Session->setFlash('All warninglists are up to date already.');
else if ($successes == 0) $this->Session->setFlash('Could not update any of the warning lists');
if ($successes == 0 && $fails == 0) $message = 'All warninglists are up to date already.';
else if ($successes == 0) $message = 'Could not update any of the warning lists';
else {
$message = 'Successfully updated ' . $successes . ' warninglists.';
if ($fails != 0) $message . ' However, could not update ' . $fails . ' warning list.';
$this->Session->setFlash($message);
}
$this->redirect(array('controller' => 'warninglists', 'action' => 'index'));
if ($this->_isRest()) {
return $this->RestResponse->saveSuccessResponse('Warninglist', 'update', false, $this->response->type(), $message);
} else {
$this->Session->setFlash($message);
$this->redirect(array('controller' => 'warninglists', 'action' => 'index'));
}
}
public function toggleEnable() {