mirror of https://github.com/MISP/MISP
new: [API] added count returnformat for the REST api, fixes #6233
- simply counts the number of attributes/events found (on each respective scope)pull/6258/head
parent
8f806c4f1b
commit
f82e10d1fb
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
// You can count on me. Raiders roll.
|
||||
class CountExport
|
||||
{
|
||||
public $additional_params = array(
|
||||
'flatten' => 1
|
||||
);
|
||||
private $__count = 0;
|
||||
public $non_restrictive_export = true;
|
||||
|
||||
public function handler($data, $options = array())
|
||||
{
|
||||
if ($options['scope'] === 'Attribute') {
|
||||
$this->__count++;
|
||||
}
|
||||
if ($options['scope'] === 'Event') {
|
||||
$this->__count++;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function header($options = array())
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return $this->__count;
|
||||
}
|
||||
|
||||
public function separator()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -420,6 +420,7 @@ class Attribute extends AppModel
|
|||
public $validFormats = array(
|
||||
'attack-sightings' => array('json', 'AttackSightingsExport', 'json'),
|
||||
'cache' => array('txt', 'CacheExport', 'cache'),
|
||||
'count' => array('txt', 'CountExport', 'txt'),
|
||||
'csv' => array('csv', 'CsvExport', 'csv'),
|
||||
'hashes' => array('txt', 'HashesExport', 'txt'),
|
||||
'json' => array('json', 'JsonExport', 'json'),
|
||||
|
|
|
@ -176,6 +176,7 @@ class Event extends AppModel
|
|||
'attack' => array('html', 'AttackExport', 'html'),
|
||||
'attack-sightings' => array('json', 'AttackSightingsExport', 'json'),
|
||||
'cache' => array('txt', 'CacheExport', 'cache'),
|
||||
'count' => array('txt', 'CountExport', 'txt'),
|
||||
'csv' => array('csv', 'CsvExport', 'csv'),
|
||||
'hashes' => array('txt', 'HashesExport', 'txt'),
|
||||
'json' => array('json', 'JsonExport', 'json'),
|
||||
|
|
Loading…
Reference in New Issue