Moving of report templates

This commit is contained in:
jokob-sk
2024-04-13 08:37:00 +10:00
parent b977781937
commit 7b714064bb
14 changed files with 23 additions and 22 deletions

View File

@@ -19,7 +19,7 @@ You can access the following files:
|----------------------|----------------------| |----------------------|----------------------|
| `notification_text.txt` | The plain text version of the last notification. | | `notification_text.txt` | The plain text version of the last notification. |
| `notification_text.html` | The full HTML of the last email notification. | | `notification_text.html` | The full HTML of the last email notification. |
| `notification_json_final.json` | The json version of the last notification (e.g. used for webhooks - [sample JSON](https://github.com/jokob-sk/NetAlertX/blob/main/back/webhook_json_sample.json)). | | `notification_json_final.json` | The json version of the last notification (e.g. used for webhooks - [sample JSON](https://github.com/jokob-sk/NetAlertX/blob/main/front/report_templates/webhook_json_sample.json)). |
| `table_devices.json` | The current (at the time of the last update as mentioned above on this page) state of all of the available Devices detected by the app. | | `table_devices.json` | The current (at the time of the last update as mentioned above on this page) state of all of the available Devices detected by the app. |
| `table_pholus_scan.json` | The latest state of the [pholus](https://github.com/jokob-sk/NetAlertX/tree/main/pholus) (A multicast DNS and DNS Service Discovery Security Assessment Tool) scan results. | | `table_pholus_scan.json` | The latest state of the [pholus](https://github.com/jokob-sk/NetAlertX/tree/main/pholus) (A multicast DNS and DNS Service Discovery Security Assessment Tool) scan results. |
| `table_plugins_events.json` | The list of the unprocessed (pending) notification events (plugins_events DB table). | | `table_plugins_events.json` | The list of the unprocessed (pending) notification events (plugins_events DB table). |

View File

@@ -5,7 +5,7 @@ N8N can be used for more advanced conditional notification use cases. For exampl
![n8n workflow](/docs/img/WEBHOOK_N8N/n8n_workflow.png) ![n8n workflow](/docs/img/WEBHOOK_N8N/n8n_workflow.png)
### Specify your email template ### Specify your email template
See [sample JSON](https://github.com/jokob-sk/NetAlertX/blob/main/back/webhook_json_sample.json) if you want to see the JSON paths used in the email template below See [sample JSON](https://github.com/jokob-sk/NetAlertX/blob/main/front/report_templates/webhook_json_sample.json) if you want to see the JSON paths used in the email template below
![Email template](/docs/img/WEBHOOK_N8N/n8n_send_email_settings.png) ![Email template](/docs/img/WEBHOOK_N8N/n8n_send_email_settings.png)
``` ```

View File

@@ -691,7 +691,7 @@
"UI_PRESENCE_name": "Anzeige im Pr\u00e4senzdiagramm", "UI_PRESENCE_name": "Anzeige im Pr\u00e4senzdiagramm",
"UI_REFRESH_description": "", "UI_REFRESH_description": "",
"UI_REFRESH_name": "", "UI_REFRESH_name": "",
"WEBHOOK_PAYLOAD_description": "The Webhook payload data format for the <code>body</code> > <code>attachments</code> > <code>text</code> attribute in the payload json. See an example of the payload <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/back/webhook_json_sample.json\">here</a>. (e.g.: for discord use <code>text</code>)", "WEBHOOK_PAYLOAD_description": "The Webhook payload data format for the <code>body</code> > <code>attachments</code> > <code>text</code> attribute in the payload json. See an example of the payload <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/front/report_templates/webhook_json_sample.json\">here</a>. (e.g.: for discord use <code>text</code>)",
"WEBHOOK_PAYLOAD_name": "Payload type", "WEBHOOK_PAYLOAD_name": "Payload type",
"WEBHOOK_REQUEST_METHOD_description": "The HTTP request method to be used for the webhook call.", "WEBHOOK_REQUEST_METHOD_description": "The HTTP request method to be used for the webhook call.",
"WEBHOOK_REQUEST_METHOD_name": "Request method", "WEBHOOK_REQUEST_METHOD_name": "Request method",

View File

@@ -691,7 +691,7 @@
"UI_PRESENCE_name": "Mostrar en el gr\u00e1fico de presencia", "UI_PRESENCE_name": "Mostrar en el gr\u00e1fico de presencia",
"UI_REFRESH_description": "Ingrese el n\u00famero de segundos despu\u00e9s de los cuales se recarga la interfaz de usuario. Ajustado a <code> 0 </code> para desactivar.", "UI_REFRESH_description": "Ingrese el n\u00famero de segundos despu\u00e9s de los cuales se recarga la interfaz de usuario. Ajustado a <code> 0 </code> para desactivar.",
"UI_REFRESH_name": "Actualizaci\u00f3n autom\u00e1tica de la interfaz de usuario", "UI_REFRESH_name": "Actualizaci\u00f3n autom\u00e1tica de la interfaz de usuario",
"WEBHOOK_PAYLOAD_description": "El formato de datos de carga de Webhook para el atributo <code>body</code> > <code>attachments</code> > <code>text</code> en el json de carga. Vea un ejemplo de la carga <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/back/webhook_json_sample.json\">aqu\u00ed</a>. (por ejemplo: para discord use <code>text</code>)", "WEBHOOK_PAYLOAD_description": "El formato de datos de carga de Webhook para el atributo <code>body</code> > <code>attachments</code> > <code>text</code> en el json de carga. Vea un ejemplo de la carga <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/front/report_templates/webhook_json_sample.json\">aqu\u00ed</a>. (por ejemplo: para discord use <code>text</code>)",
"WEBHOOK_PAYLOAD_name": "Tipo de carga", "WEBHOOK_PAYLOAD_name": "Tipo de carga",
"WEBHOOK_REQUEST_METHOD_description": "El m\u00e9todo de solicitud HTTP que se utilizar\u00e1 para la llamada de webhook.", "WEBHOOK_REQUEST_METHOD_description": "El m\u00e9todo de solicitud HTTP que se utilizar\u00e1 para la llamada de webhook.",
"WEBHOOK_REQUEST_METHOD_name": "M\u00e9todo de solicitud", "WEBHOOK_REQUEST_METHOD_name": "M\u00e9todo de solicitud",

View File

@@ -333,11 +333,11 @@
}], }],
"description": [{ "description": [{
"language_code": "en_us", "language_code": "en_us",
"string" : "The Webhook payload data format for the <code>body</code> > <code>attachments</code> > <code>text</code> attribute in the payload json. See an example of the payload <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/back/webhook_json_sample.json\">here</a>. (e.g.: for discord use <code>text</code>)" "string" : "The Webhook payload data format for the <code>body</code> > <code>attachments</code> > <code>text</code> attribute in the payload json. See an example of the payload <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/front/report_templates/webhook_json_sample.json\">here</a>. (e.g.: for discord use <code>text</code>)"
}, },
{ {
"language_code": "es_es", "language_code": "es_es",
"string" : "El formato de datos de carga de Webhook para el atributo <code>body</code> > <code>attachments</code> > <code>text</code> en el json de carga. Vea un ejemplo de la carga <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/back/webhook_json_sample.json\">aquí</a>. (por ejemplo: para discord use <code>text</code>)" "string" : "El formato de datos de carga de Webhook para el atributo <code>body</code> > <code>attachments</code> > <code>text</code> en el json de carga. Vea un ejemplo de la carga <a target=\"_blank\" href=\"https://github.com/jokob-sk/NetAlertX/blob/main/front/report_templates/webhook_json_sample.json\">aquí</a>. (por ejemplo: para discord use <code>text</code>)"
}] }]
}, },
{ {

View File

@@ -11,14 +11,15 @@ confPath = "/config/" + confFileName
dbPath = '/db/' + dbFileName dbPath = '/db/' + dbFileName
pluginsPath = applicationPath + '/front/plugins' pluginsPath = applicationPath + '/front/plugins'
logPath = applicationPath + '/front/log' logPath = applicationPath + '/front/log'
apiPath = applicationPath + '/front/api/' apiPath = applicationPath + '/front/api/'
fullConfPath = applicationPath + confPath reportTemplatesPath = applicationPath + '/front/report_templates/'
fullDbPath = applicationPath + dbPath fullConfPath = applicationPath + confPath
vendorsPath = '/usr/share/arp-scan/ieee-oui.txt' fullDbPath = applicationPath + dbPath
vendorsPath = '/usr/share/arp-scan/ieee-oui.txt'
#=============================================================================== #===============================================================================

View File

@@ -7,7 +7,7 @@ from json2table import convert
# Register NetAlertX modules # Register NetAlertX modules
import conf import conf
from const import applicationPath, logPath, apiPath, confFileName from const import applicationPath, logPath, apiPath, confFileName, reportTemplatesPath
from logger import logResult, mylog, print_log from logger import logResult, mylog, print_log
from helper import generate_mac_links, removeDuplicateNewLines, timeNowTZ, get_file_content, write_file, get_setting_value, get_timezone_offset from helper import generate_mac_links, removeDuplicateNewLines, timeNowTZ, get_file_content, write_file, get_setting_value, get_timezone_offset
@@ -80,7 +80,7 @@ class Notification_obj:
# Open text Template # Open text Template
mylog('verbose', ['[Notification] Open text Template']) mylog('verbose', ['[Notification] Open text Template'])
template_file = open(applicationPath + '/back/report_template.txt', 'r') template_file = open(reportTemplatesPath + 'report_template.txt', 'r')
mail_text = template_file.read() mail_text = template_file.read()
template_file.close() template_file.close()
@@ -89,12 +89,12 @@ class Notification_obj:
# select template type depoending if running latest version or an older one # select template type depoending if running latest version or an older one
if conf.newVersionAvailable : if conf.newVersionAvailable :
template_file_path = '/back/report_template_new_version.html' template_file_path = reportTemplatesPath + 'report_template_new_version.html'
else: else:
template_file_path = '/back/report_template.html' template_file_path = reportTemplatesPath + 'report_template.html'
mylog('verbose', ['[Notification] Using template', template_file_path]) mylog('verbose', ['[Notification] Using template', template_file_path])
template_file = open(applicationPath + template_file_path, 'r') template_file = open(template_file_path, 'r')
mail_html = template_file.read() mail_html = template_file.read()
template_file.close() template_file.close()

View File

@@ -9,7 +9,7 @@ from collections import namedtuple
# Register NetAlertX modules # Register NetAlertX modules
import conf import conf
from const import pluginsPath, logPath, applicationPath from const import pluginsPath, logPath, applicationPath, reportTemplatesPath
from logger import mylog from logger import mylog
from helper import timeNowTZ, updateState, get_file_content, write_file, get_setting, get_setting_value from helper import timeNowTZ, updateState, get_file_content, write_file, get_setting, get_setting_value
from api import update_api from api import update_api
@@ -783,9 +783,9 @@ def handle_test(runType, db, pluginsState):
mylog('minimal', ['[', timeNowTZ(), '] [Test] START Test: ', runType]) mylog('minimal', ['[', timeNowTZ(), '] [Test] START Test: ', runType])
# Prepare test samples # Prepare test samples
sample_txt = get_file_content(applicationPath + '/back/report_sample.txt') sample_txt = get_file_content(reportTemplatesPath + 'report_sample.txt')
sample_html = get_file_content(applicationPath + '/back/report_sample.html') sample_html = get_file_content(reportTemplatesPath + 'report_sample.html')
sample_json = json.loads(get_file_content(applicationPath + '/back/webhook_json_sample.json'))[0]["body"]["attachments"][0]["text"] sample_json = json.loads(get_file_content(reportTemplatesPath + 'webhook_json_sample.json'))[0]["body"]["attachments"][0]["text"]
# Create fake notification # Create fake notification
notification = Notification_obj(db) notification = Notification_obj(db)