branch develop updated (a680e7f -> 37e435d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository mum. See http://git.chorem.org/mum.git from a680e7f scan: can now add a host without nmap scan (generating an empty nmap_result) + hostpage: table is now hidden if no hosts are in the db new 42f139e hostpage: unit of value visible on table new 37e435d click on a link which is the current URL will now refresh the page + completing/harmonizing the comments The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 37e435d4cb4cdb16ce92e663f69911f1d74d1c66 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 8 17:58:46 2015 +0200 click on a link which is the current URL will now refresh the page + completing/harmonizing the comments commit 42f139eb058b718aa9f5824130bbe80e4b259a6f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 8 10:54:17 2015 +0200 hostpage: unit of value visible on table Summary of changes: app/module_loader.py | 76 +++++++++++++++++++++++++-- app/modules/monitoring_modules/load.py | 2 +- app/modules/storage_modules/shelve_db.py | 88 ++++++++++++++++++-------------- app/mum.py | 27 ++++------ app/process_monitoring.py | 8 +++ static/js/controllers/headCtrl.js | 3 -- static/js/controllers/hostPageCtrl.js | 80 +++++++++++++++++------------ static/js/mumApp.js | 65 +++++------------------ views/hostpage.html | 2 +- views/notifications.html | 2 +- views/profile.html | 2 +- 11 files changed, 204 insertions(+), 151 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 42f139eb058b718aa9f5824130bbe80e4b259a6f Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 8 10:54:17 2015 +0200 hostpage: unit of value visible on table --- app/modules/monitoring_modules/load.py | 2 +- app/mum.py | 6 +-- static/js/controllers/headCtrl.js | 3 -- static/js/controllers/hostPageCtrl.js | 77 ++++++++++++++++++++-------------- views/hostpage.html | 2 +- 5 files changed, 50 insertions(+), 40 deletions(-) diff --git a/app/modules/monitoring_modules/load.py b/app/modules/monitoring_modules/load.py index 29743aa..a85427f 100644 --- a/app/modules/monitoring_modules/load.py +++ b/app/modules/monitoring_modules/load.py @@ -3,7 +3,7 @@ __author__ = 'aguilbaud' compatible_os = ['linux', 'unix'] block = "hardware" -unit = "15 min load average" +unit = "" def check(conn, db, mnce): diff --git a/app/mum.py b/app/mum.py index 321373f..2a9e06a 100755 --- a/app/mum.py +++ b/app/mum.py @@ -134,7 +134,9 @@ def receive(ws): db = ml.get_db() ws.send(json.dumps({"RES_GET_HOSTS": db.get_hosts()})) elif code == "GET_HOST_INFO": # asked from hostpage - ws.send(json.dumps({"RES_INFO_HOST": ml.get_host_info(msg["GET_HOST_INFO"])})) + dict_host_info = ml.get_host_info(msg["GET_HOST_INFO"]) + dict_host_info['loaded_moni_mod'] = ml.get_info_mod_monitoring() + ws.send(json.dumps({"RES_INFO_HOST": dict_host_info})) elif code == "REM_HOST": ml.remove_host(msg["REM_HOST"]) ws.send(json.dumps({"RES_REM_HOST": True})) @@ -147,8 +149,6 @@ def receive(ws): ws.send(msg) elif code == "GET_LOADED_CONN_MOD": # asked from hostpage, at the connection configuration ws.send(json.dumps({"RES_GET_LOADED_CONN_MOD": ml.get_info_mod_conn()})) - elif code == "GET_LOADED_MONI_MOD": # asked from hostpage, at the block activation conf - ws.send(json.dumps({"RES_GET_LOADED_MONI_MOD": ml.get_info_mod_monitoring()})) elif code == "GET_LOADED_NOTIF_MOD": # asekd from notification parameters page ws.send(json.dumps({"RES_GET_LOADED_NOTIF_MOD": ml.get_info_mod_notification()})) elif code == "GET_ALL_SUBSCRIPTIONS": # asekd from notification parameters page diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index d57023e..4e63e29 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -47,9 +47,6 @@ mumApp.controller('headCtrl', function($scope, $rootScope, toastr, $interval, $r case "RES_GET_LOADED_CONN_MOD": $rootScope.$broadcast("resGetLoadedConnMod", obj[key]); break; - case "RES_GET_LOADED_MONI_MOD": - $rootScope.$broadcast("resGetLoadedMoniMod", obj[key]); - break; case "RES_GET_LOADED_NOTIF_MOD": $rootScope.$broadcast("resGetLoadedNotifMod", obj[key]); break; diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 2cd251a..f69c0b3 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -7,7 +7,7 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar // asks for host informations $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_HOST_INFO": $routeParams.param})); - $scope.items = [];/* result of get_host_informations => + $scope.items = {};/* result of get_host_informations => { "interventions":list, "detected": @@ -33,6 +33,15 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar }, "custom_infos":val "compatible_os_list": [os1, os2, ...] + "loaded_moni_mod": + { + mod_name: + { + 'compatible_os': [val1, val2, ...], => a list containing the compatibles os + 'unit': val, => the unit type of return ('%', 'bool' or other) + 'block': val, => the monitoring block of the module + } + } } */ $scope.update_os_name = function(){ @@ -42,6 +51,14 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'update_os_name', 'args': args}})); }; + $scope.get_unit = function(mod_name){ + res = ''; + if($scope.items.loaded_moni_mod[mod_name].unit != 'bool'){ + res = $scope.items.loaded_moni_mod[mod_name].unit; + } + return res; + } + $scope.$on("resCall", function (event, args) { if(args.func == 'update_os_name'){ $route.reload(); @@ -167,7 +184,8 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar block_args: function(){ return {'addr_host' : $scope.addr_host, 'activated_mod': $scope.items['activated_monitoring'], - 'os_host': $scope.items.detected.nmap.os}; + 'os_host': $scope.items.detected.nmap.os, + 'loaded_moni_mod': $scope.items.loaded_moni_mod}; } } }); @@ -448,16 +466,18 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal 'activated_mod':{ mod_name: bool }, - 'os_host': val */ - - $scope.loaded_moni_mods = {}; /* { - mod_name: - { - 'compatible_os': [val1, val2, ...], => a list containing the compatibles os - 'unit': val, => the unit type of return ('%', 'bool' or other) - 'block': val, => the monitoring block of the module - } - } */ + 'os_host': val, + "loaded_moni_mod": + { + mod_name: + { + 'compatible_os': [val1, val2, ...], => a list containing the compatibles os + 'unit': val, => the unit type of return ('%', 'bool' or other) + 'block': val, => the monitoring block of the module + } + } + } + */ $scope.blocks = {}; /* block_name: @@ -470,26 +490,19 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal } */ - $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOADED_MONI_MOD": ""})); - - $scope.$on("resGetLoadedMoniMod", function (event, args) { - $scope.$apply(function(){ - $scope.loaded_moni_mods = args; - for(mod in args){ - var activated = false; - var block = args[mod]['block']; - if($scope.block_args['activated_mod'].hasOwnProperty(mod)) { // if the module is known by the host - if($scope.block_args['activated_mod'][mod]){ // if the module is activated - activated = true; - } - } - if(!$scope.blocks.hasOwnProperty(block)){ - $scope.blocks[block] = []; - } - $scope.blocks[block][$scope.blocks[block].length] = {modname: mod, activated: activated}; + for(mod in $scope.block_args.loaded_moni_mod){ + var activated = false; + var block = $scope.block_args.loaded_moni_mod[mod]['block']; + if($scope.block_args.activated_mod.hasOwnProperty(mod)) { // if the module is known by the host + if($scope.block_args.activated_mod[mod]){ // if the module is activated + activated = true; } - }); - }); + } + if(!$scope.blocks.hasOwnProperty(block)){ + $scope.blocks[block] = []; + } + $scope.blocks[block][$scope.blocks[block].length] = {modname: mod, activated: activated}; + } $scope.select_all = function(block){ for(mod in block){ @@ -504,7 +517,7 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal }; $scope.is_not_compatible = function(modname){ - return $scope.loaded_moni_mods[modname]['compatible_os'].lastIndexOf($scope.block_args.os_host) < 0; + return $scope.block_args.loaded_moni_mod[modname].compatible_os.lastIndexOf($scope.block_args.os_host) < 0; }; $scope.ok = function () { diff --git a/views/hostpage.html b/views/hostpage.html index cee03c9..45330fe 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -24,7 +24,7 @@ class={{item.state}} ng-show="items.activated_monitoring[itemname]"> <td>{{itemname}}</td> - <td>{{item.value}}</td> + <td>{{item.value}} {{get_unit(itemname)}}</td> <td>{{item.state}}</td> <td>{{item.date.split('.')[0]}}</td> <td><button type="button" class="btn btn-primary btn-xs" -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 37e435d4cb4cdb16ce92e663f69911f1d74d1c66 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Apr 8 17:58:46 2015 +0200 click on a link which is the current URL will now refresh the page + completing/harmonizing the comments --- app/module_loader.py | 76 +++++++++++++++++++++++++-- app/modules/storage_modules/shelve_db.py | 88 ++++++++++++++++++-------------- app/mum.py | 21 +++----- app/process_monitoring.py | 8 +++ static/js/controllers/hostPageCtrl.js | 5 +- static/js/mumApp.js | 65 +++++------------------ views/notifications.html | 2 +- views/profile.html | 2 +- 8 files changed, 155 insertions(+), 112 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index 7a5fe61..6841807 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -63,17 +63,21 @@ class ModuleLoader: def stop_monitoring(): process_monitoring.end = True - @staticmethod - def run_nmap_detection(param, opt, db, ws, list_mod_conn, dict_mod_monitoring): + def run_nmap_detection(self, param, opt, ws): """ Instanciates the nmap_detection module from detection_modules, and runs the detection. :param param: parameter to put in nmap command. can be a hostname, a ip address or a ip range - :param db: an instance of a database module + :param opt: a string containing the options specified for the nmap command :param ws: a websocket connection :return: a list containing the IP adresses checked """ + nmap_mod = __import__("modules.nmap_detection", fromlist=modules) - nmap_mod_instance = getattr(nmap_mod, "nmap_detection")(opt, db, ws, list_mod_conn, dict_mod_monitoring, + nmap_mod_instance = getattr(nmap_mod, "nmap_detection")(opt, + self.db, + ws, + self.get_conection_modules_list(), + self.get_monitoring_modules_list(), modules.HostNotFoundException) try: if re.search('^\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?[.]\d{1,3}(-\d{1,3})?$', param): @@ -87,6 +91,11 @@ class ModuleLoader: return None def create_empty_host(self, addr_host): + """ + If for some reason the nmap scan is impossible, it is possible to add a host without preliminary nmap scan. + Therefore, a fake empty nmap result is generated and the host is added this way on the database. + :param addr_host: a string containing the IP address of the host. + """ fake_nmap_res = {} fake_nmap_res['os'] = 'unknown' fake_nmap_res['addr'] = addr_host @@ -98,6 +107,11 @@ class ModuleLoader: self.add_to_waiting_list(instr) def create_connection(self, addr_host): + """ + Creates a connection with a host, from the configured ones. + :param addr_host: the IP address of the host we want to establish a connection. + :return: An instance of the connection module once initialized. + """ avaliable_conn = self.db.get_conf_conn(addr_host) mod_inst = None if not avaliable_conn == []: @@ -113,6 +127,12 @@ class ModuleLoader: return mod_inst def test_connection(self, addr_host, conn_mod_name): + """ + Try to instanciate a connection module, with the address of the host given and the actual configuration for + this connection. + :param addr_host: The IP address of the host + :param conn_mod_name: The name of the connection module to instanciate. + """ avaliable_conn = self.db.get_conf_conn(addr_host) conn = None for i in range(len(avaliable_conn)): @@ -411,7 +431,7 @@ class ModuleLoader: def launch_db_function(self, dict_instr): """ - Calls a function of the database with the parametters sent. Used to each function which is not module dependant : + Calls a function of the database with the parametters sent. Used to each function which is not module dependant: remove host, create/remove group, add/remove to group, save settings, etc. :param dict_instr: a dictionary containing : { @@ -423,6 +443,19 @@ class ModuleLoader: return getattr(self.db, dict_instr['func'])(dict_instr['args']) def update_activated_modules(self, args): + """ + Save on the database, the new configuration concerning the activation/deactivation + of monitoring modules for a host. + Then, it creates a dictionary containing instruction about what check to add/remove on the process_monitoring + waiting list. + :param args: a dictionary containing: + { + 'addr_host': string, + 'activated':{ + mod_name: bool + } + } + """ dict_instr = self.db.config_mod_activation(args) for add_instr in dict_instr['add']: process_monitoring.add_to_waiting_list(add_instr) @@ -430,23 +463,56 @@ class ModuleLoader: process_monitoring.remove_to_waiting_list(rem_instr['addr'], rem_instr['mod_name']) def set_conf_moni_mod(self, args): + """ + Save on the database the new configuration of a monitoring module for a given host. + Then, it updates the process_monitoring waiting list with the new configuration. + :param args: a dictionary containing : + { + 'addr_host': string, + 'mod_name': string, + 'freq' : int, + 'minor_limit' : int, + 'major_limit' : int + } + """ self.db.set_conf_mod(args) process_monitoring.update_mod_on_waiting_list(args) def get_public_keys_list(self): + """ + Get the content of the directory specified on the conf['keys_location'] parameter of the application. + :return: a list containing the files on the conf['keys_location'] + """ return os.listdir(self.conf['keys_location']) def remove_host(self, args): + """ + Removes all informations concerning the given host from the database. + Also remove each instructions concerning the given host from the process_monitoring waiting list. + :param args: a dictionary containing : + {'addr_host': string} + """ self.db.remove_host(args) # removing monitoring instructions for this host process_monitoring.remove_to_waiting_list(args['addr_host'], None) def get_host_info(self, addr_host): + """ + Asks from the database the informations concerning a given host. + Add to these informations the compatible_os_list attribute. + :param addr_host: the IP address of the host + :return: a dictionary containing the result of get_host_informations() + the attribute compatible_os_list + """ host_info = self.db.get_host_informations(addr_host) host_info['compatible_os_list'] = self.compatible_os_list return host_info def get_all_subscriptions(self): + """ + Get, for every registered user, the subscriptions of these users. + :return: a dictionary containing: + {user1: {'hosts': {addr_host: {'major': {}, 'minor': {}}}, 'groups': {...}}, ... } + """ res = {} users = self.db.get_users(None) for user in users: diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index e659ad6..98487f8 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -14,7 +14,7 @@ import os.path class shelve_db: """ Storage module for the persistant objects in Python : Shelve. - Every function in need to access the database have to be moved in this class. + Every function in need to access the database have to be implemented on this class. """ def __init__(self, db_loc, key_loc): self.db = None @@ -38,6 +38,8 @@ class shelve_db: self.db["global_conf"] = {} except: print "Database initilalization error" + self.db.close() + self.lock.release() else: self.db = shelve.open(self.db_loc, writeback=True) @@ -52,7 +54,7 @@ class shelve_db: def init_global_conf(self, loaded_mod_moni): """ This method is executed once at each launch of the application. - It creates an entrey on db['global_conf'] for each loaded monitoring module. + It creates an entrey on db['global_conf'] for each new loaded monitoring module. If an entry exists for a non loaded module, it will be removed. :param loaded_mod_moni: a dictionary containing : { @@ -94,7 +96,7 @@ class shelve_db: mod_conf['minor_limit'] = 8 mod_conf['major_limit'] = 10 self.db['global_conf'][mod] = mod_conf - for mod in self.db['global_conf']: # removing entries of modules that are non loaded anymore + for mod in self.db['global_conf']: # removing entries of modules that are no loaded anymore if mod not in loaded_mod_moni: del self.db['global_conf'][mod] except Exception: @@ -105,7 +107,7 @@ class shelve_db: def get_global_settings(self, args): """ Asked from the global settings configuration page. - :param args: null (for dynamic call) + :param args: None (for dynamic call) :return: the content of db['global_conf'] """ res = {} @@ -139,7 +141,7 @@ class shelve_db: finally: self.close_db() - def add_host(self, addr_host, nmap_res, list_mod_conn, dict_mod_info): + def add_host(self, addr_host, nmap_res, conn_infos, dict_mod_info): """ Called by the nmap_detection module. Add and save a new host after its first nmap detection @@ -147,7 +149,7 @@ class shelve_db: creates empty structures for the monitoring and archive data. :param addr_host: the IP adress of the host to add :param nmap_res: a string containing the json reslult of the nmap detection of this host - :param list_mod_conn: a list containing the names of the different connection modules + :param conn_infos: a dictionary containing informations about the different connection modules (see get_conection_modules_list() on module_loader) :param dict_mod_info: a dictionnary containing informations about the different monitoring modules (see get_info_mod_monitoring() on module_loader) @@ -162,7 +164,7 @@ class shelve_db: # Preconfiguration self.db["hosts"][addr_host]["conf"] = {} nmap_res_data = json.loads(nmap_res) - self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, list_mod_conn) + self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, conn_infos) os_host = nmap_res_data['os'] self.db["hosts"][addr_host]["conf"]["monitoring"] = {} for mod in dict_mod_info: @@ -209,6 +211,7 @@ class shelve_db: def get_conn_param(self, args): """ + Called from the hostpage. Returns the connection parameters of an host. :param args: A dictionnary containing : {'addr_host': string} @@ -255,7 +258,8 @@ class shelve_db: '%Y-%m-%d %H:%M:%S.%f') dict_moni['time'] = last_check + timedelta(seconds=self.db['hosts'][addr_host]['conf']['monitoring'][mod]['check_frequency']) else: - # this is the first time this module will check this host, the next check will occure right now + # this is the first time this module will check for this host, + # the next check will occure right now dict_moni['time'] = datetime.now() dict_moni['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['check_frequency'] res.append(dict_moni) @@ -268,7 +272,7 @@ class shelve_db: def get_list_addr_hosts(self): """ Necessary when running again the application, for getting the monitoring instructions for all hosts - :return: a list containing all the IP adress of the hosts under monitoring + :return: a list containing all the IP adresses of every hosts under monitoring """ self.open_db() res = [] @@ -283,10 +287,9 @@ class shelve_db: def get_hosts(self): """ - Returns the essential data about all hosts under monitoring - These are used by the front-end - Called by the app.py, after one client demand. - :return: a list containing the essential data in json, about all hosts under monitoring on the form: + Returns the essential data about all hosts under monitoring. + These are used by the front-end application. + :return: a list containing the essential data about all hosts under monitoring on the form: [ { "addr":"192.168.74.1", @@ -303,7 +306,7 @@ class shelve_db: }, ... ] - If no hosts have been added, the function will return an empty dict. + If no hosts have been added, the function will return an empty list. """ self.open_db() res = [] @@ -400,8 +403,9 @@ class shelve_db: def remove_host(self, args): """ - Removes a host from the database. All the monitoring intructions concerning this host will be deleted. - Finally, if the host is part of a group, it will be also removed from these groups. + Called from the hostpage + Removes a host from the database. + If the host is part of a group, it will be also removed from these groups. :param args: A dictionary containing: {'addr_host': string} """ @@ -414,8 +418,8 @@ class shelve_db: # removing this host for each group it is registered in for group_id in self.db['groups']: for host in self.db['groups'][group_id]['hosts']: - if self.db['groups'][group_id]['hosts'][host]['addr'] == addr_host: - del self.db['groups'][group_id]['hosts'][host] + if addr_host in self.db['groups'][group_id]['hosts']: + self.db['groups'][group_id]['hosts'].remove(host) except Exception: print traceback.format_exc() finally: @@ -438,6 +442,7 @@ class shelve_db: def update_os_name(self, args): """ + Called from the hostpage. Updatdes the operating system detected with nmap for a given host. The os name is saved in lower case. :param args: a dictionary containing : { @@ -457,6 +462,7 @@ class shelve_db: def update_custom_informations(self, args): """ + Called from the hostpage. Updates the custom informations stored on the host's configuration :param args: a structure containing the values : { @@ -476,6 +482,7 @@ class shelve_db: def add_intervention(self, args): """ + Called from the hostpage. Add a new intervention, stored on the host's configuration :param args: a structure containing the values : { @@ -562,6 +569,7 @@ class shelve_db: def get_conf_mod(self, args): """ + Called from the hostpage. Returns a structure containing informations about the settings of a monitoring module for a given host. :param args: a list containing the arguments : {'addr_host': string, 'mod_name':string] @@ -590,7 +598,7 @@ class shelve_db: def set_conf_mod(self, args): """ - Save a new configuration for a monitoring module and for a specific host. + Called from the hostpage. Save a new configuration for a monitoring module and for a specific host. :param args: a structure containing the values : { 'addr_host': string, @@ -614,7 +622,7 @@ class shelve_db: def set_prio_conn(self, args): """ - Save the priorities of connections modules for a host. + Called from the hostpage. Save the priorities of connections modules for a host. :param args: A dictionary containing: {'addr_host' : string, 'priorities':{ @@ -634,7 +642,7 @@ class shelve_db: def set_conf_conn(self, args): """ - Save the connection configuration of a host. + Called from the hostpage. Save the connection configuration of a host. :param args: A dictionary containting: {'addr_host': string, 'modname': string, @@ -654,7 +662,7 @@ class shelve_db: def get_conf_conn(self, addr_host): """ - Get the configured connections by priority of a host. + Get the configured connections of a host by priority. :param addr_host: The IP address of the host. :return: A list containing: [{'conn_mod_name': string, 'priority': int, 'args': {arg1: val, ...}}] @@ -683,7 +691,7 @@ class shelve_db: :param addr_host: the IP adress of the host checked :param mod_name: the name of the monitoring_module which have done the check :param val: the value observed - :return: data that will be used to launch the notification modules in the form : + :return: a dictionary that will be used to launch the notification modules in the form : { notif_mod: [{'username': string, 'moni_mod': string, 'title': string, 'msg': string}, ...], ... @@ -770,7 +778,7 @@ class shelve_db: def create_notif_structure(self, addr_host, moni_mod, status): """ - Creates and returns a data structure that will be used by the notification modules + Creates and returns a data structure that will be used by the notification modules. :param addr_host: the IP address of the host :param moni_mod: the name of the monitoring module which have been launched :param status: the status of the last check @@ -781,7 +789,7 @@ class shelve_db: } """ title = "[Mum] " + status + " for " + addr_host - msg = "Mum repported a " + status + " value from the " + moni_mod + " module. " + msg = "Mum reported a " + status + " value from the " + moni_mod + " module. " dict_notif = {} notif_type = "" if status == 'warning': @@ -809,7 +817,7 @@ class shelve_db: param_notif = self.db['groups'][group]['subscribers'][username][notif_type][notif_mod] if param_notif['activated']: title = "[Mum] " + status + " for " + addr_host + " on group " + group - msg = "Mum repported a " + status + " from the " + moni_mod + " module on host " + \ + msg = "Mum reported a " + status + " from the " + moni_mod + " module on host " + \ addr_host + " member of group " + group + "." if notif_mod not in dict_notif: dict_notif[notif_mod] = [] @@ -821,6 +829,7 @@ class shelve_db: def add_host_list_to_group(self, args): """ + Called from the groups page. Add given hosts to a group. If the group doesn't exists on the database, it will be created. :param args: a dictionary containing : { @@ -848,6 +857,7 @@ class shelve_db: def remove_host_list_to_group(self, args): """ + Called from the groups page. Remove given hosts to a group. If the group is empty afterwards, il will be also deleted. :param args: a dictionary containing : { @@ -872,7 +882,7 @@ class shelve_db: def subscribe_to_group(self, args): """ - Add a list of users to the group notifications structure. + Called from the notifications page. Add a list of users to the group notifications structure. :param args: a dictionary containing : { 'users': list<string>, 'group': string } """ @@ -891,7 +901,7 @@ class shelve_db: def update_subscription_to_group(self, args): """ - Updates the subscription to a following user from a host. + Called from the notifications page. Updates the subscription to a following user from a host. :param args: { 'group': string, 'subscription': @@ -920,7 +930,7 @@ class shelve_db: def unsubscribe_to_group(self, args): """ - Unsubscribes an user for a host notifications. + Called from the notifications page. Unsubscribes an user for a host notifications. :param args: a dictionary containing : { 'username': string, 'group': string } """ @@ -936,7 +946,7 @@ class shelve_db: def get_group_subscribers(self, args): """ - + Called from the notification page. :param args: A dictionary containing : { 'group': string } :return: a dictionary containing : @@ -963,6 +973,7 @@ class shelve_db: def create_user(self, args): """ + Called from the users page. Create a basic empty structure on the database for a new user. :param args: a dictionary containing : { 'username': string } @@ -983,7 +994,7 @@ class shelve_db: def get_users(self, args): """ - Called by the user managment page. + Called from the user managment page. :param args: None (necessary for dynamic call via websocket) :return: A list containing the users registered. """ @@ -1000,7 +1011,7 @@ class shelve_db: def get_user_settings(self, args): """ - Called by the profile page. + Called from the profile page. :param args: a dictionary containing: { 'username': string } :return: a dictionary containing: @@ -1044,6 +1055,7 @@ class shelve_db: def get_user_subscriptions(self, username): """ + Called from profile and users page. Get every subscriptions of a given user (host or group), by notifications modules, including the number of itterations necessary to get the notification. :param username: the user name @@ -1082,8 +1094,8 @@ class shelve_db: def remove_user(self, args): """ - Removes a user from the database. If the user is registered to a host or a group, - it is also deleted from these lists + Called from the users page. Removes a user from the database. If the user is registered to a host or a group, + it is also deleted from these lists. :param args: a dictionary containing : { 'username': string } """ @@ -1107,7 +1119,7 @@ class shelve_db: def subscribe_to_host(self, args): """ - Add a list of users to the host notifications structure. + Called from the notifications page. Add a list of users to the host notifications structure. :param args: a dictionary containing : { 'users': list<string>, 'addr_host': string } """ @@ -1126,7 +1138,7 @@ class shelve_db: def update_subscription_to_host(self, args): """ - Updates the subscription to a following user from a host. + Called from the notifications page. Updates the subscription to a following user from a host. :param args: { 'group': string, 'subscription': @@ -1155,7 +1167,7 @@ class shelve_db: def unsubscribe_to_host(self, args): """ - Unsubscribes an user for host notifications. + Called from the notifications page. Unsubscribes an user for host notifications. :param args: a dictionary containing : { 'username': string, 'addr_host': string } """ @@ -1171,7 +1183,7 @@ class shelve_db: def get_host_subscribers(self, args): """ - Get informations about the subscribers to a host. + Called from the notifications page. Get informations about the subscribers to a host. :param args: A dictionary containing : { 'addr_host': string } :return: a dictionary containing : diff --git a/app/mum.py b/app/mum.py index 2a9e06a..820e602 100755 --- a/app/mum.py +++ b/app/mum.py @@ -11,7 +11,7 @@ import threading from module_loader import ModuleLoader import argparse -# Pour lancer la detection nmap avec un nouveau thread +# To Launch the nmap detection with a new thread class ThreadDetect(threading.Thread): def __init__(self, param, opt, ml, ws): threading.Thread.__init__(self) @@ -21,14 +21,11 @@ class ThreadDetect(threading.Thread): self.ws = ws # websocket connection def run(self): - db = self.ml.get_db() - scanned_ip = self.ml.run_nmap_detection(self.param, self.opt, db, self.ws, - self.ml.get_conection_modules_list(), - self.ml.get_monitoring_modules_list()) + scanned_ip = self.ml.run_nmap_detection(self.param, self.opt, self.ws) if scanned_ip is not None: self.ws.send(json.dumps({"SUCCESS_MODULE": scanned_ip})) for ip in json.loads(scanned_ip): - monitoring_intructions = db.get_monitoring_instructions(ip) + monitoring_intructions = ml.get_db().get_monitoring_instructions(ip) for instr in monitoring_intructions: ml.add_to_waiting_list(instr) """ @@ -44,7 +41,7 @@ class ThreadDetect(threading.Thread): """ -# Lancement de la detection apres reception d'une plage d'ip +# Launching of the detection after getting a ip range. def start_first_detection(args, ml, ws): t = ThreadDetect(args['ip_range'], args['nmap_options'], ml, ws) t.start() @@ -99,19 +96,19 @@ def error404(error): return '<h1>Cette page n\'existe pas</h1>' -# Pour recuperer les fichiers statiques via l'url +# To get static files @get('/static/<filepath:path>') def static(filepath): return static_file(filepath, root='static') -# Pour recuperer les dependances bower via l'url +# To get Bower dependancies @get('/bower_components/<filepath:path>') def bower_files(filepath): return static_file(filepath, root='bower_components') -# Creation d'une websocket pour permettre la communication avec le client +# Creation of a websocket for communicating with a client @get('/websocket', apply=[websocket]) def receive(ws): global ml @@ -184,9 +181,7 @@ def do_upload(): except IOError: return 'This file already exists. <a href="/">Back to dashboard.</a>' - - -# Lancement du serveur a l'adresse 0.0.0.0:1337 +# Launching the server if __name__ == '__main__': global ml diff --git a/app/process_monitoring.py b/app/process_monitoring.py index eaa4e2c..8c72086 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -66,6 +66,8 @@ class ProcessMonitoring(threading.Thread): def add_to_waiting_list(dict_mod): """ Adds an element to the waiting queue and keep it ordered by crescent launching times. + :param dict_mod: a dictionary containing: + {'addr': str, 'os': str, 'mod_name': str, 'time': datetime, 'freq': int} """ global waiting_list if waiting_list == []: @@ -78,6 +80,12 @@ def add_to_waiting_list(dict_mod): def remove_to_waiting_list(addr_host, modname): + """ + Removes from the waiting list all occurrences of the given host for the module modname. + If modname is None, all entries for the host are removed. + :param addr_host: the IP address of the host + :param modname: the name of the monitoring module. + """ global waiting_list i = 0 while i < len(waiting_list): diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index f69c0b3..aaba766 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -517,7 +517,10 @@ mumApp.controller('ModalBlockInstanceCtrl', function ($scope, $rootScope, $modal }; $scope.is_not_compatible = function(modname){ - return $scope.block_args.loaded_moni_mod[modname].compatible_os.lastIndexOf($scope.block_args.os_host) < 0; + // returns true if the OS of the host is part of the compatible OS list of the module modname ; Or if the module + // modname is comatible with all OS. + return ($scope.block_args.loaded_moni_mod[modname].compatible_os.lastIndexOf($scope.block_args.os_host) < 0) && + ($scope.block_args.loaded_moni_mod[modname].compatible_os.lastIndexOf('all') < 0); }; $scope.ok = function () { diff --git a/static/js/mumApp.js b/static/js/mumApp.js index 5151687..42bcc3d 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -10,47 +10,47 @@ mumApp.config(function($routeProvider){ templateUrl : 'dashboard.html', controller : 'dashboardCtrl' }) - .when('/dashboard',{ + .when('/dashboard/',{ templateUrl : 'dashboard.html', controller : 'dashboardCtrl' }) - .when('/dashboard/:param',{ + .when('/dashboard/:param/',{ templateUrl : 'dashboard.html', controller : 'dashboardCtrl' }) - .when('/groups',{ + .when('/groups/',{ templateUrl : 'groups.html', controller : 'groupCtrl' }) - .when('/hostpage/:param',{ + .when('/hostpage/:param/',{ templateUrl : 'hostpage.html', controller : 'hostPageCtrl' }) - .when('/notifications',{ + .when('/notifications/',{ templateUrl : 'notifications.html', controller : 'notificationsCtrl' }) - .when('/profile',{ + .when('/profile/',{ templateUrl : 'profile.html', controller : 'profileCtrl' }) - .when('/scan',{ + .when('/scan/',{ templateUrl : 'scan.html', controller : 'scanCtrl' }) - .when('/settings',{ + .when('/settings/',{ templateUrl : 'settings.html', controller : 'settingsCtrl' }) - .when('/signin',{ + .when('/signin/',{ templateUrl : 'signin.html' //controller : 'mainController' }) - .when('/stats',{ + .when('/stats/',{ templateUrl : 'stats.html' //controller : 'mainController' }) - .when('/users',{ + .when('/users/',{ templateUrl : 'users.html', controller : 'usersCtrl' }) @@ -60,52 +60,11 @@ mumApp.config(function($routeProvider){ }); /*mumApp.config(function($locationProvider)){ - $locationProvider.html5Mode(false).hashPrefix("!"); + $locationProvider.html5Mode(false); });*/ mumApp.$inject = ['$scope', '$filter']; -/*mumApp.directive("customSort", function() { -return { -restrict: 'A', -transclude: true, -scope: { - order: '=', - sort: '=' -}, -template : - ' <a ng-click="sort_by(order)" style="color: #555555;">'+ - ' <span ng-transclude></span>'+ - ' <i ng-class="selectedCls(order)"></i>'+ - '</a>', -link: function(scope) { - -// change sorting order -scope.sort_by = function(newSortingOrder) { - var sort = scope.sort; - - if (sort.sortingOrder == newSortingOrder){ - sort.reverse = !sort.reverse; - } - - sort.sortingOrder = newSortingOrder; -}; - - -scope.selectedCls = function(column) { - if(column == scope.sort.sortingOrder){ - return ('icon-chevron-' + ((scope.sort.reverse) ? 'down' : 'up')); - } - else{ - return'icon-sort' - } -}; -}// end link -} - - -});*/ - // https://github.com/angular-ui/angular-ui-OLDREPO/blob/master/modules/filters... (MIT licence) mumApp.filter('unique', function () { diff --git a/views/notifications.html b/views/notifications.html index 1d6a182..4a21ff2 100644 --- a/views/notifications.html +++ b/views/notifications.html @@ -75,7 +75,7 @@ </div> </form> <div ng-show="selected_host!='' || selected_grp!=''"> - <p>Check the box if you want the user to be notified by the correspondant service.</p> + <p>Check the box if you want the user to be notified by the correspondent service.</p> <p>The value represents the numbers of notifications that should occure since the last login of the user.</p> <p>The notification will be sent to the user, by this service, once this value is reached.</p> <table class="table table-bordered"> diff --git a/views/profile.html b/views/profile.html index d3d5f94..bccf9c6 100644 --- a/views/profile.html +++ b/views/profile.html @@ -84,7 +84,7 @@ <h3 class="modal-title">Summary of your subscriptions</h3> </div> <div class="modal-body"> - <p>Number of notifications between your last login</p> + <p>Number of notifications between 2 logins</p> <table class="table table-hover"> <thead> <tr> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm