mirror of https://github.com/MISP/MISP
Merge branch '2.4' of https://github.com/MISP/MISP into 2.4
commit
28cf469996
|
@ -11,6 +11,12 @@ class TaxonomiesController extends AppController {
|
|||
public $paginate = array(
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events <- no we won't, this is the max a user van view/page.
|
||||
'contain' => array(
|
||||
'TaxonomyPredicate' => array(
|
||||
'fields' => array('TaxonomyPredicate.id'),
|
||||
'TaxonomyEntry' => array('fields' => array('TaxonomyEntry.id'))
|
||||
)
|
||||
),
|
||||
'order' => array(
|
||||
'Taxonomy.id' => 'DESC'
|
||||
),
|
||||
|
@ -18,7 +24,18 @@ class TaxonomiesController extends AppController {
|
|||
|
||||
public function index() {
|
||||
$this->paginate['recursive'] = -1;
|
||||
$this->set('taxonomies', $this->paginate());
|
||||
$taxonomies = $this->paginate();
|
||||
$this->loadModel('Tag');
|
||||
foreach ($taxonomies as &$taxonomy) {
|
||||
$total = 0;
|
||||
foreach ($taxonomy['TaxonomyPredicate'] as &$predicate) {
|
||||
$total += empty($predicate['TaxonomyEntry']) ? 1 : count($predicate['TaxonomyEntry']);
|
||||
}
|
||||
$taxonomy['total_count'] = $total;
|
||||
$taxonomy['current_count'] = $this->Tag->find('count', array('conditions' => array('lower(Tag.name) LIKE ' => strtolower($taxonomy['Taxonomy']['namespace']) . ':%')));
|
||||
unset($taxonomy['TaxonomyPredicate']);
|
||||
}
|
||||
$this->set('taxonomies', $taxonomies);
|
||||
}
|
||||
|
||||
public function view($id) {
|
||||
|
@ -160,19 +177,24 @@ class TaxonomiesController extends AppController {
|
|||
$this->redirect(array('controller' => 'taxonomies', 'action' => 'index'));
|
||||
}
|
||||
|
||||
public function addTag() {
|
||||
public function addTag($taxonomy_id = false) {
|
||||
if ((!$this->_isSiteAdmin() && !$this->userRole['perm_tagger']) || !$this->request->is('post')) throw new NotFoundException('You don\'t have permission to do that.');
|
||||
if (isset($this->request->data['Taxonomy'])) {
|
||||
$this->request->data['Tag'] = $this->request->data['Taxonomy'];
|
||||
unset($this->request->data['Taxonomy']);
|
||||
}
|
||||
if (isset($this->request->data['Tag']['request'])) $this->request->data['Tag'] = $this->request->data['Tag']['request'];
|
||||
if (!isset($this->request->data['Tag']['nameList'])) $this->request->data['Tag']['nameList'] = array($this->request->data['Tag']['name']);
|
||||
else $this->request->data['Tag']['nameList'] = json_decode($this->request->data['Tag']['nameList'], true);
|
||||
if ($this->Taxonomy->addTags($this->request->data['Tag']['taxonomy_id'], $this->request->data['Tag']['nameList'])) {
|
||||
$this->Session->setFlash('The tag has been saved.');
|
||||
if ($taxonomy_id) {
|
||||
$result = $this->Taxonomy->addTags($taxonomy_id);
|
||||
} else {
|
||||
$this->Session->setFlash('The tag could not be saved. Please, try again.');
|
||||
if (isset($this->request->data['Taxonomy'])) {
|
||||
$this->request->data['Tag'] = $this->request->data['Taxonomy'];
|
||||
unset($this->request->data['Taxonomy']);
|
||||
}
|
||||
if (isset($this->request->data['Tag']['request'])) $this->request->data['Tag'] = $this->request->data['Tag']['request'];
|
||||
if (!isset($this->request->data['Tag']['nameList'])) $this->request->data['Tag']['nameList'] = array($this->request->data['Tag']['name']);
|
||||
else $this->request->data['Tag']['nameList'] = json_decode($this->request->data['Tag']['nameList'], true);
|
||||
$result = $this->Taxonomy->addTags($this->request->data['Tag']['taxonomy_id'], $this->request->data['Tag']['nameList']);
|
||||
}
|
||||
if ($result) {
|
||||
$this->Session->setFlash('The tag(s) has been saved.');
|
||||
} else {
|
||||
$this->Session->setFlash('The tag(s) could not be saved. Please, try again.');
|
||||
}
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
|
|
|
@ -395,6 +395,7 @@ class Event extends AppModel {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!isset($this->data['Event']['threat_level_id'])) $this->data['Event']['threat_level_id'] = Configure::read('MISP.default_event_threat_level') ? Configure::read('MISP.default_event_threat_level') : '1';
|
||||
|
||||
// generate UUID if it doesn't exist
|
||||
if (empty($this->data['Event']['uuid'])) {
|
||||
|
|
|
@ -371,6 +371,15 @@ class Server extends AppModel {
|
|||
'type' => 'string',
|
||||
'options' => array('0' => 'Your organisation only', '1' => 'This community only', '2' => 'Connected communities', '3' => 'All communities', 'event' => 'Inherit from event'),
|
||||
),
|
||||
'default_event_threat_level' => array(
|
||||
'level' => 1,
|
||||
'description' => 'The default threat level setting when creating events.',
|
||||
'value' => '1',
|
||||
'errorMessage' => '',
|
||||
'test' => 'testForEmpty',
|
||||
'type' => 'string',
|
||||
'options' => array('1' => 'High', '2' => 'Medium', '3' => 'Low', '4' => 'undefined'),
|
||||
),
|
||||
'tagging' => array(
|
||||
'level' => 1,
|
||||
'description' => 'Enable the tagging feature of MISP. This is highly recommended.',
|
||||
|
|
|
@ -199,8 +199,8 @@ class Taxonomy extends AppModel{
|
|||
}
|
||||
}
|
||||
|
||||
public function addTags($id, $tagList) {
|
||||
if (!is_array($tagList)) $tagList = array($tagList);
|
||||
public function addTags($id, $tagList = false) {
|
||||
if ($tagList && !is_array($tagList)) $tagList = array($tagList);
|
||||
$this->Tag = ClassRegistry::init('Tag');
|
||||
App::uses('ColourPaletteTool', 'Tools');
|
||||
$paletteTool = new ColourPaletteTool();
|
||||
|
@ -209,14 +209,22 @@ class Taxonomy extends AppModel{
|
|||
$tags = $this->Tag->getTagsForNamespace($taxonomy['Taxonomy']['namespace']);
|
||||
$colours = $paletteTool->generatePaletteFromString($taxonomy['Taxonomy']['namespace'], count($taxonomy['entries']));
|
||||
foreach ($taxonomy['entries'] as $k => &$entry) {
|
||||
foreach ($tagList as $tagName) {
|
||||
if ($tagName === $entry['tag']) {
|
||||
if (isset($tags[strtoupper($entry['tag'])])) {
|
||||
$this->Tag->quickEdit($tags[strtoupper($entry['tag'])], $tagName, $colours[$k]);
|
||||
} else {
|
||||
$this->Tag->quickAdd($tagName, $colours[$k]);
|
||||
if ($tagList) {
|
||||
foreach ($tagList as $tagName) {
|
||||
if ($tagName === $entry['tag']) {
|
||||
if (isset($tags[strtoupper($entry['tag'])])) {
|
||||
$this->Tag->quickEdit($tags[strtoupper($entry['tag'])], $tagName, $colours[$k]);
|
||||
} else {
|
||||
$this->Tag->quickAdd($tagName, $colours[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($tags[strtoupper($entry['tag'])])) {
|
||||
$this->Tag->quickEdit($tags[strtoupper($entry['tag'])], $entry['tag'], $colours[$k]);
|
||||
} else {
|
||||
$this->Tag->quickAdd($entry['tag'], $colours[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -43,7 +43,7 @@ class Whitelist extends AppModel {
|
|||
),
|
||||
'userdefined' => array(
|
||||
'rule' => array('validateValue'),
|
||||
'message' => 'Name not in the right format. Please double check the name.',
|
||||
'message' => 'Name not in the right format. Whitelist entries have to be enclosed by a valid php delimiter (which can be most non-alphanumeric / non-whitespace character). Format: "/8.8.8.8/" Please double check the name.', //'allowEmpty' => false,
|
||||
//'allowEmpty' => false,
|
||||
//'required' => true,
|
||||
//'last' => false, // Stop validation after this rule
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
</div>
|
||||
<?php
|
||||
echo $this->Form->input('threat_level_id', array(
|
||||
'div' => 'input clear'
|
||||
'div' => 'input clear',
|
||||
'selected' => Configure::read('MISP.default_event_threat_level') ? Configure::read('MISP.default_event_threat_level') : '1',
|
||||
));
|
||||
echo $this->Form->input('analysis', array(
|
||||
'options' => array($analysisLevels),
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<th><?php echo $this->Paginator->sort('description');?></th>
|
||||
<th><?php echo $this->Paginator->sort('version');?></th>
|
||||
<th><?php echo $this->Paginator->sort('enabled');?></th>
|
||||
<th>Active Tags</th>
|
||||
<th class="actions"><?php echo __('Actions');?></th>
|
||||
</tr><?php
|
||||
foreach ($taxonomies as $item): ?>
|
||||
|
@ -31,11 +32,12 @@ foreach ($taxonomies as $item): ?>
|
|||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/taxonomies/view/".h($item['Taxonomy']['id']);?>'"><?php echo h($item['Taxonomy']['namespace']); ?> </td>
|
||||
<td ondblclick="document.location.href ='<?php echo $baseurl."/taxonomies/view/".h($item['Taxonomy']['id']);?>'"><?php echo h($item['Taxonomy']['description']); ?> </td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/taxonomies/view/".h($item['Taxonomy']['id']);?>'"><?php echo h($item['Taxonomy']['version']); ?> </td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/taxonomies/view/".h($item['Taxonomy']['id']);?>'"><?php echo $item['Taxonomy']['enabled'] ? '<span class="green">Yes</span>' : '<span class="red">No</span>'; ?> </td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/taxonomies/view/".h($item['Taxonomy']['id']);?>'"><?php echo $item['Taxonomy']['enabled'] ? '<span class="green">Yes</span>' : '<span class="red">No</span>'; ?> </td>
|
||||
<td class="shortish"><span><span class="bold"><?php echo h($item['current_count']);?></span> / <?php echo h($item['total_count']);?> <?php if ($item['current_count'] != $item['total_count'] && $isSiteAdmin && $item['Taxonomy']['enabled']) echo '(' . $this->Form->postLink('enable all', array('action' => 'addTag', h($item['Taxonomy']['id'])), array('title' => 'Enable all tags'), ('Are you sure you want to enable every tag associated to this taxonomy?')) . ')'; ?></span></td>
|
||||
<td class="short action-links">
|
||||
<?php
|
||||
if ($isSiteAdmin) {
|
||||
if ($item['Taxonomy']['enabled']) {
|
||||
if ($item['Taxonomy']['enabled']) {
|
||||
echo $this->Form->postLink('', array('action' => 'disable', h($item['Taxonomy']['id'])), array('class' => 'icon-minus', 'title' => 'Disable'), ('Are you sure you want to disable this taxonomy library?'));
|
||||
} else {
|
||||
echo $this->Form->postLink('', array('action' => 'enable', h($item['Taxonomy']['id'])), array('class' => 'icon-plus', 'title' => 'Enable'), ('Are you sure you want to enable this taxonomy library?'));
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ac1a76889ee956174fc1732d82d06be6500cb213
|
||||
Subproject commit 14dd5d2a4fef912772b7df473336bcf7dfd41ea1
|
Loading…
Reference in New Issue