mirror of https://github.com/MISP/MISP
new: [API] Export warninglists to CSV
parent
e03d566c0d
commit
b39dc5cd14
|
@ -102,7 +102,7 @@ class IndexFilterComponent extends Component
|
|||
|
||||
public function isCsv()
|
||||
{
|
||||
|
||||
return $this->Controller->request->header('Accept') === 'text/csv' || $this->Controller->RequestHandler->prefers() === 'csv';
|
||||
}
|
||||
|
||||
public function isXml()
|
||||
|
|
|
@ -337,6 +337,17 @@ class WarninglistsController extends AppController
|
|||
if (empty($warninglist)) {
|
||||
throw new NotFoundException(__('Warninglist not found.'));
|
||||
}
|
||||
if ($this->IndexFilter->isCsv()) {
|
||||
$csv = [];
|
||||
foreach ($warninglist['WarninglistEntry'] as $entry) {
|
||||
$line = $entry['value'];
|
||||
if ($entry['comment']) {
|
||||
$line .= ';' . $entry['comment'];
|
||||
}
|
||||
$csv[] = $line;
|
||||
}
|
||||
return $this->RestResponse->viewData(implode("\n", $csv), 'csv');
|
||||
}
|
||||
if ($this->_isRest()) {
|
||||
$warninglist['Warninglist']['WarninglistEntry'] = $warninglist['WarninglistEntry'];
|
||||
$warninglist['Warninglist']['WarninglistType'] = $warninglist['WarninglistType'];
|
||||
|
|
Loading…
Reference in New Issue