Merge pull request #8599 from JakubOnderka/ui-event-index

chg: [UI] Change Published to icon in event index
pull/8607/head
Jakub Onderka 2022-09-21 15:31:01 +02:00 committed by GitHub
commit cd232af4ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 49 deletions

View File

@ -999,13 +999,15 @@ class EventsController extends AppController
} }
$possibleColumns[] = 'attribute_count'; $possibleColumns[] = 'attribute_count';
$possibleColumns[] = 'timestamp';
$possibleColumns[] = 'publish_timestamp';
if (Configure::read('MISP.showCorrelationsOnIndex')) { if (Configure::read('MISP.showCorrelationsOnIndex')) {
$possibleColumns[] = 'correlations'; $possibleColumns[] = 'correlations';
} }
if (Configure::read('MISP.showEventReportCountOnIndex')) {
$possibleColumns[] = 'report_count';
}
if (Configure::read('MISP.showSightingsCountOnIndex')) { if (Configure::read('MISP.showSightingsCountOnIndex')) {
$possibleColumns[] = 'sightings'; $possibleColumns[] = 'sightings';
} }
@ -1014,10 +1016,6 @@ class EventsController extends AppController
$possibleColumns[] = 'proposals'; $possibleColumns[] = 'proposals';
} }
if (Configure::read('MISP.showEventReportCountOnIndex')) {
$possibleColumns[] = 'report_count';
}
if (Configure::read('MISP.showDiscussionsCountOnIndex')) { if (Configure::read('MISP.showDiscussionsCountOnIndex')) {
$possibleColumns[] = 'discussion'; $possibleColumns[] = 'discussion';
} }
@ -1026,6 +1024,9 @@ class EventsController extends AppController
$possibleColumns[] = 'creator_user'; $possibleColumns[] = 'creator_user';
} }
$possibleColumns[] = 'timestamp';
$possibleColumns[] = 'publish_timestamp';
$userDisabledColumns = $this->User->UserSetting->getValueForUser($this->Auth->user()['id'], 'event_index_hide_columns'); $userDisabledColumns = $this->User->UserSetting->getValueForUser($this->Auth->user()['id'], 'event_index_hide_columns');
if ($userDisabledColumns === null) { if ($userDisabledColumns === null) {
$userDisabledColumns = self::DEFAULT_HIDDEN_INDEX_COLUMNS; $userDisabledColumns = self::DEFAULT_HIDDEN_INDEX_COLUMNS;

View File

@ -17,9 +17,6 @@ class Correlation extends AppModel
const CACHE_NAME = 'misp:top_correlations', const CACHE_NAME = 'misp:top_correlations',
CACHE_AGE = 'misp:top_correlations_age'; CACHE_AGE = 'misp:top_correlations_age';
/** @var array */
private $__compositeTypes;
public $belongsTo = array( public $belongsTo = array(
'Attribute' => [ 'Attribute' => [
'className' => 'Attribute', 'className' => 'Attribute',
@ -864,16 +861,19 @@ class Correlation extends AppModel
*/ */
public function attachCorrelationExclusion(array $attributes) public function attachCorrelationExclusion(array $attributes)
{ {
if (!isset($this->__compositeTypes)) { $compositeTypes = $this->Attribute->getCompositeTypes();
$this->__compositeTypes = $this->Attribute->getCompositeTypes();
}
$valuesToCheck = []; $valuesToCheck = [];
foreach ($attributes as &$attribute) { foreach ($attributes as &$attribute) {
if (in_array($attribute['type'], $this->__compositeTypes, true)) { if ($attribute['disable_correlation'] || in_array($attribute['type'],Attribute::NON_CORRELATING_TYPES, true)) {
continue;
}
$primaryOnly = in_array($attribute['type'], Attribute::PRIMARY_ONLY_CORRELATING_TYPES, true);
if (in_array($attribute['type'], $compositeTypes, true)) {
$values = explode('|', $attribute['value']); $values = explode('|', $attribute['value']);
$valuesToCheck[$values[0]] = true; $valuesToCheck[$values[0]] = true;
$valuesToCheck[$values[1]] = true; if (!$primaryOnly) {
$valuesToCheck[$values[1]] = true;
}
} else { } else {
$values = [$attribute['value']]; $values = [$attribute['value']];
$valuesToCheck[$values[0]] = true; $valuesToCheck[$values[0]] = true;
@ -881,7 +881,7 @@ class Correlation extends AppModel
if ($this->__preventExcludedCorrelations($values[0])) { if ($this->__preventExcludedCorrelations($values[0])) {
$attribute['correlation_exclusion'] = true; $attribute['correlation_exclusion'] = true;
} elseif (!empty($values[1]) && $this->__preventExcludedCorrelations($values[1])) { } elseif (!empty($values[1]) && !$primaryOnly && $this->__preventExcludedCorrelations($values[1])) {
$attribute['correlation_exclusion'] = true; $attribute['correlation_exclusion'] = true;
} }
} }
@ -890,16 +890,20 @@ class Correlation extends AppModel
unset($valuesToCheck); unset($valuesToCheck);
foreach ($attributes as &$attribute) { foreach ($attributes as &$attribute) {
if (in_array($attribute['type'], $this->__compositeTypes, true)) { if ($attribute['disable_correlation'] || in_array($attribute['type'],Attribute::NON_CORRELATING_TYPES, true)) {
$values = explode('|', $attribute['value']); continue;
} else { }
$values = [$attribute['value']]; $primaryOnly = in_array($attribute['type'], Attribute::PRIMARY_ONLY_CORRELATING_TYPES, true);
if (in_array($attribute['type'], $compositeTypes, true)) {
$values = explode('|', $attribute['value']);
$values = OverCorrelatingValue::truncateValues($values);
} else {
$values = [OverCorrelatingValue::truncate($attribute['value'])];
} }
$values = $this->OverCorrelatingValue->truncateValues($values);
if (isset($overCorrelatingValues[$values[0]])) { if (isset($overCorrelatingValues[$values[0]])) {
$attribute['over_correlation'] = true; $attribute['over_correlation'] = true;
} elseif (!empty($values[1]) && isset($overCorrelatingValues[$values[1]])) { } elseif (!empty($values[1]) && !$primaryOnly && isset($overCorrelatingValues[$values[1]])) {
$attribute['over_correlation'] = true; $attribute['over_correlation'] = true;
} }
} }

View File

@ -7,9 +7,7 @@
<?php else: ?> <?php else: ?>
<th style="padding-left:0;padding-right:0;">&nbsp;</th> <th style="padding-left:0;padding-right:0;">&nbsp;</th>
<?php endif;?> <?php endif;?>
<th class="filter"> <th class="filter" title="<?= __('Published') ?>"><?= $this->Paginator->sort('published', '<i class="fa fa-upload"></i>', ['escape' => false]) ?></th>
<?php echo $this->Paginator->sort('published');?>
</th>
<?php <?php
if (Configure::read('MISP.showorgalternate') && Configure::read('MISP.showorg')): if (Configure::read('MISP.showorgalternate') && Configure::read('MISP.showorg')):
?> ?>
@ -37,7 +35,7 @@
<?php if (in_array('creator_user', $columns, true)): ?><th><?= $this->Paginator->sort('user_id', __('Creator user')) ?></th><?php endif; ?> <?php if (in_array('creator_user', $columns, true)): ?><th><?= $this->Paginator->sort('user_id', __('Creator user')) ?></th><?php endif; ?>
<th class="filter"><?= $this->Paginator->sort('date', null, array('direction' => 'desc'));?></th> <th class="filter"><?= $this->Paginator->sort('date', null, array('direction' => 'desc'));?></th>
<?php if (in_array('timestamp', $columns, true)): ?><th title="<?= __('Last modified at') ?>"><?= $this->Paginator->sort('timestamp', __('Last modified at')) ?></th><?php endif; ?> <?php if (in_array('timestamp', $columns, true)): ?><th title="<?= __('Last modified at') ?>"><?= $this->Paginator->sort('timestamp', __('Last modified at')) ?></th><?php endif; ?>
<?php if (in_array('publish_timestamp', $columns, true)): ?><th title="<?= __('Last modified at') ?>"><?= $this->Paginator->sort('publish_timestamp', __('Published at')) ?></th><?php endif; ?> <?php if (in_array('publish_timestamp', $columns, true)): ?><th title="<?= __('Published at') ?>"><?= $this->Paginator->sort('publish_timestamp', __('Published at')) ?></th><?php endif; ?>
<th class="filter"><?= $this->Paginator->sort('info');?></th> <th class="filter"><?= $this->Paginator->sort('info');?></th>
<th title="<?= $eventDescriptions['distribution']['desc'];?>"><?= $this->Paginator->sort('distribution');?></th> <th title="<?= $eventDescriptions['distribution']['desc'];?>"><?= $this->Paginator->sort('distribution');?></th>
<th class="actions"><?php echo __('Actions');?></th> <th class="actions"><?php echo __('Actions');?></th>
@ -45,13 +43,13 @@
<?php foreach ($events as $event): $eventId = (int)$event['Event']['id']; ?> <?php foreach ($events as $event): $eventId = (int)$event['Event']['id']; ?>
<tr id="event_<?= $eventId ?>"> <tr id="event_<?= $eventId ?>">
<?php if ($isSiteAdmin || ($event['Event']['orgc_id'] == $me['org_id'])):?> <?php if ($isSiteAdmin || ($event['Event']['orgc_id'] == $me['org_id'])):?>
<td style="width:10px;"> <td style="width:10px">
<input class="select" type="checkbox" data-id="<?= $eventId ?>" data-uuid="<?= h($event['Event']['uuid']) ?>"> <input class="select" type="checkbox" data-id="<?= $eventId ?>" data-uuid="<?= h($event['Event']['uuid']) ?>">
</td> </td>
<?php else: ?> <?php else: ?>
<td style="padding-left:0;padding-right:0;"></td> <td style="padding-left:0;padding-right:0;"></td>
<?php endif; ?> <?php endif; ?>
<td class="short dblclickElement"> <td class="dblclickElement" style="width:30px">
<a href="<?= "$baseurl/events/view/$eventId" ?>" title="<?= __('View') ?>" aria-label="<?= __('View') ?>"> <a href="<?= "$baseurl/events/view/$eventId" ?>" title="<?= __('View') ?>" aria-label="<?= __('View') ?>">
<i class="fa <?= $event['Event']['published'] ? 'fa-check green' : 'fa-times grey' ?>"></i> <i class="fa <?= $event['Event']['published'] ? 'fa-check green' : 'fa-times grey' ?>"></i>
</a> </a>
@ -98,53 +96,53 @@
<?php if (in_array('tags', $columns, true)): ?> <?php if (in_array('tags', $columns, true)): ?>
<td class="shortish"> <td class="shortish">
<?= $this->element('ajaxTags', [ <?= $this->element('ajaxTags', [
'event' => $event, 'event' => $event,
'tags' => $event['EventTag'], 'tags' => $event['EventTag'],
'tagAccess' => false, 'tagAccess' => false,
'localTagAccess' => false, 'localTagAccess' => false,
'missingTaxonomies' => false, 'missingTaxonomies' => false,
'columnised' => true, 'columnised' => true,
'static_tags_only' => 1, 'static_tags_only' => 1,
'tag_display_style' => Configure::check('MISP.full_tags_on_event_index') ? Configure::read('MISP.full_tags_on_event_index') : 1 'tag_display_style' => Configure::check('MISP.full_tags_on_event_index') ? Configure::read('MISP.full_tags_on_event_index') : 1,
]); ]);
?> ?>
</td> </td>
<?php endif; ?> <?php endif; ?>
<?php if (in_array('attribute_count', $columns, true)): ?> <?php if (in_array('attribute_count', $columns, true)): ?>
<td class="dblclickElement" style="width:30px;"> <td class="dblclickElement" style="width:30px">
<?= $event['Event']['attribute_count']; ?> <?= $event['Event']['attribute_count']; ?>
</td> </td>
<?php endif; ?> <?php endif; ?>
<?php if (in_array('correlations', $columns, true)): ?> <?php if (in_array('correlations', $columns, true)): ?>
<td class="bold" style="width:30px;"> <td class="bold" style="width:30px">
<?php if (!empty($event['Event']['correlation_count'])): ?> <?php if (!empty($event['Event']['correlation_count'])): ?>
<a href="<?php echo $baseurl."/events/view/" . $eventId . '/correlation:1';?>" title="<?= __n('%s correlation', '%s correlations', $event['Event']['correlation_count'], $event['Event']['correlation_count']), '. ' . __('Show filtered event with correlation only.');?>"> <a href="<?= "$baseurl/events/view/$eventId/correlation:1" ?>" title="<?= __n('%s correlation', '%s correlations', $event['Event']['correlation_count'], $event['Event']['correlation_count']), '. ' . __('Show filtered event with correlation only.');?>">
<?php echo h($event['Event']['correlation_count']); ?> <?= intval($event['Event']['correlation_count']); ?>
</a> </a>
<?php endif; ?> <?php endif; ?>
</td> </td>
<?php endif; ?> <?php endif; ?>
<?php if (in_array('report_count', $columns, true)): ?> <?php if (in_array('report_count', $columns, true)): ?>
<td class="bold" style="width:30px;"> <td class="bold" style="width:30px">
<?= $event['Event']['report_count']; ?> <?= $event['Event']['report_count']; ?>
</td> </td>
<?php endif; ?> <?php endif; ?>
<?php if (in_array('sightings', $columns, true)): ?> <?php if (in_array('sightings', $columns, true)): ?>
<td class="bold" style="width:30px;"> <td class="bold" style="width:30px">
<?php if (!empty($event['Event']['sightings_count'])): ?> <?php if (!empty($event['Event']['sightings_count'])): ?>
<a href="<?php echo $baseurl."/events/view/" . $eventId . '/sighting:1';?>" title="<?php echo (!empty($event['Event']['sightings_count']) ? h($event['Event']['sightings_count']) : '0') . ' sighting(s). Show filtered event with sighting(s) only.';?>"> <a href="<?= "$baseurl/events/view/$eventId/sighting:1" ?>" title="<?= __n("1 sighting. Show filtered event with sighting only.", "%s sightings. Show filtered event with sightings only.", $event['Event']['sightings_count'], intval($event['Event']['sightings_count'])) ?>">
<?= intval($event['Event']['sightings_count']) ?> <?= intval($event['Event']['sightings_count']) ?>
</a> </a>
<?php endif; ?> <?php endif; ?>
</td> </td>
<?php endif; ?> <?php endif; ?>
<?php if (in_array('proposals', $columns, true)): ?> <?php if (in_array('proposals', $columns, true)): ?>
<td class="bold dblclickElement" style="width:30px;" title="<?= __n('%s proposal', '%s proposals', $event['Event']['proposals_count'], $event['Event']['proposals_count']) ?>"> <td class="bold dblclickElement" style="width:30px" title="<?= __n('%s proposal', '%s proposals', $event['Event']['proposals_count'], $event['Event']['proposals_count']) ?>">
<?= !empty($event['Event']['proposals_count']) ? intval($event['Event']['proposals_count']) : ''; ?> <?= !empty($event['Event']['proposals_count']) ? intval($event['Event']['proposals_count']) : ''; ?>
</td> </td>
<?php endif;?> <?php endif;?>
<?php if (in_array('discussion', $columns, true)): ?> <?php if (in_array('discussion', $columns, true)): ?>
<td class="bold dblclickElement" style="width:30px;"> <td class="bold dblclickElement" style="width:30px">
<?php <?php
if (!empty($event['Event']['post_count'])) { if (!empty($event['Event']['post_count'])) {
$post_count = h($event['Event']['post_count']); $post_count = h($event['Event']['post_count']);
@ -179,7 +177,7 @@
<td class="dblclickElement"> <td class="dblclickElement">
<?= nl2br(h($event['Event']['info']), false) ?> <?= nl2br(h($event['Event']['info']), false) ?>
</td> </td>
<td class="short dblclickElement<?php if ($event['Event']['distribution'] == 0) echo ' privateRedText';?>" title="<?php echo $event['Event']['distribution'] != 3 ? $distributionLevels[$event['Event']['distribution']] : __('All');?>"> <td class="short dblclickElement<?php if ($event['Event']['distribution'] == 0) echo ' privateRedText';?>" title="<?= $event['Event']['distribution'] != 3 ? $distributionLevels[$event['Event']['distribution']] : __('All');?>">
<?php if ($event['Event']['distribution'] == 4):?> <?php if ($event['Event']['distribution'] == 4):?>
<a href="<?php echo $baseurl;?>/sharingGroups/view/<?= intval($event['SharingGroup']['id']); ?>"><?= h($event['SharingGroup']['name']) ?></a> <a href="<?php echo $baseurl;?>/sharingGroups/view/<?= intval($event['SharingGroup']['id']); ?>"><?= h($event['SharingGroup']['name']) ?></a>
<?php else: <?php else:
@ -191,7 +189,7 @@
'<it type="button" title="%s" class="%s" aria-hidden="true" style="font-size: x-small;" data-event-distribution="%s" data-event-distribution-name="%s" data-scope-id="%s"></it>', '<it type="button" title="%s" class="%s" aria-hidden="true" style="font-size: x-small;" data-event-distribution="%s" data-event-distribution-name="%s" data-scope-id="%s"></it>',
__('Toggle advanced sharing network viewer'), __('Toggle advanced sharing network viewer'),
'fa fa-share-alt useCursorPointer distributionNetworkToggle', 'fa fa-share-alt useCursorPointer distributionNetworkToggle',
h($event['Event']['distribution']), intval($event['Event']['distribution']),
$event['Event']['distribution'] == 4 ? h($event['SharingGroup']['name']) : h($shortDist[$event['Event']['distribution']]), $event['Event']['distribution'] == 4 ? h($event['SharingGroup']['name']) : h($shortDist[$event['Event']['distribution']]),
$eventId $eventId
) )

View File

@ -44,7 +44,7 @@
'proposals' => __('Proposals'), 'proposals' => __('Proposals'),
'discussion' => __('Posts'), 'discussion' => __('Posts'),
'report_count' => __('Report count'), 'report_count' => __('Report count'),
'timestamp' => __('Last change at'), 'timestamp' => __('Last modified at'),
'publish_timestamp' => __('Published at') 'publish_timestamp' => __('Published at')
]; ];