fix: several fixes to the feed overlay matrix

- lookup was broken for csv/freetext feeds
- allow users to see the feeds if the admin allows it
pull/2211/head
iglocska 2017-05-09 16:35:59 +02:00
parent f0136d5774
commit e18344b3f5
8 changed files with 54 additions and 43 deletions

View File

@ -159,6 +159,9 @@ class FeedsController extends AppController {
if (empty($this->request->data['Feed']['target_event'])) {
$this->request->data['Feed']['target_event'] = 0;
}
if (empty($this->request->data['Feed']['lookup_visible'])) {
$this->request->data['Feed']['lookup_visible'] = 0;
}
if (empty($this->request->data['Feed']['input_source'])) {
$this->request->data['Feed']['input_source'] = 'network';
}
@ -227,7 +230,7 @@ class FeedsController extends AppController {
$this->request->data['Feed']['settings']['delimiter'] = ',';
}
$this->request->data['Feed']['settings'] = json_encode($this->request->data['Feed']['settings']);
$fields = array('id', 'name', 'provider', 'enabled', 'rules', 'url', 'distribution', 'sharing_group_id', 'tag_id', 'fixed_event', 'event_id', 'publish', 'delta_merge', 'source_format', 'override_ids', 'settings', 'input_source', 'delete_local_file');
$fields = array('id', 'name', 'provider', 'enabled', 'rules', 'url', 'distribution', 'sharing_group_id', 'tag_id', 'fixed_event', 'event_id', 'publish', 'delta_merge', 'source_format', 'override_ids', 'settings', 'input_source', 'delete_local_file', 'lookup_visible');
$feed = array();
foreach ($fields as $field) {
if (isset($this->request->data['Feed'][$field])) {

View File

@ -42,7 +42,7 @@ class AppModel extends Model {
51 => false, 52 => false, 55 => true, 56 => true, 57 => true,
58 => false, 59 => false, 60 => false, 61 => false, 62 => false,
63 => false, 64 => false, 65 => false, 66 => false, 67 => true,
68 => false, 69 => false, 71 => false
68 => false, 69 => false, 71 => false, 72 => false
)
)
);
@ -681,6 +681,9 @@ class AppModel extends Model {
$sqlArray[] = "UPDATE attributes SET comment = '' WHERE comment is NULL;";
$sqlArray[] = "ALTER TABLE attributes CHANGE comment comment text COLLATE utf8_bin NOT NULL;";
break;
case '2.4.72':
$sqlArray[] = 'ALTER TABLE feeds ADD lookup_visible tinyint(1) DEFAULT 0;';
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;';

View File

@ -1460,9 +1460,9 @@ class Event extends AppModel {
$this->Warninglist = ClassRegistry::init('Warninglist');
$warninglists = $this->Warninglist->fetchForEventView();
}
if ($isSiteAdmin && isset($options['includeFeedCorrelations']) && $options['includeFeedCorrelations']) {
if (isset($options['includeFeedCorrelations']) && $options['includeFeedCorrelations']) {
$this->Feed = ClassRegistry::init('Feed');
$event['Attribute'] = $this->Feed->attachFeedCorrelations($event['Attribute']);
$event['Attribute'] = $this->Feed->attachFeedCorrelations($event['Attribute'], $user);
}
foreach ($event['Attribute'] as $key => $attribute) {
if ($options['enforceWarninglist'] && !$this->Warninglist->filterWarninglistAttributes($warninglists, $attribute, $this->Warninglist)) {
@ -1498,7 +1498,7 @@ class Event extends AppModel {
if (isset($event['ShadowAttribute'])) {
if ($isSiteAdmin && isset($options['includeFeedCorrelations']) && $options['includeFeedCorrelations']) {
$this->Feed = ClassRegistry::init('Feed');
$event['ShadowAttribute'] = $this->Feed->attachFeedCorrelations($event['ShadowAttribute']);
$event['ShadowAttribute'] = $this->Feed->attachFeedCorrelations($event['ShadowAttribute'], $user);
}
foreach ($event['ShadowAttribute'] as $k => $sa) {
if (!empty($sa['old_id'])) {

View File

@ -173,6 +173,9 @@ class Feed extends AppModel {
$this->Warninglist = ClassRegistry::init('Warninglist');
$complexTypeTool->setTLDs($this->Warninglist->fetchTLDLists());
$settings = array();
if (!empty($feed['Feed']['settings']) && !is_array($feed['Feed']['settings'])) {
$feed['Feed']['settings'] = json_decode($feed['Feed']['settings'], true);
}
if (isset($feed['Feed']['settings'][$type])) {
$settings = $feed['Feed']['settings'][$type];
}
@ -238,13 +241,17 @@ class Feed extends AppModel {
return $data;
}
public function attachFeedCorrelations($objects) {
public function attachFeedCorrelations($objects, $user) {
$redis = $this->setupRedis();
if ($redis !== false) {
$feeds = $this->find('all', array(
$params = array(
'recursive' => -1,
'fields' => array('id', 'name', 'url', 'provider', 'source_format')
));
);
if (!$user['Role']['perm_site_admin']) {
$params['conditions'] = array('Feed.lookup_visible' => 1);
}
$feeds = $this->find('all', $params);
foreach ($objects as $k => $object) {
foreach ($feeds as $k2 => $feed) {
if ($redis->sismember('misp:feed_cache:' . $feed['Feed']['id'], md5($object['value']))) {
@ -735,7 +742,7 @@ class Feed extends AppModel {
$params = array(
'conditions' => array('enabled' => 1),
'recursive' => -1,
'fields' => array('source_format', 'input_source', 'url', 'id')
'fields' => array('source_format', 'input_source', 'url', 'id', 'settings')
);
if ($scope !== 'all') {
if (is_numeric($scope)) {

View File

@ -152,13 +152,7 @@
endif;
?>
<th>Related Events</th>
<?php
if ($isSiteAdmin):
?>
<th>Feed hits</th>
<?php
endif;
?>
<th>Feed hits</th>
<th title="<?php echo $attrDescriptions['signature']['desc'];?>"><?php echo $this->Paginator->sort('to_ids', 'IDS');?></th>
<th title="<?php echo $attrDescriptions['distribution']['desc'];?>"><?php echo $this->Paginator->sort('distribution');?></th>
<?php if (Configure::read('Plugin.Sightings_enable') !== false): ?>
@ -410,34 +404,28 @@
?>
</ul>
</td>
<?php
if ($isSiteAdmin):
?>
<td class="shortish <?php echo $extra; ?>">
<ul class="inline" style="margin:0px;">
<?php
if (!empty($object['Feed'])):
foreach ($object['Feed'] as $feed):
$popover = '';
foreach ($feed as $k => $v):
if ($k == 'id') continue;
$popover .= '<span class=\'bold black\'>' . Inflector::humanize(h($k)) . '</span>: <span class="blue">' . h($v) . '</span><br />';
endforeach;
?>
<li style="padding-right: 0px; padding-left:0px;" data-toggle="popover" data-content="<?php echo h($popover);?>" data-trigger="hover"><span>
<?php
echo $this->Html->link($feed['id'], array('controller' => 'feeds', 'action' => 'previewIndex', $feed['id']));
endforeach;
?>
</li>
<?php
endif;
<td class="shortish <?php echo $extra; ?>">
<ul class="inline" style="margin:0px;">
<?php
if (!empty($object['Feed'])):
foreach ($object['Feed'] as $feed):
$popover = '';
foreach ($feed as $k => $v):
if ($k == 'id') continue;
$popover .= '<span class=\'bold black\'>' . Inflector::humanize(h($k)) . '</span>: <span class="blue">' . h($v) . '</span><br />';
endforeach;
?>
</ul>
</td>
<?php
endif;
?>
<li style="padding-right: 0px; padding-left:0px;" data-toggle="popover" data-content="<?php echo h($popover);?>" data-trigger="hover"><span>
<?php
echo $this->Html->link($feed['id'], array('controller' => 'feeds', 'action' => 'previewIndex', $feed['id']), array('style' => 'margin-right:3px;'));
endforeach;
?>
</li>
<?php
endif;
?>
</ul>
</td>
<td class="short <?php echo $extra; ?>">
<div id = "<?php echo $currentType . '_' . $object['id'] . '_to_ids_placeholder'; ?>" class = "inline-field-placeholder"></div>
<div id = "<?php echo $currentType . '_' . $object['id'] . '_to_ids_solid'; ?>" class="inline-field-solid" ondblclick="activateField('<?php echo $currentType; ?>', '<?php echo $object['id']; ?>', 'to_ids', <?php echo $event['Event']['id'];?>);">

View File

@ -5,6 +5,10 @@
<p>Add a new MISP feed source.</p>
<?php
echo $this->Form->input('enabled', array());
?>
<div class="input clear"></div>
<?php
echo $this->Form->input('lookup_visible', array());
echo $this->Form->input('name', array(
'div' => 'input clear',
'placeholder' => 'Feed name',

View File

@ -5,6 +5,10 @@
<p>Edit a new MISP feed source.</p>
<?php
echo $this->Form->input('enabled', array());
?>
<div class="input clear"></div>
<?php
echo $this->Form->input('lookup_visible', array());
echo $this->Form->input('name', array(
'div' => 'input clear',
'placeholder' => 'Feed name',

View File

@ -43,6 +43,7 @@
<th><?php echo $this->Paginator->sort('distribution');?></th>
<th><?php echo $this->Paginator->sort('tag');?></th>
<th><?php echo $this->Paginator->sort('enabled');?></th>
<th><?php echo $this->Paginator->sort('lookup_visible');?></th>
<th class="actions"><?php echo __('Caching');?></th>
<th class="actions"><?php echo __('Actions');?></th>
</tr><?php
@ -135,6 +136,7 @@ foreach ($feeds as $item):
<?php endif;?>
</td>
<td class="short"><span class="<?php echo ($item['Feed']['enabled'] ? 'icon-ok' : 'icon-remove'); ?>"></span><span class="short <?php if (!$item['Feed']['enabled'] || empty($ruleDescription)) echo "hidden"; ?>" data-toggle="popover" title="Filter rules" data-content="<?php echo $ruleDescription; ?>"> (Rules)</span>
<td class="short"><span class="<?php echo ($item['Feed']['lookup_visible'] ? 'icon-ok' : 'icon-remove'); ?>"></span>
<td class="short action-links <?php echo $item['Feed']['cache_timestamp'] ? 'bold' : 'bold red';?>">
<?php
if ($item['Feed']['cache_timestamp']):