Redact the MAC in the reservations unsubscribe warning - #127
Merged
Conversation
fetch_reservations logged device_info.mac_address in the clear when its cleanup unsubscribe raised. The identical warning in update_reservations_confirmed, seventy lines below, already passed the value through redact_mac - this call site was simply missed. CodeQL has flagged it as py/clear-text-logging-sensitive-data (high) since 2026-07-23; it shipped in 9.3.1. The local `from .mqtt.utils import redact_mac` matches the sibling and the three other call sites in the package, which import it inside the function rather than at module scope. A test drives the cleanup path with a failing unsubscribe and asserts the MAC does not appear in the emitted warning; it fails against the unredacted version. Claude-Session: https://claude.ai/code/session_01XVj9BYvuLj7Th3iFUVoeCn
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, consistent with existing redaction patterns in the codebase, and includes a targeted regression test.
Pull request overview
This PR addresses a security logging issue in the reservations helpers by ensuring device MAC addresses are redacted in a warning emitted when an unsubscribe cleanup step fails. It aligns fetch_reservations with the already-redacting behavior in update_reservations_confirmed and adds a regression test to prevent reintroducing clear-text MAC logging.
Changes:
- Redact
device.device_info.mac_addressin thefetch_reservationsunsubscribe-failure warning (matching the existing redaction inupdate_reservations_confirmed). - Add a unit test that forces the unsubscribe failure path and asserts the clear-text MAC does not appear in the warning output.
- Document the security fix in the Unreleased changelog.
File summaries
| File | Description |
|---|---|
src/nwp500/reservations.py |
Redacts MAC address in the unsubscribe failure warning in fetch_reservations. |
tests/test_reservations.py |
Adds regression coverage ensuring clear-text MAC is not logged when unsubscribe fails. |
CHANGELOG.rst |
Notes the security-related logging redaction fix under Unreleased. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ervations-warning # Conflicts: # CHANGELOG.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
fetch_reservationsloggeddevice_info.mac_addressin the clear when its cleanup unsubscribe raised:The identical warning in
update_reservations_confirmed, seventy lines below in the same file, already passes the value throughredact_mac. This call site was simply missed.CodeQL has flagged it as
py/clear-text-logging-sensitive-data(high severity) since 2026-07-23, and it shipped in 9.3.1.Fix
Both call sites now redact. The function-local
from .mqtt.utils import redact_macmatches the sibling and the three other call sites in the package (tou_schedule.py,device_info_cache.py,mqtt/client.py), all of which import it inside the function rather than at module scope.I grepped for other unredacted
mac_address/device_macvalues reaching a logger — this was the only one.Tests
test_fetch_reservations_redacts_mac_when_unsubscribe_failsdrives the cleanup path with a failing unsubscribe and asserts the MAC does not appear in the emitted warning. Verified it fails against the unredacted version and passes with the fix. Full suite: 736 passed.https://claude.ai/code/session_01XVj9BYvuLj7Th3iFUVoeCn