Skip to content

Commit e331d70

Browse files
committed
Fix CI failures (CodeQL + Formatting)
Resolved CodeQL 'Clear-text logging of sensitive information' alerts by using generic log messages for sensitive topics, as taint analysis flagged redaction as insufficient. Also fixed formatting issues to pass lint checks.
1 parent 9ba1582 commit e331d70

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/nwp500/mqtt/subscriptions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ async def unsubscribe(self, topic: str) -> int:
230230
# Redact topic for logging to avoid leaking sensitive information
231231
# (device IDs). We perform this check early to ensure we don't log raw
232232
# topics.
233-
_logger.info(f"Unsubscribing from topic: {redact_topic(topic)}")
233+
# Note: CodeQL flags log calls using the topic variable (even redacted)
234+
# as a security risk ("Clear-text logging of sensitive information").
235+
# To pass CI, we must use a generic message here.
236+
_logger.info("Unsubscribing from topic (redacted)")
234237

235238
try:
236239
# Convert concurrent.futures.Future to asyncio.Future and await
@@ -244,24 +247,21 @@ async def unsubscribe(self, topic: str) -> int:
244247
# complete independently, preventing InvalidStateError
245248
# in AWS CRT callbacks
246249
_logger.debug(
247-
"Unsubscribe from topic: %s was cancelled but will "
248-
"complete in background",
249-
redact_topic(topic),
250+
"Unsubscribe from topic (redacted) was "
251+
"cancelled but will complete in background"
250252
)
251253
raise
252254

253255
# Remove from tracking
254256
self._subscriptions.pop(topic, None)
255257
self._message_handlers.pop(topic, None)
256258

257-
_logger.info(f"Unsubscribed from topic: {redact_topic(topic)}")
259+
_logger.info("Unsubscribed from topic (redacted)")
258260

259261
return int(packet_id)
260262

261263
except (AwsCrtError, RuntimeError) as e:
262-
_logger.error(
263-
f"Failed to unsubscribe from topic: {redact_topic(topic)}: {e}"
264-
)
264+
_logger.error(f"Failed to unsubscribe from topic (redacted): {e}")
265265
raise
266266

267267
async def resubscribe_all(self) -> None:

0 commit comments

Comments
 (0)