-
-
Notifications
You must be signed in to change notification settings - Fork 154
Sigenergy: redact accessToken from the MQTT publish log line #4926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+141
−5
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e033d40
Sigenergy: redact accessToken from the MQTT publish log line
0b92ad0
Sigenergy: extend redaction to listener topics and _request logs, cov…
7f4d822
Improve docstring for redact function
springfall2008 ad41b5c
Fix typo in comments regarding sets handling
springfall2008 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same bug class on the inbound path — the topic embeds
app_keyand the listener logs it raw.The listener logs the full
topic_stron every received message (sigenergy.py:1521) and in the non-JSON warning (sigenergy.py:1507), and those topics embedapp_key(SIGENERGY_MQTT_TOPIC_CHANGE/PERIOD/ALARM,sigenergy.py:148-150) — a key this very list classifies as credential-bearing (it is the MQTT broker username and half of the base64 login key). So a user pasting a debug log still leaks it on every inbound line; the fix covers only the outbound publish line.Worth either
redact()-ing the topic (or the format args) in those two listener lines as part of this PR, or an explicit follow-up. The CLI tools (test_sigenergy_api,test_mqtt_connection) deliberately print only a 10-charapp_keyprefix, but the listener lines print the full topic.Separately: the
key/tokencatch-alls here will mask benign diagnostic fields in what is often the only log line for debugging a broker-side rejection (an alarm/instruction entry carrying a literalkeyid renders as<redacted>), while the match is case-exact, so a snake_caseaccess_tokenvariant would slip through. Sibling lists cover both directions (Deye addstokenHash; Sunsynk covers snake_case plusAuthorization/sign). Worth a conscious decision on both edges.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated reply from the triage bot (pr-cleanup).
Fixed in 0b92ad0: both listener lines now log a
safe_topicwithapp_keymasked (topic_str.replace(self.app_key, "<redacted>"), computed once after topic parsing and used for the non-JSON warning and the message line). I redacted only the topic, not thevalue_dictformat arg, on purpose: inboundvaluepayloads are device telemetry, and running them throughredact()would amplify the over-masking problem flagged below onto every inbound state log line for no credential risk.On the two edges of the key list — conscious decision, unchanged: the catch-alls stay, because the failure direction is asymmetric (a benign field rendering as
<redacted>costs one diagnostic detail; a missed credential leaks it permanently), and case-exact matching stays to mirror the sibling integrations (deye/sunsynk are also exact-match). Verified the Sigenergy API is camelCase throughout (accessToken/refreshTokenin the login/refresh responses, camelCase in the value dicts), so the snake_case variant has no live path here. Worth revisiting only if the shared-helper refactor in the third thread ever lands.