mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 10:18:57 +00:00
Merge pull request #446 from wazuh/3.2-ruleset-improvements
Improvements for Manager/Ruleset
This commit is contained in:
commit
532a166f27
@ -33,6 +33,11 @@ app.controller('managerController', function ($scope, $rootScope, $routeParams,
|
||||
$rootScope.groupsIsReloaded = true;
|
||||
}
|
||||
|
||||
$scope.reloadRuleset = () => {
|
||||
$scope.submenuNavItem = 'ruleset';
|
||||
$rootScope.rulesetIsReloaded = true;
|
||||
}
|
||||
|
||||
// Watchers
|
||||
$scope.$watch('submenuNavItem', () => {
|
||||
if($scope.submenuNavItem === 'ruleset') {
|
||||
|
@ -14,19 +14,54 @@ import CsvGenerator from './csv-generator'
|
||||
|
||||
const app = modules.get('app/wazuh', []);
|
||||
|
||||
app.controller('rulesController', function ($timeout, $scope, $rootScope, Rules, RulesRelated, RulesAutoComplete, errorHandler, genericReq, appState, csvReq) {
|
||||
app.controller('rulesController', function ($timeout, $scope, $rootScope, $sce, Rules, RulesRelated, RulesAutoComplete, errorHandler, genericReq, appState, csvReq) {
|
||||
|
||||
$scope.setRulesTab = tab => $rootScope.globalsubmenuNavItem2 = tab;
|
||||
|
||||
//Initialization
|
||||
$scope.searchTerm = '';
|
||||
$scope.loading = true;
|
||||
$scope.viewingDetail = false;
|
||||
$scope.rules = Rules;
|
||||
$scope.rulesRelated = RulesRelated;
|
||||
$scope.rulesAutoComplete = RulesAutoComplete;
|
||||
$scope.setRulesTab('rules');
|
||||
$scope.isArray = angular.isArray;
|
||||
|
||||
$scope.analyzeRules = async search => {
|
||||
const colors = [
|
||||
'#004A65', '#00665F', '#BF4B45', '#BF9037', '#1D8C2E', 'BB3ABF',
|
||||
'#00B1F1', '#00F2E2', '#7F322E', '#7F6025', '#104C19', '7C267F',
|
||||
'#0079A5', '#00A69B', '#FF645C', '#FFC04A', '#2ACC43', 'F94DFF',
|
||||
'#0082B2', '#00B3A7', '#401917', '#403012', '#2DD947', '3E1340',
|
||||
'#00668B', '#008C83', '#E55A53', '#E5AD43', '#25B23B', 'E045E5'
|
||||
];
|
||||
|
||||
$scope.colorRuleArg = ruleArg => {
|
||||
ruleArg = ruleArg.toString();
|
||||
let valuesArray = ruleArg.match(/\$\(((?!<\/span>).)*?\)(?!<\/span>)/gmi);
|
||||
let coloredString = ruleArg;
|
||||
|
||||
// If valuesArray is empty, means that the description doesn't have any arguments
|
||||
// In this case, then simply return the string
|
||||
// In other case, then colour the string and return
|
||||
if (valuesArray && valuesArray.length) {
|
||||
for (let i = 0, len = valuesArray.length; i < len; i++) {
|
||||
coloredString = coloredString.replace(/\$\(((?!<\/span>).)*?\)(?!<\/span>)/mi, '<span style="color: ' + colors[i] + ' ">' + valuesArray[i] + '</span>');
|
||||
}
|
||||
}
|
||||
|
||||
return $sce.trustAsHtml(coloredString);
|
||||
};
|
||||
|
||||
// Reloading watcher initialization
|
||||
const reloadWatcher = $rootScope.$watch('rulesetIsReloaded',() => {
|
||||
delete $rootScope.rulesetIsReloaded;
|
||||
$scope.viewingDetail = false;
|
||||
if(!$scope.$$phase) $scope.$digest();
|
||||
});
|
||||
|
||||
$scope.analizeRules = async search => {
|
||||
|
||||
try {
|
||||
if(search && search.length <= 1) return $scope.rulesAutoComplete.items;
|
||||
await $timeout(200);
|
||||
@ -144,25 +179,12 @@ app.controller('rulesController', function ($timeout, $scope, $rootScope, Rules,
|
||||
//Load
|
||||
load();
|
||||
|
||||
let timesOpened = 0;
|
||||
let lastName = false;
|
||||
$scope.closeOther = rule => {
|
||||
const item = rule.id ? rule.id : rule;
|
||||
if(item !== lastName){
|
||||
lastName = item;
|
||||
timesOpened = 0;
|
||||
}
|
||||
timesOpened++;
|
||||
$scope.activeItem = (timesOpened <= 1) ? item : false;
|
||||
if(timesOpened > 1) timesOpened = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
//Destroy
|
||||
$scope.$on('$destroy', () => {
|
||||
$scope.rules.reset();
|
||||
$scope.rulesRelated.reset();
|
||||
$scope.rulesAutoComplete.reset();
|
||||
reloadWatcher();
|
||||
});
|
||||
});
|
||||
|
||||
@ -170,7 +192,9 @@ app.controller('decodersController', function ($timeout, $scope, $rootScope, $sc
|
||||
$scope.setRulesTab = tab => $rootScope.globalsubmenuNavItem2 = tab;
|
||||
|
||||
//Initialization
|
||||
$scope.searchTerm = '';
|
||||
$scope.loading = true;
|
||||
$scope.viewingDetail = false;
|
||||
$scope.decoders = Decoders;
|
||||
$scope.decodersRelated = DecodersRelated;
|
||||
$scope.decodersAutoComplete = DecodersAutoComplete;
|
||||
@ -179,13 +203,11 @@ app.controller('decodersController', function ($timeout, $scope, $rootScope, $sc
|
||||
$scope.isArray = angular.isArray;
|
||||
|
||||
const colors = [
|
||||
'#3F6833', '#967302', '#2F575E', '#99440A', '#58140C', '#052B51', '#511749', '#3F2B5B', //6
|
||||
'#508642', '#CCA300', '#447EBC', '#C15C17', '#890F02', '#0A437C', '#6D1F62', '#584477', //2
|
||||
'#629E51', '#E5AC0E', '#64B0C8', '#E0752D', '#BF1B00', '#0A50A1', '#962D82', '#614D93', //4
|
||||
'#7EB26D', '#EAB839', '#6ED0E0', '#EF843C', '#E24D42', '#1F78C1', '#BA43A9', '#705DA0', // Normal
|
||||
'#9AC48A', '#F2C96D', '#65C5DB', '#F9934E', '#EA6460', '#5195CE', '#D683CE', '#806EB7', //5
|
||||
'#B7DBAB', '#F4D598', '#70DBED', '#F9BA8F', '#F29191', '#82B5D8', '#E5A8E2', '#AEA2E0', //3
|
||||
'#E0F9D7', '#FCEACA', '#CFFAFF', '#F9E2D2', '#FCE2DE', '#BADFF4', '#F9D9F9', '#DEDAF7' //7
|
||||
'#004A65', '#00665F', '#BF4B45', '#BF9037', '#1D8C2E', 'BB3ABF',
|
||||
'#00B1F1', '#00F2E2', '#7F322E', '#7F6025', '#104C19', '7C267F',
|
||||
'#0079A5', '#00A69B', '#FF645C', '#FFC04A', '#2ACC43', 'F94DFF',
|
||||
'#0082B2', '#00B3A7', '#401917', '#403012', '#2DD947', '3E1340',
|
||||
'#00668B', '#008C83', '#E55A53', '#E5AD43', '#25B23B', 'E045E5'
|
||||
];
|
||||
|
||||
$scope.colorRegex = regex => {
|
||||
@ -208,18 +230,12 @@ app.controller('decodersController', function ($timeout, $scope, $rootScope, $sc
|
||||
return $sce.trustAsHtml(coloredString);
|
||||
};
|
||||
|
||||
let timesOpened = 0;
|
||||
let lastName = false;
|
||||
$scope.closeOther = name => {
|
||||
if(name !== lastName){
|
||||
lastName = name;
|
||||
timesOpened = 0;
|
||||
}
|
||||
timesOpened++;
|
||||
$scope.activeItem = (timesOpened <= 1) ? name : false;
|
||||
if(timesOpened > 1) timesOpened = 0;
|
||||
return true;
|
||||
}
|
||||
// Reloading watcher initialization
|
||||
const reloadWatcher = $rootScope.$watch('rulesetIsReloaded',() => {
|
||||
delete $rootScope.rulesetIsReloaded;
|
||||
$scope.viewingDetail = false;
|
||||
if(!$scope.$$phase) $scope.$digest();
|
||||
});
|
||||
|
||||
$scope.checkEnter = search => {
|
||||
$scope.searchTerm = '';
|
||||
@ -337,5 +353,6 @@ app.controller('decodersController', function ($timeout, $scope, $rootScope, $sc
|
||||
$scope.decoders.reset();
|
||||
$scope.decodersRelated.reset();
|
||||
$scope.decodersAutoComplete.reset();
|
||||
reloadWatcher();
|
||||
});
|
||||
});
|
||||
|
@ -16,6 +16,7 @@
|
||||
background-color: white !important;
|
||||
min-height: 36px;
|
||||
height: 36px;
|
||||
line-height: 20px;
|
||||
border-bottom: 1px solid #D9D9D9;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ app.directive('wzTable',function(){
|
||||
noheight : '=noheight',
|
||||
isruleset : '=isruleset',
|
||||
isdecoders : '=isdecoders',
|
||||
activeitem : '=activeitem',
|
||||
isagents : '=isagents',
|
||||
specialfunc : '&'
|
||||
},
|
||||
|
@ -5,7 +5,7 @@
|
||||
<div layout="row" layout-align="center start">
|
||||
<md-nav-bar flex class="pading-right-0 wz-md-navbar" md-selected-nav-item="submenuNavItem" nav-bar-aria-label="navigation submenu">
|
||||
<md-nav-item md-nav-click="submenuNavItem = 'status'" name="status">Status</md-nav-item>
|
||||
<md-nav-item md-nav-click="submenuNavItem = 'ruleset'" name="ruleset">Ruleset</md-nav-item>
|
||||
<md-nav-item md-nav-click="reloadRuleset()" name="ruleset">Ruleset</md-nav-item>
|
||||
<md-nav-item md-nav-click="submenuNavItem = 'configuration'" name="configuration">Configuration</md-nav-item>
|
||||
<md-nav-item md-nav-click="submenuNavItem = 'logs'" name="logs">Logs</md-nav-item>
|
||||
<md-nav-item md-nav-click="reloadGroups()" name="groups">Groups</md-nav-item>
|
||||
|
@ -116,7 +116,7 @@
|
||||
<md-divider class="wz-margin-top-10"></md-divider>
|
||||
<div ng-repeat="item in currentDecoder.details.regex">
|
||||
<div layout="row" class="wz-padding-top-10">
|
||||
<span class="wz-text-right color-grey" ng-bind-html="colorRegex(item)"></span>
|
||||
<span ng-bind-html="colorRegex(item)"></span>
|
||||
</div>
|
||||
</div>
|
||||
</md-card-content>
|
||||
@ -130,7 +130,7 @@
|
||||
<md-divider class="wz-margin-top-10"></md-divider>
|
||||
<div ng-repeat="item in currentDecoder.details.match">
|
||||
<div layout="row" class="wz-padding-top-10">
|
||||
<span class="wz-text-right color-grey">{{item}}</span>
|
||||
<span>{{item}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</md-card-content>
|
||||
@ -144,7 +144,7 @@
|
||||
<md-divider class="wz-margin-top-10"></md-divider>
|
||||
<div ng-repeat="item in currentDecoder.details.prematch">
|
||||
<div layout="row" class="wz-padding-top-10">
|
||||
<span class="wz-text-right color-grey">{{item}}</span>
|
||||
<span>{{item}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</md-card-content>
|
||||
@ -171,7 +171,6 @@
|
||||
func="openDetailView(decoderRelated)"
|
||||
data="decodersRelated"
|
||||
full="'decoderRelated'"
|
||||
activeitem="activeItem"
|
||||
keys="[
|
||||
{col:'name',size:20},
|
||||
{col:'details.program_name',size:20},
|
||||
|
@ -72,7 +72,6 @@
|
||||
func="openDetailView(decoder)"
|
||||
data="decoders"
|
||||
full="'decoder'"
|
||||
activeitem="activeItem"
|
||||
keys="[
|
||||
{col:'name',size:20},
|
||||
{col:'details.program_name',size:20},
|
||||
@ -83,6 +82,7 @@
|
||||
isdecoders="true"
|
||||
class="no-lateral-padding">
|
||||
</wz-table>
|
||||
|
||||
<div layout="row" class="wz-margin-top-10">
|
||||
<span flex></span>
|
||||
<a class="small" id="btnDownload" ng-click="downloadCsv()">Formatted <i aria-hidden="true" class="fa fa-download"></i></a>
|
||||
|
@ -5,7 +5,8 @@
|
||||
<!-- Back button -->
|
||||
<md-button class="md-icon-button" aria-label="Back to rules list" tooltip="Back" tooltip-placement="bottom" ng-click="closeDetailView()"><i class="fa fa-fw fa-arrow-left" aria-hidden="true"></i></md-button>
|
||||
<!-- Rule title -->
|
||||
<h1 class="md-headline wz-headline">{{currentRule.description}}</h1>
|
||||
<h1 class="md-headline wz-headline" ng-bind-html="colorRuleArg(currentRule.description)"></h1>
|
||||
|
||||
</div>
|
||||
<!-- End back button, title and status indicator -->
|
||||
|
||||
@ -138,7 +139,7 @@
|
||||
<md-divider class="wz-margin-top-10"></md-divider>
|
||||
<div ng-repeat="item in currentRule.details.regex">
|
||||
<div layout="row" class="wz-padding-top-10">
|
||||
<span class="wz-text-right color-grey">{{item}}</span>
|
||||
<span>{{item}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</md-card-content>
|
||||
@ -152,7 +153,7 @@
|
||||
<md-divider class="wz-margin-top-10"></md-divider>
|
||||
<div ng-repeat="item in currentRule.details.match">
|
||||
<div layout="row" class="wz-padding-top-10">
|
||||
<span class="wz-text-right color-grey">{{item}}</span>
|
||||
<span>{{item}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</md-card-content>
|
||||
@ -166,7 +167,7 @@
|
||||
<md-divider class="wz-margin-top-10"></md-divider>
|
||||
<div ng-repeat="item in currentRule.details.prematch">
|
||||
<div layout="row" class="wz-padding-top-10">
|
||||
<span class="wz-text-right color-grey">{{item}}</span>
|
||||
<span>{{item}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</md-card-content>
|
||||
@ -195,7 +196,6 @@
|
||||
func="openDetailView(ruleRelated)"
|
||||
data="rulesRelated"
|
||||
full="'ruleRelated'"
|
||||
activeitem="activeItem"
|
||||
keys="[
|
||||
{col:'id',size:5},
|
||||
{col:'file',size:15},
|
||||
|
@ -95,7 +95,6 @@
|
||||
func="openDetailView(rule)"
|
||||
data="rules"
|
||||
full="'rule'"
|
||||
activeitem="activeItem"
|
||||
keys="[
|
||||
{col:'id',size:5},
|
||||
{col:'file',size:15},
|
||||
@ -108,6 +107,7 @@
|
||||
isdecoders="false"
|
||||
class="no-lateral-padding">
|
||||
</wz-table>
|
||||
|
||||
<div layout="row" class="wz-margin-top-10">
|
||||
<span flex></span>
|
||||
<a class="small" id="btnDownload" ng-click="downloadCsv()">Formatted <i aria-hidden="true" class="fa fa-download"></i></a>
|
||||
|
@ -1 +1,2 @@
|
||||
<div flex layout="column" ng-if="globalRuleSet == 'ruleset'" class="mozilla-table-size-85">
|
||||
<div ng-cloak flex layout="column" ng-if="globalRuleSet == 'ruleset'" class="mozilla-table-size-85">
|
||||
<md-progress-linear class="md-accent" md-mode="indeterminate" ng-show="load"></md-progress-linear>
|
||||
|
Loading…
Reference in New Issue
Block a user