diff --git a/docker-compose.yml b/docker-compose.yml index ca180001..cdca7e7b 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,7 +38,6 @@ services: - ${DEV_LOCATION}/back/update_vendors.sh:/app/back/update_vendors.sh - ${DEV_LOCATION}/front/lib:/app/front/lib - ${DEV_LOCATION}/front/js:/app/front/js - - ${DEV_LOCATION}/front/report_templates:/front/report_templates - ${DEV_LOCATION}/front/php:/app/front/php - ${DEV_LOCATION}/front/deviceDetails.php:/app/front/deviceDetails.php - ${DEV_LOCATION}/front/deviceDetailsEdit.php:/app/front/deviceDetailsEdit.php diff --git a/front/js/db_methods.js b/front/js/db_methods.js index e73c56ab..a328eb23 100755 --- a/front/js/db_methods.js +++ b/front/js/db_methods.js @@ -32,7 +32,7 @@ function renderList( // remove first item containing the SQL query options.shift(); - const apiUrl = `php/server/dbHelper.php?action=read&rawSql=${encodeURIComponent(sqlQuery)}`; + const apiUrl = `php/server/dbHelper.php?action=read&rawSql=${btoa(encodeURIComponent(sqlQuery))}`; $.get(apiUrl, function (sqlOptionsData) { diff --git a/front/php/server/dbHelper.php b/front/php/server/dbHelper.php index 8b848352..6e0bddd6 100755 --- a/front/php/server/dbHelper.php +++ b/front/php/server/dbHelper.php @@ -63,7 +63,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php'; } if (isset ($_REQUEST['rawSql'])) { - $rawSql = $_REQUEST['rawSql']; + $rawSql = urldecode(base64_decode($_REQUEST['rawSql'])); } if (isset ($_REQUEST['dbtable'])) { diff --git a/front/php/templates/language/ca_ca.json b/front/php/templates/language/ca_ca.json old mode 100644 new mode 100755 diff --git a/front/report_templates/report_sample.html b/front/report_templates/report_sample.html deleted file mode 100755 index 2cc3a875..00000000 --- a/front/report_templates/report_sample.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
- NetAlertX Logo - NetAlertx -
- πŸ†• New version available πŸ†• -
- - - - -
Report Date: 2023-01-30 22:17
-
- - - - - - - -
New devices
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MACDatetimeIPEvent TypeDevice nameCommentsDevice Vendor
00:00:00:ef:a5:6c2023-01-30 22:15:09192.168.1.1New Device(name not found)
00:00:00:ef:a5:6c2023-01-30 22:17:59192.168.1.82New Device(name not found)
-
- - - - - - - -
Events
-
    -
  • - - - - - - - - - - - - - - - - - - -
    MACDatetimeIPEvent TypeDevice nameCommentsDevice Vendor
    00:00:00:ef:a5:6c2023-01-30 22:15:09192.168.1.92Disconnected(name not found)
    -
  • -
-
- - - - - - - -
Changed or new ports
- - - - - - - - - - - -
new
- - - - - - - - - - - - - - - - - -
NameMACPortStateServiceExtra
New device00:00:00:ef:a5:6c3263/tcpopenecolor-imager
-
- - - - - - - - - - - - - - - - - -
NameMACPortStateServiceExtra
New device00:00:00:ef:a5:6c3264/tcpopenccmail
-
-
-
- - - - -
NetAlertX - Synology-NAS
-
-
- - - \ No newline at end of file diff --git a/front/report_templates/report_sample.txt b/front/report_templates/report_sample.txt index f7f584dd..e476e5da 100755 --- a/front/report_templates/report_sample.txt +++ b/front/report_templates/report_sample.txt @@ -1,50 +1,46 @@ -Report Date: 2021-12-08 12:30 -Server: Synology-NAS - New Devices ---------------------- Name: (name not found) - MAC: 2c:2c:2c:2c:2c:2c - IP: 192.168.1.121 - Time: 2021-12-08 12:30 - More Info: Micro-Star INTL CO., LTD. +MAC: 2c:2c:2c:2c:2c:2c +IP: 192.168.1.121 +Time: 2021-12-08 12:30 +More Info: Micro-Star INTL CO., LTD. Name: (name not found) - MAC: 2c:2c:2c:2c:2c:2c - IP: 192.168.1.151 - Time: 2021-12-08 12:30 - More Info: Espressif Inc. - - +MAC: 2c:2c:2c:2c:2c:2c +IP: 192.168.1.151 +Time: 2021-12-08 12:30 +More Info: Espressif Inc. Events ---------------------- Name: Samsung - MAC: 2c:2c:2c:2c:2c:2c - IP: 192.168.1.27 - Time: 2021-12-08 12:30 - Event: Connected - More Info: +MAC: 2c:2c:2c:2c:2c:2c +IP: 192.168.1.27 +Time: 2021-12-08 12:30 +Event: Connected +More Info: Name: (name not found) - MAC: 2c:2c:2c:2c:2c:2c - IP: 192.168.1.6 - Time: 2021-12-08 12:30 - Event: Disconnected - More Info: +MAC: 2c:2c:2c:2c:2c:2c +IP: 192.168.1.6 +Time: 2021-12-08 12:30 +Event: Disconnected +More Info: Name: Google-Home-Mini - MAC: 2c:2c:2c:2c:2c:2c - IP: 192.168.1.16 - Time: 2021-12-08 12:30 - Event: Disconnected - More Info: +MAC: 2c:2c:2c:2c:2c:2c +IP: 192.168.1.16 +Time: 2021-12-08 12:30 +Event: Disconnected +More Info: Name: (name not found) - MAC: 2c:2c:2c:2c:2c:2c - IP: 192.168.1.119 - Time: 2021-12-08 12:30 - Event: Disconnected - More Info: - +MAC: 2c:2c:2c:2c:2c:2c +IP: 192.168.1.119 +Time: 2021-12-08 12:30 +Event: Disconnected +More Info: +Report Date: 2021-12-08 12:30 +Server: Synology-NAS diff --git a/front/report_templates/report_template.html b/front/report_templates/report_template.html index 57322710..babc58fd 100755 --- a/front/report_templates/report_template.html +++ b/front/report_templates/report_template.html @@ -8,33 +8,18 @@ --> - - - - + - - - - -
- NetAlertX Logo - NetAlertx + NetAlertX Logo + NetAlertx
- - - -
Report Date:
-
- - @@ -46,16 +31,14 @@
- - +
+
- NetAlertX - () -
©2022 - jokob-sk | Built on: | Version: | - - Docs - + + | Sent: + | Server: + | Built: + | Version:
diff --git a/front/report_templates/report_template.txt b/front/report_templates/report_template.txt index ce814751..8be4447b 100755 --- a/front/report_templates/report_template.txt +++ b/front/report_templates/report_template.txt @@ -1,8 +1,9 @@ -Report Date: -Server: - + +Report Date: +Server: + \ No newline at end of file diff --git a/front/report_templates/report_template_new_version.html b/front/report_templates/report_template_new_version.html deleted file mode 100755 index 7abbd37a..00000000 --- a/front/report_templates/report_template_new_version.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- NetAlertX Logo - NetAlertx -
- New version available -
- - - -
Report Date:
-
- - - - - - - - -
- - - - -
- NetAlertX - () -
©2022 - jokob-sk | Built on: | Version: | - - Docs - -
-
-
- - diff --git a/front/report_templates/webhook_json_sample.json b/front/report_templates/webhook_json_sample.json index be98f5f9..c252e4e6 100755 --- a/front/report_templates/webhook_json_sample.json +++ b/front/report_templates/webhook_json_sample.json @@ -18,37 +18,36 @@ "title_link": "", "text": { "new_devices_meta": { - "title": "πŸ†•New devices", - "columnNames": [ - "MAC", - "Datetime", - "IP", - "Event Type", - "Device name", - "Comments" - ] + "title": "πŸ†• New devices", + "columnNames": [ + "MAC", + "Datetime", + "IP", + "Event Type", + "Device name", + "Comments" + ] }, "new_devices": [ { - "MAC": "74:ac:74:ac:74:ac", - "Datetime": "2023-01-30 22:15:09", - "IP": "192.168.1.1", + "MAC": "00:1a:76:e3:26:4a", + "Datetime": "2025-01-06 11:05:00+11:00", + "IP": "192.168.1.82", "Event Type": "New Device", - "Device name": "(name not found)", - "Comments": null, - "Device Vendor": null + "Device name": "(unknown) TEST", + "Comments": "" } ], "down_devices_meta": { - "title": "Down devices", - "columnNames": [ - "MAC", - "Datetime", - "IP", - "Event Type", - "Device name", - "Comments" - ] + "title": "πŸ”΄ Down devices", + "columnNames": [ + "devName", + "eve_MAC", + "devVendor", + "eve_IP", + "eve_DateTime", + "eve_EventType" + ] }, "down_devices": [], "events_meta": { @@ -64,12 +63,12 @@ }, "down_reconnected": [ { - "devName": "Phone - Pixel", + "devName": "Phone - Moto 82", "eve_MAC": "74:ac:74:ac:74:ac", - "devVendor": "Google", + "devVendor": "Motorola Mobility LLC, a Lenovo Company", "eve_IP": "192.168.1.167", - "DownTime": "2024-05-26 09:06:56+10:00", - "ConnectedTime": "2024-05-26 09:13:24+10:00" + "eve_DateTime": "2025-01-11 10:05:01+11:00", + "eve_EventType": "Down Reconnected" } ], "down_reconnected_meta": { @@ -79,8 +78,8 @@ "eve_MAC", "devVendor", "eve_IP", - "DownTime", - "ConnectedTime" + "eve_DateTime", + "eve_EventType" ] }, "events": [ @@ -90,8 +89,7 @@ "IP": "192.168.1.92", "Event Type": "Disconnected", "Device name": "(name not found)", - "Comments": null, - "Device Vendor": null + "Comments": null }, { "MAC": "74:ac:74:ac:74:ac", @@ -99,45 +97,34 @@ "IP": "192.168.1.150", "Event Type": "Disconnected", "Device name": "(name not found)", - "Comments": null, - "Device Vendor": null + "Comments": null } ], "plugins_meta": { - "title": "Plugins", + "title": "πŸ”Œ Plugins", "columnNames": [ - "Plugin", - "Object_PrimaryID", - "Object_SecondaryID", - "DateTimeChanged", - "Watched_Value1", - "Watched_Value2", - "Watched_Value3", - "Watched_Value4", - "Status", - "Extra", - "UserData", - "ForeignKey", - "SyncHubNodeName" + "Plugin", + "Object_PrimaryID", + "Object_SecondaryID", + "DateTimeChanged", + "Watched_Value1", + "Watched_Value2", + "Watched_Value3", + "Watched_Value4", + "Status" ] }, "plugins": [ { - "Index": 138, - "Plugin": "INTRSPD", - "Object_PrimaryID": "Speedtest", - "Object_SecondaryID": "2023-10-08 02:01:16+02:00", - "DateTimeCreated": "2023-10-08 02:01:16", - "DateTimeChanged": "2023-10-08 02:32:15", - "Watched_Value1": "-1", - "Watched_Value2": "-1", - "Watched_Value3": "null", - "Watched_Value4": "null", - "Status": "missing-in-last-scan", - "Extra": "null", - "UserData": "null", - "ForeignKey": "null", - "SyncHubNodeName": "null" + "Plugin": "ARPSCAN", + "Object_PrimaryID": "74:ac:74:ac:74:ac", + "Object_SecondaryID": "192.168.1.114", + "DateTimeChanged": "2025-01-11 12:21:00", + "Watched_Value1": "192.168.1.114", + "Watched_Value2": "Microsoft Corporation", + "Watched_Value3": "192.168.1.0/24 --interface=eth1", + "Watched_Value4": "", + "Status": "new" } ] } diff --git a/server/notification.py b/server/notification.py index a2e106f9..a771488b 100755 --- a/server/notification.py +++ b/server/notification.py @@ -78,7 +78,8 @@ class Notification_obj: # mylog('debug', ['[Notification] notiStruc:', json.dumps(notiStruc.__dict__, indent=4)]) Text = "" - HTML = "" + HTML = "" + template_file_path = reportTemplatesPath + 'report_template.html' # Open text Template @@ -90,17 +91,17 @@ class Notification_obj: # Open html Template mylog('verbose', ['[Notification] Open html Template']) - # select template type depoending if running latest version or an older one - if conf.newVersionAvailable : - template_file_path = reportTemplatesPath + 'report_template_new_version.html' - else: - template_file_path = reportTemplatesPath + 'report_template.html' - - mylog('verbose', ['[Notification] Using template', template_file_path]) template_file = open(template_file_path, 'r') mail_html = template_file.read() template_file.close() + # prepare new version text + newVersionText = '' + if conf.newVersionAvailable : + newVersionText = 'πŸš€A new version is available.' + + mail_text = mail_text.replace ('', newVersionText) + mail_html = mail_html.replace ('', newVersionText) # Report "REPORT_DATE" in Header & footer timeFormated = timeNowTZ().strftime ('%Y-%m-%d %H:%M') diff --git a/server/plugin.py b/server/plugin.py index b517a777..6973c0c7 100755 --- a/server/plugin.py +++ b/server/plugin.py @@ -913,8 +913,6 @@ def handle_test(runType, db, all_plugins, pluginsState): mylog('minimal', ['[', timeNowTZ(), '] [Test] START Test: ', runType]) # Prepare test samples - sample_txt = get_file_content(reportTemplatesPath + 'report_sample.txt') - sample_html = get_file_content(reportTemplatesPath + 'report_sample.html') sample_json = json.loads(get_file_content(reportTemplatesPath + 'webhook_json_sample.json'))[0]["body"]["attachments"][0]["text"] # Create fake notification