From c38758d61adde76dcaca6f401e9a21d7b984e4de Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Sat, 15 Nov 2025 13:48:18 +1100 Subject: [PATCH] PLG: PIHOLEAPI skipping invalid macs #1282 Signed-off-by: jokob-sk --- docs/PLUGINS.md | 1 + .../pihole_api_scan/pihole_api_scan.py | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/PLUGINS.md b/docs/PLUGINS.md index 7f934a19..6191e384 100755 --- a/docs/PLUGINS.md +++ b/docs/PLUGINS.md @@ -75,6 +75,7 @@ Device-detecting plugins insert values into the `CurrentScan` database table. T | `OMDSDN` | [omada_sdn_imp](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/omada_sdn_imp/) | 📥/🆎 ❌ | UNMAINTAINED use `OMDSDNOPENAPI` | 🖧 🔄 | | | `OMDSDNOPENAPI` | [omada_sdn_openapi](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/omada_sdn_openapi/) | 📥/🆎 | OMADA TP-Link import via OpenAPI | 🖧 | | | `PIHOLE` | [pihole_scan](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/pihole_scan/) | 🔍/🆎/📥 | Pi-hole device import & sync | | | +| `PIHOLEAPI` | [pihole_api_scan](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/pihole_api_scan/) | 🔍/🆎/📥 | Pi-hole device import & sync via API v6+ | | | | `PUSHSAFER` | [_publisher_pushsafer](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/_publisher_pushsafer/) | ▶️ | Pushsafer notifications | | | | `PUSHOVER` | [_publisher_pushover](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/_publisher_pushover/) | ▶️ | Pushover notifications | | | | `SETPWD` | [set_password](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/set_password/) | ⚙ | Set password | | Yes | diff --git a/front/plugins/pihole_api_scan/pihole_api_scan.py b/front/plugins/pihole_api_scan/pihole_api_scan.py index d654786b..a6b08baf 100644 --- a/front/plugins/pihole_api_scan/pihole_api_scan.py +++ b/front/plugins/pihole_api_scan/pihole_api_scan.py @@ -17,7 +17,7 @@ sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"]) pluginName = 'PIHOLEAPI' -from plugin_helper import Plugin_Objects +from plugin_helper import Plugin_Objects, is_mac from logger import mylog, Logger from helper import get_setting_value from const import logPath @@ -266,19 +266,22 @@ def main(): else: for entry in device_entries: - # Map to Plugin_Objects fields - mylog('verbose', [f'[{pluginName}] found: {entry['name']}|{entry['mac']}|{entry['ip']}']) + if is_mac(entry['mac']): + # Map to Plugin_Objects fields + mylog('verbose', [f'[{pluginName}] found: {entry['name']}|{entry['mac']}|{entry['ip']}']) - plugin_objects.add_object( - primaryId=str(entry['mac']), - secondaryId=str(entry['ip']), - watched1=str(entry['name']), - watched2=str(entry['macVendor']), - watched3=str(entry['lastQuery']), - watched4="", - extra=pluginName, - foreignKey=str(entry['mac']) - ) + plugin_objects.add_object( + primaryId=str(entry['mac']), + secondaryId=str(entry['ip']), + watched1=str(entry['name']), + watched2=str(entry['macVendor']), + watched3=str(entry['lastQuery']), + watched4="", + extra=pluginName, + foreignKey=str(entry['mac']) + ) + else: + mylog('verbose', [f'[{pluginName}] Skipping invalid MAC: {entry['name']}|{entry['mac']}|{entry['ip']}']) # Write result file for NetAlertX to ingest plugin_objects.write_result_file()