Merge branch '2.4' of github.com:MISP/MISP into chrisr3d_patch

pull/3725/head
chrisr3d 2018-09-11 11:31:45 +02:00
commit b66ff52a16
5 changed files with 30 additions and 5 deletions

View File

@ -69,7 +69,8 @@ class AppModel extends Model
public $db_changes = array( public $db_changes = array(
1 => false, 2 => false, 3 => false, 4 => true, 5 => false, 6 => false, 1 => false, 2 => false, 3 => false, 4 => true, 5 => false, 6 => false,
7 => false, 8 => false, 9 => false, 10 => false, 11 => false, 12 => false, 7 => false, 8 => false, 9 => false, 10 => false, 11 => false, 12 => false,
13 => false, 14 => false, 15 => false, 18 => false, 19 => false, 20 => false 13 => false, 14 => false, 15 => false, 18 => false, 19 => false, 20 => false,
21 => false
); );
public function afterSave($created, $options = array()) public function afterSave($created, $options = array())
@ -1031,9 +1032,14 @@ class AppModel extends Model
case 19: case 19:
$sqlArray[] = 'ALTER TABLE `taxonomies` ADD COLUMN exclusive tinyint(1) DEFAULT 0;'; $sqlArray[] = 'ALTER TABLE `taxonomies` ADD COLUMN exclusive tinyint(1) DEFAULT 0;';
break; break;
case 20: case 20:
$sqlArray[] = "ALTER TABLE `servers` ADD `skip_proxy` tinyint(1) NOT NULL DEFAULT 0;"; $sqlArray[] = "ALTER TABLE `servers` ADD `skip_proxy` tinyint(1) NOT NULL DEFAULT 0;";
break; break;
case 21:
$sqlArray[] = 'ALTER TABLE `tags` ADD COLUMN numerical_value int(11) NULL;';
$sqlArray[] = 'ALTER TABLE `taxonomy_predicates` ADD COLUMN numerical_value int(11) NULL;';
$sqlArray[] = 'ALTER TABLE `taxonomy_entries` ADD COLUMN numerical_value int(11) NULL;';
break;
case 'fixNonEmptySharingGroupID': case 'fixNonEmptySharingGroupID':
$sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;'; $sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';
$sqlArray[] = 'UPDATE `attributes` SET `sharing_group_id` = 0 WHERE `distribution` != 4;'; $sqlArray[] = 'UPDATE `attributes` SET `sharing_group_id` = 0 WHERE `distribution` != 4;';

View File

@ -2453,6 +2453,9 @@ class Attribute extends AppModel
// array 1 will have all of the non negated terms and array 2 all the negated terms // array 1 will have all of the non negated terms and array 2 all the negated terms
public function dissectArgs($args) public function dissectArgs($args)
{ {
if (empty($args)) {
return array(0 => array(), 1 => array());
}
if (!is_array($args)) { if (!is_array($args)) {
$args = explode('&&', $args); $args = explode('&&', $args);
} }

View File

@ -215,6 +215,7 @@ class Module extends AppModel
); );
if ($moduleFamily == 'Cortex') { if ($moduleFamily == 'Cortex') {
if (!empty(Configure::read('Plugin.' . $moduleFamily . '_authkey'))) { if (!empty(Configure::read('Plugin.' . $moduleFamily . '_authkey'))) {
unset($request['header']['Content-Type']);
$request['header']['Authorization'] = 'Bearer ' . Configure::read('Plugin.' . $moduleFamily . '_authkey'); $request['header']['Authorization'] = 'Bearer ' . Configure::read('Plugin.' . $moduleFamily . '_authkey');
} }
} }

View File

