mirror of https://github.com/MISP/MISP
Merge branch 'develop' of github.com:MISP/MISP into migration-taxonomy
commit
d4de10fa4b
|
@ -33,7 +33,6 @@
|
|||
"hashes": [
|
||||
"sha256:2bbf76fd432960138b3ef6dda3dde0544f27cbf8546c458e60baf371917ba9ee",
|
||||
"sha256:50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8"
|
||||
],
|
||||
"version": "==2021.5.30"
|
||||
},
|
||||
"cffi": {
|
||||
|
@ -491,7 +490,11 @@
|
|||
"sha256:753a0374df26658f99d826cfe40394a686d05985786d946fbe4165b5148f5a7c",
|
||||
"sha256:a7acd0977125325f516bda9735fa7142b909a8d01e8b2e4c8108d0984e6e0098"
|
||||
],
|
||||
<<<<<<< HEAD
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
|
||||
=======
|
||||
"index": "pypi",
|
||||
>>>>>>> develop
|
||||
"version": "==1.26.5"
|
||||
},
|
||||
"weakrefmethod": {
|
||||
|
|
|
@ -734,14 +734,17 @@ class ACLComponent extends Component
|
|||
'eventIndexColumnToggle' => ['*'],
|
||||
),
|
||||
'warninglists' => array(
|
||||
'checkValue' => array('perm_auth'),
|
||||
'delete' => array(),
|
||||
'enableWarninglist' => array(),
|
||||
'getToggleField' => array(),
|
||||
'index' => array('*'),
|
||||
'toggleEnable' => array(),
|
||||
'update' => array(),
|
||||
'view' => array('*')
|
||||
'checkValue' => array('perm_auth'),
|
||||
'delete' => ['perm_warninglist'],
|
||||
'enableWarninglist' => ['perm_warninglist'],
|
||||
'getToggleField' => ['perm_warninglist'],
|
||||
'index' => array('*'),
|
||||
'toggleEnable' => ['perm_warninglist'],
|
||||
'update' => array(),
|
||||
'view' => array('*'),
|
||||
'edit' => ['perm_warninglist'],
|
||||
'add' => ['perm_warninglist'],
|
||||
'export' => ['*'],
|
||||
),
|
||||
'allowedlists' => array(
|
||||
'admin_add' => array('perm_regexp_access'),
|
||||
|
|
|
@ -85,9 +85,15 @@ class CRUDComponent extends Component
|
|||
} else {
|
||||
$data = $input;
|
||||
}
|
||||
if (isset($params['beforeSave'])) {
|
||||
$data = $params['beforeSave']($data);
|
||||
}
|
||||
/** @var Model $model */
|
||||
$model = $this->Controller->{$modelName};
|
||||
if ($model->save($data)) {
|
||||
if (isset($params['afterSave'])) {
|
||||
$params['afterSave']($data);
|
||||
}
|
||||
$data = $model->find('first', [
|
||||
'recursive' => -1,
|
||||
'conditions' => [
|
||||
|
@ -161,9 +167,15 @@ class CRUDComponent extends Component
|
|||
if (!empty($params['conditions'])) {
|
||||
$query['conditions']['AND'][] = $params['conditions'];
|
||||
}
|
||||
if (!empty($params['contain'])) {
|
||||
$query['contain'] = $params['contain'];
|
||||
}
|
||||
/** @var Model $model */
|
||||
$model = $this->Controller->{$modelName};
|
||||
$data = $model->find('first', $query);
|
||||
if (empty($data)) {
|
||||
throw new NotFoundException(__('Invalid %s.', $modelName));
|
||||
}
|
||||
if (isset($params['afterFind'])) {
|
||||
$data = $params['afterFind']($data);
|
||||
}
|
||||
|
@ -190,6 +202,9 @@ class CRUDComponent extends Component
|
|||
$data = $params['beforeSave']($data);
|
||||
}
|
||||
if ($model->save($data)) {
|
||||
if (isset($params['afterSave'])) {
|
||||
$params['afterSave']($data);
|
||||
}
|
||||
$message = __('%s updated.', $modelName);
|
||||
if ($this->Controller->IndexFilter->isRest()) {
|
||||
$this->Controller->restResponsePayload = $this->Controller->RestResponse->viewData($data, 'json');
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -69,17 +69,11 @@ class TaxonomiesController extends AppController
|
|||
}
|
||||
|
||||
$this->set('taxonomy', $taxonomy['Taxonomy']);
|
||||
$this->set('id', $id);
|
||||
$this->set('id', $taxonomy['Taxonomy']['id']);
|
||||
}
|
||||
|
||||
public function taxonomy_tags($id)
|
||||
{
|
||||
if (isset($this->passedArgs['pages'])) {
|
||||
$currentPage = $this->passedArgs['pages'];
|
||||
} else {
|
||||
$currentPage = 1;
|
||||
}
|
||||
$this->set('page', $currentPage);
|
||||
$urlparams = '';
|
||||
App::uses('CustomPaginationTool', 'Tools');
|
||||
$filter = isset($this->passedArgs['filter']) ? $this->passedArgs['filter'] : false;
|
||||
|
@ -121,12 +115,20 @@ class TaxonomiesController extends AppController
|
|||
return $this->RestResponse->viewData($taxonomy, $this->response->type());
|
||||
}
|
||||
|
||||
if (isset($this->passedArgs['pages'])) {
|
||||
$currentPage = $this->passedArgs['pages'];
|
||||
} else {
|
||||
$currentPage = 1;
|
||||
}
|
||||
$this->set('page', $currentPage);
|
||||
|
||||
$this->set('entries', $taxonomy['entries']);
|
||||
$this->set('urlparams', $urlparams);
|
||||
$this->set('passedArgs', json_encode($this->passedArgs));
|
||||
$this->set('passedArgsArray', $this->passedArgs);
|
||||
$this->set('taxonomy', $taxonomy['Taxonomy']);
|
||||
$this->set('id', $id);
|
||||
$this->set('id', $taxonomy['Taxonomy']['id']);
|
||||
$this->set('title_for_layout', __('%s Taxonomy Library', h(strtoupper($taxonomy['Taxonomy']['namespace']))));
|
||||
$this->render('ajax/taxonomy_tags');
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,17 @@ class WarninglistsController extends AppController
|
|||
'LOWER(Warninglist.name) LIKE' => '%' . strtolower($filters['value']) . '%',
|
||||
'LOWER(Warninglist.description) LIKE' => '%' . strtolower($filters['value']) . '%',
|
||||
'LOWER(Warninglist.type)' => strtolower($filters['value']),
|
||||
]
|
||||
];
|
||||
]
|
||||
];
|
||||
}
|
||||
if (isset($filters['enabled'])) {
|
||||
$this->paginate['conditions'][] = ['Warninglist.enabled' => $filters['enabled']];
|
||||
}
|
||||
$this->Warninglist->addCountField(
|
||||
'warninglist_entry_count',
|
||||
$this->Warninglist->WarninglistEntry,
|
||||
['WarninglistEntry.warninglist_id = Warninglist.id']
|
||||
);
|
||||
$warninglists = $this->paginate();
|
||||
foreach ($warninglists as &$warninglist) {
|
||||
$validAttributes = array_column($warninglist['WarninglistType'], 'type');
|
||||
|
@ -43,10 +48,11 @@ class WarninglistsController extends AppController
|
|||
}
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->viewData(['Warninglists' => $warninglists], $this->response->type());
|
||||
} else {
|
||||
$this->set('warninglists', $warninglists);
|
||||
$this->set('passedArgsArray', $filters);
|
||||
}
|
||||
|
||||
$this->set('warninglists', $warninglists);
|
||||
$this->set('passedArgsArray', $filters);
|
||||
$this->set('possibleCategories', $this->Warninglist->categories());
|
||||
}
|
||||
|
||||
public function update()
|
||||
|
@ -68,14 +74,14 @@ class WarninglistsController extends AppController
|
|||
}
|
||||
$this->Log->create();
|
||||
$this->Log->save(array(
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Warninglist',
|
||||
'model_id' => $id,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'update',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => __('Warning list updated'),
|
||||
'change' => $change,
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Warninglist',
|
||||
'model_id' => $id,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'update',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => __('Warning list updated'),
|
||||
'change' => $change,
|
||||
));
|
||||
$successes++;
|
||||
}
|
||||
|
@ -84,14 +90,14 @@ class WarninglistsController extends AppController
|
|||
foreach ($result['fails'] as $id => $fail) {
|
||||
$this->Log->create();
|
||||
$this->Log->save(array(
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Warninglist',
|
||||
'model_id' => $id,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'update',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => __('Warning list failed to update'),
|
||||
'change' => $fail['name'] . __(' could not be installed/updated. Error: ') . $fail['fail'], // TODO: needs to be optimized for non-SVO languages
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Warninglist',
|
||||
'model_id' => $id,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'update',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => __('Warning list failed to update'),
|
||||
'change' => __('%s could not be installed/updated. Error: %s', $fail['name'], $fail['fail']), // TODO: needs to be optimized for non-SVO languages
|
||||
));
|
||||
$fails++;
|
||||
}
|
||||
|
@ -99,14 +105,14 @@ class WarninglistsController extends AppController
|
|||
} else {
|
||||
$this->Log->create();
|
||||
$this->Log->save(array(
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Warninglist',
|
||||
'model_id' => 0,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'update',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => __('Warninglist update (nothing to update)'),
|
||||
'change' => __('Executed an update of the warning lists, but there was nothing to update.'),
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Warninglist',
|
||||
'model_id' => 0,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'update',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => __('Warninglist update (nothing to update)'),
|
||||
'change' => __('Executed an update of the warning lists, but there was nothing to update.'),
|
||||
));
|
||||
}
|
||||
if ($successes == 0 && $fails == 0) {
|
||||
|
@ -130,6 +136,91 @@ class WarninglistsController extends AppController
|
|||
}
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$types = array_combine($this->Warninglist->validate['type']['rule'][1], $this->Warninglist->validate['type']['rule'][1]);
|
||||
$this->set('possibleTypes', $types);
|
||||
$this->set('possibleCategories', $this->Warninglist->categories());
|
||||
|
||||
$this->loadModel('Attribute');
|
||||
$this->set('matchingAttributes', array_combine(array_keys($this->Attribute->typeDefinitions), array_keys($this->Attribute->typeDefinitions)));
|
||||
|
||||
$this->CRUD->add([
|
||||
'beforeSave' => function (array $warninglist) {
|
||||
if (isset($warninglist['Warninglist']['entries'])) {
|
||||
$entries = $this->Warninglist->parseFreetext($warninglist['Warninglist']['entries']);
|
||||
unset($warninglist['Warninglist']['entries']);
|
||||
$warninglist['WarninglistEntry'] = $entries;
|
||||
}
|
||||
if (isset($warninglist['Warninglist']['matching_attributes']) && is_array($warninglist['Warninglist']['matching_attributes'])) {
|
||||
$warninglist['WarninglistType'] = [];
|
||||
foreach ($warninglist['Warninglist']['matching_attributes'] as $attribute) {
|
||||
$warninglist['WarninglistType'][] = ['type' => $attribute];
|
||||
}
|
||||
}
|
||||
$warninglist['Warninglist']['default'] = 0;
|
||||
return $warninglist;
|
||||
},
|
||||
]);
|
||||
if ($this->restResponsePayload) {
|
||||
return $this->restResponsePayload;
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id = null)
|
||||
{
|
||||
$types = array_combine($this->Warninglist->validate['type']['rule'][1], $this->Warninglist->validate['type']['rule'][1]);
|
||||
$this->set('possibleTypes', $types);
|
||||
$this->set('possibleCategories', $this->Warninglist->categories());
|
||||
|
||||
$this->loadModel('Attribute');
|
||||
$this->set('matchingAttributes', array_combine(array_keys($this->Attribute->typeDefinitions), array_keys($this->Attribute->typeDefinitions)));
|
||||
|
||||
$this->CRUD->edit($id, [
|
||||
'conditions' => ['default' => 0], // it is not possible to edit default warninglist
|
||||
'contain' => ['WarninglistEntry', 'WarninglistType'],
|
||||
'fields' => ['name', 'description', 'type', 'category', 'entries', 'matching_attributes'],
|
||||
'redirect' => ['action' => 'view', $id],
|
||||
'beforeSave' => function (array $warninglist) {
|
||||
if (isset($warninglist['Warninglist']['entries'])) {
|
||||
$entries = $this->Warninglist->parseFreetext($warninglist['Warninglist']['entries']);
|
||||
unset($warninglist['Warninglist']['entries']);
|
||||
$warninglist['WarninglistEntry'] = $entries;
|
||||
}
|
||||
if (isset($warninglist['Warninglist']['matching_attributes']) && is_array($warninglist['Warninglist']['matching_attributes'])) {
|
||||
$warninglist['WarninglistType'] = [];
|
||||
foreach ($warninglist['Warninglist']['matching_attributes'] as $attribute) {
|
||||
$warninglist['WarninglistType'][] = ['type' => $attribute];
|
||||
}
|
||||
}
|
||||
$warninglist['Warninglist']['version']++;
|
||||
return $warninglist;
|
||||
},
|
||||
]);
|
||||
if ($this->restResponsePayload) {
|
||||
return $this->restResponsePayload;
|
||||
}
|
||||
|
||||
if (isset($this->request->data['WarninglistEntry'])) {
|
||||
$entries = [];
|
||||
foreach ($this->request->data['WarninglistEntry'] as $entry) {
|
||||
$value = $entry['value'];
|
||||
if ($entry['comment']) {
|
||||
$value .= ' # ' . $entry['comment'];
|
||||
}
|
||||
$entries[] = $value;
|
||||
}
|
||||
$this->request->data['Warninglist']['entries'] = implode("\n", $entries);
|
||||
}
|
||||
|
||||
if (isset($this->request->data['WarninglistType'])) {
|
||||
$attributes = array_column($this->request->data['WarninglistType'], 'type');
|
||||
$this->request->data['Warninglist']['matching_attributes'] = $attributes;
|
||||
}
|
||||
|
||||
$this->render('add');
|
||||
}
|
||||
|
||||
/*
|
||||
* toggle warninglists on or offset
|
||||
* Simply POST an ID or a list of IDs to toggle the current state
|
||||
|
@ -156,13 +247,12 @@ class WarninglistsController extends AppController
|
|||
$names = $this->request->data['name'];
|
||||
}
|
||||
$conditions = array();
|
||||
foreach ($names as $k => $name) {
|
||||
foreach ($names as $name) {
|
||||
$conditions['OR'][] = array('LOWER(Warninglist.name) LIKE' => strtolower($name));
|
||||
}
|
||||
$id = $this->Warninglist->find('list', array(
|
||||
$id = $this->Warninglist->find('column', array(
|
||||
'conditions' => $conditions,
|
||||
'recursive' => -1,
|
||||
'fields' => array('Warninglist.id', 'Warninglist.id')
|
||||
'fields' => array('Warninglist.id')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -240,18 +330,59 @@ class WarninglistsController extends AppController
|
|||
if (!is_numeric($id)) {
|
||||
throw new NotFoundException(__('Invalid ID.'));
|
||||
}
|
||||
$warninglist = $this->Warninglist->find('first', array('contain' => array('WarninglistEntry', 'WarninglistType'), 'conditions' => array('id' => $id)));
|
||||
$warninglist = $this->Warninglist->find('first', array(
|
||||
'contain' => array('WarninglistEntry', 'WarninglistType'),
|
||||
'conditions' => array('id' => $id))
|
||||
);
|
||||
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'];
|
||||
$this->set('Warninglist', $warninglist['Warninglist']);
|
||||
$this->set('_serialize', array('Warninglist'));
|
||||
} else {
|
||||
$this->set('warninglist', $warninglist);
|
||||
return $this->RestResponse->viewData($warninglist, $this->response->type());
|
||||
}
|
||||
|
||||
$this->set('warninglist', $warninglist);
|
||||
$this->set('possibleCategories', $this->Warninglist->categories());
|
||||
}
|
||||
|
||||
public function export($id = null)
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new NotFoundException(__('Warninglist not found.'));
|
||||
}
|
||||
$warninglist = $this->Warninglist->find('first', [
|
||||
'contain' => ['WarninglistType'],
|
||||
'conditions' => ['id' => $id],
|
||||
]);
|
||||
if (empty($warninglist)) {
|
||||
throw new NotFoundException(__('Warninglist not found.'));
|
||||
}
|
||||
$matchingAttributes = array_column($warninglist['WarninglistType'], 'type');
|
||||
$list = $this->Warninglist->WarninglistEntry->find('column', [
|
||||
'conditions' => ['warninglist_id' => $warninglist['Warninglist']['id']],
|
||||
'fields' => ['value'],
|
||||
]);
|
||||
$output = [
|
||||
'name' => $warninglist['Warninglist']['name'],
|
||||
'version' => $warninglist['Warninglist']['version'],
|
||||
'description' => $warninglist['Warninglist']['description'],
|
||||
'matching_attributes' => $matchingAttributes,
|
||||
'list' => $list,
|
||||
];
|
||||
return $this->RestResponse->viewData($output, 'json');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
|
@ -260,7 +391,7 @@ class WarninglistsController extends AppController
|
|||
$id = intval($id);
|
||||
$result = $this->Warninglist->quickDelete($id);
|
||||
if ($result) {
|
||||
$this->Flash->success(__('Warninglist successfuly deleted.'));
|
||||
$this->Flash->success(__('Warninglist successfully deleted.'));
|
||||
$this->redirect(array('controller' => 'warninglists', 'action' => 'index'));
|
||||
} else {
|
||||
$this->Flash->error(__('Warninglists could not be deleted.'));
|
||||
|
|
|
@ -136,6 +136,14 @@ class PubSubTool
|
|||
return $this->pushToRedis(':data:misp_json_sighting', json_encode($sighting, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
public function warninglist_save(array $warninglist, $action = false)
|
||||
{
|
||||
if (!empty($action)) {
|
||||
$warninglist['action'] = $action;
|
||||
}
|
||||
return $this->pushToRedis(':data:misp_json_warninglist', json_encode($warninglist, JSON_PRETTY_PRINT));
|
||||
}
|
||||
|
||||
public function modified($data, $type, $action = false)
|
||||
{
|
||||
if (!empty($action)) {
|
||||
|
|
|
@ -90,7 +90,7 @@ class AppModel extends Model
|
|||
51 => false, 52 => false, 53 => false, 54 => false, 55 => false, 56 => false,
|
||||
57 => false, 58 => false, 59 => false, 60 => false, 61 => false, 62 => false,
|
||||
63 => true, 64 => false, 65 => false, 66 => false, 67 => false, 68 => false,
|
||||
69 => false, 70 => false,
|
||||
69 => false, 70 => false, 71 => true,
|
||||
);
|
||||
|
||||
public $advanced_updates_description = array(
|
||||
|
@ -1603,6 +1603,11 @@ class AppModel extends Model
|
|||
case 70:
|
||||
$sqlArray[] = "ALTER TABLE `galaxies` ADD `enabled` tinyint(1) NOT NULL DEFAULT 1 AFTER `namespace`;";
|
||||
break;
|
||||
case 71:
|
||||
$sqlArray[] = "ALTER TABLE `roles` ADD `perm_warninglist` tinyint(1) NOT NULL DEFAULT 0;";
|
||||
$sqlArray[] = "ALTER TABLE `warninglist_entries` ADD `comment` text DEFAULT NULL;";
|
||||
$sqlArray[] = "ALTER TABLE `warninglists` ADD `default` tinyint(1) NOT NULL DEFAULT 1, ADD `category` varchar(20) NOT NULL DEFAULT 'false_positive', DROP COLUMN `warninglist_entry_count`";
|
||||
break;
|
||||
case 'fixNonEmptySharingGroupID':
|
||||
$sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';
|
||||
$sqlArray[] = 'UPDATE `attributes` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';
|
||||
|
|
|
@ -26,7 +26,6 @@ class AuditLogBehavior extends ModelBehavior
|
|||
'last_login' => true, // User
|
||||
'newsread' => true, // User
|
||||
'proposal_email_lock' => true, // Event
|
||||
'warninglist_entry_count' => true, // Warninglist
|
||||
];
|
||||
|
||||
private $modelInfo = [
|
||||
|
|
|
@ -319,6 +319,12 @@ class Role extends AppModel
|
|||
'readonlyenabled' => false,
|
||||
'title' => __('Allow users to publish data to Kafka via the publish event to Kafka button.'),
|
||||
),
|
||||
'perm_warninglist' => array(
|
||||
'id' => 'RolePermWarninglist',
|
||||
'text' => 'Warninglist Editor',
|
||||
'readonlyenabled' => false,
|
||||
'title' => __('Allow to manage warninglists.'),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6617,6 +6617,14 @@ class Server extends AppModel
|
|||
'test' => 'testBool',
|
||||
'type' => 'boolean'
|
||||
),
|
||||
'ZeroMQ_warninglist_notifications_enable' => array(
|
||||
'level' => 2,
|
||||
'description' => __('Enables or disables the publishing of new/modified warninglist to the ZMQ pubsub feed.'),
|
||||
'value' => false,
|
||||
'errorMessage' => '',
|
||||
'test' => 'testBool',
|
||||
'type' => 'boolean'
|
||||
),
|
||||
'ElasticSearch_logging_enable' => array(
|
||||
'level' => 2,
|
||||
'description' => __('Enabled logging to an ElasticSearch instance'),
|
||||
|
|
|
@ -164,6 +164,11 @@ class Taxonomy extends AppModel
|
|||
return $this->validationErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $id Taxonomy ID or namespace
|
||||
* @param string|null $options
|
||||
* @return array|false
|
||||
*/
|
||||
private function __getTaxonomy($id, $options = array('full' => false, 'filter' => false))
|
||||
{
|
||||
$recursive = -1;
|
||||
|
@ -190,6 +195,9 @@ class Taxonomy extends AppModel
|
|||
foreach ($predicate['TaxonomyEntry'] as $entry) {
|
||||
$temp = array('tag' => $taxonomy['Taxonomy']['namespace'] . ':' . $predicate['value'] . '="' . $entry['value'] . '"');
|
||||
$temp['expanded'] = (!empty($predicate['expanded']) ? $predicate['expanded'] : $predicate['value']) . ': ' . (!empty($entry['expanded']) ? $entry['expanded'] : $entry['value']);
|
||||
if (isset($entry['description']) && !empty($entry['description'])) {
|
||||
$temp['description'] = $entry['description'];
|
||||
}
|
||||
if (isset($entry['colour']) && !empty($entry['colour'])) {
|
||||
$temp['colour'] = $entry['colour'];
|
||||
}
|
||||
|
@ -202,6 +210,9 @@ class Taxonomy extends AppModel
|
|||
} else {
|
||||
$temp = array('tag' => $taxonomy['Taxonomy']['namespace'] . ':' . $predicate['value']);
|
||||
$temp['expanded'] = !empty($predicate['expanded']) ? $predicate['expanded'] : $predicate['value'];
|
||||
if (isset($predicate['description']) && !empty($predicate['description'])) {
|
||||
$temp['description'] = $predicate['description'];
|
||||
}
|
||||
if (isset($predicate['colour']) && !empty($predicate['colour'])) {
|
||||
$temp['colour'] = $predicate['colour'];
|
||||
}
|
||||
|
@ -213,9 +224,10 @@ class Taxonomy extends AppModel
|
|||
}
|
||||
$taxonomy = array('Taxonomy' => $taxonomy['Taxonomy']);
|
||||
if ($filter) {
|
||||
$filter = mb_strtolower($filter);
|
||||
$namespaceLength = strlen($taxonomy['Taxonomy']['namespace']);
|
||||
foreach ($entries as $k => $entry) {
|
||||
if (strpos(substr(mb_strtolower($entry['tag']), $namespaceLength), mb_strtolower($filter)) === false) {
|
||||
if (strpos(substr(mb_strtolower($entry['tag']), $namespaceLength), $filter) === false) {
|
||||
unset($entries[$k]);
|
||||
}
|
||||
}
|
||||
|
@ -315,14 +327,20 @@ class Taxonomy extends AppModel
|
|||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|string $id Taxonomy ID or namespace
|
||||
* @param array|null $options
|
||||
* @return array|false
|
||||
*/
|
||||
public function getTaxonomy($id, $options = array('full' => true))
|
||||
{
|
||||
$taxonomy = $this->__getTaxonomy($id, $options);
|
||||
if (empty($taxonomy)) {
|
||||
return false;
|
||||
}
|
||||
$this->Tag = ClassRegistry::init('Tag');
|
||||
$taxonomy = $this->__getTaxonomy($id, $options);
|
||||
if (isset($options['full']) && $options['full']) {
|
||||
if (empty($taxonomy)) {
|
||||
return false;
|
||||
}
|
||||
$tagNames = array_column($taxonomy['entries'], 'tag');
|
||||
$tags = $this->Tag->getTagsByName($tagNames, false);
|
||||
$filterActive = false;
|
||||
|
|
|
@ -8,6 +8,9 @@ App::uses('CidrTool', 'Tools');
|
|||
*/
|
||||
class Warninglist extends AppModel
|
||||
{
|
||||
const CATEGORY_FALSE_POSITIVE = 'false_positive',
|
||||
CATEGORY_KNOWN = 'known';
|
||||
|
||||
public $useTable = 'warninglists';
|
||||
|
||||
public $recursive = -1;
|
||||
|
@ -19,7 +22,13 @@ class Warninglist extends AppModel
|
|||
|
||||
public $validate = array(
|
||||
'name' => array(
|
||||
'rule' => array('valueNotEmpty'),
|
||||
'notEmpty' => [
|
||||
'rule' => 'valueNotEmpty',
|
||||
],
|
||||
'unique' => [
|
||||
'rule' => 'isUnique',
|
||||
'message' => 'Warninglist with same name already exists.'
|
||||
],
|
||||
),
|
||||
'description' => array(
|
||||
'rule' => array('valueNotEmpty'),
|
||||
|
@ -27,6 +36,12 @@ class Warninglist extends AppModel
|
|||
'version' => array(
|
||||
'rule' => array('numeric'),
|
||||
),
|
||||
'type' => [
|
||||
'rule' => ['inList', ['cidr', 'hostname', 'string', 'substring', 'regex']],
|
||||
],
|
||||
'category' => [
|
||||
'rule' => ['inList', ['false_positive', 'known']],
|
||||
],
|
||||
);
|
||||
|
||||
public $hasMany = array(
|
||||
|
@ -56,6 +71,31 @@ class Warninglist extends AppModel
|
|||
$this->showForAll = Configure::read('MISP.warning_for_all');
|
||||
}
|
||||
|
||||
public function beforeValidate($options = array())
|
||||
{
|
||||
if (isset($this->data['WarninglistEntry'])) {
|
||||
if ($this->data['Warninglist']['type'] === 'cidr') {
|
||||
foreach ($this->data['WarninglistEntry'] as $entry) {
|
||||
if (!CidrTool::validate($entry['value'])) {
|
||||
$this->validationErrors['entries'][] = __('`%s` is not valid CIDR', $entry['value']);
|
||||
}
|
||||
}
|
||||
} else if ($this->data['Warninglist']['type'] === 'regex') {
|
||||
foreach ($this->data['WarninglistEntry'] as $entry) {
|
||||
if (@preg_match($entry['value'], '') === false) {
|
||||
$this->validationErrors['entries'][] = __('`%s` is not valid regular expression', $entry['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->validationErrors['entries'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach warninglist matches to attributes or proposals with IDS mark.
|
||||
*
|
||||
|
@ -89,10 +129,10 @@ class Warninglist extends AppModel
|
|||
return $eventWarnings;
|
||||
}
|
||||
|
||||
$warninglistIdToName = [];
|
||||
$warninglists = [];
|
||||
$enabledTypes = [];
|
||||
foreach ($enabledWarninglists as $warninglist) {
|
||||
$warninglistIdToName[$warninglist['Warninglist']['id']] = $warninglist['Warninglist']['name'];
|
||||
$warninglists[$warninglist['Warninglist']['id']] = $warninglist['Warninglist'];
|
||||
foreach ($warninglist['types'] as $type) {
|
||||
$enabledTypes[$type] = true;
|
||||
}
|
||||
|
@ -128,9 +168,10 @@ class Warninglist extends AppModel
|
|||
'value' => $match['value'],
|
||||
'match' => $match['match'],
|
||||
'warninglist_id' => $warninglistId,
|
||||
'warninglist_name' => $warninglistIdToName[$warninglistId],
|
||||
'warninglist_name' => $warninglists[$warninglistId]['name'],
|
||||
'warninglist_category' => $warninglists[$warninglistId]['category'],
|
||||
];
|
||||
$eventWarnings[$warninglistId] = $warninglistIdToName[$warninglistId];
|
||||
$eventWarnings[$warninglistId] = $warninglists[$warninglistId]['name'];
|
||||
|
||||
$store[$warninglistId] = [$match['value'], $match['match']];
|
||||
}
|
||||
|
@ -146,9 +187,10 @@ class Warninglist extends AppModel
|
|||
'value' => $matched[0],
|
||||
'match' => $matched[1],
|
||||
'warninglist_id' => $warninglistId,
|
||||
'warninglist_name' => $warninglistIdToName[$warninglistId],
|
||||
'warninglist_name' => $warninglists[$warninglistId]['name'],
|
||||
'warninglist_category' => $warninglists[$warninglistId]['category'],
|
||||
];
|
||||
$eventWarnings[$warninglistId] = $warninglistIdToName[$warninglistId];
|
||||
$eventWarnings[$warninglistId] = $warninglists[$warninglistId]['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,9 +208,11 @@ class Warninglist extends AppModel
|
|||
|
||||
public function update()
|
||||
{
|
||||
// Existing default warninglists
|
||||
$existingWarninglist = $this->find('all', [
|
||||
'fields' => ['id', 'name', 'version', 'enabled'],
|
||||
'recursive' => -1,
|
||||
'condition' => ['default' => 1],
|
||||
]);
|
||||
$existingWarninglist = array_column(array_column($existingWarninglist, 'Warninglist'), null, 'name');
|
||||
|
||||
|
@ -228,6 +272,7 @@ class Warninglist extends AppModel
|
|||
if ($current['enabled']) {
|
||||
$list['enabled'] = 1;
|
||||
}
|
||||
$list['id'] = $current['id']; // keep list ID
|
||||
$this->quickDelete($current['id']);
|
||||
}
|
||||
$fieldsToSave = array('name', 'version', 'description', 'type', 'enabled');
|
||||
|
@ -245,13 +290,11 @@ class Warninglist extends AppModel
|
|||
}
|
||||
}
|
||||
unset($list['list']);
|
||||
$count = count($values);
|
||||
$result = true;
|
||||
foreach (array_chunk($values, 500) as $chunk) {
|
||||
$result = $db->insertMulti('warninglist_entries', array('value', 'warninglist_id'), $chunk);
|
||||
}
|
||||
if ($result) {
|
||||
$this->saveField('warninglist_entry_count', $count);
|
||||
} else {
|
||||
if (!$result) {
|
||||
return 'Could not insert values.';
|
||||
}
|
||||
if (!empty($list['matching_attributes'])) {
|
||||
|
@ -300,7 +343,7 @@ class Warninglist extends AppModel
|
|||
$warninglists = $this->find('all', array(
|
||||
'contain' => array('WarninglistType'),
|
||||
'conditions' => array('enabled' => 1),
|
||||
'fields' => ['id', 'name', 'type'],
|
||||
'fields' => ['id', 'name', 'type', 'category'],
|
||||
));
|
||||
$this->cacheWarninglists($warninglists);
|
||||
|
||||
|
@ -365,9 +408,9 @@ class Warninglist extends AppModel
|
|||
}
|
||||
} else {
|
||||
$warninglists = $this->find('all', array(
|
||||
'contain' => array('WarninglistType'),
|
||||
'conditions' => array('enabled' => 1),
|
||||
'fields' => ['id', 'name', 'type'],
|
||||
'contain' => ['WarninglistType'],
|
||||
'conditions' => ['enabled' => 1],
|
||||
'fields' => ['id', 'name', 'type', 'category'],
|
||||
));
|
||||
$this->cacheWarninglists($warninglists);
|
||||
}
|
||||
|
@ -457,8 +500,9 @@ class Warninglist extends AppModel
|
|||
$object['warnings'][] = array(
|
||||
'match' => $result[0],
|
||||
'value' => $result[1],
|
||||
'warninglist_name' => $list['Warninglist']['name'],
|
||||
'warninglist_id' => $list['Warninglist']['id'],
|
||||
'warninglist_name' => $list['Warninglist']['name'],
|
||||
'warninglist_category' => $list['Warninglist']['category'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -634,4 +678,108 @@ class Warninglist extends AppModel
|
|||
}
|
||||
return $missingTldLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $data
|
||||
* @param bool $validate
|
||||
* @param array $fieldList
|
||||
* @return array|bool|mixed|null
|
||||
* @throws Exception
|
||||
*/
|
||||
public function save($data = null, $validate = true, $fieldList = array())
|
||||
{
|
||||
$db = $this->getDataSource();
|
||||
$transactionBegun = $db->begin();
|
||||
|
||||
$success = parent::save($data, $validate, $fieldList);
|
||||
|
||||
$db = $this->getDataSource();
|
||||
|
||||
try {
|
||||
$id = (int)$this->id;
|
||||
if (isset($data['WarninglistEntry'])) {
|
||||
$this->WarninglistEntry->deleteAll(['warninglist_id' => $id]);
|
||||
$entriesToInsert = [];
|
||||
foreach ($data['WarninglistEntry'] as &$entry) {
|
||||
$entriesToInsert[] = [$entry['value'], isset($entry['comment']) ? $entry['comment'] : null, $id];
|
||||
}
|
||||
$db->insertMulti(
|
||||
$this->WarninglistEntry->table,
|
||||
['value', 'comment', 'warninglist_id'],
|
||||
$entriesToInsert
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($data['WarninglistType'])) {
|
||||
$this->WarninglistType->deleteAll(['warninglist_id' => $id]);
|
||||
foreach ($data['WarninglistType'] as &$entry) {
|
||||
$entry['warninglist_id'] = $id;
|
||||
}
|
||||
$this->WarninglistType->saveMany($data['WarninglistType']);
|
||||
}
|
||||
|
||||
if ($transactionBegun) {
|
||||
if ($success) {
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
if ($transactionBegun) {
|
||||
$db->rollback();
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function afterSave($created, $options = array())
|
||||
{
|
||||
if (isset($this->data['Warninglist']['default']) && $this->data['Warninglist']['default'] == 0) {
|
||||
$this->regenerateWarninglistCaches($this->data['Warninglist']['id']);
|
||||
}
|
||||
|
||||
$pubToZmq = Configure::read('Plugin.ZeroMQ_enable') && Configure::read('Plugin.ZeroMQ_warninglist_notifications_enable');
|
||||
if ($pubToZmq) {
|
||||
$warninglist = $this->find('first', [
|
||||
'conditions' => ['id' => $this->data['Warninglist']['id']],
|
||||
'contains' => ['WarninglistEntry', 'WarninglistType'],
|
||||
]);
|
||||
$pubSubTool = $this->getPubSubTool();
|
||||
$pubSubTool->warninglist_save($warninglist, $created ? 'add' : 'edit');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $input
|
||||
* @return array
|
||||
*/
|
||||
public function parseFreetext($input)
|
||||
{
|
||||
$input = trim($input);
|
||||
if (empty($input)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$entries = [];
|
||||
foreach (explode("\n", trim($input)) as $entry) {
|
||||
$valueAndComment = explode("#", $entry, 2);
|
||||
$entries[] = [
|
||||
'value' => trim($valueAndComment[0]),
|
||||
'comment' => count($valueAndComment) === 2 ? trim($valueAndComment[1]) : null,
|
||||
];
|
||||
}
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function categories()
|
||||
{
|
||||
return [
|
||||
self::CATEGORY_FALSE_POSITIVE => __('False positive'),
|
||||
self::CATEGORY_KNOWN => __('Known identifier'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ function triggerEventFilteringTool(hide) {
|
|||
"id": "distribution",
|
||||
"label": "Distribution",
|
||||
"values": {
|
||||
0: "Your orginisation only",
|
||||
0: "Your organisation only",
|
||||
1: "This community only",
|
||||
2: "Connected community",
|
||||
3: "All communities",
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
if (!empty($fieldData['description'])) {
|
||||
$temp .= sprintf('<small class="clear form-field-description apply_css_arrow">%s</small>', h($fieldData['description']));
|
||||
}
|
||||
$fieldsArrayForPersistence []= $modelForForm . Inflector::camelize($fieldData['field']);
|
||||
$fieldsArrayForPersistence[] = $modelForForm . Inflector::camelize($fieldData['field']);
|
||||
if (!empty($fieldData['hidden'])) {
|
||||
$temp = '<span class="hidden">' . $temp . '</span>';
|
||||
}
|
||||
|
|
|
@ -506,11 +506,26 @@ $divider = $this->element('/genericElements/SideMenu/side_menu_divider');
|
|||
));
|
||||
break;
|
||||
case 'warninglist':
|
||||
if ($menuItem === 'view') {
|
||||
if ($menuItem === 'view' || $menuItem === 'edit') {
|
||||
echo $this->element('/genericElements/SideMenu/side_menu_link', array(
|
||||
'element_id' => 'view',
|
||||
'url' => $baseurl . '/warninglists/view/' . h($id),
|
||||
'text' => __('View Warninglist')
|
||||
));
|
||||
if (!$isDefault && $canAccess('warninglists', 'edit')) {
|
||||
echo $this->element('/genericElements/SideMenu/side_menu_link', [
|
||||
'element_id' => 'edit',
|
||||
'url' => $baseurl . '/warninglists/edit/' . h($id),
|
||||
'text' => __('Edit Warninglist'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
if ($canAccess('warninglists', 'add')) {
|
||||
echo $this->element('/genericElements/SideMenu/side_menu_link', [
|
||||
'element_id' => 'add',
|
||||
'url' => $baseurl . '/warninglists/add',
|
||||
'text' => __('Add Warninglist'),
|
||||
]);
|
||||
}
|
||||
echo $this->element('/genericElements/SideMenu/side_menu_link', array(
|
||||
'url' => $baseurl . '/warninglists/index',
|
||||
|
|
|
@ -158,17 +158,17 @@
|
|||
'requirement' => !$isAclRegexp
|
||||
),
|
||||
array(
|
||||
'text' => __('List Warninglists'),
|
||||
'text' => __('Warninglists'),
|
||||
'url' => $baseurl . '/warninglists/index'
|
||||
),
|
||||
array(
|
||||
'text' => __('List Noticelists'),
|
||||
'text' => __('Noticelists'),
|
||||
'url' => $baseurl . '/noticelists/index'
|
||||
),
|
||||
array(
|
||||
'text' => __('List Correlation Exclusions'),
|
||||
'url' => $baseurl . '/correlation_exclusions/index',
|
||||
'requirement' => $canAccess('correlation_exclusions', 'index'),
|
||||
'text' => __('Correlation Exclusions'),
|
||||
'url' => $baseurl . '/correlation_exclusions/index',
|
||||
'requirement' => $canAccess('correlation_exclusions', 'index'),
|
||||
)
|
||||
)
|
||||
),
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
$action = $this->request->params['action'];
|
||||
echo $this->element('genericElements/Form/genericForm', array(
|
||||
'form' => $this->Form,
|
||||
'data' => array(
|
||||
'title' => $action === 'add' ? __('Add warninglist') : __('Edit warninglist'),
|
||||
'model' => 'Warninglist',
|
||||
'fields' => array(
|
||||
array(
|
||||
'field' => 'name',
|
||||
'class' => 'input span6',
|
||||
),
|
||||
array(
|
||||
'field' => 'description',
|
||||
'class' => 'input span6',
|
||||
'rows' => 1,
|
||||
),
|
||||
array(
|
||||
'field' => 'type',
|
||||
'class' => 'input',
|
||||
'options' => $possibleTypes,
|
||||
),
|
||||
array(
|
||||
'field' => 'category',
|
||||
'class' => 'input',
|
||||
'options' => $possibleCategories,
|
||||
),
|
||||
array(
|
||||
'label' => __('Accepted attribute types'),
|
||||
'field' => 'matching_attributes',
|
||||
'type' => 'select',
|
||||
'multiple' => 'multiple',
|
||||
),
|
||||
array(
|
||||
'label' => __('Values (one value per line, for value comment use #)'),
|
||||
'field' => 'entries',
|
||||
'type' => 'textarea',
|
||||
'rows' => 10,
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'action' => $action
|
||||
)
|
||||
)
|
||||
));
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', [
|
||||
'menuList' => 'warninglist',
|
||||
'menuItem' => $action === 'add' ? 'add' : 'edit',
|
||||
'id' => $action === 'add' ? null : $entity['Warninglist']['id'],
|
||||
'isDefault' => false,
|
||||
]);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$('#WarninglistMatchingAttributes').chosen();
|
||||
</script>
|
|
@ -1,5 +1,5 @@
|
|||
<div class="warninglist view">
|
||||
<h2><?= __('Search in Warninglists') ?></h2>
|
||||
<h2><?= __('Search in enabled Warninglists') ?></h2>
|
||||
<?php
|
||||
echo $this->Form->create('Warninglist');
|
||||
echo sprintf('<div class="input-append">%s%s</div>',
|
||||
|
@ -28,4 +28,4 @@
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?= $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'warninglist', 'menuItem' => 'check_value')); ?>
|
||||
<?= $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'warninglist', 'menuItem' => 'check_value')); ?>
|
||||
|
|
|
@ -67,26 +67,37 @@
|
|||
'name' => __('Description'),
|
||||
'data_path' => 'Warninglist.description',
|
||||
),
|
||||
array(
|
||||
'name' => __('Category'),
|
||||
'sort' => 'category',
|
||||
'class' => 'short',
|
||||
'element' => 'custom',
|
||||
'function' => function (array $row) use ($possibleCategories) {
|
||||
return $possibleCategories[$row['Warninglist']['category']];
|
||||
}
|
||||
),
|
||||
array(
|
||||
'name' => __('Type'),
|
||||
'sort' => 'type',
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.type',
|
||||
),
|
||||
array(
|
||||
'name' => __('Valid attributes'),
|
||||
'class' => 'short',
|
||||
'sort' => 'Warninglist.valid_attributes',
|
||||
'data_path' => 'Warninglist.valid_attributes',
|
||||
),
|
||||
array(
|
||||
'name' => __('Entries'),
|
||||
'sort' => 'warninglist_entry_count',
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.warninglist_entry_count',
|
||||
),
|
||||
array(
|
||||
'name' => __('Default'),
|
||||
'sort' => 'default',
|
||||
'class' => 'short',
|
||||
'element' => 'boolean',
|
||||
'data_path' => 'Warninglist.default',
|
||||
),
|
||||
array(
|
||||
'name' => __('Enabled'),
|
||||
'sort' => 'enabled',
|
||||
'class' => 'short',
|
||||
'element' => 'boolean',
|
||||
'data_path' => 'Warninglist.enabled',
|
||||
|
@ -128,11 +139,25 @@
|
|||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'url' => $baseurl . '/warninglists/edit',
|
||||
'url_params_data_paths' => array(
|
||||
'Warninglist.id'
|
||||
),
|
||||
'title' => __('Edit'),
|
||||
'icon' => 'edit',
|
||||
'complex_requirement' => [
|
||||
'function' => function($row) use ($me) {
|
||||
return $row['Warninglist']['default'] == 0 && $me['Role']['perm_warninglist'];
|
||||
}
|
||||
]
|
||||
),
|
||||
array(
|
||||
'url' => $baseurl . '/warninglists/view',
|
||||
'url_params_data_paths' => array(
|
||||
'Warninglist.id'
|
||||
),
|
||||
'title' => __('View'),
|
||||
'icon' => 'eye',
|
||||
'dbclickAction' => true
|
||||
),
|
||||
|
@ -153,7 +178,6 @@
|
|||
echo '</div>';
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'warninglist', 'menuItem' => 'index'));
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#quickFilterButton').click(function() {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
<?php
|
||||
$data = $warninglist['Warninglist'];
|
||||
$types = array_column($warninglist['WarninglistType'], 'type');
|
||||
$types = implode(', ', array_column($warninglist['WarninglistType'], 'type'));
|
||||
$table_data = array(
|
||||
array('key' => __('ID'), 'value' => $data['id']),
|
||||
array('key' => __('Name'), 'value' => $data['name']),
|
||||
array('key' => __('Description'), 'value' => $data['description']),
|
||||
array('key' => __('Version'), 'value' => $data['version']),
|
||||
array('key' => __('Category'), 'value' => $possibleCategories[$data['category']]),
|
||||
array('key' => __('Type'), 'value' => $data['type']),
|
||||
array('key' => __('Accepted attribute types'), 'value' => implode(', ', $types)),
|
||||
array('key' => __('Accepted attribute types'), 'value' => $types),
|
||||
array(
|
||||
'key' => __('Enabled'),
|
||||
'boolean' => $data['enabled'],
|
||||
|
@ -21,15 +22,29 @@
|
|||
)
|
||||
),
|
||||
);
|
||||
|
||||
$values = [];
|
||||
foreach ($warninglist['WarninglistEntry'] as $entry) {
|
||||
$value = h($entry['value']);
|
||||
if ($entry['comment']) {
|
||||
$value .= ' <span style="color: gray"># ' . h($entry['comment']) . '</span>';
|
||||
}
|
||||
$values[] = $value;
|
||||
}
|
||||
|
||||
echo sprintf(
|
||||
'<div class="warninglist view"><div class="row-fluid"><div class="span8" style="margin:0;">%s</div></div><h4>%s</h4>%s</div>',
|
||||
sprintf(
|
||||
'<h2>%s</h2>%s',
|
||||
h(strtoupper($warninglist['Warninglist']['name'])),
|
||||
h(mb_strtoupper($warninglist['Warninglist']['name'])),
|
||||
$this->element('genericElements/viewMetaTable', array('table_data' => $table_data))
|
||||
),
|
||||
__('Values'),
|
||||
implode('<br>', array_column($warninglist['WarninglistEntry'], 'value'))
|
||||
implode('<br>', $values)
|
||||
);
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'warninglist', 'menuItem' => 'view'));
|
||||
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', [
|
||||
'menuList' => 'warninglist',
|
||||
'menuItem' => 'view',
|
||||
'id' => $data['id'],
|
||||
'isDefault' => $data['default'] == 1,
|
||||
]);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a3cdbc1309e36c41f6a090fdb35eeebd86dff3e1
|
||||
Subproject commit 42935032314c8de4587fb18064535e30a80ece63
|
|
@ -1 +1 @@
|
|||
Subproject commit 212e4102586a34b523e53c926a5313050dcb478d
|
||||
Subproject commit fca66ddd7d955968a76b1bf485671084ff765658
|
|
@ -1,6 +1,6 @@
|
|||
openapi: 3.0.0
|
||||
info:
|
||||
version: 2.4.142
|
||||
version: 2.4.144
|
||||
title: MISP Automation API
|
||||
description: |
|
||||
|
||||
|
@ -60,7 +60,7 @@ tags:
|
|||
description: "Galaxies in MISP are a method used to express a large object called cluster that can be attached to MISP events or attributes."
|
||||
externalDocs:
|
||||
url: https://www.circl.lu/doc/misp/galaxy/
|
||||
- name: GalaxyClusters
|
||||
- name: Galaxy Clusters
|
||||
description: "A galaxy cluster that can be attached to MISP events or attributes."
|
||||
externalDocs:
|
||||
url: https://www.circl.lu/doc/misp/galaxy/
|
||||
|
@ -106,6 +106,26 @@ tags:
|
|||
url: https://www.circl.lu/doc/misp/noticelists/
|
||||
|
||||
paths:
|
||||
/attributes/restSearch:
|
||||
post:
|
||||
summary: "[restSearch] Get a filtered and paginated list of attributes"
|
||||
description: |
|
||||
**This is the recommended endpoint for searching attributes.**
|
||||
operationId: restSearchAttributes
|
||||
tags:
|
||||
- Attributes
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/returnFormatParameter"
|
||||
requestBody:
|
||||
$ref: "#/components/requestBodies/RestSearchAttributesRequest"
|
||||
responses:
|
||||
"200":
|
||||
$ref: "#/components/responses/AttributesRestSearchResponse"
|
||||
"403":
|
||||
$ref: "#/components/responses/UnauthorizedApiErrorResponse"
|
||||
default:
|
||||
$ref: "#/components/responses/ApiErrorResponse"
|
||||
|
||||
/attributes/add/{eventId}:
|
||||
post:
|
||||
summary: "Add an attribute"
|
||||
|
@ -248,27 +268,9 @@ paths:
|
|||
default:
|
||||
$ref: "#/components/responses/ApiErrorResponse"
|
||||
|
||||
/attributes/restSearch:
|
||||
post:
|
||||
summary: "Get a filtered and paginated list of attributes"
|
||||
operationId: restSearchAttributes
|
||||
tags:
|
||||
- Attributes
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/returnFormatParameter"
|
||||
requestBody:
|
||||
$ref: "#/components/requestBodies/RestSearchAttributesRequest"
|
||||
responses:
|
||||
"200":
|
||||
$ref: "#/components/responses/AttributesRestSearchResponse"
|
||||
"403":
|
||||
$ref: "#/components/responses/UnauthorizedApiErrorResponse"
|
||||
default:
|
||||
$ref: "#/components/responses/ApiErrorResponse"
|
||||
|
||||
/attributes/attributeStatistics/{context}/{percentage}:
|
||||
get:
|
||||
summary: "Get a filtered and paginated list of attributes"
|
||||
summary: "Get the count of attributes per category"
|
||||
operationId: getAttributeStatistics
|
||||
tags:
|
||||
- Attributes
|
||||
|
@ -297,6 +299,26 @@ paths:
|
|||
default:
|
||||
$ref: "#/components/responses/ApiErrorResponse"
|
||||
|
||||
/events/restSearch:
|
||||
post:
|
||||
summary: "[restSearch] Get a filtered and paginated list of events"
|
||||
operationId: restSearchEvents
|
||||
description: |
|
||||
**This is the recommended endpoint for searching events.**
|
||||
tags:
|
||||
- Events
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/returnFormatParameter"
|
||||
requestBody:
|
||||
$ref: "#/components/requestBodies/RestSearchEventsRequest"
|
||||
responses:
|
||||
"200":
|
||||
$ref: "#/components/responses/EventsRestSearchResponse"
|
||||
"403":
|
||||
$ref: "#/components/responses/UnauthorizedApiErrorResponse"
|
||||
default:
|
||||
$ref: "#/components/responses/ApiErrorResponse"
|
||||
|
||||
/events/add:
|
||||
post:
|
||||
summary: "Add event"
|
||||
|
@ -393,24 +415,6 @@ paths:
|
|||
default:
|
||||
$ref: "#/components/responses/ApiErrorResponse"
|
||||
|
||||
/events/restSearch:
|
||||
post:
|
||||
summary: "Get a filtered and paginated list of events"
|
||||
operationId: restSearchEvents
|
||||
tags:
|
||||
- Events
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/returnFormatParameter"
|
||||
requestBody:
|
||||
$ref: "#/components/requestBodies/RestSearchEventsRequest"
|
||||
responses:
|
||||
"200":
|
||||
$ref: "#/components/responses/EventsRestSearchResponse"
|
||||
"403":
|
||||
$ref: "#/components/responses/UnauthorizedApiErrorResponse"
|
||||
default:
|
||||
$ref: "#/components/responses/ApiErrorResponse"
|
||||
|
||||
/events/publish/{eventId}:
|
||||
post:
|
||||
summary: "Publish an event"
|
||||
|
@ -619,7 +623,7 @@ paths:
|
|||
summary: "Add galaxy cluster"
|
||||
operationId: addGalaxyCluster
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyIdParameter"
|
||||
requestBody:
|
||||
|
@ -639,7 +643,7 @@ paths:
|
|||
summary: "Edit galaxy cluster"
|
||||
operationId: editGalaxyCluster
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyClusterIdParameter"
|
||||
requestBody:
|
||||
|
@ -659,7 +663,7 @@ paths:
|
|||
summary: "Get galaxy clusters"
|
||||
operationId: getGalaxyClusters
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyIdParameter"
|
||||
responses:
|
||||
|
@ -675,7 +679,7 @@ paths:
|
|||
summary: "Search galaxy clusters"
|
||||
operationId: searchGalaxyClusters
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyIdParameter"
|
||||
requestBody:
|
||||
|
@ -695,7 +699,7 @@ paths:
|
|||
summary: "Get galaxy cluster by ID"
|
||||
operationId: getGalaxyClusterById
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyClusterIdParameter"
|
||||
responses:
|
||||
|
@ -713,7 +717,7 @@ paths:
|
|||
summary: "Publish galaxy cluster"
|
||||
operationId: publishGalaxyCluster
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyClusterIdParameter"
|
||||
responses:
|
||||
|
@ -731,7 +735,7 @@ paths:
|
|||
summary: "Unpublish galaxy cluster"
|
||||
operationId: unpublishGalaxyCluster
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyClusterIdParameter"
|
||||
responses:
|
||||
|
@ -749,7 +753,7 @@ paths:
|
|||
summary: "Delete galaxy cluster"
|
||||
operationId: deleteGalaxyCluster
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyClusterIdParameter"
|
||||
responses:
|
||||
|
@ -767,7 +771,7 @@ paths:
|
|||
summary: "Restore galaxy cluster"
|
||||
operationId: restoreGalaxyCluster
|
||||
tags:
|
||||
- GalaxyClusters
|
||||
- Galaxy Clusters
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/galaxyClusterIdParameter"
|
||||
responses:
|
||||
|
|
|
@ -7609,6 +7609,17 @@
|
|||
"column_default": "string",
|
||||
"extra": ""
|
||||
},
|
||||
{
|
||||
"column_name": "category",
|
||||
"is_nullable": "NO",
|
||||
"data_type": "varchar",
|
||||
"character_maximum_length": "20",
|
||||
"numeric_precision": null,
|
||||
"collation_name": "utf8_general_ci",
|
||||
"column_type": "varchar(20)",
|
||||
"column_default": "false_positive",
|
||||
"extra": ""
|
||||
},
|
||||
{
|
||||
"column_name": "description",
|
||||
"is_nullable": "NO",
|
||||
|
@ -7643,14 +7654,14 @@
|
|||
"extra": ""
|
||||
},
|
||||
{
|
||||
"column_name": "warninglist_entry_count",
|
||||
"column_name": "default",
|
||||
"is_nullable": "NO",
|
||||
"data_type": "int",
|
||||
"data_type": "tinyint",
|
||||
"character_maximum_length": null,
|
||||
"numeric_precision": "10",
|
||||
"numeric_precision": "3",
|
||||
"collation_name": null,
|
||||
"column_type": "int(11) unsigned",
|
||||
"column_default": "0",
|
||||
"column_type": "tinyint(1)",
|
||||
"column_default": "1",
|
||||
"extra": ""
|
||||
}
|
||||
],
|
||||
|
@ -7677,6 +7688,17 @@
|
|||
"column_default": null,
|
||||
"extra": ""
|
||||
},
|
||||
{
|
||||
"column_name": "comment",
|
||||
"is_nullable": "YES",
|
||||
"data_type": "text",
|
||||
"character_maximum_length": "65535",
|
||||
"numeric_precision": null,
|
||||
"collation_name": "utf8_unicode_ci",
|
||||
"column_type": "text",
|
||||
"column_default": null,
|
||||
"extra": ""
|
||||
},
|
||||
{
|
||||
"column_name": "warninglist_id",
|
||||
"is_nullable": "NO",
|
||||
|
@ -8169,5 +8191,5 @@
|
|||
"id": true
|
||||
}
|
||||
},
|
||||
"db_version": "70"
|
||||
"db_version": "71"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue