chg: [periodic_notification] Generate tag trendings for mitre ATTACK if none are provided

pull/8583/head
Sami Mokaddem 2022-09-12 08:55:56 +02:00 committed by Sami Mokaddem
parent 77bc6b2d6c
commit 046fd49b06
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
3 changed files with 7 additions and 2 deletions

View File

@ -2,6 +2,9 @@
class TrendingTool
{
private $eventModel;
public const defaultTagNamespaceForTrends = [
'misp-galaxy:mitre-attack-pattern',
];
public function __construct($eventModel)
{
@ -10,6 +13,7 @@ class TrendingTool
public function getTrendsForTags(array $events, int $baseDayRange, int $rollingWindows=3, $tagFilterPrefixes=null): array
{
$tagFilterPrefixes = $tagFilterPrefixes ?: self::defaultTagNamespaceForTrends;
$clusteredTags = $this->__clusterTagsForRollingWindow($events, $baseDayRange, $rollingWindows, $tagFilterPrefixes);
$trendAnalysis = $this->__computeTrendAnalysis($clusteredTags);
return [

View File

@ -1787,9 +1787,10 @@ class User extends AppModel
$rollingWindows = 2;
$trendAnalysis = $this->Event->getTrendsForTagsFromEvents($events, $this->__periodToDays($period), $rollingWindows, $periodicSettings['trending_for_tags']);
$tagFilterPrefixes = $periodicSettings['trending_for_tags'] ?: array_keys($trendAnalysis['all_tags']);
$trendData = [
'trendAnalysis' => $trendAnalysis,
'tagFilterPrefixes' => $periodicSettings['trending_for_tags'],
'tagFilterPrefixes' => $tagFilterPrefixes,
];
$trending_summary = $this->__renderTrendingSummary($trendData);

View File

@ -59,7 +59,7 @@ echo $this->element('genericElements/Form/genericForm', [
'type' => 'tagsPicker',
'placeholder' => '["tlp:red"]',
],
sprintf('<h4>%s</h4>', __('Notification filters')),
sprintf('<h4>%s</h4>', __('Report settings')),
[
'field' => 'periodic_settings.trending_for_tags',
'label' => __('Generate trends for tag namespaces'),