- +
@@ -55,13 +81,14 @@ diff --git a/public/templates/directives/kibana-searchbar-template.html b/public/templates/directives/kibana-searchbar-template.html index 0c6ecc38c..b7ec2cf9a 100644 --- a/public/templates/directives/kibana-searchbar-template.html +++ b/public/templates/directives/kibana-searchbar-template.html @@ -6,7 +6,7 @@
-
+
-
+
@@ -28,7 +28,7 @@
-
+
diff --git a/public/templates/directives/kibana-visualization-value-template.html b/public/templates/directives/kibana-visualization-value-template.html index 4760c5b47..35014abe5 100644 --- a/public/templates/directives/kibana-visualization-value-template.html +++ b/public/templates/directives/kibana-visualization-value-template.html @@ -15,7 +15,7 @@
-
+
@@ -27,7 +27,7 @@
-
+
diff --git a/public/templates/manager-status.html b/public/templates/manager-status.html index eb0fdb831..29545a71d 100644 --- a/public/templates/manager-status.html +++ b/public/templates/manager-status.html @@ -48,7 +48,7 @@
-

Manager information

+

Manager information

Version

@@ -88,7 +88,7 @@ -

Last registered agent

+

Last registered agent

Name

diff --git a/public/templates/overview-audit.html b/public/templates/overview-audit.html index 7d89e8699..aa6b71e07 100644 --- a/public/templates/overview-audit.html +++ b/public/templates/overview-audit.html @@ -1,7 +1,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/public/templates/overview-fim.html b/public/templates/overview-fim.html index 02dd5356d..b4ce94e07 100644 --- a/public/templates/overview-fim.html +++ b/public/templates/overview-fim.html @@ -1,7 +1,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -27,19 +27,19 @@
- + - + - + @@ -50,7 +50,7 @@ Events over time - @@ -61,14 +61,14 @@ Top user owners - Top group owners - + @@ -77,7 +77,7 @@ - + - + diff --git a/public/templates/overview-general.html b/public/templates/overview-general.html index 76037ee3c..969b0a327 100644 --- a/public/templates/overview-general.html +++ b/public/templates/overview-general.html @@ -1,7 +1,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -108,7 +108,7 @@
-
+
diff --git a/public/templates/overview-oscap.html b/public/templates/overview-oscap.html index 10595234d..65017368d 100644 --- a/public/templates/overview-oscap.html +++ b/public/templates/overview-oscap.html @@ -1,7 +1,7 @@ - + @@ -13,7 +13,7 @@ - + @@ -22,7 +22,7 @@
- + diff --git a/public/templates/overview-pci.html b/public/templates/overview-pci.html index c7bb1049d..887d68d7a 100644 --- a/public/templates/overview-pci.html +++ b/public/templates/overview-pci.html @@ -1,7 +1,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -28,7 +28,7 @@ -

PCI DSS Requirement: {{tab.title}}

+

PCI DSS Requirement: {{tab.title}}

diff --git a/public/templates/overview-pm.html b/public/templates/overview-pm.html index 3020dc777..4c70195a1 100644 --- a/public/templates/overview-pm.html +++ b/public/templates/overview-pm.html @@ -1,7 +1,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/public/templates/ruleset-rules.html b/public/templates/ruleset-rules.html index 116f5afe2..64fb42284 100644 --- a/public/templates/ruleset-rules.html +++ b/public/templates/ruleset-rules.html @@ -150,7 +150,7 @@ -

Groups

+

Groups

{{ group }}

@@ -160,7 +160,7 @@ -

PCI DSS

+

PCI DSS

{{ pci }}

@@ -170,7 +170,7 @@ -

Extra settings

+

Extra settings

{{detailk}}

diff --git a/public/templates/settings.html b/public/templates/settings.html index 16fbe0782..390b7e266 100644 --- a/public/templates/settings.html +++ b/public/templates/settings.html @@ -26,7 +26,7 @@ -

Welcome to the Wazuh App for Kibana 5

+

Welcome to the Wazuh App for Kibana 5

The Wazuh App brings together a new and useful web interface for managing and monitoring your Wazuh infrastructure. You can check agent status, alert evolution, most recent events, popular alerts, top alert groups, etc. You can also display configuration and logs of the manager.

In addition, make use of any or all of these extensions:

@@ -45,7 +45,7 @@ -

