Skip to content

Fixes from HACS - Mask secrets in logs, redact card names in diagnostics - #141

Merged
mk-maddin merged 3 commits into
masterfrom
hacs_fixes
Oct 20, 2026
Merged

mk-maddin merged 3 commits into
masterfrom
hacs_fixes

Conversation

@mk-maddin

Copy link
Copy Markdown
Owner

Addresses the code review feedback from the HACS default repository submission (hacs/default#11260).

  • Property debug output: async_PropertyDebug now logs *** instead of the value for cak, ocppck, ocppcc and ocppsc, also for properties that are watched explicitly via set_debug_properties.
  • wattpilot library 0.2.2h: the debug log of received websocket messages masks the values of the same properties. Stored values are not changed.
  • Diagnostics: cards (contains RFID card names) is added to REDACT_ALLPROPS.
  • Tests / CI: new unit tests for the masking and a diagnostics test on a real Home Assistant core (tests_ha/); importlib_metadata added to the ha-flow-tests job.

The other review points (awaited cleanup coroutines, charger defined before use, disconnect on failed connect) were already fixed on master.

No change to entities, services or configuration. The log and diagnostics output is the only visible difference.

async_PropertyDebug logged every watched property with its value, so the
cloud API key (cak) and the OCPP keys appeared in the Home Assistant log.
An exclude list alone is not enough because properties listed explicitly
via set_debug_properties bypass it.

utils.py:
- Replace the value of cak, ocppck, ocppcc and ocppsc by *** before
  logging, in both the all-properties and the explicit-list mode. The
  property name is still logged so that changes remain visible.

tests/test_utils.py:
- Add tests for the masked secrets and for unchanged logging of other
  properties.
__on_message logged every received message at debug level, including the
values of the cloud API key (cak) and the OCPP keys (ocppck, ocppcc,
ocppsc).

wattpilot library (0.2.2g -> 0.2.2h, __init__.py and PKG-INFO):
- Add CONST_SECRET_PROPERTIES and _mask_secrets() which replace the value
  of these properties inside the message by ***, including values with
  escaped quotes.
- __on_message masks the message before logging and only builds the log
  text if debug logging is enabled. The stored property values are not
  changed.

tests/test_wattpilot_lib.py:
- Add tests for the masked log output, all secret properties, escaped
  quotes and unchanged stored values.
The cards property contains a name for each configured RFID card, which is
personal data and was part of the downloadable diagnostics.

diagnostics.py:
- Add cards to REDACT_ALLPROPS.

tests_ha/test_diagnostics.py:
- Add a test on a real Home Assistant core which checks that the cloud API
  key and the card names are redacted and other properties are kept.

.github/workflows/ci.yml:
- Install importlib_metadata in the ha-flow-tests job because the
  diagnostics module imports it.
@mk-maddin
mk-maddin merged commit 404c197 into master Oct 20, 2026
14 checks passed
@mk-maddin
mk-maddin deleted the hacs_fixes branch October 21, 2026 18:49
mstoffel-sag added a commit to mstoffel-sag/wattpilot-HA that referenced this pull request Oct 22, 2026
Brings in upstream PRs mk-maddin#138-mk-maddin#141: shutdown/setup error-path fixes,
connection config in the retry state (mk-maddin#115), failed responses without
requestId (mk-maddin#133), empty car profile (mk-maddin#134), secret masking in debug logs
and diagnostics (wattpilot 0.2.2h), and the AGENTS.md agent guidance.

Keeps the fork's manifest version (0.4.9) over upstream's 0.4.0, the
Wattpilot.astValues fix and the dropped standalone vendor files.
.gitignore now ignores CLAUDE.local.md instead of CLAUDE.md, since
upstream tracks its own CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HLdU8AYNGCyfJSLQ8HUwmb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant