branch develop updated (9a5c8da -> c657453)
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 9a5c8da plus de millisecondes dans l'affichage des temps + changmeent du formulaire pour le paramétrage de la fréquence des check new a9bcc51 changer la fréquence de check d'un module est maintenant appliqué dans le process monitoring new c657453 user page : OK pour la création et la suppression d'un utilisateur 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 c6574534099a656b63c3ff5851b33f28e711fa6b Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 18 16:04:39 2015 +0100 user page : OK pour la création et la suppression d'un utilisateur commit a9bcc5186eb1bfa8da4a3f07ba54b9d2915ce5a3 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 18 11:51:15 2015 +0100 changer la fréquence de check d'un module est maintenant appliqué dans le process monitoring Summary of changes: app/app.py | 25 +++++++++-------- app/modules/storage_modules/shelve_db.py | 46 +++++++++++++++++++++++++++----- app/process_monitoring.py | 23 ++++++++++++++++ static/js/controllers/hostPageCtrl.js | 4 +-- static/js/controllers/usersCtrl.js | 32 ++++++++++++++++++++++ static/js/mumApp.js | 4 +-- views/index.html | 1 + views/scan.html | 6 ++--- views/users.html | 20 +++++--------- 9 files changed, 123 insertions(+), 38 deletions(-) create mode 100644 static/js/controllers/usersCtrl.js -- 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 a9bcc5186eb1bfa8da4a3f07ba54b9d2915ce5a3 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 18 11:51:15 2015 +0100 changer la fréquence de check d'un module est maintenant appliqué dans le process monitoring --- app/app.py | 3 +++ app/modules/storage_modules/shelve_db.py | 4 ++-- app/process_monitoring.py | 23 +++++++++++++++++++++++ static/js/controllers/hostPageCtrl.js | 4 ++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/app.py b/app/app.py index 8ffda84..1d89861 100755 --- a/app/app.py +++ b/app/app.py @@ -146,6 +146,9 @@ def receive(ws): ws.send(json_dumps({"RES_GET_LOADED_MONI_MOD": ml.get_info_mod_monitoring()})) elif code == "SET_MOD_ACTIVATION": ml.update_activated_modules(msg["SET_MOD_ACTIVATION"]) + elif code == "SET_CONF_MOD": + ml.launch_db_function({'func': 'set_conf_mod', 'args': msg["SET_CONF_MOD"]}) + process_monitoring.update_mod_on_waiting_list(msg["SET_CONF_MOD"]) elif code == "CHECK_NOW": args = msg["CHECK_NOW"] ml.run_one_monitoring_module(args['mod_name'], args['addr_host'], None, None) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 4522c9a..97e993e 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -517,7 +517,7 @@ class shelve_db: def get_conf_mod(self, args): """ - Returns a structure containing informations about the settings of a monitoring module. + 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': val, 'mod_name':val] :return: a structure containing : @@ -545,7 +545,7 @@ class shelve_db: def set_conf_mod(self, args): """ - Save a new configuration for a monitoring module + Save a new configuration for a monitoring module and for a specific host. :param args: a structure containing the values : { 'addr_host': val, diff --git a/app/process_monitoring.py b/app/process_monitoring.py index c056d7f..bfe6076 100644 --- a/app/process_monitoring.py +++ b/app/process_monitoring.py @@ -90,6 +90,29 @@ def remove_to_waiting_list(addr_host, modname): # we remove only the necessary module from the list waiting_list.pop(i) + +def update_mod_on_waiting_list(new_conf): + """ + Updates the check frequency of a module after its configuration changed. The next check will be launched right after + this new configuration. + :param new_conf: a structure containing the values : + { + 'addr_host': val, + 'mod_name': val, + 'freq' : val, + 'minor_limit' : val, + 'major_limit' : val + } + """ + global waiting_list + for i in range(len(waiting_list)): + if waiting_list[i]['addr'] == new_conf['addr_host'] and waiting_list[i]['mod_name'] == new_conf['mod_name']: + prev_conf = waiting_list.pop(i) + prev_conf['freq'] = new_conf['freq'] + prev_conf['time'] = datetime.now() + add_to_waiting_list(prev_conf) + + class RunMonitoring(threading.Thread): def __init__(self, list_dict_mod, ml, wsc): threading.Thread.__init__(self) diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index 3a10a96..0900387 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -197,7 +197,7 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI var args = {}; args.addr_host = $scope.conf_args.addr_host; args.mod_name = $scope.conf_args.mod_name; - args.freq = 86400 * parseInt($scope.freq_days) + 3600 * parseInt($scope.freq_hours) + 60 * parseInt($scope.freq_minutes); + args.freq = 86400 * $scope.freq_days + 3600 * $scope.freq_hours + 60 * $scope.freq_minutes; if($scope.items.unit == 'bool'){ args.minor_limit = ($scope.limit_bool == 'minor'); args.major_limit = ($scope.limit_bool == 'major'); @@ -210,7 +210,7 @@ mumApp.controller('ModalConfInstanceCtrl', function ($scope, $rootScope, $modalI args.minor_limit = $scope.minor_limit_unit; args.major_limit = $scope.major_limit_unit; } - $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'set_conf_mod', 'args': args}})); + $rootScope.$broadcast("sendViaWs", JSON.stringify({"SET_CONF_MOD": args})); $modalInstance.close(); -- 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 c6574534099a656b63c3ff5851b33f28e711fa6b Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Mar 18 16:04:39 2015 +0100 user page : OK pour la création et la suppression d'un utilisateur --- app/app.py | 24 +++++++++--------- app/modules/storage_modules/shelve_db.py | 42 +++++++++++++++++++++++++++++--- static/js/controllers/usersCtrl.js | 32 ++++++++++++++++++++++++ static/js/mumApp.js | 4 +-- views/index.html | 1 + views/scan.html | 6 ++--- views/users.html | 20 +++++---------- 7 files changed, 94 insertions(+), 35 deletions(-) diff --git a/app/app.py b/app/app.py index 1d89861..15a5180 100755 --- a/app/app.py +++ b/app/app.py @@ -123,40 +123,40 @@ def receive(ws): if response is not None: msg = json.loads(response) for code in msg: - if code == "NMAP_SCAN_DEMAND": + if code == "NMAP_SCAN_DEMAND": # asked from scan page start_first_detection(msg["NMAP_SCAN_DEMAND"], ml, ws) - elif code == "LAUNCH_FULL_DETECTION": + elif code == "LAUNCH_FULL_DETECTION": # asked from hostpage ml.run_all_detection_modules(msg["LAUNCH_FULL_DETECTION"]) ws.send(json_dumps({"SUCCESS_MODULE": "Full detection"})) - elif code == "GET_HOSTS": + elif code == "GET_HOSTS": # asked from head controller db = ml.get_db() ws.send(json.dumps({"RES_GET_HOSTS": db.get_hosts()})) - elif code == "GET_HOST_INFO": + elif code == "GET_HOST_INFO": # asked from hostpage db = ml.get_db() ws.send(json.dumps({"RES_INFO_HOST": db.get_host_informations(msg["GET_HOST_INFO"])})) - elif code == "CALL_FUNC_DB": + elif code == "CALL_FUNC_DB": # asked when the request can directly pass by database res = ml.launch_db_function(msg["CALL_FUNC_DB"]) if res is not None: ws.send(json.dumps({"RES_CALL_FUNC_DB": res})) else: print 'res is None' - elif code == "GET_LOADED_CONN_MOD": + 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": + 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 == "SET_MOD_ACTIVATION": + elif code == "SET_MOD_ACTIVATION": # asked from hostpage, at the block activation conf ml.update_activated_modules(msg["SET_MOD_ACTIVATION"]) - elif code == "SET_CONF_MOD": + elif code == "SET_CONF_MOD": # asked from hostpage, at the monitoring module configuration ml.launch_db_function({'func': 'set_conf_mod', 'args': msg["SET_CONF_MOD"]}) process_monitoring.update_mod_on_waiting_list(msg["SET_CONF_MOD"]) - elif code == "CHECK_NOW": + elif code == "CHECK_NOW": # asekd from hostpage args = msg["CHECK_NOW"] ml.run_one_monitoring_module(args['mod_name'], args['addr_host'], None, None) - elif code == "GET_KEYS_LIST": + elif code == "GET_KEYS_LIST": # asked from hostpage, at the connection configuration ws.send(json_dumps({"KEYS_LIST": ml.get_public_keys_list()})) else: break - except WebSocketError: # Should be WebSocketError when closing the connection + except WebSocketError: # Should be WebSocketError when closing the connection wsc.remove_websocket(ws) break diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 97e993e..19e5776 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -631,6 +631,7 @@ class shelve_db: :param mod_name: the name of the monitoring_module which have done the check :param val: the value observed """ + #failure = None self.open_db() new_val = {"date": str(datetime.now()), "value": val} try: @@ -673,6 +674,19 @@ class shelve_db: and not state == 'danger': state = 'warning' self.db['hosts'][addr_host]['status']['state'] = state + # create a notify structure if the state is not a success + """ + if not new_val['state'] == 'success': + failure = {} + failure['addr_host'] = addr_host + failure['mod_name'] = mod_name + failure['state'] = new_val['state'] + failure['subscribers'] = {} + for subscriber in self.db['hosts'][addr_host]['conf']['subscribers']: + failure['subscribers'][subscriber] = {} + failure['subscribers'][subscriber][''] + failure['groups_to_notify'] = self.db['hosts'][addr_host]['conf']['groups'] + """ # now performing archiving """ if mod_name in self.db['hosts'][addr_host]['archive']: @@ -681,6 +695,7 @@ class shelve_db: """ finally: self.close_db() + #return failure def update_stats(self, stats, val): """ @@ -750,11 +765,13 @@ class shelve_db: finally: self.close_db() - def create_user(self, username): + def create_user(self, args): """ Create a basic empty structure on the database for a new user. - :param username:string containing the name of the user + :param args: a dictionary containing : + { 'username': val } """ + username = args['username'] self.open_db() try: self.db['users'][username] = {} @@ -765,11 +782,28 @@ class shelve_db: finally: self.close_db() - def remove_user(self, username): + def get_users(self, args): + """ + Called by the user managment page. + :param args: None (necessary for dynamic call via websocket) + :return: A list containing the users registered. + """ + res = [] + self.open_db() + try: + for user in self.db['users']: + res.append(user) + finally: + self.close_db() + return json.dumps(res) + + 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 - :param username: string containing the name of the user + :param args: a dictionary containing : + { 'username': val } """ + username = args['username'] self.open_db() try: # deletion of the user diff --git a/static/js/controllers/usersCtrl.js b/static/js/controllers/usersCtrl.js new file mode 100644 index 0000000..dca6322 --- /dev/null +++ b/static/js/controllers/usersCtrl.js @@ -0,0 +1,32 @@ +mumApp.controller('usersCtrl', function($scope, $rootScope, $route) { + $scope.users = {}; + + $scope.selected_user = ""; + + $scope.show_new_user = false; + + $scope.new_username = ""; + + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'get_users', 'args': null}})); + + // receiving the user list + $scope.$on("resCall", function (event, args) { + $scope.$apply(function(){ + $scope.users = args; + }); + }); + + $scope.addUser = function(){ + var args = {}; + args['username'] = $scope.new_username; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'create_user', 'args': args}})); + $route.reload(); + } + + $scope.removeUser = function(){ + var args = {}; + args['username'] = $scope.selected_user; + $rootScope.$broadcast("sendViaWs", JSON.stringify({"CALL_FUNC_DB": {'func': 'remove_user', 'args': args}})); + $route.reload(); + } +}); \ No newline at end of file diff --git a/static/js/mumApp.js b/static/js/mumApp.js index bc223ef..2068b61 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -51,8 +51,8 @@ mumApp.config(function($routeProvider){ //controller : 'mainController' }) .when('/users',{ - templateUrl : 'users.html' - //controller : 'mainController' + templateUrl : 'users.html', + controller : 'usersCtrl' }) .otherwise({ redirectTo: '/' diff --git a/views/index.html b/views/index.html index f273638..d80e11c 100644 --- a/views/index.html +++ b/views/index.html @@ -32,6 +32,7 @@ <script src="static/js/controllers/scanCtrl.js"></script> <script src="static/js/controllers/hostPageCtrl.js"></script> <script src="static/js/controllers/groupCtrl.js"></script> + <script src="static/js/controllers/usersCtrl.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]><!-- diff --git a/views/scan.html b/views/scan.html index 4eb2162..1a94296 100644 --- a/views/scan.html +++ b/views/scan.html @@ -1,16 +1,16 @@ <div class="col-md-offset-2 main"> <h1 class="page-header">Scan for new machines</h1> - <div ng-show="validated == false" class="ng-hide"> + <div ng-show="!validated" class="ng-hide"> <form class="form-inline" ng_submit="post_val()"> <label for="input_ip_range">Enter a hostname, a single IP or an IP range to scan (example : 198.116.0.1-10)</label> <input type="text" class="form-control" id="input_ip_range" ng-model="ip_range"/><br/> <button type="button" class="btn btn-danger" ng-click="show_opt = !show_opt">Show nmap options (careful)</button> - <input type="text" class="form-control" ng-show="show_opt == true" ng-model="nmap_options"/> + <input type="text" class="form-control" ng-show="show_opt" ng-model="nmap_options"/> <button type="submit" class="btn btn-primary" ng-click="validated = true">Scan now</button> </form> </div> - <div ng-show="validated == true"> + <div ng-show="validated"> <p>{{state}}</p> <p>Scanned IP : {{ip_scanned}}</p> </div> diff --git a/views/users.html b/views/users.html index 10d7d23..eeb1f4d 100644 --- a/views/users.html +++ b/views/users.html @@ -4,20 +4,12 @@ <div class="row"> <div class="col-xs-4"> <label for="usrlist">Registered users</label> - <select class="form-control" id="usrlist"> - <option>D.D.</option> - <option>G.G.</option> - <option>J.C.</option> - <option>J.D.</option> - <option>X.R.</option> - </select> - </div> - </div> - <div class="row"> - <div class="col-xs-4"> - <button type="button" class="btn btn-primary btn-xs" data-toggle="popover" - data-placement="bottom" title="Add user..." data-content="ger">Add user</button> - <button type="button" class="btn btn-danger btn-xs">Remove selected</button> + <select class="form-control input-sm" id="usrlist" ng-model="selected_user" ng-options="user as user for user in users"></select> </div> </div> + <button type="button" class="btn btn-primary" data-toggle="popover" + data-placement="bottom" title="Add user..." data-content="ger" ng-click="show_new_user=!show_new_user">Add user</button> + <input type="text" ng-show="show_new_user" ng-model="new_username"> + <button type="button" class="btn btn-primary" ng-show="show_new_user && new_username!=''" ng-click="addUser()">Create user</button> + <button type="button" class="btn btn-danger" ng-show="selected_user!=''" ng-click="removeUser()">Remove {{selected_user}}</button> </div> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm