Skip to content

Commit f4761cf

Browse files
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>
1 parent 83c3930 commit f4761cf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

examples/test_mqtt_messaging.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,15 @@ def message_handler(topic: str, message: dict):
117117
f"evt/{device_type}/{device_topic}/#",
118118
]
119119

120+
def mask_mac_in_topic(topic, mac_addr):
121+
if mac_addr and mac_addr in topic:
122+
return topic.replace(mac_addr, "[REDACTED_MAC]")
123+
return topic
124+
120125
for topic in topics:
121126
try:
122127
await mqtt_client.subscribe(topic, message_handler)
123-
print(f" ✅ Subscribed to: {topic}")
128+
print(f" ✅ Subscribed to: {mask_mac_in_topic(topic, device_id)}")
124129
except Exception as e:
125130
print(
126131
f" ⚠️ Failed to subscribe to device topic (type: {device_type}): {e}"

0 commit comments

Comments
 (0)