mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-08 02:38:51 +00:00
Merge branch '3.9-6.6' into issue-1164
This commit is contained in:
commit
9f2c762fef
@ -100,7 +100,6 @@ export class CdbListsController {
|
||||
}
|
||||
|
||||
search(term) {
|
||||
console.log('TERM:' + term)
|
||||
if (term && term.startsWith('group:') && term.split('group:')[1].trim()) {
|
||||
this.custom_search = '';
|
||||
const filter = { name: 'group', value: term.split('group:')[1].trim() };
|
||||
|
@ -144,7 +144,7 @@ export class ConfigurationRulesetController {
|
||||
|
||||
this.$scope.addNewList = () => {
|
||||
this.$scope.currentList = {
|
||||
file: '',
|
||||
name: '',
|
||||
path: 'etc/lists/',
|
||||
list: [],
|
||||
new: true
|
||||
@ -175,9 +175,12 @@ export class ConfigurationRulesetController {
|
||||
}
|
||||
if (rulesettab === 'cdblists') {
|
||||
this.$scope.searchPlaceholder = 'Filter CDB lists...';
|
||||
this.$scope.currentList = false;
|
||||
this.$scope.search();
|
||||
}
|
||||
if (!this.$scope.$$phase) this.$scope.$digest();
|
||||
};
|
||||
|
||||
this.$scope.switchRulesetTab('rules');
|
||||
|
||||
this.$scope.cancelEditList = () => {
|
||||
|
@ -51,17 +51,16 @@ export class EditionController {
|
||||
if (this.$scope.clusterStatus.data.data.enabled === 'yes') {
|
||||
data = await this.apiReq.request(
|
||||
'GET',
|
||||
`/cluster/${this.$scope.selectedNode}/configuration`,
|
||||
{}
|
||||
`/cluster/${this.$scope.selectedNode}/files`,
|
||||
{ path: 'etc/ossec.conf'}
|
||||
);
|
||||
const json = ((data || {}).data || {}).data || false;
|
||||
xml = this.configurationHandler.json2xml(json);
|
||||
} else {
|
||||
data = await this.apiReq.request('GET', `/manager/files`, {
|
||||
path: 'etc/ossec.conf'
|
||||
});
|
||||
xml = ((data || {}).data || {}).data || false;
|
||||
}
|
||||
|
||||
xml = ((data || {}).data || {}).data || false;
|
||||
if (!xml) {
|
||||
throw new Error('Could not fetch configuration file');
|
||||
}
|
||||
@ -112,6 +111,10 @@ export class EditionController {
|
||||
return this.$scope.editConf();
|
||||
};
|
||||
|
||||
this.$scope.changeNode = () => {
|
||||
this.$scope.editConf();
|
||||
};
|
||||
|
||||
this.$scope.closeEditingFile = () => {};
|
||||
|
||||
//listeners
|
||||
|
@ -558,6 +558,9 @@ export class SettingsController {
|
||||
return;
|
||||
} catch (error) {
|
||||
if (!this.wzMisc.getApiIsDown()) this.printError(error);
|
||||
else {
|
||||
this.errorHandler.handle(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,20 @@
|
||||
<div layout="column" layout-align="start">
|
||||
<div layout="row" ng-show="currentList.name" class="wz-margin-top-8 md-padding-h">
|
||||
<input placeholder="Filter entries..." ng-model="searchTerm" ng-change="filterTable()" type="text" class="kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid">
|
||||
<button class="kuiLocalSearchButton height-40"><span class="fa fa-search" aria-hidden="true"></span> </button>
|
||||
</div>
|
||||
<div layout="row" class="wz-margin-top-8 md-padding-h">
|
||||
<input ng-show="currentList.new && !currentList.name" placeholder="Enter list file name" ng-model="currentList.newName" type="text"
|
||||
class="height-40 kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid" aria-invalid="false">
|
||||
<button ng-disabled='items.length === 0 || (currentList.new && !currentList.newName)' ng-click='saveList()'
|
||||
class='btn btn-primary pull-right'>
|
||||
<span><i aria-hidden='true' class='fa fa-fw fa-save'></i>Save list</span>
|
||||
</button>
|
||||
<input ng-show="currentList.new && !currentList.name" placeholder="Enter list file name" ng-model="currentList.newName"
|
||||
type="text" class="kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid wz-margin-left-8"
|
||||
aria-invalid="false">
|
||||
</div>
|
||||
<div layout="row" class="wz-padding-left-8 wz-padding-right-8" layout-align="start stretch">
|
||||
<md-card flex class="wz-md-card">
|
||||
<md-card-content>
|
||||
<div layout="row">
|
||||
<input placeholder="Filter entries..." ng-model="searchTerm" ng-change="filterTable()" type="text"
|
||||
class="kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid height-40">
|
||||
</div>
|
||||
<table class="table table-striped table-condensed table-layout-fixed table-hover table-vertical-align-middle">
|
||||
<thead class="wz-text-bold">
|
||||
<th class="wz-text-left">Key</th>
|
||||
@ -20,7 +25,7 @@
|
||||
<tr ng-if="adminMode">
|
||||
<td><input placeholder="Key" type="text" class="wz-input-text" ng-model="newKey"></input></td>
|
||||
<td><input placeholder="Value" type="text" class="wz-input-text" ng-model="newValue"></input></td>
|
||||
<td><button class="btn btn-primary btn-as-i" ng-disabled="!newKey || !newValue" ng-click="addEntry(newKey, newValue);newKey = ''; newValue = ''"
|
||||
<td><button class="btn btn-primary btn-as-i" ng-disabled="!newKey" ng-click="addEntry(newKey, newValue);newKey = ''; newValue = ''"
|
||||
tooltip="Add new entry" tooltip-placement="right">
|
||||
<i class="fa fa-fw fa-plus" style="width:15px"></i></button></td>
|
||||
</tr>
|
||||
@ -28,7 +33,7 @@
|
||||
<td>{{item[0]}}</td>
|
||||
<td>
|
||||
<input ng-show="editingKey === item[0]" ng-disabled="loadingChange" type="text" class="wz-input-text"
|
||||
ng-model="editingNewValue"></input>
|
||||
ng-model="currentList.editingNewValue"></input>
|
||||
<span ng-show="!editingKey || editingKey !== item[0]">{{item[1]}}</span>
|
||||
</td>
|
||||
<td class="action-btn-td">
|
||||
@ -37,8 +42,8 @@
|
||||
tooltip="Edit" ng-click="setEditingKey(item[0], item[1])" class="fa fa-fw fa-pencil cursor-pointer"></span>
|
||||
<span ng-show="editingKey === item[0] && !loadingChange" tooltip="Cancel" class="fa fa-fw fa-times cursor-pointer"
|
||||
ng-click="cancelEditingKey()"></span>
|
||||
<span ng-show="editingKey === item[0] && editingNewValue !== '' && !loadingChange"
|
||||
tooltip="Apply" class="fa fa-fw fa-success cursor-pointer" ng-click="editKey(item[0], editingNewValue)"></span>
|
||||
<span ng-show="editingKey === item[0] && currentList.editingNewValue !== '' && !loadingChange"
|
||||
tooltip="Apply" class="fa fa-fw fa-success cursor-pointer" ng-click="editKey(item[0])"></span>
|
||||
<span ng-show="editingKey === item[0] && loadingChange"><i class="fa fa-fw fa-spin fa-spinner"></i></span>
|
||||
<i ng-if="(!removingEntry || removingEntry !== item[0]) && editingKey !== item[0]"
|
||||
ng-click="showConfirmRemoveEntry($event, item[0]); $event.stopPropagation()"
|
||||
|
@ -14,7 +14,6 @@ import template from './wz-list-manage.html';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import * as pagination from '../wz-table/lib/pagination';
|
||||
import { checkGap } from '../wz-table/lib/check-gap';
|
||||
import { stringToObj } from '../../utils/cdblist-to-object';
|
||||
|
||||
const app = uiModules.get('app/wazuh', []);
|
||||
|
||||
@ -81,22 +80,6 @@ app.directive('wzListManage', function() {
|
||||
$scope.sortReverse = false;
|
||||
$scope.searchTerm = '';
|
||||
|
||||
$scope.$watch('currentList.list', () => {
|
||||
if ($scope.currentList.list) fetch();
|
||||
});
|
||||
|
||||
const refresh = () => {
|
||||
rulesetHandler
|
||||
.getCdbList(`${$scope.currentList.path}/${$scope.currentList.name}`)
|
||||
.then(data => {
|
||||
$scope.currentList.list = stringToObj(data.data.data);
|
||||
fetch();
|
||||
$scope.$emit('setCurrentList', { currentList: $scope.currentList });
|
||||
$scope.viewingDetail = true;
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on('changeCdbList', (ev, params) => {
|
||||
if (params.currentList) {
|
||||
$scope.currentList = params.currentList;
|
||||
@ -104,12 +87,15 @@ app.directive('wzListManage', function() {
|
||||
}
|
||||
});
|
||||
|
||||
const saveList = async () => {
|
||||
$scope.saveList = async () => {
|
||||
let addingNew = false;
|
||||
try {
|
||||
if ($scope.currentList.new && !$scope.currentList.newName) {
|
||||
$scope.currentList.list = [];
|
||||
throw new Error('New list name is needed');
|
||||
} else {
|
||||
} else if ($scope.currentList.new && $scope.currentList.newName) {
|
||||
addingNew = true;
|
||||
$scope.currentList.new = false;
|
||||
$scope.currentList.name = $scope.currentList.newName;
|
||||
}
|
||||
let raw = '';
|
||||
@ -125,7 +111,11 @@ app.directive('wzListManage', function() {
|
||||
$scope.loadingChange = false;
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
} catch (err) {
|
||||
refresh();
|
||||
if (addingNew) {
|
||||
$scope.currentList.name = false;
|
||||
$scope.currentList.new = true;
|
||||
$scope.$applyAsync();
|
||||
}
|
||||
errorHandler.handle(err, 'Error updating list');
|
||||
$scope.loadingChange = false;
|
||||
}
|
||||
@ -133,8 +123,8 @@ app.directive('wzListManage', function() {
|
||||
|
||||
$scope.addEntry = (key, value) => {
|
||||
if (!$scope.currentList.list[key]) {
|
||||
$scope.currentList.list[key] = value;
|
||||
saveList();
|
||||
$scope.currentList.list[key] = value ? value : '';
|
||||
fetch();
|
||||
} else {
|
||||
errorHandler.handle('Entry already exists', '');
|
||||
}
|
||||
@ -146,7 +136,7 @@ app.directive('wzListManage', function() {
|
||||
*/
|
||||
$scope.setEditingKey = (key, value) => {
|
||||
$scope.editingKey = key;
|
||||
$scope.editingNewValue = value;
|
||||
$scope.currentList.editingNewValue = value;
|
||||
};
|
||||
/**
|
||||
* Cancel edition of an entry
|
||||
@ -160,11 +150,12 @@ app.directive('wzListManage', function() {
|
||||
$scope.removingEntry = key;
|
||||
};
|
||||
|
||||
$scope.editKey = (key, newValue) => {
|
||||
$scope.editKey = (key) => {
|
||||
$scope.loadingChange = true;
|
||||
$scope.currentList.list[key] = newValue;
|
||||
$scope.currentList.list[key] = $scope.currentList.editingNewValue;
|
||||
$scope.currentList.editingNewValue = '';
|
||||
$scope.cancelEditingKey();
|
||||
saveList();
|
||||
fetch();
|
||||
};
|
||||
|
||||
$scope.cancelRemoveEntry = () => {
|
||||
@ -174,7 +165,7 @@ app.directive('wzListManage', function() {
|
||||
$scope.confirmRemoveEntry = key => {
|
||||
delete $scope.currentList.list[key];
|
||||
$scope.removingEntry = false;
|
||||
saveList();
|
||||
fetch();
|
||||
};
|
||||
},
|
||||
template
|
||||
|
@ -185,7 +185,7 @@ app.directive('wzXmlFileEditor', function() {
|
||||
} else if (params.node) {
|
||||
await saveConfig.saveNodeConfiguration(params.node, xml);
|
||||
errorHandler.info(
|
||||
'Success. Node configuration has been updated',
|
||||
`Success. Node (${params.node}) configuration has been updated`,
|
||||
''
|
||||
);
|
||||
} else if (params.manager) {
|
||||
|
@ -256,6 +256,7 @@ div.uil-ring-css {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
box-shadow: none!important;
|
||||
}
|
||||
|
||||
.btn-as-i:hover{
|
||||
|
@ -92,6 +92,10 @@
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.wz-margin-bottom-25 {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.wz-margin-bottom-40 {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
@ -38,7 +38,12 @@ export class SaveConfig {
|
||||
*/
|
||||
async saveNodeConfiguration(node, content) {
|
||||
try {
|
||||
//
|
||||
const result = await this.apiReq.request(
|
||||
'POST',
|
||||
`/cluster/${node}/files?path=etc/ossec.conf`,
|
||||
{ content, origin: 'xmleditor' }
|
||||
);
|
||||
return result;
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
@ -16,16 +16,6 @@
|
||||
<div layout="row">
|
||||
<span class="md-subheader">Edit master/worker configuration</span>
|
||||
</div>
|
||||
|
||||
<!-- List of nodes if cluster is enabled -->
|
||||
<div ng-show="selectedNode && clusterStatus.data.data.enabled === 'yes'" layout="row" layout-padding style="position: absolute;right: calc(0% + 260px);">
|
||||
<div layout="column" layout-align="center" class="height-40 wz-select-input">
|
||||
<select class="kuiSelect wz-border-none cursor-pointer max-height-35" id="categoryBox" ng-model="selectedNode"
|
||||
ng-change="changeNode(selectedNode)" aria-label="Select node">
|
||||
<option ng-repeat="node in nodes" value="{{node.name}}">{{node.name}} ({{node.type}})</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Headline (manager) -->
|
||||
@ -49,6 +39,16 @@
|
||||
<span ng-show='xmlHasErrors' class='btn-danger'><i aria-hidden='true' class='fa fa-fw fa-exclamation-triangle'></i>
|
||||
XML format error</span>
|
||||
</button>
|
||||
<!-- List of nodes if cluster is enabled -->
|
||||
<div ng-show="selectedNode && clusterStatus.data.data.enabled === 'yes'" layout="row" class="wz-margin-left-8"
|
||||
layout-padding style="padding: 0;height: 32px;">
|
||||
<div layout="column" layout-align="center" class="height-35 wz-select-input">
|
||||
<select class="kuiSelect wz-border-none cursor-pointer max-height-35" id="categoryBox"
|
||||
ng-model="selectedNode" ng-change="changeNode()" aria-label="Select node">
|
||||
<option ng-repeat="node in nodes" value="{{node.name}}">{{node.name}} ({{node.type}})</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-padding md-padding-top-10" style="height: calc(100vh - 280px);" ng-if="fetchedXML">
|
||||
<wz-xml-file-editor file-name='ossec.conf' data="fetchedXML" target-name="selectedNode" valid-fn='xmlIsValid(valid)'
|
||||
|
@ -9,7 +9,7 @@
|
||||
<span ng-if='adminMode && !editingFile && selectedRulesetTab === "decoders"' class="font-size-18 wz-text-link"
|
||||
ng-click="addNewFile('decoders')" tooltip="Add new decoders file" tooltip-placement="right">
|
||||
<i class="fa fa-fw fa-plus-circle"></i></span>
|
||||
<span ng-if='adminMode && !editingFile && selectedRulesetTab === "cdblists"' class="font-size-18 wz-text-link"
|
||||
<span ng-if='adminMode && !currentList && selectedRulesetTab === "cdblists"' class="font-size-18 wz-text-link"
|
||||
ng-click="addNewList()" tooltip="Add new list file" tooltip-placement="right">
|
||||
<i class="fa fa-fw fa-plus-circle"></i></span>
|
||||
</div>
|
||||
@ -88,6 +88,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-padding" ng-show="viewingDetail">
|
||||
<div class="wz-margin-bottom-25">
|
||||
<h1 class="font-size-18">{{currentList.name}}</h1>
|
||||
</div>
|
||||
<div flex layout="column">
|
||||
<wz-list-manage style="margin: -16px;" ng-if="currentList" list="currentList"></wz-list-manage>
|
||||
</div>
|
||||
|
@ -153,7 +153,13 @@ export class WazuhApiCtrl {
|
||||
throw new Error(`${api.url}:${api.port}/version is unreachable`);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code === 'ECONNREFUSED') {
|
||||
if (error.code === 'EPROTO') {
|
||||
log('POST /api/check-stored-api', 'Wrong protocol being used to connect to the Wazuh API');
|
||||
return {
|
||||
statusCode: 200,
|
||||
data: { password: '****', apiIsDown: true }
|
||||
};
|
||||
} else if (error.code === 'ECONNREFUSED') {
|
||||
log('POST /api/check-stored-api', error.message || error);
|
||||
return {
|
||||
statusCode: 200,
|
||||
@ -335,6 +341,10 @@ export class WazuhApiCtrl {
|
||||
|
||||
throw new Error(tmpMsg);
|
||||
} catch (error) {
|
||||
if (error.code === 'EPROTO') {
|
||||
log('POST /api/check-api', 'Wrong protocol being used to connect to the Wazuh API');
|
||||
return ErrorResponse('Wrong protocol being used to connect to the Wazuh API', 3005, 500, reply);
|
||||
}
|
||||
log('POST /api/check-api', error.message || error);
|
||||
return ErrorResponse(error.message || error, 3005, 500, reply);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user