From 87b114604ca83b390ad328d6b64e4c4cc286eca6 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sat, 27 Apr 2024 10:30:40 +1000 Subject: [PATCH] =?UTF-8?q?NMAPDEV=20plugin=20work=20v0.6=20#645=20?= =?UTF-8?q?=F0=9F=86=95=F0=9F=94=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/NOTIFICATIONS.md | 2 +- docs/README.md | 1 + front/plugins/README.md | 2 -- front/plugins/csv_backup/README.md | 12 ------------ front/plugins/nmap_dev_scan/nmap_dev.py | 15 ++++++++++++--- front/plugins/plugin_helper.py | 8 +++++--- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/docs/NOTIFICATIONS.md b/docs/NOTIFICATIONS.md index 77997dd9..33055b63 100755 --- a/docs/NOTIFICATIONS.md +++ b/docs/NOTIFICATIONS.md @@ -43,7 +43,7 @@ In the Notification Processing section, you can specify blanket rules. These all 3. A filter to allow you to set device-specific exceptions to New devices being added to the app. 4. A filter to allow you to set device-specific exceptions to generated Events. -## Ignoring devices 🛑 +## Ignoring devices 🔕 ![Ignoring new devices](/docs/img/NOTIFICATIONS/NEWDEV_ignores.png) diff --git a/docs/README.md b/docs/README.md index a909a2ed..da4d0b88 100755 --- a/docs/README.md +++ b/docs/README.md @@ -30,6 +30,7 @@ There is also an in-app Help / FAQ section that should be answering frequently a - [Subnets and VLANs configuration for arp-scan](/docs/SUBNETS.md) - [SMTP server config](/docs/SMTP.md) - [Custom Icon configuration and support](/docs/ICONS.md) +- [Notifications](/docs/NOTIFICATIONS.md) - [Better name resolution with Reverse DNS](/docs/REVERSE_DNS.md) - [Network treemap configuration](/docs/NETWORK_TREE.md) - [Backups](/docs/BACKUPS.md) diff --git a/front/plugins/README.md b/front/plugins/README.md index ac9234ce..15be16fe 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -1,5 +1,3 @@ -> Community translations of this file (might be out-of-date): Spanish(README_ES.md), German(README_DE.md) - # 📚 Docs for individual plugins >[!NOTE] diff --git a/front/plugins/csv_backup/README.md b/front/plugins/csv_backup/README.md index 4f5e97a9..41495252 100755 --- a/front/plugins/csv_backup/README.md +++ b/front/plugins/csv_backup/README.md @@ -1,15 +1,3 @@ -### Community translations of this file - - - README_ES.md - Spanish (Spain) - -
- - README_DE.md - German (Germany) - - ## Overview Plugin generating CSV backups of your Devices database table, including the network mappings. Can be used for importing your setup via the Maintenance > Backup / Restore > CSV Import feature (See also: [Devices Bulk Editing](https://github.com/jokob-sk/NetAlertX/blob/main/docs/DEVICES_BULK_EDITING.md)). diff --git a/front/plugins/nmap_dev_scan/nmap_dev.py b/front/plugins/nmap_dev_scan/nmap_dev.py index 476a6860..ba23a7b7 100755 --- a/front/plugins/nmap_dev_scan/nmap_dev.py +++ b/front/plugins/nmap_dev_scan/nmap_dev.py @@ -100,14 +100,23 @@ def execute_scan (subnets_list, timeout): # lines[1] can be Host is up (0.21s latency). # lines[2] can be MAC Address: 6C:4A:4A:7B:4A:43 (Motorola Mobility, a Lenovo Company) - ip_address = extract_ip_addresses(lines[0])[0] + ip_addresses = extract_ip_addresses(lines[0]) host_name = extract_between_strings(lines[0], ' ', ' ') vendor = extract_between_strings(lines[2], '(', ')') mac_addresses = extract_mac_addresses(lines[2]) - if len(mac_addresses) == 1: + # only include results with a MAC address and IPs as it's used as a unique ID + if len(mac_addresses) == 1 and len(ip_addresses) == 1: - devices_list.append({'name': host_name, 'ip': ip_address, 'mac': mac_addresses[0], 'vendor': vendor, 'interface': interface}) + devices_list.append({'name' : host_name, + 'ip' : ip_addresses[0], + 'mac' : mac_addresses[0], + 'vendor' : vendor, + 'interface': interface}) + else: + mylog('verbose', [f"[{pluginName}] Skipped (Couldn't parse MAC or IP): ", lines]) + else: + mylog('verbose', [f"[{pluginName}] Skipped (Not enough info in output): ", lines]) return devices_list diff --git a/front/plugins/plugin_helper.py b/front/plugins/plugin_helper.py index 501ea23a..4c031926 100755 --- a/front/plugins/plugin_helper.py +++ b/front/plugins/plugin_helper.py @@ -38,15 +38,17 @@ timeZoneSetting = configFile['TIMEZONE'] timeZone = pytz.timezone(timeZoneSetting) # ------------------------------------------------------------------- +# Sanitizes plugin output def handleEmpty(input): - if input == '' or None: + if not input: return 'null' else: # Validate and sanitize message content # Remove potentially problematic characters if string - if isinstance(input, str): + if isinstance(input, str): input = re.sub(r'[^\x00-\x7F]+', ' ', input) - return input + input = input.replace('\n', '') # Removing new lines + return input # ------------------------------------------------------------------- # Check if a valid MAC address