report cleanup + #960

This commit is contained in:
jokob-sk
2025-01-19 12:56:00 +11:00
parent af1e9b921b
commit 6b390b66de
12 changed files with 105 additions and 390 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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'])) {

0
front/php/templates/language/ca_ca.json Normal file → Executable file
View File

View File

@@ -1,178 +0,0 @@
<!-- ---------------------------------------------------------------------------
# NetAlertX
# Open Source Network Guard / WIFI & LAN intrusion detector
#
# repot_template.html - Back module. Template to email reporting in HTML format
#-------------------------------------------------------------------------------
# Puche 2021 GNU GPLv3
#--------------------------------------------------------------------------- -->
<html>
<head></head>
<body>
<font face=sans-serif>
<table align=center width=100% cellpadding=0 cellspacing=0 style="border-radius: 5px;">
<tr>
<td bgcolor=#3c8dbc align=center style="padding: 20px 10px 10px 10px; font-size: 30px; font-weight: bold; color:#ffffff; border-top-right-radius: 5px; border-top-left-radius: 5px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<img src="https://netalertx.com/favicon.ico" alt="NetAlertX Logo" style="vertical-align: middle;" width="32" height="32" />
Net<b>Alert</b><sup>x</sup>
</td>
</tr>
<tr>
<td bgcolor=#2656f1 width=100% align=center style="padding: 20px 10px 10px 10px; font-size: 20px; font-weight: bold; color:#ffffff; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<a style="color:#ffffff;cursor:pointer;" href="https://github.com/jokob-sk/NetAlertX/releases">🆕 New version available 🆕</a>
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#00c0ef cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#404040">
<tr>
<td width=100%> Report Date: <b>2023-01-30 22:17</b> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor=#F5F5F5 height=200 valign=top style="padding: 10px">
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:blue; font-size: 12px;' bgcolor='#909090' >New devices</th>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Datetime</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >IP</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Event Type</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Device name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Comments</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Device Vendor</th>
</tr>
<tr>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>2023-01-30 22:15:09</td>
<td>192.168.1.1</td>
<td>New Device</td>
<td>(name not found)</td>
<td></td>
<td></td>
</tr>
<tr>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>2023-01-30 22:17:59</td>
<td>192.168.1.82</td>
<td>New Device</td>
<td>(name not found)</td>
<td></td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:blue; font-size: 12px;' bgcolor='#909090' >Events</th>
</tr>
<tr>
<td>
<ul>
<li>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Datetime</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >IP</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Event Type</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Device name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Comments</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Device Vendor</th>
</tr>
<tr>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>2023-01-30 22:15:09</td>
<td>192.168.1.92</td>
<td>Disconnected</td>
<td>(name not found)</td>
<td></td>
</tr>
</table>
</li>
</ul>
</td>
</tr>
</table>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:blue; font-size: 12px;' bgcolor='#909090' >Changed or new ports</th>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th>new</th>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Port</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >State</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Service</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Extra</th>
</tr>
<tr>
<td>New device</td>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>3263/tcp</td>
<td>open</td>
<td>ecolor-imager</td>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table style="border-collapse: collapse; font-size: 12px; color:#70707" width="100%" cellspacing="0" cellpadding="3px" bordercolor="#C0C0C0" border="1">
<tr>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Name</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >MAC</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Port</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >State</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Service</th>
<th width='120px' style='color:#F0F0F0' bgcolor='#909090' >Extra</th>
</tr>
<tr>
<td>New device</td>
<td><a href="http://192.168.1.1:20211/deviceDetails.php?mac=00:00:00:ef:a5:6c">00:00:00:ef:a5:6c</a></td>
<td>3264/tcp</td>
<td>open</td>
<td>ccmail</td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<tr>
<td>
<table width=100% bgcolor=#46802e cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tr>
<td width=50% style="text-align:center"> NetAlertX - Synology-NAS</td>
</tr>
</table>
</td>
</tr>
</table>
</font>
</body>
</html>

View File

@@ -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

View File

@@ -8,33 +8,18 @@
-->
<html>
<head>
</head>
<head></head>
<body>
<font face=sans-serif>
<table align=center width=100% cellpadding=0 cellspacing=0 style="border-radius: 5px;">
<tr>
<td bgcolor=#3c8dbc align=center style="padding: 20px 10px 10px 10px; font-size: 20px; color:#ffffff; border-top-right-radius: 5px; border-top-left-radius: 5px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<img src="https://netalertx.com/favicon.ico" alt="NetAlertX Logo" style="vertical-align: middle;" width="32" height="32" />
Net<b>Alert</b><sup>x</sup>
<img src="https://netalertx.com/NetAlertX_logo.png" alt="NetAlertX Logo" style="vertical-align: middle;" width="32" height="32" />
Net<b>Alert</b><sup>x</sup>
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#4b99d3 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#ffffff"> <tr>
<td width=100% bgcolor="#3c8dbc"> Report Date: <b><REPORT_DATE></b> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height=200 valign=top style="padding: 10px">
<NEW_DEVICES_TABLE>
<DOWN_DEVICES_TABLE>
<DOWN_RECONNECTED_TABLE>
@@ -46,16 +31,14 @@
<tr>
<td>
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tr>
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 10px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tr>
<td width=50% style="text-align:center;color: white;" bgcolor="#3c8dbc">
<a href="https://github.com/jokob-sk/NetAlertX" target="_blank" style="color: white">NetAlertX</a>
<a href=".." target="_blank" style="color: white"> (<SERVER_NAME>)</a>
<br><span style="display:inline-block;color: white; transform: rotate(180deg)">&copy;</span>2022
<a style="color: white" href="mailto:jokob@duck.com?subject=NetAlertX">jokob-sk</a> | <b>Built on: <BUILD_DATE> </b> | <b> Version: <BUILD_VERSION> </b> |
<a href="https://github.com/jokob-sk/NetAlertX/tree/main/docs" target="_blank" style="color: white">
<span>Docs <i class="fa fa-circle-question"></i>
</a><span>
<NEW_VERSION>
| Sent: <REPORT_DATE>
| Server: <SERVER_NAME>
| Built: <BUILD_DATE>
| Version: <BUILD_VERSION>
</td>
</tr>
</table>

View File

@@ -1,8 +1,9 @@
Report Date: <REPORT_DATE>
Server: <SERVER_NAME>
<NEW_DEVICES_TABLE>
<DOWN_DEVICES_TABLE>
<DOWN_RECONNECTED_TABLE>
<EVENTS_TABLE>
<PLUGINS_TABLE>
Report Date: <REPORT_DATE>
Server: <SERVER_NAME>
<NEW_VERSION>

View File

@@ -1,72 +0,0 @@
<!--
#---------------------------------------------------------------------------------#
# NetAlertX #
# Open Source Network Guard / WIFI & LAN intrusion detector #
# #
# report_template.html - Back module. Template to email reporting in HTML format #
#---------------------------------------------------------------------------------#
-->
<html>
<head>
</head>
<body>
<font face=sans-serif>
<table align=center width=100% cellpadding=0 cellspacing=0 style="border-radius: 5px;">
<tr>
<td bgcolor=#3c8dbc align=center style="padding: 20px 10px 10px 10px; font-size: 20px; color:#ffffff; border-top-right-radius: 5px; border-top-left-radius: 5px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<img src="https://netalertx.com/favicon.ico" alt="NetAlertX Logo" style="vertical-align: middle;" width="32" height="32" />
Net<b>Alert</b><sup>x</sup>
</td>
</tr>
<tr>
<td bgcolor=#2656f1 width=100% align=center style="padding: 10px 10px 10px 10px; font-size: 20px; color:#ffffff; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2)">
<a style="color:#ffffff;cursor:pointer;" href="https://github.com/jokob-sk/NetAlertX/releases">New version available</a>
</td>
</tr>
<tr>
<td>
<table width=100% border=0 bgcolor=#4b99d3 cellpadding=5px cellspacing=0 style="border-collapse: collapse; font-size: 15px; text-align:center; color:#ffffff"> <tr>
<td width=100% bgcolor="#3c8dbc"> Report Date: <b><REPORT_DATE></b> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height=200 valign=top style="padding: 10px">
<NEW_DEVICES_TABLE>
<DOWN_DEVICES_TABLE>
<DOWN_RECONNECTED_TABLE>
<EVENTS_TABLE>
<PLUGINS_TABLE>
</td>
</tr>
<tr>
<td>
<table width=100% bgcolor=#3c8dbc cellpadding=5px cellspacing=0 style="font-size: 13px; font-weight: bold; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
<tr>
<td width=50% style="text-align:center;color: white;" bgcolor="#3c8dbc">
<a href="https://github.com/jokob-sk/NetAlertX" target="_blank" style="color: white">NetAlertX</a>
<a href=".." target="_blank" style="color: white"> (<SERVER_NAME>)</a>
<br><span style="display:inline-block;color: white; transform: rotate(180deg)">&copy;</span>2022
<a style="color: white" href="mailto:jokob@duck.com?subject=NetAlertX">jokob-sk</a> | <b>Built on: <BUILD_DATE> </b> | <b> Version: <BUILD_VERSION> </b> |
<a href="https://github.com/jokob-sk/NetAlertX/tree/main/docs" target="_blank" style="color: white">
<span>Docs <i class="fa fa-circle-question"></i>
</a><span>
</td>
</tr>
</table>
</td>
</tr>
</table>
</font>
</body>
</html>

View File

@@ -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"
}
]
}

View File

@@ -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 ('<NEW_VERSION>', newVersionText)
mail_html = mail_html.replace ('<NEW_VERSION>', newVersionText)
# Report "REPORT_DATE" in Header & footer
timeFormated = timeNowTZ().strftime ('%Y-%m-%d %H:%M')

View File

@@ -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