mirror of https://github.com/MISP/MISP
Merge branch '2.4' of github.com:MISP/MISP into galaxy-cluster2.0
commit
1879bc05b7
|
@ -48,7 +48,7 @@ class AppController extends Controller
|
|||
|
||||
public $helpers = array('Utility', 'OrgImg', 'FontAwesome', 'UserName', 'DataPathCollector');
|
||||
|
||||
private $__queryVersion = '117';
|
||||
private $__queryVersion = '118';
|
||||
public $pyMispVersion = '2.4.134';
|
||||
public $phpmin = '7.2';
|
||||
public $phprec = '7.4';
|
||||
|
|
|
@ -190,7 +190,13 @@ class EventReportsController extends AppController
|
|||
if (empty($filters['event_id'])) {
|
||||
throw new MethodNotAllowedException("When requesting index for event, event ID must be provided.");
|
||||
}
|
||||
$this->set('canModify', $this->__canModifyReport($filters['event_id']));
|
||||
try {
|
||||
$this->__canModifyReport($filters['event_id']);
|
||||
$canModify = true;
|
||||
} catch (Exception $e) {
|
||||
$canModify = false;
|
||||
}
|
||||
$this->set('canModify', $canModify);
|
||||
$this->set('extendedEvent', !empty($filters['extended_event']));
|
||||
$fetcherModule = $this->EventReport->isFetchURLModuleEnabled();
|
||||
$this->set('importModuleEnabled', is_array($fetcherModule));
|
||||
|
@ -454,9 +460,15 @@ class EventReportsController extends AppController
|
|||
$this->set('canEdit', $canEdit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $eventId
|
||||
* @return array
|
||||
* @throws NotFoundException
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
private function __canModifyReport($eventId)
|
||||
{
|
||||
$event = $this->EventReport->Event->fetchSimpleEvent($this->Auth->user(), $eventId, array());
|
||||
$event = $this->EventReport->Event->fetchSimpleEvent($this->Auth->user(), $eventId);
|
||||
if (empty($event)) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
|
|
|
@ -1672,7 +1672,7 @@ class ServersController extends AppController
|
|||
throw new MethodNotAllowedException('You don\'t have permission to do that.');
|
||||
}
|
||||
|
||||
$server = $this->Server->find('first', ['Server.id' => $id]);
|
||||
$server = $this->Server->find('first', ['conditions' => ['Server.id' => $id]]);
|
||||
if (!$server) {
|
||||
throw new NotFoundException(__('Invalid server'));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,17 @@ class WarninglistsController extends AppController
|
|||
|
||||
public function index()
|
||||
{
|
||||
$filters = $this->IndexFilter->harvestParameters(['value']);
|
||||
$this->paginate['recursive'] = -1;
|
||||
if (!empty($filters['value'])) {
|
||||
$this->paginate['conditions'] = [
|
||||
'OR' => [
|
||||
'LOWER(Warninglist.name) LIKE' => '%' . strtolower($filters['value']) . '%',
|
||||
'LOWER(Warninglist.description) LIKE' => '%' . strtolower($filters['value']) . '%',
|
||||
'LOWER(Warninglist.type)' => strtolower($filters['value']),
|
||||
]
|
||||
];
|
||||
}
|
||||
$warninglists = $this->paginate();
|
||||
foreach ($warninglists as &$warninglist) {
|
||||
$warninglist['Warninglist']['valid_attributes'] = array();
|
||||
|
|
|
@ -110,6 +110,7 @@ class DistributionGraphTool
|
|||
'noShadowAttributes' => true,
|
||||
'noEventReports' => true,
|
||||
'noSightings' => true,
|
||||
'includeEventCorrelations' => false,
|
||||
'extended' => $this->__extended_view,
|
||||
));
|
||||
$event = array();
|
||||
|
|
|
@ -793,7 +793,7 @@ class MispObject extends AppModel
|
|||
if ($f == 'sharing_group_id' && empty($newAttribute[$f])) {
|
||||
$newAttribute[$f] = 0;
|
||||
}
|
||||
if (isset($newAttribute[$f]) && $newAttribute[$f] != $originalAttribute[$f]) {
|
||||
if (isset($newAttribute[$f]) && $this->attributeValueDifferent($originalAttribute[$f], $newAttribute[$f], $f)) {
|
||||
$different = true;
|
||||
}
|
||||
}
|
||||
|
@ -1486,4 +1486,13 @@ class MispObject extends AppModel
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function attributeValueDifferent($newValue, $originalValue, $field)
|
||||
{
|
||||
if (in_array($field, ['first_seen', 'last_seen'])) {
|
||||
return new DateTime($newValue) != new DateTime($originalValue);
|
||||
} else {
|
||||
return $newValue != $originalValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
</td>
|
||||
<td colspan="<?= $includeRelatedTags ? 6 : 5 ?>">
|
||||
<span class="bold"><?php echo __('Name: ');?></span><?php echo h($object['name']);?>
|
||||
<span class="bold"><?php echo __('Object name: ');?></span><?php echo h($object['name']);?>
|
||||
<span class="fa fa-expand useCursorPointer" title="<?php echo __('Expand or Collapse');?>" role="button" tabindex="0" aria-label="<?php echo __('Expand or Collapse');?>" data-toggle="collapse" data-target="#Object_<?php echo h($object['id']); ?>_collapsible"></span>
|
||||
<br />
|
||||
<div id="Object_<?php echo $object['id']; ?>_collapsible" class="collapse">
|
||||
|
|
|
@ -1,85 +1,143 @@
|
|||
<div class="taxonomies index">
|
||||
<h2><?php echo __('Warninglists');?></h2>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
$this->Paginator->options(array(
|
||||
'update' => '.span12',
|
||||
'evalScripts' => true,
|
||||
'before' => '$(".progress").show()',
|
||||
'complete' => '$(".progress").hide()',
|
||||
));
|
||||
|
||||
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
|
||||
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="hiddenFormDiv">
|
||||
<?php
|
||||
if ($isSiteAdmin) {
|
||||
echo $this->Form->create('Warninglist', array('url' => $baseurl . '/warninglists/toggleEnable'));
|
||||
echo $this->Form->input('data', array('label' => false, 'style' => 'display:none;'));
|
||||
echo $this->Form->end();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th><?php echo $this->Paginator->sort('id');?></th>
|
||||
<th><?php echo $this->Paginator->sort('name');?></th>
|
||||
<th><?php echo $this->Paginator->sort('version');?></th>
|
||||
<th><?php echo $this->Paginator->sort('description');?></th>
|
||||
<th><?php echo $this->Paginator->sort('type');?></th>
|
||||
<th><?php echo __('Valid attributes');?></th>
|
||||
<th><?php echo $this->Paginator->sort('warninglist_entry_count', __('Entries'));?></th>
|
||||
<th><?php echo $this->Paginator->sort('enabled');?></th>
|
||||
<th class="actions"><?php echo __('Actions');?></th>
|
||||
</tr><?php
|
||||
foreach ($warninglists as $k => $item): ?>
|
||||
<tr>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/warninglists/view/".h($item['Warninglist']['id']);?>'"><?php echo h($item['Warninglist']['id']); ?> </td>
|
||||
<td ondblclick="document.location.href ='<?php echo $baseurl."/warninglists/view/".h($item['Warninglist']['id']);?>'"><?php echo h($item['Warninglist']['name']); ?> </td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/warninglists/view/".h($item['Warninglist']['id']);?>'"><?php echo h($item['Warninglist']['version']); ?> </td>
|
||||
<td ondblclick="document.location.href ='<?php echo $baseurl."/warninglists/view/".h($item['Warninglist']['id']);?>'"><?php echo h($item['Warninglist']['description']); ?> </td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/warninglists/view/".h($item['Warninglist']['id']);?>'"><?php echo h($item['Warninglist']['type']); ?> </td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/warninglists/view/".h($item['Warninglist']['id']);?>'"><?php echo h($item['Warninglist']['valid_attributes']); ?> </td>
|
||||
<td class="short" ondblclick="document.location.href ='<?php echo $baseurl."/warninglists/view/".h($item['Warninglist']['id']);?>'"><?php echo h($item['Warninglist']['warninglist_entry_count']); ?> </td>
|
||||
<td class="short" id ="checkbox_row_<?php echo h($item['Warninglist']['id']);?>">
|
||||
<?php
|
||||
if ($isSiteAdmin) {
|
||||
$onClick = 'onClick="toggleSetting(event, \'warninglist_enable\', \'' . h($item['Warninglist']['id']) . '\')"';
|
||||
} else {
|
||||
$onClick = 'disabled';
|
||||
}
|
||||
?>
|
||||
<input id="checkBox_<?php echo h($item['Warninglist']['id']); ?>" type="checkbox" <?php echo $onClick; ?> <?php echo $item['Warninglist']['enabled'] ? 'checked' : ''; ?>/>
|
||||
</td>
|
||||
<td class="short action-links">
|
||||
<a href='<?php echo $baseurl."/warninglists/view/". h($item['Warninglist']['id']);?>' class = "fa fa-eye" title = "<?php echo __('View');?>" aria-label = "<?php echo __('View');?>"></a>
|
||||
<span class="fa fa-trash useCursorPointer" title="<?php echo __('Delete Warninglist');?>" role="button" tabindex="0" aria-label="<?php echo __('Delete warninglist');?>" onClick="deleteObject('warninglists', 'delete', '<?php echo h($item['Warninglist']['id']); ?>', '<?php echo h($item['Warninglist']['id']); ?>');"></span>
|
||||
</td>
|
||||
</tr><?php
|
||||
endforeach; ?>
|
||||
</table>
|
||||
<p>
|
||||
<?php
|
||||
echo $this->Paginator->counter(array(
|
||||
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
|
||||
));
|
||||
?>
|
||||
</p>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
|
||||
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
echo '<div class="index">';
|
||||
if ($isSiteAdmin) {
|
||||
echo '<div id="hiddenFormDiv">';
|
||||
echo $this->Form->create('Warninglist', array('url' => $baseurl . '/warninglists/toggleEnable'));
|
||||
echo $this->Form->input('data', array('label' => false, 'style' => 'display:none;'));
|
||||
echo $this->Form->end();
|
||||
echo '</div>';
|
||||
}
|
||||
echo $this->element('/genericElements/IndexTable/index_table', array(
|
||||
'data' => array(
|
||||
'data' => $warninglists,
|
||||
'top_bar' => array(
|
||||
'children' => array(
|
||||
array(
|
||||
'type' => 'search',
|
||||
'button' => __('Filter'),
|
||||
'placeholder' => __('Enter value to search'),
|
||||
'data' => '',
|
||||
'searchKey' => 'value'
|
||||
)
|
||||
)
|
||||
),
|
||||
'title' => __('Warninglists'),
|
||||
'primary_id_path' => 'Warninglist.id',
|
||||
'fields' => array(
|
||||
array(
|
||||
'name' => __('ID'),
|
||||
'sort' => 'id',
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.id',
|
||||
'element' => 'links',
|
||||
'url' => $baseurl . '/Warninglist/view/%s'
|
||||
),
|
||||
array(
|
||||
'name' => __('Name'),
|
||||
'sort' => 'name',
|
||||
'data_path' => 'Warninglist.name',
|
||||
),
|
||||
array(
|
||||
'name' => __('Version'),
|
||||
'sort' => 'version',
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.version',
|
||||
),
|
||||
array(
|
||||
'name' => __('Description'),
|
||||
'data_path' => 'Warninglist.description',
|
||||
),
|
||||
array(
|
||||
'name' => __('Type'),
|
||||
'sort' => 'type',
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.type',
|
||||
),
|
||||
array(
|
||||
'name' => __('Valid attributes'),
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.valid_attributes',
|
||||
),
|
||||
array(
|
||||
'name' => __('Entries'),
|
||||
'sort' => 'warninglist_entry_count',
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.warninglist_entry_count',
|
||||
),
|
||||
array(
|
||||
'name' => __('Enabled'),
|
||||
'class' => 'short',
|
||||
'element' => 'boolean',
|
||||
'data_path' => 'Warninglist.enabled',
|
||||
),
|
||||
),
|
||||
'actions' => array(
|
||||
array(
|
||||
'title' => __('Enable'),
|
||||
'icon' => 'play',
|
||||
'onclick' => sprintf('toggleSetting(%s, \'%s\', \'%s\')', 'event', 'warninglist_enable', '[onclick_params_data_path]'),
|
||||
'onclick_params_data_path' => 'Warninglist.id',
|
||||
'complex_requirement' => array(
|
||||
'function' => function ($row, $options) {
|
||||
return $options['me']['Role']['perm_site_admin'] && !$options['datapath']['enabled'];
|
||||
},
|
||||
'options' => array(
|
||||
'me' => $me,
|
||||
'datapath' => array(
|
||||
'orgc' => 'Event.orgc_id',
|
||||
'enabled' => 'Warninglist.enabled'
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => __('Disabled'),
|
||||
'icon' => 'stop',
|
||||
'onclick' => sprintf('toggleSetting(%s, \'%s\', \'%s\')', 'event', 'warninglist_enable', '[onclick_params_data_path]'),
|
||||
'onclick_params_data_path' => 'Warninglist.id',
|
||||
'complex_requirement' => array(
|
||||
'function' => function ($row, $options) {
|
||||
return $options['me']['Role']['perm_site_admin'] && $options['datapath']['enabled'];
|
||||
},
|
||||
'options' => array(
|
||||
'me' => $me,
|
||||
'datapath' => array(
|
||||
'enabled' => 'Warninglist.enabled'
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'url' => $baseurl . '/warninglists/view',
|
||||
'url_params_data_paths' => array(
|
||||
'Warninglist.id'
|
||||
),
|
||||
'icon' => 'eye',
|
||||
'dbclickAction' => true
|
||||
),
|
||||
array(
|
||||
'title' => __('Delete'),
|
||||
'icon' => 'trash',
|
||||
'onclick' => 'simplePopup(\'' . $baseurl . '/warninglists/delete/[onclick_params_data_path]\');',
|
||||
'onclick_params_data_path' => 'Warninglist.id',
|
||||
'requirement' => $me['Role']['perm_site_admin'],
|
||||
),
|
||||
)
|
||||
)
|
||||
));
|
||||
echo '</div>';
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'warninglist', 'menuItem' => 'index'));
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#quickFilterButton').click(function() {
|
||||
runIndexQuickFilter();
|
||||
});
|
||||
$('#quickFilterField').on('keypress', function (e) {
|
||||
if(e.which === 13) {
|
||||
runIndexQuickFilter();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8d60a4f5052c4e303ac3f7f90b3ee14f655f88fd
|
||||
Subproject commit aa499f4059bd1c14205176a3434550e7fba75a8a
|
|
@ -230,6 +230,16 @@ function toggleSetting(e, setting, id) {
|
|||
dataDiv = '#WarninglistData';
|
||||
replacementForm = baseurl + '/warninglists/getToggleField/';
|
||||
searchString = 'enabled';
|
||||
var successCallback = function(setting) {
|
||||
var icon = $(e.target).closest('tr').find('[data-path="Warninglist.enabled"] .fa')
|
||||
if (setting) {
|
||||
icon.removeClass('fa-times').addClass('fa-check')
|
||||
$(e.target).removeClass('fa-play').addClass('fa-stop')
|
||||
} else {
|
||||
icon.removeClass('fa-check').addClass('fa-times')
|
||||
$(e.target).removeClass('fa-stop').addClass('fa-play')
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'favourite_tag':
|
||||
formID = '#FavouriteTagIndexForm';
|
||||
|
@ -262,7 +272,11 @@ function toggleSetting(e, setting, id) {
|
|||
if (result.success) {
|
||||
var setting = false;
|
||||
if (result.success.indexOf(searchString) > -1) setting = true;
|
||||
$('#' + e.target.id).prop('checked', setting);
|
||||
if (typeof successCallback === 'function') {
|
||||
successCallback(setting)
|
||||
} else {
|
||||
$('#' + e.target.id).prop('checked', setting);
|
||||
}
|
||||
}
|
||||
handleGenericAjaxResponse(data);
|
||||
},
|
||||
|
|
|
@ -145,16 +145,18 @@ function removeRestClientHistoryItem(id) {
|
|||
$('#TemplateSelect').val($(this).val()).trigger("chosen:updated").trigger("change");
|
||||
});
|
||||
|
||||
$('#TemplateSelect').change(function() {
|
||||
$('#TemplateSelect').change(function(e) {
|
||||
var selected_template = $('#TemplateSelect').val();
|
||||
var previously_selected_template = $('#ServerUrl').data('urlWithoutParam')
|
||||
if (selected_template !== '' && allValidApis[selected_template] !== undefined) {
|
||||
$('#template_description').show();
|
||||
$('#ServerMethod').val('POST');
|
||||
var server_url_changed = $('#ServerUrl').val() != allValidApis[selected_template].url;
|
||||
$('#ServerUrl').val(allValidApis[selected_template].url);
|
||||
$('#ServerUrl').data('urlWithoutParam', selected_template);
|
||||
var body_value = $('#ServerBody').val();
|
||||
var refreshBody = (body_value === '' || server_url_changed)
|
||||
var body_value = cm.getValue();
|
||||
var body_changed = allValidApis[previously_selected_template] !== undefined ? allValidApis[previously_selected_template].body != body_value : true;
|
||||
var refreshBody = (body_value === '' || (server_url_changed && !body_changed))
|
||||
if (refreshBody) {
|
||||
$('#ServerBody').val(allValidApis[selected_template].body);
|
||||
cm.setValue(allValidApis[selected_template].body)
|
||||
|
@ -231,7 +233,11 @@ function updateQueryTool(url, isEmpty) {
|
|||
isEmpty = isEmpty === undefined ? false : isEmpty;
|
||||
var body = cm.getValue();
|
||||
if (!isEmpty && body !== undefined && body.length > 0) {
|
||||
body = JSON.parse(body);
|
||||
try {
|
||||
body = JSON.parse(body);
|
||||
} catch(e) {
|
||||
body = {};
|
||||
}
|
||||
} else {
|
||||
body = {};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue