From de5dfa9d06802cf2c12fb2c6c709ab889c35fbe2 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Fri, 8 Dec 2023 07:32:50 +1100 Subject: [PATCH] =?UTF-8?q?fix=20SNMP=20discovery=20+=20other=20=20#512?= =?UTF-8?q?=F0=9F=A9=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 +++++++-------- dockerfiles/README.md | 16 ++++++++++------ docs/SETTINGS_SYSTEM.md | 2 +- front/plugins/README.md | 2 +- front/plugins/README_DE.md | 2 +- front/plugins/pihole_scan/config.json | 2 +- front/plugins/snmp_discovery/script.py | 2 +- pialert/database.py | 6 +++--- pialert/plugin.py | 6 +++--- 9 files changed, 28 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index bfe4052cd..9d6829f79 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# πŸ’»πŸ” Network security scanner +# πŸ’»πŸ” Network security scanner & notification framework -Scans for devices, port changes on your WIFI/LAN and alerts you if unknown devices or changes are found. +Get visibility of what's going on on your WIFI/LAN network. Scan for devices, port changes and get alerts if unknown devices or changes are found. Write your own [Plugins](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) with auto-generated UI and in-build notification system. [![Docker](https://img.shields.io/github/actions/workflow/status/jokob-sk/Pi.Alert/docker_prod.yml?label=Build&logo=GitHub)](https://github.com/jokob-sk/Pi.Alert/actions/workflows/docker_prod.yml) [![GitHub Committed](https://img.shields.io/github/last-commit/jokob-sk/Pi.Alert?color=40ba12&label=Committed&logo=GitHub&logoColor=fff)](https://github.com/jokob-sk/Pi.Alert) @@ -13,15 +13,15 @@ Scans for devices, port changes on your WIFI/LAN and alerts you if unknown devic ## Why PiAlert❓ -Most of us don't know what's going on on our home network, but we want our family and data to _be safe_. _Command-line tools_ are great, but the output can be _hard to understand_ and action if you are not a network specialist πŸ˜–. +Most of us don't know what's going on on our home network, but we want our family and data to be safe. _Command-line tools_ are great, but the output can be _hard to understand_ and action if you are not a network specialist. PiAlert gives you peace of mind. _Visualize and immediately report πŸ“¬_ what is going on in your network - this is the first step to enhance your _network security πŸ”_. -_PiAlert combines several network and other scanning tools πŸ” with notifications πŸ“§ into one user-friendly package πŸ“¦_. You get an overview of network device Sessions, Connected devices, Favorites, Events, Presence, Down alerts, and IPs. You can schedule Nmap scans to detect changes in device ports and visualize your Network topology (even with undetectable, dummy devices). +_PiAlert combines several network and other scanning tools πŸ” with notifications πŸ“§ into one user-friendly package πŸ“¦_. You get an overview of network device Sessions, Connected devices, Events, Presence, Down alerts, and IPs. You can schedule Nmap scans to detect changes in device ports and visualize your Network topology (even with undetectable, dummy devices). Setup a _kill switch ☠_ for your network via a smart plug with the available [Home Assistant](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/HOME_ASSISTANT.md) integration. Implement custom automations with the [CSV device Exports πŸ“€](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins/csv_backup), [Webhooks](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/WEBHOOK_N8N.md), or [API endpoints](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md) features. -Extend the app if you want to create your own scanner and handle the results and notifications in PiAlert. Check available [Plugins & Instructions](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins). +Extend the app if you want to create your own scanner [Plugin](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) and handle the results and notifications in PiAlert. Looking forward to your contributions if you decide to share your work with the community ❀. @@ -34,11 +34,10 @@ Looking forward to your contributions if you decide to share your work with the | Features | Details | |-------------|-------------| -| πŸ” | The app scans your network for, **New devices**, **New connections** (re-connections), **Disconnections**, **"Always Connected" devices down**, Devices **IP changes** and **Internet IP address changes**. Discovery & scan methods include: **arp-scan**. **Pi-hole - DB import**, **Pi-hole - DHCP leases import**, **Generic DHCP leases import**. **UNIFI controller import**, **SNMP-enabled router import**. Check the [Plugins](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins) docs for more info on individual scans. | +| πŸ” | The app scans your network for, **New devices**, **New connections** (re-connections), **Disconnections**, **"Always Connected" devices down**, Devices **IP changes** and **Internet IP address changes**. Discovery & scan methods include: **arp-scan**. **Pi-hole - DB import**, **Pi-hole - DHCP leases import**, **Generic DHCP leases import**. **UNIFI controller import**, **SNMP-enabled router import**. Check the [Plugins](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) docs for more info on individual scans. | |πŸ“§ | Send notifications to more than 80+ services, including Telegram via [Apprise](https://hub.docker.com/r/caronc/apprise), or use [Pushsafer](https://www.pushsafer.com/), or [NTFY](https://ntfy.sh/). | |🧩 | Feed your data and device changes into [Home Assistant](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/HOME_ASSISTANT.md), read [API endpoints](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/API.md), or use [Webhooks](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/WEBHOOK_N8N.md) to setup custom automation flows. | -|βž• | Build your own scanners with the [Plugin system](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins) | - +|βž• | Build your own scanners with the [Plugin system](https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins#readme) | ## Installation & Documentation diff --git a/dockerfiles/README.md b/dockerfiles/README.md index 45a47b9ea..7a95f1a7f 100755 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -4,7 +4,7 @@ [![Docker Pulls](https://img.shields.io/docker/pulls/jokobsk/pi.alert?label=Pulls&logo=docker&color=0aa8d2&logoColor=fff)](https://hub.docker.com/r/jokobsk/pi.alert) [![Docker Pushed](https://img.shields.io/badge/dynamic/json?color=0aa8d2&logoColor=fff&label=Pushed&query=last_updated&url=https%3A%2F%2Fhub.docker.com%2Fv2%2Frepositories%2Fjokobsk%2Fpi.alert%2F&logo=docker&link=http://left&link=https://hub.docker.com/repository/docker/jokobsk/pi.alert)](https://hub.docker.com/r/jokobsk/pi.alert) -# PiAlert πŸ’»πŸ” Network security scanner +# PiAlert πŸ’»πŸ” Network security scanner & notification framework | 🐳 [Docker hub](https://registry.hub.docker.com/r/jokobsk/pi.alert) | πŸ“‘ [Docker guide](https://github.com/jokob-sk/Pi.Alert/blob/main/dockerfiles/README.md) |πŸ†• [Release notes](https://github.com/jokob-sk/Pi.Alert/releases) | πŸ“š [All Docs](https://github.com/jokob-sk/Pi.Alert/tree/main/docs) | |----------------------|----------------------| ----------------------| ----------------------| @@ -83,15 +83,16 @@ There are 2 approaches how to get PiHole devices imported. Via the PiHole import > [!NOTE] > It's recommended to use the same schedule interval for all plugins responsible for discovering new devices. -#### Community guides + +#### 🧭 Community guides > Primarily use the official installation guides in this document and use community content as suplementary material. Open an issue if you'd like to add your link to the list πŸ™ -- πŸ“„ [How to Install Pi.Alert on Your Synology NAS by Marius hosting (English)](https://mariushosting.com/how-to-install-pi-alert-on-your-synology-nas/) (Updated frequently) +- πŸ“„ [How to Install Pi.Alert on Your Synology NAS - Marius hosting (English)](https://mariushosting.com/how-to-install-pi-alert-on-your-synology-nas/) (Updated frequently) - πŸ“„ [μ‹œλ†€/ν—€λ†€μ—μ„œ λ„€νŠΈμ›Œν¬ μŠ€μΊλ„ˆ Pi.Alert Docker둜 μ„€μΉ˜ 및 μ‚¬μš©ν•˜κΈ° (Korean)](https://blog.dalso.org/article/%EC%8B%9C%EB%86%80-%ED%97%A4%EB%86%80%EC%97%90%EC%84%9C-%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%81%AC-%EC%8A%A4%EC%BA%90%EB%84%88-pi-alert-docker%EB%A1%9C-%EC%84%A4%EC%B9%98-%EB%B0%8F-%EC%82%AC%EC%9A%A9) (July 2023) -- β–Ά [Pi.Alert auf Synology & Docker (German)](https://www.youtube.com/watch?v=-ouvA2UNu-A) (March 2023) -- β–Ά [Top Docker Container for Home Server Security by VirtualizationHowto (English)](https://www.youtube.com/watch?v=tY-w-enLF6Q) (March 2023) -- β–Ά [Pi.Alert or WatchYourLAN can alert you to unknown devices appearing on your WiFi or LAN network by Danie van der Merwe (English)](https://www.youtube.com/watch?v=v6an9QG2xF0) (November 2022) +- β–Ά [Pi.Alert auf Synology & Docker by - JΓΌrgen Barth (German)](https://www.youtube.com/watch?v=-ouvA2UNu-A) (March 2023) +- β–Ά [Top Docker Container for Home Server Security - VirtualizationHowto (English)](https://www.youtube.com/watch?v=tY-w-enLF6Q) (March 2023) +- β–Ά [Pi.Alert or WatchYourLAN can alert you to unknown devices appearing on your WiFi or LAN network - Danie van der Merwe (English)](https://www.youtube.com/watch?v=v6an9QG2xF0) (November 2022) > Ordered by last update time. @@ -101,6 +102,9 @@ There are 2 approaches how to get PiHole devices imported. Via the PiHole import ⚠ Check also common issues and [debugging tips](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md). +> [!NOTE] +> You can bulk-update devices via the [CSV import method](https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEVICES_BULK_EDITING.md). + ## πŸ“„ docker-compose.yml Examples ### Example 1 diff --git a/docs/SETTINGS_SYSTEM.md b/docs/SETTINGS_SYSTEM.md index 8dd44c80a..427fd782b 100755 --- a/docs/SETTINGS_SYSTEM.md +++ b/docs/SETTINGS_SYSTEM.md @@ -10,7 +10,7 @@ The source of truth for user-defined values is the `pialert.conf` file. Editing #### Settings database table -The `Settings` database table contains settings for App run purposes. The table is recreated every time the App restarts. The settings are loaded from the source-of-truth, that is the `pialert.conf` file. A high-level overview on the databse structure can be found in the [database documentation](/docs/DATABASE.md). +The `Settings` database table contains settings for App run purposes. The table is recreated every time the App restarts. The settings are loaded from the source-of-truth, that is the `pialert.conf` file. A high-level overview on the database structure can be found in the [database documentation](/docs/DATABASE.md). #### table_settings.json diff --git a/front/plugins/README.md b/front/plugins/README.md index d7fae4c6a..0d9d38ecc 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -400,7 +400,7 @@ Plugin results are always inserted into the standard `Plugin_Objects` database t >3. That's it. PiAlert takes care of the rest. It loops thru the objects discovered by the plugin, takes the results line, by line and inserts them into the database table specified in `"mapped_to_table"`. The columns are translated from the generic plugin columns to the target table via the `"mapped_to_column"` property in the column definitions. > [!NOTE] -> You can create a column mapping with a default value via the `mapped_to_column_data` property. This means that the value of the given column will always be this value. Taht also menas that the `"column": "NameDoesntMatter"` is not important as there is no databse source column. +> You can create a column mapping with a default value via the `mapped_to_column_data` property. This means that the value of the given column will always be this value. Taht also menas that the `"column": "NameDoesntMatter"` is not important as there is no database source column. >πŸ” Example: diff --git a/front/plugins/README_DE.md b/front/plugins/README_DE.md index b65f1d6a1..2559e4094 100755 --- a/front/plugins/README_DE.md +++ b/front/plugins/README_DE.md @@ -381,7 +381,7 @@ Plugin results are always inserted into the standard `Plugin_Objects` database t >3. That's it. PiAlert takes care of the rest. It loops thru the objects discovered by the plugin, takes the results line, by line and inserts them into the database table specified in `"mapped_to_table"`. The columns are translated from the generic plugin columns to the target table via the `"mapped_to_column"` property in the column definitions. > [!NOTE] -> You can create a column mapping with a default value via the `mapped_to_column_data` property. This means that the value of the given column will always be this value. Taht also menas that the `"column": "NameDoesntMatter"` is not important as there is no databse source column. +> You can create a column mapping with a default value via the `mapped_to_column_data` property. This means that the value of the given column will always be this value. Taht also menas that the `"column": "NameDoesntMatter"` is not important as there is no database source column. >πŸ” Beispiel: diff --git a/front/plugins/pihole_scan/config.json b/front/plugins/pihole_scan/config.json index a3a286021..6adb98f62 100755 --- a/front/plugins/pihole_scan/config.json +++ b/front/plugins/pihole_scan/config.json @@ -73,7 +73,7 @@ }], "description": [{ "language_code":"en_us", - "string" : "Specify when your PiHole device import from the PiHole databse will run. The typical setting would be schedule and then you specify a cron-like schedule in the PIHOLE_RUN_SCHDsetting. If enabled, you must map the pihole db into your container to the :/etc/pihole/pihole-FTL.db mount path as specified in the DB_PATH setting." + "string" : "Specify when your PiHole device import from the PiHole database will run. The typical setting would be schedule and then you specify a cron-like schedule in the PIHOLE_RUN_SCHDsetting. If enabled, you must map the pihole db into your container to the :/etc/pihole/pihole-FTL.db mount path as specified in the DB_PATH setting." }, { "language_code":"es_es", diff --git a/front/plugins/snmp_discovery/script.py b/front/plugins/snmp_discovery/script.py index 4c4714a07..7cf6d0a13 100755 --- a/front/plugins/snmp_discovery/script.py +++ b/front/plugins/snmp_discovery/script.py @@ -13,7 +13,7 @@ sys.path.append("/home/pi/pialert/front/plugins") sys.path.append('/home/pi/pialert/pialert') -from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64 +from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64, handleEmpty from logger import mylog from helper import timeNowTZ from const import logPath, pialertPath diff --git a/pialert/database.py b/pialert/database.py index a9e42e51b..53f0d505f 100755 --- a/pialert/database.py +++ b/pialert/database.py @@ -24,7 +24,7 @@ def __init__(self): def open (self): # Check if DB is open if self.sql_connection != None : - mylog('debug','openDB: databse already open') + mylog('debug','openDB: database already open') return mylog('none', '[Database] Opening DB' ) @@ -42,7 +42,7 @@ def open (self): #------------------------------------------------------------------------------- def commitDB (self): if self.sql_connection == None : - mylog('debug','commitDB: databse is not open') + mylog('debug','commitDB: database is not open') return False # Commit changes to DB @@ -57,7 +57,7 @@ def rollbackDB(self): #------------------------------------------------------------------------------- def get_sql_array(self, query): if self.sql_connection == None : - mylog('debug','getQueryArray: databse is not open') + mylog('debug','getQueryArray: database is not open') return self.sql.execute(query) diff --git a/pialert/plugin.py b/pialert/plugin.py index b6e520410..ca837cf35 100755 --- a/pialert/plugin.py +++ b/pialert/plugin.py @@ -241,7 +241,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): if len(columns) == 9: # Create a tuple containing values to be inserted into the database. # Each value corresponds to a column in the table in the order of the columns. - # must match the Plugins_Objects and Plugins_Events databse tables and can be used as input for the plugin_object_class. + # must match the Plugins_Objects and Plugins_Events database tables and can be used as input for the plugin_object_class. sqlParams.append( ( 0, # "Index" placeholder @@ -281,7 +281,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): if len(row) == 9 and (row[0] in ['','null']) == False : # Create a tuple containing values to be inserted into the database. # Each value corresponds to a column in the table in the order of the columns. - # must match the Plugins_Objects and Plugins_Events databse tables and can be used as input for the plugin_object_class + # must match the Plugins_Objects and Plugins_Events database tables and can be used as input for the plugin_object_class sqlParams.append( ( 0, # "Index" placeholder @@ -337,7 +337,7 @@ def execute_plugin(db, plugin, pluginsState = plugins_state() ): if len(row) == 9 and (row[0] in ['','null']) == False : # Create a tuple containing values to be inserted into the database. # Each value corresponds to a column in the table in the order of the columns. - # must match the Plugins_Objects and Plugins_Events databse tables and can be used as input for the plugin_object_class + # must match the Plugins_Objects and Plugins_Events database tables and can be used as input for the plugin_object_class sqlParams.append(( 0, # "Index" placeholder plugin["unique_prefix"], # "Plugin"