From f4761cf75972424b7e7139265016d9dd7e758dce Mon Sep 17 00:00:00 2001 From: Emmanuel Levijarvi Date: Thu, 9 Oct 2025 20:21:28 -0700 Subject: [PATCH] Potential fix for code scanning alert no. 44: Clear-text logging of sensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- examples/test_mqtt_messaging.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/test_mqtt_messaging.py b/examples/test_mqtt_messaging.py index 7a04d73..aa47ed9 100644 --- a/examples/test_mqtt_messaging.py +++ b/examples/test_mqtt_messaging.py @@ -117,10 +117,15 @@ def message_handler(topic: str, message: dict): f"evt/{device_type}/{device_topic}/#", ] + def mask_mac_in_topic(topic, mac_addr): + if mac_addr and mac_addr in topic: + return topic.replace(mac_addr, "[REDACTED_MAC]") + return topic + for topic in topics: try: await mqtt_client.subscribe(topic, message_handler) - print(f" ✅ Subscribed to: {topic}") + print(f" ✅ Subscribed to: {mask_mac_in_topic(topic, device_id)}") except Exception as e: print( f" ⚠️ Failed to subscribe to device topic (type: {device_type}): {e}"