Skip to content

Commit

Permalink
Fix index patterns invalid field errors. Fix Auditd panel styles
Browse files Browse the repository at this point in the history
  • Loading branch information
snaow committed Feb 9, 2017
1 parent 7224f46 commit a43edc2
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 252 deletions.
398 changes: 198 additions & 200 deletions public/directives/kibanaDashboardDirective.js

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions public/directives/kibanaVisualizationDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,7 @@ require('ui/modules').get('app/wazuh', []).controller('VisController', function
// Bind visualization, index pattern and state
$scope.vis = $scope.newVis.vis;
$scope.indexPattern = $scope.vis.indexPattern;
angular.forEach($scope.indexPattern.fields, function(value, key) {
if(value.aggregatable)
agg_fields.push(value.displayName);
});

$scope.state = $state;

// Check if needed fields are agreggable
$scope.not_aggregable = false;
angular.forEach(visDecoded.vis.aggs, function(value, key) {
if(value.type == "terms" && (agg_fields.indexOf(value.params.field) === -1)){
$scope.not_aggregable = true;
return;
}
});


// Build visualization
visState.aggs = visDecoded.vis.aggs;
Expand Down
6 changes: 4 additions & 2 deletions public/objects/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
var routes = require('ui/routes');

//Installation wizard
var settingsWizard = function ($location, testConnection, $mdToast, appState, $q) {
var settingsWizard = function ($location, testConnection, $mdToast, appState, $q, genericReq) {
var deferred = $q.defer();
testConnection.test().then(function (data)
{
appState.setDefaultManager(data.manager);
appState.setExtensions(data.extensions);
deferred.resolve();
genericReq.request('PUT', '/api/wazuh-elastic/wazuh-pattern').then(function (data) {
deferred.resolve();
});
}, function (data) {
$mdToast.show({
template: '<md-toast>Could not connect with Wazuh API. Please, configure it on settings tab.</md-toast>',
Expand Down
2 changes: 1 addition & 1 deletion public/templates/agents-audit.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</md-content>


<md-content layout="row" layout-align="center stretch">
<md-content style="height: 448px" layout="row" layout-align="center stretch">
<md-content flex="20" layout="column" layout-align="center stretch">

<md-card flex="50">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<div ng-controller="VisController">

<div ng-if="not_aggregable" class="text-center visualize-error visualize-chart ng-scope">
<div class="item top"></div>
<div class="item">
<h2 aria-hidden="true"><i aria-hidden="true" class="fa fa-meh-o"></i></h2>
<h4>No results found</h4>
</div>
<div class="item bottom"></div>
</div>

<div ng-if="loadBeforeShow" class="app-container vis-editor vis-type-{{ vis.type.name }}" ng-style="{height:visHeight}">

<kbn-top-nav name="visualize" config="topNavMenu" ng-if="visSearchable">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
<div ng-controller="VisController">

<div ng-if="not_aggregable" class="text-center visualize-error visualize-chart ng-scope">
<div class="item top"></div>
<div class="item">
<h4>No results found</h4>
</div>
<div class="item bottom"></div>
</div>

<div ng-if="loadBeforeShow" class="app-container vis-editor vis-type-{{ vis.type.name }}" ng-style="{height:visHeight}">
<kbn-top-nav name="visualize" config="topNavMenu" ng-if="visSearchable">
Expand Down
2 changes: 1 addition & 1 deletion public/templates/overview-audit.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
</md-content>


<md-content layout="row" layout-align="center stretch">
<md-content style="height: 448px" layout="row" layout-align="center stretch">
<md-content flex="20" layout="column" layout-align="center stretch">

<md-card flex="50">
Expand Down
64 changes: 48 additions & 16 deletions server/routes/wazuh-elastic.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,28 +180,60 @@ module.exports = function (server, options) {
};

var putWazuhPattern = function (req, reply) {

function extend(target) {
var sources = [].slice.call(arguments, 1);
sources.forEach(function (source) {
for (var prop in source) {
target[prop] = source[prop];
}
});
return target;
}

try {
kibana_fields_data = JSON.parse(fs.readFileSync(path.resolve(__dirname, KIBANA_FIELDS_FILE), 'utf8'));
kibana_fields_data = JSON.parse(fs.readFileSync(path.resolve(__dirname, KIBANA_FIELDS_FILE), 'utf8'));
// Get fields index pattern template
var wazuhAlerts_indexPattern_template = JSON.parse(kibana_fields_data.wazuh_alerts)
var wazuhAlerts_indexPattern_current = {};
var fields = [];
for (var i = 0, len = wazuhAlerts_indexPattern_template.length; i < len; i++) {
fields.push(wazuhAlerts_indexPattern_template[i].name);
}

// Get current fields index pattern
client.get({
index: '.kibana',
type: 'index-pattern',
id: index_pattern
}, function (error, response) {
wazuhAlerts_indexPattern_current = JSON.parse(response._source.fields);
// Compare and update fields properties
for (var i = 0, len = wazuhAlerts_indexPattern_current.length; i < len; i++) {
if (fields.indexOf(wazuhAlerts_indexPattern_current[i].name) >= 0) {
wazuhAlerts_indexPattern_current[i].searchable = true;
wazuhAlerts_indexPattern_current[i].aggregatable = true;
}
}
// Update index pattern
client.update({
index: '.kibana',
type: 'index-pattern',
id: index_pattern,
body: {
doc: {
fields: JSON.stringify((wazuhAlerts_indexPattern_current))
}
}
}, function (error, response) {
reply({ 'response': response, 'error': error }).code(200);
})
})

} catch (e) {
server.log([blueWazuh, 'initialize', 'error'], 'Could not read the mapping file.');
server.log([blueWazuh, 'initialize', 'error'], 'Path: ' + KIBANA_FIELDS_FILE);
server.log([blueWazuh, 'initialize', 'error'], 'Exception: ' + e);
};

client.update({
index: '.kibana',
type: 'index-pattern',
id: index_pattern,
body: {
doc: {
fields: kibana_fields_data.wazuh_alerts
}
}
}, function (error, response) {
reply({ 'response': response, 'error': error }).code(200);
})

};

//Server routes
Expand Down

0 comments on commit a43edc2

Please sign in to comment.