Wazuh App: API configuration

+

Wazuh App: API configuration

Manager

@@ -106,7 +106,7 @@ -

Wazuh App: Extensions

+

Wazuh App: Extensions

Enable or disable extensions according to your needs. The extension includes: Panels, discover and dashboards, for agents / overview.

@@ -154,7 +154,7 @@ -

About

+

About

The Wazuh App brings together a new and useful web interface for managing and monitoring your Wazuh infrastructure. You can check agent status, alert evolution, most recent events, popular alerts, top alert groups, etc. You can also display configuration and logs of the manager.

In addition, make use of any or all of these extensions:

@@ -172,7 +172,7 @@ -

Version

+

Version

App version

{{appInfo["app-version"]}}

diff --git a/server/api/wazuh-api.js b/server/api/wazuh-api.js index 229a5f193..447914327 100644 --- a/server/api/wazuh-api.js +++ b/server/api/wazuh-api.js @@ -39,7 +39,7 @@ module.exports = function (server, options) { //Handlers - Generic var getConfig = function (callback) { - elasticRequest.callWithInternalUser('search', { index: '.kibana', type: 'wazuh-configuration', q: 'active:true'}).then( + elasticRequest.callWithInternalUser('search', { index: '.wazuh', type: 'wazuh-configuration', q: 'active:true'}).then( function (data) { if (data.hits.total == 1) { callback({ 'user': data.hits.hits[0]._source.api_user, 'password': new Buffer(data.hits.hits[0]._source.api_password, 'base64').toString("ascii"), 'url': data.hits.hits[0]._source.url, 'port': data.hits.hits[0]._source.api_port, 'insecure': data.hits.hits[0]._source.insecure, 'manager': data.hits.hits[0]._source.manager, 'extensions': data.hits.hits[0]._source.extensions }); @@ -52,7 +52,7 @@ module.exports = function (server, options) { }; var getAPI_entries = function (req,reply) { - elasticRequest.callWithRequest(req, 'search', { index: '.kibana', type: 'wazuh-configuration'}).then( + elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-configuration'}).then( function (data) { reply(data.hits.hits); }, function (data, error) { @@ -61,7 +61,7 @@ module.exports = function (server, options) { }; var deleteAPI_entries = function (req,reply) { - elasticRequest.callWithRequest(req, 'delete', { index: '.kibana', type: 'wazuh-configuration', id: req.params.id}).then( + elasticRequest.callWithRequest(req, 'delete', { index: '.wazuh', type: 'wazuh-configuration', id: req.params.id}).then( function (data) { reply(data); }, function (data, error) { @@ -71,15 +71,15 @@ module.exports = function (server, options) { var setAPI_entry_default = function (req,reply) { // Searching for previous default - elasticRequest.callWithRequest(req, 'search', { index: '.kibana', type: 'wazuh-configuration', q: 'active:true'}).then( + elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-configuration', q: 'active:true'}).then( function (data) { if (data.hits.total == 1) { // Setting off previous default var idPreviousActive = data.hits.hits[0]._id; - elasticRequest.callWithRequest(req, 'update', { index: '.kibana', type: 'wazuh-configuration', id: idPreviousActive, body: {doc: {"active": "false"}} }).then( + elasticRequest.callWithRequest(req, 'update', { index: '.wazuh', type: 'wazuh-configuration', id: idPreviousActive, body: {doc: {"active": "false"}} }).then( function () { // Set new default - elasticRequest.callWithRequest(req, 'update', { index: '.kibana', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then( + elasticRequest.callWithRequest(req, 'update', { index: '.wazuh', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then( function () { reply({ 'statusCode': 200, 'message': 'ok' }); }, function (error) { @@ -90,7 +90,7 @@ module.exports = function (server, options) { }); }else{ // Set new default - elasticRequest.callWithRequest(req, 'update', { index: '.kibana', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then( + elasticRequest.callWithRequest(req, 'update', { index: '.wazuh', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"active": "true"}} }).then( function () { reply({ 'statusCode': 200, 'message': 'ok' }); }, function (error) { @@ -129,7 +129,7 @@ module.exports = function (server, options) { }; var getExtensions = function (req,reply) { - elasticRequest.callWithRequest(req, 'search', { index: '.kibana', type: 'wazuh-configuration'}).then( + elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-configuration'}).then( function (data) { reply(data.hits.hits); }, function (data, error) { @@ -142,7 +142,7 @@ module.exports = function (server, options) { var extension = {}; extension[req.params.extensionName] = (req.params.extensionValue == "true") ? true : false; - elasticRequest.callWithRequest(req, 'update',{ index: '.kibana', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"extensions" : extension}} }).then( + elasticRequest.callWithRequest(req, 'update',{ index: '.wazuh', type: 'wazuh-configuration', id: req.params.id, body: {doc: {"extensions" : extension}} }).then( function () { reply({ 'statusCode': 200, 'message': 'ok' }); }, function (error) { @@ -344,7 +344,7 @@ module.exports = function (server, options) { var settings = { 'api_user': req.payload.user, 'api_password': req.payload.password, 'url': req.payload.url, 'api_port': req.payload.port , 'insecure': req.payload.insecure, 'component' : 'API', 'active' : req.payload.active, 'manager' : req.payload.manager, 'extensions' : req.payload.extensions}; - elasticRequest.callWithRequest(req, 'index', { index: '.kibana', type: 'wazuh-configuration', body: settings, refresh: true }) + elasticRequest.callWithRequest(req, 'index', { index: '.wazuh', type: 'wazuh-configuration', body: settings, refresh: true }) .then(function (response) { reply({ 'statusCode': 200, 'message': 'ok', 'response' : response }); }, function (error) { diff --git a/server/api/wazuh-elastic.js b/server/api/wazuh-elastic.js index 04e721072..028a30c07 100644 --- a/server/api/wazuh-elastic.js +++ b/server/api/wazuh-elastic.js @@ -120,6 +120,21 @@ module.exports = function (server, options) { }); }; + var getSetupInfo = function (req, reply) { + elasticRequest.callWithRequest(req, 'search', { index: '.wazuh', type: 'wazuh-setup' }) + .then(function (data) { + if (data.hits.total == 0) { + reply({ 'statusCode': 200, 'data': '' }); + } + else { + reply({ 'statusCode': 200, 'data': data.hits.hits[0]._source }); + } + }, function (error) { + console.log(error); + reply({ 'statusCode': 500, 'error': 9, 'message': 'Could not get data from elasticsearch' }).code(500); + }); + }; + var putWazuhAlertsPattern = function (req, reply) { try { @@ -313,6 +328,17 @@ module.exports = function (server, options) { handler: getLastField }); + /* + * GET /api/wazuh-elastic/setup + * Return Wazuh Appsetup info + * + **/ + server.route({ + method: 'GET', + path: '/api/wazuh-elastic/setup', + handler: getSetupInfo + }); + /* * PUT /api/wazuh-elastic/wazuh-pattern * Set wazuh index pattern diff --git a/server/startup/initialize.js b/server/startup/initialize.js index f642c8c96..8151f6c55 100644 --- a/server/startup/initialize.js +++ b/server/startup/initialize.js @@ -47,7 +47,7 @@ module.exports = function (server, options) { var setup_info = {"name" : "Wazuh App", "app-version": packageJSON.version, "revision": packageJSON.revision, "installationDate": new Date().toISOString() }; if(type == "install"){ - elasticRequest.callWithInternalUser('create', { index: ".kibana", type: 'wazuh-setup', id: 1, body: setup_info }).then( + elasticRequest.callWithInternalUser('create', { index: ".wazuh", type: 'wazuh-setup', id: 1, body: setup_info }).then( function () { server.log([blueWazuh, 'initialize', 'info'], 'Wazuh set up info inserted'); }, function () { @@ -56,13 +56,23 @@ module.exports = function (server, options) { } if(type == "upgrade"){ - elasticRequest.callWithInternalUser('update', { index: ".kibana", type: 'wazuh-setup', id: 1, body: {doc: setup_info}}).then( + elasticRequest.callWithInternalUser('update', { index: ".wazuh", type: 'wazuh-setup', id: 1, body: {doc: setup_info}}).then( function () { server.log([blueWazuh, 'initialize', 'info'], 'Wazuh set up info updated'); }, function () { server.log([blueWazuh, 'initialize', 'error'], 'Could not upgrade Wazuh set up info'); }); } + + if(type == "migration"){ + elasticRequest.callWithInternalUser('create', { index: ".wazuh", type: 'wazuh-setup', id: 1, body: setup_info }).then( + function () { + server.log([blueWazuh, 'initialize', 'info'], 'Wazuh set up info inserted'); + }, function (error) { + server.log([blueWazuh, 'initialize', 'error'], 'Could not insert Wazuh set up info'); + }); + + } }; @@ -122,7 +132,7 @@ module.exports = function (server, options) { var setDefaultKibanaSettings = function () { server.log([blueWazuh, 'initialize', 'info'], 'Setting Kibana default values: Index pattern, time picker and metaFields...'); - uiSettings.setMany(req,{'defaultIndex':'wazuh-alerts-*', 'timepicker:timeDefaults':'{ \"from\": \"now-24h\", \"to\": \"now\", \"mode\": \"quick\"}','metaFields':[]}) + uiSettings.setMany(req,{'defaultIndex':'wazuh-alerts-*', 'timepicker:timeDefaults':'{ \"from\": \"now-24h\", \"to\": \"now\", \"mode\": \"quick\"}','metaFields':['_source']}) .then(function (data) { server.log([blueWazuh, 'initialize', 'info'], 'Kibana default values set'); }).catch(function (data) { @@ -131,6 +141,32 @@ module.exports = function (server, options) { }); }; + var importConfigurationFromKibana = function () { + elasticRequest.callWithInternalUser('search',{ index: '.kibana', type: 'wazuh-configuration'}) + .then(function (data) { + if (data.hits.total > 0) { + var body = ''; + data.hits.hits.forEach(function (element) { + body += '{ "index": { "_index": ".wazuh", "_type": "wazuh-configuration", "_id": "'+element._id+'" } }\n'; + body += JSON.stringify(element._source) + "\n"; + }); + elasticRequest.callWithInternalUser('bulk',{ + index: '.wazuh', + body: body + }).then(function () { + elasticRequest.callWithInternalUser('indices.refresh',{ index: '.wazuh' }); + server.log([blueWazuh, 'initialize', 'info'], 'wazuh-configuration documents were successfully imported.'); + }, function (err) { + server.log([blueWazuh, 'initialize', 'error'], 'Error importing wazuh-configuration documents into .wazuh index. Bulk request failed.'); + }); + } + else{ + server.log([blueWazuh, 'initialize', 'info'], 'No wazuh-configuration documents were found in .kibana index.'); + } + }, function () { + server.log([blueWazuh, 'initialize', 'error'], 'wazuh-configuration documents could not be imported from .kibana index to .wazuh index.'); + }); + } // Configure Kibana status: Index pattern, default index pattern, default time, import dashboards. var configureKibana = function (type) { @@ -144,6 +180,10 @@ module.exports = function (server, options) { importObjects(); } + if(type == "migration"){ + importConfigurationFromKibana(); + importObjects(); + } // Save Setup Info saveSetupInfo(type); @@ -152,13 +192,19 @@ module.exports = function (server, options) { // Init function. Check for "wazuh-setup" document existance. var init = function () { - elasticRequest.callWithInternalUser('get', { index: ".kibana", type: "wazuh-setup", id: "1" }).then( + elasticRequest.callWithInternalUser('get', { index: ".wazuh", type: "wazuh-setup", id: "1" }).then( function (data) { server.log([blueWazuh, 'initialize', 'info'], 'Wazuh-setup document already exists. Proceed to upgrade.'); configure("upgrade"); }, function (data) { server.log([blueWazuh, 'initialize', 'info'], 'Wazuh-setup document does not exist. Initializating configuration...'); - configure("install"); + elasticRequest.callWithInternalUser('get', { index: ".kibana", type: "wazuh-setup", id: "1" }).then( + function (result) { + configure("migration"); + }, function () { + configure("install"); + } + ); } ); }; diff --git a/server/wazuh-monitoring.js b/server/wazuh-monitoring.js index 322b44049..342178391 100644 --- a/server/wazuh-monitoring.js +++ b/server/wazuh-monitoring.js @@ -207,7 +207,7 @@ module.exports = function (server, options) { // Get API configuration from elastic and callback to loadCredentials var getConfig = function (callback) { - elasticRequest.callWithInternalUser('search',{ index: '.kibana', type: 'wazuh-configuration'}) + elasticRequest.callWithInternalUser('search',{ index: '.wazuh', type: 'wazuh-configuration'}) .then(function (data) { if (data.hits.total > 0) { callback(data.hits);