@ -147,6 +147,9 @@ class Taxonomy extends AppModel
if (isset($entry['colour']) && !empty($entry['colour'])) { if (isset($entry['colour']) && !empty($entry['colour'])) {
$temp['colour'] = $entry['colour']; $temp['colour'] = $entry['colour'];
} }
if (isset($entry['numerical_value']) && $entry['numerical_value'] !== null) {
$temp['numerical_value'] = $entry['numerical_value'];
}
$entries[] = $temp; $entries[] = $temp;
} }
} else { } else {
@ -155,6 +158,9 @@ class Taxonomy extends AppModel
if (isset($predicate['colour']) && !empty($predicate['colour'])) { if (isset($predicate['colour']) && !empty($predicate['colour'])) {
$temp['colour'] = $predicate['colour']; $temp['colour'] = $predicate['colour'];
} }
if (isset($predicate['numerical_value']) && $predicate['numerical_value'] !== null) {
$temp['numerical_value'] = $predicate['numerical_value'];
}
$entries[] = $temp; $entries[] = $temp;
} }
} }
@ -267,13 +273,20 @@ class Taxonomy extends AppModel
foreach ($taxonomy['entries'] as $k => $entry) { foreach ($taxonomy['entries'] as $k => $entry) {
if (isset($tags[strtoupper($entry['tag'])])) { if (isset($tags[strtoupper($entry['tag'])])) {
$temp = $tags[strtoupper($entry['tag'])]; $temp = $tags[strtoupper($entry['tag'])];
if ((in_array('colour', $skipUpdateFields) && $temp['Tag']['colour'] != $colours[$k]) || (in_array('name', $skipUpdateFields) && $temp['Tag']['name'] !== $entry['tag'])) { if (
(!in_array('colour', $skipUpdateFields) && $temp['Tag']['colour'] != $colours[$k]) ||
(!in_array('name', $skipUpdateFields) && $temp['Tag']['name'] !== $entry['tag']) ||
(!in_array('numerical_value', $skipUpdateFields) && isset($entry['numerical_value']) && isset($temp['Tag']['numerical_value']) && $temp['Tag']['numerical_value'] !== $entry['numerical_value'])
) {
if (!in_array('colour', $skipUpdateFields)) { if (!in_array('colour', $skipUpdateFields)) {
$temp['Tag']['colour'] = (isset($entry['colour']) && !empty($entry['colour'])) ? $entry['colour'] : $colours[$k]; $temp['Tag']['colour'] = (isset($entry['colour']) && !empty($entry['colour'])) ? $entry['colour'] : $colours[$k];
} }
if (!in_array('name', $skipUpdateFields)) { if (!in_array('name', $skipUpdateFields)) {
$temp['Tag']['name'] = $entry['tag']; $temp['Tag']['name'] = $entry['tag'];
} }
if (!in_array('numerical_value', $skipUpdateFields)) {
$temp['Tag']['numerical_value'] = $entry['numerical_value'];
}
$this->Tag->save($temp['Tag']); $this->Tag->save($temp['Tag']);
} }
} }

View File

@ -72,6 +72,7 @@
<?php endif;?> <?php endif;?>
<th><?php echo $this->Paginator->sort('tag');?></th> <th><?php echo $this->Paginator->sort('tag');?></th>
<th><?php echo $this->Paginator->sort('expanded');?></th> <th><?php echo $this->Paginator->sort('expanded');?></th>
<th><?php echo $this->Paginator->sort('numerical_value');?></th>
<th><?php echo $this->Paginator->sort('events');?></th> <th><?php echo $this->Paginator->sort('events');?></th>
<th><?php echo $this->Paginator->sort('attributes');?></th> <th><?php echo $this->Paginator->sort('attributes');?></th>
<th><?php echo $this->Paginator->sort('tag');?></th> <th><?php echo $this->Paginator->sort('tag');?></th>
@ -86,6 +87,7 @@
<?php endif; ?> <?php endif; ?>
<td id="tag_<?php echo h($k); ?>" class="short"><?php echo h($item['tag']); ?></td> <td id="tag_<?php echo h($k); ?>" class="short"><?php echo h($item['tag']); ?></td>
<td><?php echo h($item['expanded']); ?>&nbsp;</td> <td><?php echo h($item['expanded']); ?>&nbsp;</td>
<td class="short"><?php echo isset($item['numerical_value']) ? h($item['numerical_value']) : ''; ?>&nbsp;</td>
<td class="short"> <td class="short">
<?php <?php
if ($item['existing_tag']) { if ($item['existing_tag']) {