branch develop updated (6630299 -> 6300cc0)
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 6630299 modules can now be dynamically invoked via module_loader new 6300cc0 run_all_detection_modules OK run_all_monitoring_modules OK get_hosts now at the opening of websocket The 1 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 6300cc098075e04ce57f1109508f35412cf76bcc Author: aguilbaud <aguilbaud@codelutin.com> Date: Thu Feb 19 18:15:21 2015 +0100 run_all_detection_modules OK run_all_monitoring_modules OK get_hosts now at the opening of websocket Summary of changes: app/module_loader.py | 20 ++++++++++++++++---- app/modules/detection_modules/__init__.py | 1 + app/modules/detection_modules/nmap_detection.py | 6 ++++-- .../detection_modules/unix/kernel_detection.py | 1 + app/modules/monitoring_modules/__init__.py | 2 ++ app/modules/monitoring_modules/unix/__init__.py | 1 + .../monitoring_modules/unix/updated_packages.py | 19 +++++++++++++++++++ static/js/controllers/table_ctrl.js | 10 +++++----- views/dashboard.html | 1 - 9 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 app/modules/monitoring_modules/__init__.py create mode 100644 app/modules/monitoring_modules/unix/updated_packages.py -- 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 6300cc098075e04ce57f1109508f35412cf76bcc Author: aguilbaud <aguilbaud@codelutin.com> Date: Thu Feb 19 18:15:21 2015 +0100 run_all_detection_modules OK run_all_monitoring_modules OK get_hosts now at the opening of websocket --- app/module_loader.py | 20 ++++++++++++++++---- app/modules/detection_modules/__init__.py | 1 + app/modules/detection_modules/nmap_detection.py | 6 ++++-- .../detection_modules/unix/kernel_detection.py | 1 + app/modules/monitoring_modules/__init__.py | 2 ++ app/modules/monitoring_modules/unix/__init__.py | 1 + .../monitoring_modules/unix/updated_packages.py | 19 +++++++++++++++++++ static/js/controllers/table_ctrl.js | 10 +++++----- views/dashboard.html | 1 - 9 files changed, 49 insertions(+), 12 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index ccde508..d12d3d7 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -1,7 +1,8 @@ __author__ = 'aguilbaud' -import modules.detection_modules -import modules.detection_modules.unix +import modules import modules.connection_modules +import modules.detection_modules +import modules.monitoring_modules import modules.storage_modules @@ -25,7 +26,18 @@ def load_conn(conn_name, addr_host, key_location): # /home/aguilbaud/.ssh/id_ def run_all_detection_modules(os, conn, db): - for mod_name in "modules.detection_modules." + os + ".__all__": + __import__("modules.detection_modules." + os) + pack_mod_os = __import__("modules.detection_modules." + os, fromlist=modules.detection_modules.__all__) + for mod_name in pack_mod_os.__all__: mod = __import__ ("modules.detection_modules." + os + "." + mod_name, fromlist=modules.detection_modules.unix.__all__) # on charge le module mod_instance = getattr(mod, mod_name)(conn, db) # on appelle le constructeur - mod_instance.run_detection() \ No newline at end of file + mod_instance.run_detection() + + +def run_all_monitoring_modules(os, conn, db): + __import__("modules.monitoring_modules." + os) + pack_mod_os = __import__("modules.monitoring_modules." + os, fromlist=modules.monitoring_modules.__all__) + for mod_name in pack_mod_os.__all__: + mod = __import__ ("modules.monitoring_modules." + os + "." + mod_name, fromlist=modules.monitoring_modules.unix.__all__) # on charge le module + mod_instance = getattr(mod, mod_name)(conn, db) # on appelle le constructeur + #mod_instance.check() \ No newline at end of file diff --git a/app/modules/detection_modules/__init__.py b/app/modules/detection_modules/__init__.py index fcb43f2..9735bce 100644 --- a/app/modules/detection_modules/__init__.py +++ b/app/modules/detection_modules/__init__.py @@ -1 +1,2 @@ __author__ = 'aguilbaud' +__all__ = ['unix'] \ No newline at end of file diff --git a/app/modules/detection_modules/nmap_detection.py b/app/modules/detection_modules/nmap_detection.py index 9570695..9fe5a3a 100644 --- a/app/modules/detection_modules/nmap_detection.py +++ b/app/modules/detection_modules/nmap_detection.py @@ -80,9 +80,8 @@ class nmap_detection: def launch_detection(self, byte_1, byte_2, byte_3, byte_4): ip = str(byte_1) + '.' + str(byte_2) + '.' + str(byte_3) + '.' + str(byte_4) self.ws.send(json.dumps({"30": "Scanning ip : " + ip})) - child = pexpect.spawn('nmap', ['-A', ip, '-oX', 'res.xml']) - # here : possible to check the advancement of the scan, by putting verbose "-v3" option on command try: + child = pexpect.spawn('nmap', ['-A', ip, '-oX', 'res.xml']) while child.isalive(): child.expect('Completed', timeout=None) except pexpect.EOF: @@ -92,6 +91,9 @@ class nmap_detection: self.ws.send(json.dumps({"40": "Database error"})) except pexpect.TIMEOUT: self.ws.send(json.dumps({"40": "Timeout on nmap execution"})) + except pexpect.ExceptionPexpect: + self.ws.send(json.dumps({"40": "nmap command not avaliable on server"})) + # parse the xml result to keep only interesting values # save directly it on the database diff --git a/app/modules/detection_modules/unix/kernel_detection.py b/app/modules/detection_modules/unix/kernel_detection.py index 037098a..3298a21 100644 --- a/app/modules/detection_modules/unix/kernel_detection.py +++ b/app/modules/detection_modules/unix/kernel_detection.py @@ -5,6 +5,7 @@ class kernel_detection: def __init__(self, conn, db): self.conn = conn self.db = db + print __name__ def run_detection(self): cmd = "cat /proc/version" diff --git a/app/modules/monitoring_modules/__init__.py b/app/modules/monitoring_modules/__init__.py new file mode 100644 index 0000000..64f86cc --- /dev/null +++ b/app/modules/monitoring_modules/__init__.py @@ -0,0 +1,2 @@ +__author__ = 'alexis' +__all__=['unix'] \ No newline at end of file diff --git a/app/modules/monitoring_modules/unix/__init__.py b/app/modules/monitoring_modules/unix/__init__.py index fcb43f2..e7ab721 100644 --- a/app/modules/monitoring_modules/unix/__init__.py +++ b/app/modules/monitoring_modules/unix/__init__.py @@ -1 +1,2 @@ __author__ = 'aguilbaud' +__all__=['updated_packages'] \ No newline at end of file diff --git a/app/modules/monitoring_modules/unix/updated_packages.py b/app/modules/monitoring_modules/unix/updated_packages.py new file mode 100644 index 0000000..4a5232b --- /dev/null +++ b/app/modules/monitoring_modules/unix/updated_packages.py @@ -0,0 +1,19 @@ +__author__ = 'alexis' +import json + + +class updated_packages: + def __init__(self, conn, db): + self.conn = conn + self.db = db + self.part = "software" + + def check(self): + cmd = "apt-get upgrade -s" + stdout = self.conn.exec_command(cmd) + tab_res = stdout.split(':') + if len(tab_res) == 2: + res_check = json.dumps({'non_updated_packages': False}) + else: + res_check = json.dumps({'non_updated_packages': True}) + self.db.add_check(self.conn.get_addr_host(), "updated_packages", res_check) \ No newline at end of file diff --git a/static/js/controllers/table_ctrl.js b/static/js/controllers/table_ctrl.js index bc8d1f6..d08b2c7 100644 --- a/static/js/controllers/table_ctrl.js +++ b/static/js/controllers/table_ctrl.js @@ -30,6 +30,11 @@ tablemodule.controller('ctrlRead', function ($scope, $filter) { var ws = new WebSocket("ws://0.0.0.0:1337/websocket"); + ws.onopen = function() { + var request = '{"14" : ""}'; + ws.send(request); + }; + // actions effectuees lors de la reception d'un message via la websocket ws.onmessage = function (evt) { JSON.parse(evt.data, function (key, value) { @@ -87,11 +92,6 @@ tablemodule.controller('ctrlRead', function ($scope, $filter) { toastr.error(msg, title); }; - $scope.getHosts = function(){ - var request = '{"14" : ""}'; - ws.send(request); - } - var searchMatch = function (haystack, needle) { if (!needle) { return true; diff --git a/views/dashboard.html b/views/dashboard.html index 9995f95..60f6a14 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -146,7 +146,6 @@ </tr> </tbody> </table> - <button type="submit" class="btn btn-primary" ng-click="getHosts()">Get hosts</button> </div> </div> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm