From c5d1cd919add709328b75db9f6f41f208357b2ef Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Wed, 20 Sep 2023 22:20:41 +1000 Subject: [PATCH] internet_ip plugin 0.3 --- front/plugins/csv_backup/config.json | 3 ++- front/plugins/db_cleanup/config.json | 3 ++- front/plugins/dhcp_leases/config.json | 3 ++- front/plugins/dhcp_servers/config.json | 3 ++- front/plugins/internet_ip/config.json | 32 ++++++++++++++++++----- front/plugins/internet_ip/script.py | 17 ++++++------ front/plugins/nmap_scan/config.json | 1 + front/plugins/pihole_scan/config.json | 3 ++- front/plugins/set_password/config.json | 3 ++- front/plugins/snmp_discovery/config.json | 3 ++- front/plugins/undiscoverables/config.json | 1 + front/plugins/unifi_import/config.json | 1 + front/plugins/vendor_update/config.json | 1 + front/plugins/website_monitor/config.json | 3 ++- 14 files changed, 55 insertions(+), 22 deletions(-) diff --git a/front/plugins/csv_backup/config.json b/front/plugins/csv_backup/config.json index af2651d9..0817c2fe 100755 --- a/front/plugins/csv_backup/config.json +++ b/front/plugins/csv_backup/config.json @@ -62,7 +62,8 @@ "settings": [ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"schedule", "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"], diff --git a/front/plugins/db_cleanup/config.json b/front/plugins/db_cleanup/config.json index aa2917f5..7f22084c 100755 --- a/front/plugins/db_cleanup/config.json +++ b/front/plugins/db_cleanup/config.json @@ -48,7 +48,8 @@ "settings": [ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"schedule", "options": ["disabled", "once", "schedule", "always_after_scan"], diff --git a/front/plugins/dhcp_leases/config.json b/front/plugins/dhcp_leases/config.json index a462da94..0fa8e7d5 100755 --- a/front/plugins/dhcp_leases/config.json +++ b/front/plugins/dhcp_leases/config.json @@ -309,7 +309,8 @@ ], "settings":[ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"], diff --git a/front/plugins/dhcp_servers/config.json b/front/plugins/dhcp_servers/config.json index 69e72e94..a1290c15 100755 --- a/front/plugins/dhcp_servers/config.json +++ b/front/plugins/dhcp_servers/config.json @@ -273,7 +273,8 @@ ], "settings":[ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"], diff --git a/front/plugins/internet_ip/config.json b/front/plugins/internet_ip/config.json index ed112649..8e8cb617 100755 --- a/front/plugins/internet_ip/config.json +++ b/front/plugins/internet_ip/config.json @@ -78,6 +78,7 @@ "settings": [ { "function": "RUN", + "events": ["run"], "type": "text.select", "default_value": "schedule", "options": [ @@ -254,14 +255,33 @@ "description": [ { "language_code": "en_us", - "string": "Send a notification if selected values change. Use CTRL + Click to select/deselect. " - }, - { - "language_code": "es_es", - "string": "Envíe una notificación si los valores seleccionados cambian. Use CTRL + Click para seleccionar/deseleccionar. " + "string": "Send a notification if selected values change. Use CTRL + Click to select/deselect. " } ] - } + }, + { + "function": "REPORT_ON", + "type": "text.multiselect", + "default_value":["new","watched-changed"], + "options": ["new","watched-changed","watched-not-changed", "missing-in-last-scan"], + "localized": ["name", "description"], + "name" :[{ + "language_code":"en_us", + "string" : "Report on" + }, + { + "language_code":"es_es", + "string" : "Informar sobre" + } ] , + "description":[{ + "language_code":"en_us", + "string" : "Send a notification only on these statuses. new means a new unique (unique combination of PrimaryId and SecondaryId) object was discovered. watched-changed means that selected Watched_ValueN columns changed." + }, + { + "language_code":"es_es", + "string" : "Envíe una notificación solo en estos estados. new significa que se descubrió un nuevo objeto único (una combinación única de PrimaryId y SecondaryId). watched-changed significa que las columnas Watched_ValueN seleccionadas cambiaron." + }] + } ], "database_column_definitions": [ { diff --git a/front/plugins/internet_ip/script.py b/front/plugins/internet_ip/script.py index 5abfb858..fc88da93 100755 --- a/front/plugins/internet_ip/script.py +++ b/front/plugins/internet_ip/script.py @@ -10,6 +10,7 @@ import hashlib import csv import subprocess import re +import base64 import sqlite3 from io import StringIO from datetime import datetime @@ -41,7 +42,7 @@ def main(): parser.add_argument('DDNS_DOMAIN', action="store", help="Dynamic DNS (DDNS) domain name") parser.add_argument('DIG_GET_IP_ARG', action="store", help="Arguments for the 'dig' command to retrieve the IP address") - args = parser.parse_args() + values = parser.parse_args() PREV_IP = values.prev_ip.split('=')[1] DDNS_ACTIVE = values.DDNS_ACTIVE.split('=')[1] @@ -54,9 +55,9 @@ def main(): mylog('verbose', ['[INTRNT] DIG_GET_IP_ARG: ', DIG_GET_IP_ARG]) # Decode the base64-encoded value to get the actual value in ASCII format. - DIG_GET_IP_ARG = base64.b64decode(DIG_GET_IP_ARG).decode('ascii') + DIG_GET_IP_ARG = base64.b64decode(DIG_GET_IP_ARG.split('b')[1]).decode('ascii') - mylog('verbose', ['[INTRNT] DIG_GET_IP_ARG resolved: ', DIG_GET_IP_ARG]) + mylog('verbose', [f'[INTRNT] DIG_GET_IP_ARG resolved: {DIG_GET_IP_ARG} ']) # if internet_IP != "" : # sql.execute (f"""INSERT INTO CurrentScan (cur_MAC, cur_IP, cur_Vendor, cur_ScanMethod) @@ -90,10 +91,10 @@ def main(): primaryId = 'Internet', # MAC (Device Name) secondaryId = '', watched1 = new_internet_IP, # IP Address - watched2 = f'Previous IP: {prev_ip}', + watched2 = f'Previous IP: {PREV_IP}', watched3 = '', watched4 = '', - extra = f'Previous IP: {prev_ip}', + extra = f'Previous IP: {PREV_IP}', foreignKey = 'Internet') plugin_objects.write_result_file() @@ -120,18 +121,18 @@ def check_internet_IP ( DDNS_ACTIVE, DDNS_UPDATE_URL, DDNS_USER, DDNS_PASSWORD, # Get previous stored IP previous_IP = '0.0.0.0' - if PREV_IP is not None and len(result) > 0 : + if PREV_IP is not None and len(PREV_IP) > 0 : previous_IP = PREV_IP mylog('verbose', ['[INTRNT] ', previous_IP]) # logging - append_line_to_file (logPath + '/IP_changes.log', '['+str(timeNowTZ()) +']\t'+ pNewIP +'\n') + append_line_to_file (logPath + '/IP_changes.log', '['+str(timeNowTZ()) +']\t'+ internet_IP +'\n') # Get Dynamic DNS IP if DDNS_ACTIVE : mylog('verbose', ['[DDNS] Retrieving Dynamic DNS IP']) - dns_IP = get_dynamic_DNS_IP() + dns_IP = get_dynamic_DNS_IP(DDNS_DOMAIN) # Check Dynamic DNS IP if dns_IP == "" or dns_IP == "0.0.0.0" : diff --git a/front/plugins/nmap_scan/config.json b/front/plugins/nmap_scan/config.json index 54acffd3..d1d840c3 100755 --- a/front/plugins/nmap_scan/config.json +++ b/front/plugins/nmap_scan/config.json @@ -319,6 +319,7 @@ "settings":[ { "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"], diff --git a/front/plugins/pihole_scan/config.json b/front/plugins/pihole_scan/config.json index f75f285d..80a03d1d 100755 --- a/front/plugins/pihole_scan/config.json +++ b/front/plugins/pihole_scan/config.json @@ -56,7 +56,8 @@ "settings": [ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"], diff --git a/front/plugins/set_password/config.json b/front/plugins/set_password/config.json index 7530ae47..0449b0ea 100755 --- a/front/plugins/set_password/config.json +++ b/front/plugins/set_password/config.json @@ -41,7 +41,8 @@ ], "settings":[ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "before_config_save"], diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index aef045a9..0e2555ca 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -305,7 +305,8 @@ ], "settings":[ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"], diff --git a/front/plugins/undiscoverables/config.json b/front/plugins/undiscoverables/config.json index 2080c739..6bde9463 100755 --- a/front/plugins/undiscoverables/config.json +++ b/front/plugins/undiscoverables/config.json @@ -47,6 +47,7 @@ "settings": [ { "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "once", "always_after_scan"], diff --git a/front/plugins/unifi_import/config.json b/front/plugins/unifi_import/config.json index 66b744f3..fac277aa 100755 --- a/front/plugins/unifi_import/config.json +++ b/front/plugins/unifi_import/config.json @@ -488,6 +488,7 @@ } ], "function": "RUN", + "events": ["run"], "localized": [ "name", "description" diff --git a/front/plugins/vendor_update/config.json b/front/plugins/vendor_update/config.json index e04eb87e..2f56cada 100755 --- a/front/plugins/vendor_update/config.json +++ b/front/plugins/vendor_update/config.json @@ -31,6 +31,7 @@ "settings": [ { "function": "RUN", + "events": ["run"], "type": "text.select", "default_value": "schedule", "options": [ diff --git a/front/plugins/website_monitor/config.json b/front/plugins/website_monitor/config.json index 9ec01241..60314086 100755 --- a/front/plugins/website_monitor/config.json +++ b/front/plugins/website_monitor/config.json @@ -308,7 +308,8 @@ ], "settings":[ { - "function": "RUN", + "function": "RUN", + "events": ["run"], "type": "text.select", "default_value":"disabled", "options": ["disabled", "once", "schedule", "always_after_scan", "on_new_device"],