Redact sensitive info from debug logs (#1069)

Redacts sensitive data when debug logging device responses such as mac,
location and usernames
This commit is contained in:
Steven B.
2024-07-17 18:57:09 +01:00
committed by GitHub
parent c19389f236
commit c4f015a2fb
11 changed files with 300 additions and 39 deletions

View File

@@ -50,7 +50,6 @@ import logging
import secrets
import struct
import time
from pprint import pformat as pf
from typing import Any, cast
from cryptography.hazmat.primitives import padding
@@ -353,7 +352,7 @@ class KlapTransport(BaseTransport):
+ f"request with seq {seq}"
)
else:
_LOGGER.debug("Query posted " + msg)
_LOGGER.debug("Device %s query posted %s", self._host, msg)
# Check for mypy
if self._encryption_session is not None:
@@ -361,11 +360,7 @@ class KlapTransport(BaseTransport):
json_payload = json_loads(decrypted_response)
_LOGGER.debug(
"%s << %s",
self._host,
_LOGGER.isEnabledFor(logging.DEBUG) and pf(json_payload),
)
_LOGGER.debug("Device %s query response received", self._host)
return json_payload