Skip to content

Support for sonos 80.0.0#226

Open
simojenki wants to merge 3 commits into
masterfrom
sonos80
Open

Support for sonos 80.0.0#226
simojenki wants to merge 3 commits into
masterfrom
sonos80

Conversation

@simojenki

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/smapi.ts
return this.tokens[token]!;
}
associateCredentialsForToken(token: string, fullSmapiToken: SmapiToken, oldToken?:string) {
logger.debug("Adding token: " + token + " " + JSON.stringify(fullSmapiToken));

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This logs sensitive data returned by
an access to fullSmapiToken
as clear text.

Copilot Autofix

AI 9 months ago

To fix the problem, sensitive data such as authentication tokens (token, fullSmapiToken) must not be logged in cleartext. The code should avoid serializing and outputting secret data entirely. If logging is required for troubleshooting, one can either:

  • Redact sensitive fields before stringification (e.g., mask the token, redact fields, or only log safe object keys),
  • Or, preferably, avoid logging the object altogether, only logging non-sensitive operational context (such as logging that a token was added, with an anonymized or truncated ID).

To implement this:

  • In src/smapi.ts, on line 245, replace the logger.debug call with one that avoids logging any secret data. For example, log only that a token was added, and reference a hash or truncated version of the token and non-secret fields from the object (e.g., a user ID hash, if present).

No new methods are needed unless you wish to add a utility for redaction, but simplest/safer is not to log the sensitive data at all. No new external libraries are required.


Suggested changeset 1
src/smapi.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/smapi.ts b/src/smapi.ts
--- a/src/smapi.ts
+++ b/src/smapi.ts
@@ -242,7 +242,7 @@
     return this.tokens[token]!;
   }
   associateCredentialsForToken(token: string, fullSmapiToken: SmapiToken, oldToken?:string) {
-    logger.debug("Adding token: " + token + " " + JSON.stringify(fullSmapiToken));
+    logger.debug("Added credentials for new token; token length: " + token.length);
     if(oldToken) {
       delete this.tokens[oldToken];
     }
EOF
@@ -242,7 +242,7 @@
return this.tokens[token]!;
}
associateCredentialsForToken(token: string, fullSmapiToken: SmapiToken, oldToken?:string) {
logger.debug("Adding token: " + token + " " + JSON.stringify(fullSmapiToken));
logger.debug("Added credentials for new token; token length: " + token.length);
if(oldToken) {
delete this.tokens[oldToken];
}
Copilot is powered by AI and may make mistakes. Always verify output.
@thestift

Copy link
Copy Markdown

it would be nice perhaps when the old method is still working for S1 users

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.

3 participants