mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-02-01 18:41:24 -05:00
BE+FE: new fields handling in views and skipping device heuristics for random macs
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -1,17 +1,3 @@
|
||||
<!--
|
||||
#---------------------------------------------------------------------------------#
|
||||
# NetAlertX #
|
||||
# Open Source Network Guard / WIFI & LAN intrusion detector #
|
||||
# #
|
||||
# devices.php - Front module. Devices list page #
|
||||
#---------------------------------------------------------------------------------#
|
||||
# Puche 2021 pi.alert.application@gmail.com GNU GPLv3 #
|
||||
# jokob-sk 2022 jokob.sk@gmail.com GNU GPLv3 #
|
||||
# leiweibau 2022 https://github.com/leiweibau GNU GPLv3 #
|
||||
# cvc90 2023 https://github.com/cvc90 GNU GPLv3 #
|
||||
#---------------------------------------------------------------------------------#
|
||||
-->
|
||||
|
||||
<?php
|
||||
|
||||
require 'php/templates/header.php';
|
||||
|
||||
@@ -590,26 +590,6 @@ def normalize_string(text):
|
||||
# MAC and IP helper methods
|
||||
# -------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# # -------------------------------------------------------------------------------------------
|
||||
# def is_random_mac(mac: str) -> bool:
|
||||
# """Determine if a MAC address is random, respecting user-defined prefixes not to mark as random."""
|
||||
|
||||
# is_random = mac[1].upper() in ["2", "6", "A", "E"]
|
||||
|
||||
# # Get prefixes from settings
|
||||
# prefixes = get_setting_value("UI_NOT_RANDOM_MAC")
|
||||
|
||||
# # If detected as random, make sure it doesn't start with a prefix the user wants to exclude
|
||||
# if is_random:
|
||||
# for prefix in prefixes:
|
||||
# if mac.upper().startswith(prefix.upper()):
|
||||
# is_random = False
|
||||
# break
|
||||
|
||||
# return is_random
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------
|
||||
def generate_mac_links(html, deviceUrl):
|
||||
p = re.compile(r"(?:[0-9a-fA-F]:?){12}")
|
||||
|
||||
@@ -5,6 +5,7 @@ import base64
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple
|
||||
from logger import mylog
|
||||
from helpers import is_random_mac
|
||||
|
||||
# Register NetAlertX directories
|
||||
INSTALL_PATH = os.getenv("NETALERTX_APP", "/app")
|
||||
@@ -176,6 +177,12 @@ def guess_device_attributes(
|
||||
name = str(name).lower().strip() if name else "(unknown)"
|
||||
mac_clean = mac.replace(":", "").replace("-", "").upper()
|
||||
|
||||
# --- Check for Random MAC ---
|
||||
# If the MAC is randomized (private), skip vendor/heuristics assignment
|
||||
if is_random_mac(mac):
|
||||
mylog("debug", f"[guess_device_attributes] Random MAC detected ({mac}); returning defaults to avoid incorrect assignment.")
|
||||
return default_icon, default_type
|
||||
|
||||
# # Internet shortcut
|
||||
# if mac == "INTERNET":
|
||||
# return ICONS.get("globe", default_icon), DEVICE_TYPES.get("Internet", default_type)
|
||||
@@ -261,4 +268,4 @@ def guess_type(
|
||||
|
||||
# Handler for when this is run as a program instead of called as a module.
|
||||
if __name__ == "__main__":
|
||||
mylog("error", "This module is not intended to be run directly.")
|
||||
mylog("none", "This module is not intended to be run directly.")
|
||||
|
||||
Reference in New Issue
Block a user