2016-09-16 12:35:56 +00:00
|
|
|
var app = require('ui/modules').get('app/wazuh', []);
|
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
app.controller('overviewGeneralController', function ($scope, DataFactory, genericReq, $mdToast, errlog) {
|
2016-09-16 12:35:56 +00:00
|
|
|
//Initialisation
|
|
|
|
$scope.load = true;
|
2016-09-16 16:51:42 +00:00
|
|
|
$scope.$parent.state.setOverviewState('general');
|
2016-11-09 19:10:48 +00:00
|
|
|
$scope.defaultManager = $scope.$parent.state.getDefaultManager().name;
|
2016-09-17 20:38:31 +00:00
|
|
|
$scope.stats = [];
|
|
|
|
|
|
|
|
//Print Error
|
|
|
|
var printError = function (error) {
|
|
|
|
$mdToast.show({
|
|
|
|
template: '<md-toast>' + error.html + '</md-toast>',
|
|
|
|
position: 'bottom left',
|
|
|
|
hideDelay: 5000,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
//Functions
|
|
|
|
$scope.setTimer = function (time) {
|
2016-09-22 12:02:46 +00:00
|
|
|
$scope.timerFilterValue = time;
|
2016-09-17 20:38:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
var load_tops = function () {
|
|
|
|
var daysAgo = 1;
|
2016-09-20 18:07:07 +00:00
|
|
|
if ($scope.timerFilterValue == "24h") {
|
|
|
|
daysAgo = 1;
|
|
|
|
} else if ($scope.timerFilterValue == "7d") {
|
|
|
|
daysAgo = 7;
|
|
|
|
} else if ($scope.timerFilterValue == "30d") {
|
|
|
|
daysAgo = 30;
|
2016-09-20 08:55:43 +00:00
|
|
|
} else {
|
2016-09-20 18:07:07 +00:00
|
|
|
daysAgo = 1;
|
2016-09-20 08:55:43 +00:00
|
|
|
}
|
2016-09-20 18:07:07 +00:00
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
var date = new Date();
|
|
|
|
date.setDate(date.getDate() - daysAgo);
|
|
|
|
var timeAgo = date.getTime();
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/srcuser/' + timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.topsrcuser = (data.data != "") ? data.data : "(no data)";
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/srcip/' + timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.topsrcip = (data.data != "") ? data.data : "(no data)";
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/rule.groups/' + timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.topgroup = (data.data != "") ? data.data : "(no data)";
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/rule.PCI_DSS/' + timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.toppci = (data.data != "") ? data.data : "(no data)";
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-09-17 20:38:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//Load
|
2016-09-20 08:55:43 +00:00
|
|
|
try {
|
2016-09-22 12:12:53 +00:00
|
|
|
$scope.setTimer($scope.$parent.timeFilter);
|
2016-09-20 08:55:43 +00:00
|
|
|
load_tops();
|
|
|
|
} catch (e) {
|
|
|
|
$mdToast.show({
|
|
|
|
template: '<md-toast> Unexpected exception loading controller </md-toast>',
|
|
|
|
position: 'bottom left',
|
|
|
|
hideDelay: 5000,
|
|
|
|
});
|
|
|
|
errlog.log('Unexpected exception loading controller', e);
|
|
|
|
}
|
2016-09-17 20:38:31 +00:00
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
// Timer filter watch
|
|
|
|
var loadWatch = $scope.$watch(function () {
|
2016-09-17 20:38:31 +00:00
|
|
|
return $scope.$parent.timeFilter;
|
|
|
|
}, function () {
|
|
|
|
$scope.setTimer($scope.$parent.timeFilter);
|
2016-09-20 08:55:43 +00:00
|
|
|
load_tops();
|
2016-09-17 20:38:31 +00:00
|
|
|
});
|
2016-09-20 08:55:43 +00:00
|
|
|
|
2016-09-17 20:38:31 +00:00
|
|
|
|
|
|
|
//Destroy
|
|
|
|
$scope.$on("$destroy", function () {
|
|
|
|
$scope.stats.length = 0;
|
2016-09-20 08:55:43 +00:00
|
|
|
loadWatch();
|
2016-09-17 20:38:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
app.controller('overviewFimController', function ($scope, DataFactory, genericReq, $mdToast, errlog) {
|
2016-09-17 20:38:31 +00:00
|
|
|
//Initialisation
|
|
|
|
$scope.load = true;
|
|
|
|
$scope.$parent.state.setOverviewState('fim');
|
2016-11-09 19:10:48 +00:00
|
|
|
$scope.defaultManager = $scope.$parent.state.getDefaultManager().name;
|
2016-09-20 08:55:43 +00:00
|
|
|
$scope.stats = [];
|
2016-09-16 12:35:56 +00:00
|
|
|
|
|
|
|
//Print Error
|
|
|
|
var printError = function (error) {
|
|
|
|
$mdToast.show({
|
|
|
|
template: '<md-toast>' + error.html + '</md-toast>',
|
|
|
|
position: 'bottom left',
|
|
|
|
hideDelay: 5000,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
//Functions
|
|
|
|
$scope.setTimer = function (time) {
|
2016-09-22 12:02:46 +00:00
|
|
|
$scope.timerFilterValue = time;
|
2016-09-16 12:35:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
var load_tops = function () {
|
2016-09-20 18:07:07 +00:00
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
var daysAgo = 1;
|
2016-09-20 18:07:07 +00:00
|
|
|
if ($scope.timerFilterValue == "24h") {
|
|
|
|
daysAgo = 1;
|
|
|
|
} else if ($scope.timerFilterValue == "7d") {
|
|
|
|
daysAgo = 7;
|
|
|
|
} else if ($scope.timerFilterValue == "30d") {
|
|
|
|
daysAgo = 30;
|
2016-09-20 08:55:43 +00:00
|
|
|
} else {
|
2016-09-20 18:07:07 +00:00
|
|
|
daysAgo = 1;
|
2016-09-20 08:55:43 +00:00
|
|
|
}
|
2016-09-20 18:07:07 +00:00
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
var date = new Date();
|
|
|
|
date.setDate(date.getDate() - daysAgo);
|
|
|
|
var timeAgo = date.getTime();
|
2016-09-20 14:16:44 +00:00
|
|
|
|
|
|
|
// Top fields
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/AgentName/'+timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.topagent = (data.data != "") ? data.data : "(no data)";
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/SyscheckFile.perm_before/'+timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.toppermissions = (data.data != "") ? data.data : "(no data)";
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/rule.PCI_DSS/' + timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.toppci = (data.data != "") ? data.data : "(no data)";
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/SyscheckFile.path/' + timeAgo + '/location/syscheck')
|
2016-09-22 11:08:59 +00:00
|
|
|
.then(function (data) {
|
2016-09-29 12:52:43 +00:00
|
|
|
$scope.topfile = (data.data != "") ? data.data : "(no data)";
|
2016-09-22 11:08:59 +00:00
|
|
|
}, printError);
|
2016-09-20 14:16:44 +00:00
|
|
|
|
|
|
|
// Last fields
|
|
|
|
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/last/'+$scope.defaultManager+'/SyscheckFile/SyscheckFile.event/modified')
|
2016-09-20 14:16:44 +00:00
|
|
|
.then(function (data) {
|
|
|
|
$scope.last_file_changed = (data.data != "") ? data.data.path : "(no data)";
|
|
|
|
}, printError);
|
|
|
|
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/last/'+$scope.defaultManager+'/SyscheckFile/SyscheckFile.event/added')
|
2016-09-20 14:16:44 +00:00
|
|
|
.then(function (data) {
|
|
|
|
$scope.last_file_added = (data.data != "") ? data.data.path : "(no data)";
|
|
|
|
}, printError);
|
|
|
|
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/last/'+$scope.defaultManager+'/SyscheckFile/SyscheckFile.event/deleted')
|
2016-09-20 14:16:44 +00:00
|
|
|
.then(function (data) {
|
|
|
|
$scope.last_file_deleted = (data.data != "") ? data.data.path : "(no data)";
|
|
|
|
}, printError);
|
|
|
|
|
2016-09-16 12:35:56 +00:00
|
|
|
};
|
|
|
|
|
2016-09-22 12:02:46 +00:00
|
|
|
//Load
|
|
|
|
try {
|
2016-09-22 12:12:53 +00:00
|
|
|
$scope.setTimer($scope.$parent.timeFilter);
|
2016-09-22 12:02:46 +00:00
|
|
|
load_tops();
|
|
|
|
} catch (e) {
|
|
|
|
$mdToast.show({
|
|
|
|
template: '<md-toast> Unexpected exception loading controller </md-toast>',
|
|
|
|
position: 'bottom left',
|
|
|
|
hideDelay: 5000,
|
|
|
|
});
|
|
|
|
errlog.log('Unexpected exception loading controller', e);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Timer filter watch
|
|
|
|
var loadWatch = $scope.$watch(function () {
|
|
|
|
return $scope.$parent.timeFilter;
|
|
|
|
}, function () {
|
|
|
|
$scope.setTimer($scope.$parent.timeFilter);
|
|
|
|
load_tops();
|
|
|
|
});
|
|
|
|
|
|
|
|
//Destroy
|
|
|
|
$scope.$on("$destroy", function () {
|
|
|
|
$scope.stats.length = 0;
|
|
|
|
loadWatch();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
app.controller('overviewPMController', function ($scope, DataFactory, genericReq, $mdToast, errlog) {
|
|
|
|
//Initialisation
|
|
|
|
$scope.load = true;
|
|
|
|
$scope.$parent.state.setOverviewState('pm');
|
2016-11-09 19:10:48 +00:00
|
|
|
$scope.defaultManager = $scope.$parent.state.getDefaultManager().name;
|
2016-09-22 12:02:46 +00:00
|
|
|
$scope.stats = [];
|
|
|
|
|
|
|
|
//Print Error
|
|
|
|
var printError = function (error) {
|
|
|
|
$mdToast.show({
|
|
|
|
template: '<md-toast>' + error.html + '</md-toast>',
|
|
|
|
position: 'bottom left',
|
|
|
|
hideDelay: 5000,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
//Functions
|
|
|
|
$scope.setTimer = function (time) {
|
|
|
|
$scope.timerFilterValue = time;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var load_tops = function () {
|
|
|
|
|
|
|
|
var daysAgo = 1;
|
|
|
|
if ($scope.timerFilterValue == "24h") {
|
|
|
|
daysAgo = 1;
|
|
|
|
} else if ($scope.timerFilterValue == "7d") {
|
|
|
|
daysAgo = 7;
|
|
|
|
} else if ($scope.timerFilterValue == "30d") {
|
|
|
|
daysAgo = 30;
|
|
|
|
} else {
|
|
|
|
daysAgo = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
var date = new Date();
|
|
|
|
date.setDate(date.getDate() - daysAgo);
|
|
|
|
var timeAgo = date.getTime();
|
|
|
|
|
|
|
|
// Top fields
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/top/'+$scope.defaultManager+'/AgentName/'+timeAgo)
|
2016-09-20 08:55:43 +00:00
|
|
|
.then(function (data) {
|
2016-09-22 12:02:46 +00:00
|
|
|
$scope.topagent = data.data;
|
2016-09-20 08:55:43 +00:00
|
|
|
}, printError);
|
2016-09-22 12:02:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Last fields
|
|
|
|
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/last/'+$scope.defaultManager+'/title/location/rootcheck')
|
2016-09-22 12:02:46 +00:00
|
|
|
.then(function (data) {
|
|
|
|
$scope.lastEventTitle = (data.data != "") ? data.data : "(no data)";
|
|
|
|
}, printError);
|
|
|
|
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/last/'+$scope.defaultManager+'/AgentName/location/rootcheck')
|
2016-09-22 12:02:46 +00:00
|
|
|
.then(function (data) {
|
|
|
|
$scope.lastEventAgentName = (data.data != "") ? data.data : "(no data)";
|
|
|
|
}, printError);
|
|
|
|
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/last/'+$scope.defaultManager+'/AgentID/location/rootcheck')
|
2016-09-22 12:02:46 +00:00
|
|
|
.then(function (data) {
|
2016-09-28 11:46:52 +00:00
|
|
|
$scope.lastEventAgentID = (data.data != "") ? data.data : "";
|
2016-09-22 12:02:46 +00:00
|
|
|
}, printError);
|
|
|
|
|
2016-11-09 19:10:48 +00:00
|
|
|
genericReq.request('GET', '/api/wazuh-elastic/last/'+$scope.defaultManager+'/AgentIP/location/rootcheck')
|
2016-09-22 12:02:46 +00:00
|
|
|
.then(function (data) {
|
|
|
|
$scope.lastEventAgentIP = (data.data != "") ? data.data : "";
|
|
|
|
}, printError);
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-09-16 12:35:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//Load
|
2016-09-20 08:55:43 +00:00
|
|
|
try {
|
2016-09-22 12:12:53 +00:00
|
|
|
$scope.setTimer($scope.$parent.timeFilter);
|
2016-09-20 08:55:43 +00:00
|
|
|
load_tops();
|
|
|
|
} catch (e) {
|
|
|
|
$mdToast.show({
|
|
|
|
template: '<md-toast> Unexpected exception loading controller </md-toast>',
|
|
|
|
position: 'bottom left',
|
|
|
|
hideDelay: 5000,
|
|
|
|
});
|
|
|
|
errlog.log('Unexpected exception loading controller', e);
|
|
|
|
}
|
2016-09-16 12:35:56 +00:00
|
|
|
|
2016-09-20 08:55:43 +00:00
|
|
|
// Timer filter watch
|
|
|
|
var loadWatch = $scope.$watch(function () {
|
2016-09-16 12:35:56 +00:00
|
|
|
return $scope.$parent.timeFilter;
|
|
|
|
}, function () {
|
|
|
|
$scope.setTimer($scope.$parent.timeFilter);
|
2016-09-20 08:55:43 +00:00
|
|
|
load_tops();
|
2016-09-16 12:35:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
//Destroy
|
|
|
|
$scope.$on("$destroy", function () {
|
|
|
|
$scope.stats.length = 0;
|
2016-09-20 08:55:43 +00:00
|
|
|
loadWatch();
|
2016-09-16 12:35:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|