From a1b17a238b0ab9e44bbed68a824161318c4c71cc Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Mon, 28 Aug 2023 06:44:19 +1000 Subject: [PATCH] NMAP plugin conversion v0.2 --- front/plugins/nmap_scan/config.json | 2 +- pialert/plugin.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/front/plugins/nmap_scan/config.json b/front/plugins/nmap_scan/config.json index 77c2c301..7d7f4a66 100755 --- a/front/plugins/nmap_scan/config.json +++ b/front/plugins/nmap_scan/config.json @@ -389,7 +389,7 @@ { "function": "RUN_TIMEOUT", "type": "integer", - "default_value": 300, + "default_value": 30, "options": [], "localized": ["name", "description"], "name": [ diff --git a/pialert/plugin.py b/pialert/plugin.py index 8f276611..cbfeb1ee 100755 --- a/pialert/plugin.py +++ b/pialert/plugin.py @@ -156,7 +156,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): # handle missing "function":"CMD" setting if set == None: - return + return pluginsState set_CMD = set["value"] @@ -168,7 +168,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): else: set_RUN_TIMEOUT = set["value"] - mylog('debug', ['[Plugins] Timeout: ', set_RUN_TIMEOUT]) + # Prepare custom params params = [] @@ -191,7 +191,8 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): mylog('debug', [f'[Plugins] The parameter "name":"{param["name"]}" will multiply the timeout {tempParam.paramValuesCount} times. Total timeout: {set_RUN_TIMEOUT}s']) - + mylog('debug', ['[Plugins] Timeout: ', set_RUN_TIMEOUT]) + # build SQL query parameters to insert into the DB sqlParams = [] @@ -316,7 +317,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): # handle missing "function":"DB_PATH" setting if set == None: mylog('none', ['[Plugins] Error: DB_PATH setting for plugin type sqlite-db-query missing.']) - return + return pluginsState fullSqlitePath = set["value"] @@ -356,7 +357,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): # check if the subprocess / SQL query failed / there was no valid output if len(sqlParams) == 0: mylog('none', ['[Plugins] No output received from the plugin ', plugin["unique_prefix"], ' - enable LOG_LEVEL=debug and check logs']) - return + return pluginsState else: mylog('verbose', ['[Plugins] SUCCESS, received ', len(sqlParams), ' entries'])