Merge branch '2.4' into develop

bad_encoding_pymisp
iglocska 2023-05-31 09:01:30 +02:00
commit a9f40fe91c
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
4 changed files with 20 additions and 7 deletions

View File

@ -16,6 +16,7 @@ class UsageDataWidget
private $Correlation = null;
private $Thread = null;
private $AuthKey = null;
private $redis = null;
private $validFilterKeys = [
'nationality',
@ -41,8 +42,12 @@ class UsageDataWidget
'Discussion posts'
];
public function handler($user, $options = array()){
public function handler($user, $options = array()) {
$this->User = ClassRegistry::init('User');
$this->redis = $this->User->setupRedis();
if (!$this->redis) {
throw new NotFoundException(__('No redis connection found.'));
}
$this->Event = ClassRegistry::init('Event');
$this->Thread = ClassRegistry::init('Thread');
$this->Correlation = ClassRegistry::init('Correlation');
@ -203,11 +208,17 @@ class UsageDataWidget
if (!empty($orgIdList)) {
$conditions['AND'][] = ['Event.orgc_id IN' => $orgIdList];
}
return $this->Event->Attribute->find('count', [
'conditions' => $conditions,
'contain' => ['Event'],
'recursive' => -1
]);
$hash = hash('sha256', json_encode($orgIdList));
$count = $this->redis->get('misp:dashboard:attribute_count:' . $hash);
if (empty($count)) {
$count = $this->Event->Attribute->find('count', [
'conditions' => $conditions,
'contain' => ['Event'],
'recursive' => -1
]);
$this->redis->setEx('misp:dashboard:attribute_count:' . $hash, 3600, $count);
}
return $count;
}
private function getAttributesCountMonth($orgConditions, $orgIdList, $thisMonth)

View File

@ -36,6 +36,7 @@ class Attribute extends AppModel
'Trim',
'Containable',
'Regexp' => array('fields' => array('value')),
'LightPaginator'
);
public $displayField = 'value';

View File

@ -8,6 +8,7 @@ echo $this->element('/genericElements/IndexTable/index_table', [
'title' => __('Attributes'),
'primary_id_path' => 'Attribute.id',
'data' => $attributes,
'light_paginator' => true,
'fields' => [
[
'name' => __('Date'),

View File

@ -239,7 +239,7 @@ $humanReadableFilesize = function ($bytes, $dec = 2) {
</table>
<h4><?= __('PHP Dependencies') ?></h4>
<p><?= _("Dependencies located in the Vendor folder. You can use composer to install them: 'php composer.phar help' ") ?></p>
<p><?= __("Dependencies located in the Vendor folder. You can use composer to install them: 'php composer.phar help' ") ?></p>
<table class="table table-condensed table-bordered" style="width: 40vw">
<thead>
<tr>