chore(core): exclude logging on non-debug builds
What changed, and why it matters
This commit removes leftover debug logging from production firmware builds. In non-debug builds, two log messages will no longer be emitted. This is a routine code-quality change with no direct security impact visible in the diff.
No action required. Treat as routine maintenance. If security relevance is suspected, verify whether the logging infrastructure itself could leak sensitive data in release builds elsewhere, but this diff does not introduce or fix such a leak.
Security signals we found
No security-relevant functional change in the diff
Logging statements guarded by __debug__ to reduce release-build output
No input validation, cryptographic, or access-control changes
Evidence from the diff
The change wraps two self.channel._log(...) calls in if __debug__: guards inside core/src/trezor/wire/thp/session_context.py. One is an informational log at the end of a session loop; the other is a warning about an unexpected session ID in decrypted messages. The commit message labels this as a chore with no changelog entry. There is no functional behavior change beyond suppressing logs in optimized/non-debug builds.
Changed components
core/src/trezor/wire/thp/session_context.pyInspect captured patch +6 / −4
diff --git a/core/src/trezor/wire/thp/session_context.py b/core/src/trezor/wire/thp/session_context.py
index 6253a0117..13a131777 100644
--- a/core/src/trezor/wire/thp/session_context.py
+++ b/core/src/trezor/wire/thp/session_context.py
@@ -50,7 +50,8 @@ class GenericSessionContext(Context):
if message is None:
message = await self._read_next_message()
await handle_single_message(self, message)
- self.channel._log("session loop is over")
+ if __debug__:
+ self.channel._log("session loop is over")
return
except protocol_common.WireError as e:
if __debug__:
@@ -71,9 +72,10 @@ class GenericSessionContext(Context):
session_id, message = await self.channel.decrypt_message()
if session_id == self.session_id:
return message
- self.channel._log(
- "Ignored message for unexpected session", logger=log.warning
- )
+ if __debug__:
+ self.channel._log(
+ "Ignored message for unexpected session", logger=log.warning
+ )
async def read(
self,
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.