diff --git a/package.json b/package.json index 6f631825c..60ef3b3f4 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,11 @@ "wazuh", "ossec" ], + "agents": { + "add": true, + "delete": true, + "restart": true + }, "author": "Wazuh, Inc", "license": "GPL-2.0", "repository": { diff --git a/public/controllers/agentsPreview.js b/public/controllers/agentsPreview.js index 5d775d75f..f6d594c74 100644 --- a/public/controllers/agentsPreview.js +++ b/public/controllers/agentsPreview.js @@ -43,6 +43,11 @@ app.controller('agentsPreviewController', function ($scope, $mdDialog, DataFacto 'name': '', 'ip': '' }; $scope.newAgentKey = ''; + $scope.permissions = { + 'add': false, + 'delete':false, + 'restart': false + }; const notify = new Notifier({location: 'Agents - Preview'}); @@ -264,6 +269,15 @@ app.controller('agentsPreviewController', function ($scope, $mdDialog, DataFacto $mdDialog.hide('#newAgentDialog'); }; + var getAgentsPermissions = function () { + genericReq.request('GET', '/api/wazuh-api/agents/permissions') + .then(function (data, status) { + $scope.permissions = data; + }, function (data, status) { + notify.error("Error while loading agents permissions."); + }) + } + getAgentsPermissions(); var load = function () { $scope.newAgent = { 'name': '', 'ip': '' diff --git a/public/templates/agents-preview.html b/public/templates/agents-preview.html index 16a65daa8..dfea34e2d 100644 --- a/public/templates/agents-preview.html +++ b/public/templates/agents-preview.html @@ -127,15 +127,15 @@
- + add - + refresh - + delete
diff --git a/server/api/wazuh-api.js b/server/api/wazuh-api.js index 447914327..4f133fb32 100644 --- a/server/api/wazuh-api.js +++ b/server/api/wazuh-api.js @@ -12,7 +12,7 @@ module.exports = function (server, options) { var package_info = {}; const package_file = '../../package.json'; var appVersion = ""; - + var permissions = {} // Read Wazuh App package file try { package_info = JSON.parse(fs.readFileSync(path.resolve(__dirname, package_file), 'utf8')); @@ -272,7 +272,20 @@ module.exports = function (server, options) { }; - + + var getAgentsPermissions = function (req, reply) { + try { + package_info = JSON.parse(fs.readFileSync(path.resolve(__dirname, package_file), 'utf8')); + permissions = package_info.agents; + reply(permissions); + } catch (e) { + server.log([blueWazuh, 'initialize', 'error'], 'Could not read the Wazuh package file.'); + server.log([blueWazuh, 'initialize', 'error'], 'Path: ' + package_file); + server.log([blueWazuh, 'initialize', 'error'], 'Exception: ' + e); + reply({ 'statusCode': 500, 'error': 8, 'message': 'Could not load agents permissions' }).code(500); + }; + + } //Handlers - Route request @@ -530,6 +543,17 @@ module.exports = function (server, options) { path: '/api/wazuh-api/pci/{requirement}', handler: getPciRequirement }); + + /* + * GET /api/wazuh-api/agents/permissions + * Return the permissions on agents + * + **/ + server.route({ + method: 'GET', + path: '/api/wazuh-api/agents/permissions', + handler: getAgentsPermissions + }); /* * POST /api/wazuh/debug