🔌Plugin execution order
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "__template",
|
"code_name": "__template",
|
||||||
"unique_prefix": "TMP",
|
"unique_prefix": "TMP",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_0",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"mapped_to_table": "CurrentScan",
|
"mapped_to_table": "CurrentScan",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"code_name": "arp_scan",
|
"code_name": "arp_scan",
|
||||||
"unique_prefix": "ARPSCAN",
|
"unique_prefix": "ARPSCAN",
|
||||||
|
"execution_order" : "Layer_2",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "dhcp_leases",
|
"code_name": "dhcp_leases",
|
||||||
"unique_prefix": "DHCPLSS",
|
"unique_prefix": "DHCPLSS",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_3",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"data_filters": [
|
"data_filters": [
|
||||||
@@ -513,12 +514,23 @@
|
|||||||
],
|
],
|
||||||
"transformers": []
|
"transformers": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"elementType": "button",
|
||||||
|
"elementOptions": [
|
||||||
|
{ "sourceSuffixes": ["_in"] },
|
||||||
|
{ "separator": "" },
|
||||||
|
{ "cssClasses": "col-xs-12" },
|
||||||
|
{ "onClick": "addList(this, false)" },
|
||||||
|
{ "getStringKey": "Gen_Add" }
|
||||||
|
],
|
||||||
|
"transformers": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"elementType": "button",
|
"elementType": "button",
|
||||||
"elementOptions": [
|
"elementOptions": [
|
||||||
{ "sourceSuffixes": [] },
|
{ "sourceSuffixes": [] },
|
||||||
{ "separator": "" },
|
{ "separator": "" },
|
||||||
{ "cssClasses": "col-sm-3" },
|
{ "cssClasses": "col-xs-6" },
|
||||||
{ "onClick": "removeAllOptions(this)" },
|
{ "onClick": "removeAllOptions(this)" },
|
||||||
{ "getStringKey": "Gen_Remove_All" }
|
{ "getStringKey": "Gen_Remove_All" }
|
||||||
],
|
],
|
||||||
@@ -529,23 +541,12 @@
|
|||||||
"elementOptions": [
|
"elementOptions": [
|
||||||
{ "sourceSuffixes": [] },
|
{ "sourceSuffixes": [] },
|
||||||
{ "separator": "" },
|
{ "separator": "" },
|
||||||
{ "cssClasses": "col-sm-3" },
|
{ "cssClasses": "col-xs-6" },
|
||||||
{ "onClick": "removeFromList(this)" },
|
{ "onClick": "removeFromList(this)" },
|
||||||
{ "getStringKey": "Gen_Remove_Last" }
|
{ "getStringKey": "Gen_Remove_Last" }
|
||||||
],
|
],
|
||||||
"transformers": []
|
"transformers": []
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"elementType": "button",
|
|
||||||
"elementOptions": [
|
|
||||||
{ "sourceSuffixes": ["_in"] },
|
|
||||||
{ "separator": "" },
|
|
||||||
{ "cssClasses": "col-sm-2" },
|
|
||||||
{ "onClick": "addList(this, false)" },
|
|
||||||
{ "getStringKey": "Gen_Add" }
|
|
||||||
],
|
|
||||||
"transformers": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"elementType": "select",
|
"elementType": "select",
|
||||||
"elementOptions": [
|
"elementOptions": [
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "dhcp_servers",
|
"code_name": "dhcp_servers",
|
||||||
"unique_prefix": "DHCPSRVS",
|
"unique_prefix": "DHCPSRVS",
|
||||||
"plugin_type": "other",
|
"plugin_type": "other",
|
||||||
|
"execution_order" : "Layer_3",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"show_ui": true,
|
"show_ui": true,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "internet_ip",
|
"code_name": "internet_ip",
|
||||||
"unique_prefix": "INTRNT",
|
"unique_prefix": "INTRNT",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_3",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"mapped_to_table": "CurrentScan",
|
"mapped_to_table": "CurrentScan",
|
||||||
"data_filters": [
|
"data_filters": [
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"plugin_type": "other",
|
"plugin_type": "other",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
|
"execution_order" : "Layer_3",
|
||||||
"show_ui": true,
|
"show_ui": true,
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [
|
"display_name": [
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "nmap_dev_scan",
|
"code_name": "nmap_dev_scan",
|
||||||
"unique_prefix": "NMAPDEV",
|
"unique_prefix": "NMAPDEV",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_3",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"mapped_to_table": "CurrentScan",
|
"mapped_to_table": "CurrentScan",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "nmap_scan",
|
"code_name": "nmap_scan",
|
||||||
"unique_prefix": "NMAP",
|
"unique_prefix": "NMAP",
|
||||||
"plugin_type": "other",
|
"plugin_type": "other",
|
||||||
|
"execution_order" : "Layer_4",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"data_filters": [
|
"data_filters": [
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "nslookup_scan",
|
"code_name": "nslookup_scan",
|
||||||
"unique_prefix": "NSLOOKUP",
|
"unique_prefix": "NSLOOKUP",
|
||||||
"plugin_type": "other",
|
"plugin_type": "other",
|
||||||
|
"execution_order" : "Layer_4",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"show_ui": true,
|
"show_ui": true,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "omada_sdn_imp",
|
"code_name": "omada_sdn_imp",
|
||||||
"unique_prefix": "OMDSDN",
|
"unique_prefix": "OMDSDN",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_1",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"mapped_to_table": "CurrentScan",
|
"mapped_to_table": "CurrentScan",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "pihole_scan",
|
"code_name": "pihole_scan",
|
||||||
"unique_prefix": "PIHOLE",
|
"unique_prefix": "PIHOLE",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_2",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "sqlite-db-query",
|
"data_source": "sqlite-db-query",
|
||||||
"mapped_to_table": "CurrentScan",
|
"mapped_to_table": "CurrentScan",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"code_name": "snmp_discovery",
|
"code_name": "snmp_discovery",
|
||||||
"unique_prefix": "SNMPDSC",
|
"unique_prefix": "SNMPDSC",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_1",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"data_filters": [
|
"data_filters": [
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"show_ui": true,
|
"show_ui": true,
|
||||||
"unique_prefix": "UNFIMP",
|
"unique_prefix": "UNFIMP",
|
||||||
"plugin_type": "device_scanner",
|
"plugin_type": "device_scanner",
|
||||||
|
"execution_order" : "Layer_1",
|
||||||
"data_source": "script",
|
"data_source": "script",
|
||||||
"localized": ["display_name", "description", "icon"],
|
"localized": ["display_name", "description", "icon"],
|
||||||
"display_name": [
|
"display_name": [
|
||||||
|
|||||||
@@ -96,33 +96,33 @@ def print_scan_stats(db):
|
|||||||
mylog('verbose', f'[Scan Stats] IP Changes.............: {stats[0]["ip_changes"]}')
|
mylog('verbose', f'[Scan Stats] IP Changes.............: {stats[0]["ip_changes"]}')
|
||||||
|
|
||||||
# if str(stats[0]["new_devices"]) != '0':
|
# if str(stats[0]["new_devices"]) != '0':
|
||||||
mylog('debug', f' ================ DEVICES table content ================')
|
mylog('trace', f' ================ DEVICES table content ================')
|
||||||
sql.execute('select * from Devices')
|
sql.execute('select * from Devices')
|
||||||
rows = sql.fetchall()
|
rows = sql.fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
row_dict = dict(row)
|
row_dict = dict(row)
|
||||||
mylog('debug', f' {row_dict}')
|
mylog('trace', f' {row_dict}')
|
||||||
|
|
||||||
mylog('debug', f' ================ CurrentScan table content ================')
|
mylog('trace', f' ================ CurrentScan table content ================')
|
||||||
sql.execute('select * from CurrentScan')
|
sql.execute('select * from CurrentScan')
|
||||||
rows = sql.fetchall()
|
rows = sql.fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
row_dict = dict(row)
|
row_dict = dict(row)
|
||||||
mylog('debug', f' {row_dict}')
|
mylog('trace', f' {row_dict}')
|
||||||
|
|
||||||
mylog('debug', f' ================ Events table content where eve_PendingAlertEmail = 1 ================')
|
mylog('trace', f' ================ Events table content where eve_PendingAlertEmail = 1 ================')
|
||||||
sql.execute('select * from Events where eve_PendingAlertEmail = 1')
|
sql.execute('select * from Events where eve_PendingAlertEmail = 1')
|
||||||
rows = sql.fetchall()
|
rows = sql.fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
row_dict = dict(row)
|
row_dict = dict(row)
|
||||||
mylog('debug', f' {row_dict}')
|
mylog('trace', f' {row_dict}')
|
||||||
|
|
||||||
mylog('debug', f' ================ Events table COUNT ================')
|
mylog('trace', f' ================ Events table COUNT ================')
|
||||||
sql.execute('select count(*) from Events')
|
sql.execute('select count(*) from Events')
|
||||||
rows = sql.fetchall()
|
rows = sql.fetchall()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
row_dict = dict(row)
|
row_dict = dict(row)
|
||||||
mylog('debug', f' {row_dict}')
|
mylog('trace', f' {row_dict}')
|
||||||
|
|
||||||
|
|
||||||
mylog('verbose', '[Scan Stats] Scan Method Statistics:')
|
mylog('verbose', '[Scan Stats] Scan Method Statistics:')
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ def importConfigs (db, all_plugins):
|
|||||||
|
|
||||||
conf.LOADED_PLUGINS = ccd('LOADED_PLUGINS', [] , c_d, 'Loaded plugins', '{"dataType":"array", "elements": [{"elementType" : "select", "elementOptions" : [{"multiple":"true"}] ,"transformers": []}]}', '[]', 'General')
|
conf.LOADED_PLUGINS = ccd('LOADED_PLUGINS', [] , c_d, 'Loaded plugins', '{"dataType":"array", "elements": [{"elementType" : "select", "elementOptions" : [{"multiple":"true"}] ,"transformers": []}]}', '[]', 'General')
|
||||||
conf.SCAN_SUBNETS = ccd('SCAN_SUBNETS', ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0'] , c_d, 'Subnets to scan', '{"dataType": "array","elements": [ {"elementType": "input","elementOptions": [{ "placeholder": "192.168.1.0/24 --interface=eth1" },{ "suffix": "_in" },{ "cssClasses": "col-sm-10" },{ "prefillValue": "null" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": ["_in"] },{ "separator": "" },{ "cssClasses": "col-xs-12" },{ "onClick": "addList(this, false)" },{ "getStringKey": "Gen_Add" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeAllOptions(this)" },{ "getStringKey": "Gen_Remove_All" }],"transformers": []},{"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeFromList(this)" },{ "getStringKey": "Gen_Remove_Last" }],"transformers": []}, {"elementType": "select","elementOptions": [{ "multiple": "true" },{ "readonly": "true" },{ "editable": "true" }],"transformers": [] }]}', '[]', 'General')
|
conf.SCAN_SUBNETS = ccd('SCAN_SUBNETS', ['192.168.1.0/24 --interface=eth1', '192.168.1.0/24 --interface=eth0'] , c_d, 'Subnets to scan', '{"dataType": "array","elements": [ {"elementType": "input","elementOptions": [{ "placeholder": "192.168.1.0/24 --interface=eth1" },{ "suffix": "_in" },{ "cssClasses": "col-sm-10" },{ "prefillValue": "null" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": ["_in"] },{ "separator": "" },{ "cssClasses": "col-xs-12" },{ "onClick": "addList(this, false)" },{ "getStringKey": "Gen_Add" }],"transformers": [] }, {"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeAllOptions(this)" },{ "getStringKey": "Gen_Remove_All" }],"transformers": []},{"elementType": "button","elementOptions": [{ "sourceSuffixes": [] },{ "separator": "" },{ "cssClasses": "col-xs-6" },{ "onClick": "removeFromList(this)" },{ "getStringKey": "Gen_Remove_Last" }],"transformers": []}, {"elementType": "select","elementOptions": [{ "multiple": "true" },{ "readonly": "true" },{ "editable": "true" }],"transformers": [] }]}', '[]', 'General')
|
||||||
conf.LOG_LEVEL = ccd('LOG_LEVEL', 'verbose' , c_d, 'Log verboseness', '{"dataType":"string", "elements": [{"elementType" : "select", "elementOptions" : [] ,"transformers": []}]}', "['none', 'minimal', 'verbose', 'debug']", 'General')
|
conf.LOG_LEVEL = ccd('LOG_LEVEL', 'verbose' , c_d, 'Log verboseness', '{"dataType":"string", "elements": [{"elementType" : "select", "elementOptions" : [] ,"transformers": []}]}', "['none', 'minimal', 'verbose', 'debug', 'trace']", 'General')
|
||||||
conf.TIMEZONE = ccd('TIMEZONE', 'Europe/Berlin' , c_d, 'Time zone', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [] ,"transformers": []}]}', '[]', 'General')
|
conf.TIMEZONE = ccd('TIMEZONE', 'Europe/Berlin' , c_d, 'Time zone', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [] ,"transformers": []}]}', '[]', 'General')
|
||||||
conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 250 , c_d, 'Keep history entries', '{"dataType":"integer", "elements": [{"elementType" : "input", "elementOptions" : [{"type": "number"}] ,"transformers": []}]}', '[]', 'General')
|
conf.PLUGINS_KEEP_HIST = ccd('PLUGINS_KEEP_HIST', 250 , c_d, 'Keep history entries', '{"dataType":"integer", "elements": [{"elementType" : "input", "elementOptions" : [{"type": "number"}] ,"transformers": []}]}', '[]', 'General')
|
||||||
conf.REPORT_DASHBOARD_URL = ccd('REPORT_DASHBOARD_URL', 'http://netalertx/' , c_d, 'NetAlertX URL', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [] ,"transformers": []}]}', '[]', 'General')
|
conf.REPORT_DASHBOARD_URL = ccd('REPORT_DASHBOARD_URL', 'http://netalertx/' , c_d, 'NetAlertX URL', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [] ,"transformers": []}]}', '[]', 'General')
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ def timeNowTZ():
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# More verbose as the numbers go up
|
# More verbose as the numbers go up
|
||||||
debugLevels = [
|
debugLevels = [
|
||||||
('none', 0), ('minimal', 1), ('verbose', 2), ('debug', 3)
|
('none', 0), ('minimal', 1), ('verbose', 2), ('debug', 3), ('trace', 4)
|
||||||
]
|
]
|
||||||
|
|
||||||
currentLevel = 0
|
currentLevel = 0
|
||||||
|
|||||||
@@ -172,15 +172,25 @@ def resolve_wildcards_arr(commandArr, params):
|
|||||||
|
|
||||||
return commandArr
|
return commandArr
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Function to extract layer number from "execution_order"
|
||||||
|
def get_layer(plugin):
|
||||||
|
order = plugin.get("execution_order", "Layer_N")
|
||||||
|
if order == "Layer_N":
|
||||||
|
return float('inf') # Treat as the last layer if "execution_order" is missing
|
||||||
|
return int(order.split('_')[1])
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
def get_plugins_configs():
|
def get_plugins_configs():
|
||||||
pluginsList = [] # Create an empty list to store plugin configurations
|
pluginsList = [] # Create an empty list to store plugin configurations
|
||||||
|
pluginsListSorted = [] # Sorted by "execution_order" : "Layer_0" first, Layer_N last
|
||||||
|
|
||||||
# Get a list of top-level directories in the specified pluginsPath
|
# Get a list of top-level directories in the specified pluginsPath
|
||||||
dirs = next(os.walk(pluginsPath))[1]
|
dirs = next(os.walk(pluginsPath))[1]
|
||||||
|
|
||||||
|
# Sort the directories list if needed
|
||||||
|
dirs.sort() # This will sort the directories alphabetically
|
||||||
|
|
||||||
# Loop through each directory (plugin folder) in dirs
|
# Loop through each directory (plugin folder) in dirs
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
# Check if the directory name does not start with "__" to skip python cache
|
# Check if the directory name does not start with "__" to skip python cache
|
||||||
@@ -194,7 +204,10 @@ def get_plugins_configs():
|
|||||||
# Load the contents of the config.json file as a JSON object and append it to pluginsList
|
# Load the contents of the config.json file as a JSON object and append it to pluginsList
|
||||||
pluginsList.append(json.loads(get_file_content(config_path)))
|
pluginsList.append(json.loads(get_file_content(config_path)))
|
||||||
|
|
||||||
return pluginsList # Return the list of plugin configurations
|
# Sort pluginsList based on "execution_order"
|
||||||
|
pluginsListSorted = sorted(pluginsList, key=get_layer)
|
||||||
|
|
||||||
|
return pluginsListSorted # Return the sorted list of plugin configurations
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user