From 919b5e730cf862033c458c33ad32f9b8e8ffab41 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Thu, 3 Oct 2024 23:45:44 -0700 Subject: [PATCH] enhance --- ...mesh_bot_w3.tmp => mesh_bot_reporting.tmp} | 0 etc/report_generator.py | 25 ++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) rename etc/{mesh_bot_w3.tmp => mesh_bot_reporting.tmp} (100%) diff --git a/etc/mesh_bot_w3.tmp b/etc/mesh_bot_reporting.tmp similarity index 100% rename from etc/mesh_bot_w3.tmp rename to etc/mesh_bot_reporting.tmp diff --git a/etc/report_generator.py b/etc/report_generator.py index d80010d..0164d69 100644 --- a/etc/report_generator.py +++ b/etc/report_generator.py @@ -15,6 +15,7 @@ from collections import Counter, defaultdict LOG_PATH = '/opt/meshing-around/logs' W3_PATH = '/var/www/html' multiLogReader = False +shameWordList = ['password', 'combo', 'key', 'hidden', 'secret', 'pass', 'token', 'login', 'username', 'admin', 'root'] def parse_log_file(file_path): global log_data @@ -57,7 +58,8 @@ def parse_log_file(file_path): 'node1_name': "N/A", 'node2_name': "N/A", 'node1_ID': "N/A", - 'node2_ID': "N/A" + 'node2_ID': "N/A", + 'shameList': [] } for line in lines: @@ -82,6 +84,11 @@ def parse_log_file(file_path): log_data['message_types']['Incoming DM'] += 1 log_data['total_messages'] += 1 log_data['message_timestamps'].append((timestamp.isoformat(), 'Incoming DM')) + # check for shame words in the message + for word in shameWordList: + if word in line.lower(): + if line not in log_data['shameList']: + log_data['shameList'].append(line) user_match = re.search(r'From: (\w+)', line) if user_match: @@ -231,10 +238,15 @@ def get_system_info(): } def get_wall_of_shame(): - # Get the wall of shame + # Get the wall of shame out of the log data + logShameList = log_data['shameList'] + print(f"Shame List: {logShameList}") + + # future space for other ideas return { - 'shame': "N/A", + 'shame': ', '.join(shameWordList), + 'shameList': '\n'.join(f'
  • {line}
  • ' for line in logShameList), } def get_database_info(): @@ -690,7 +702,7 @@ def generate_sys_hosts_html(system_info): Available Memory${memory_available} Total Disk Space${disk_total} Free Disk Space${disk_free} - Meshtastic CLI/APIValue + Meshtastic MetricValue API Version/Latest${cli_local} / ${cli_web} Int1 Name ID${node1_name} (${node1_ID}) Int1 Stat${node1_uptime} @@ -723,10 +735,11 @@ def generate_wall_of_shame_html(shame_info): -

    Put Shame Here

    +

    Collected Shame

    - + +
    Shame MetricValue
    shame${shame}
    Shamefull words${shame}
    Shamefull messages${shameList}