Conversation
| 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
Show autofix suggestion
Hide autofix suggestion
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 thelogger.debugcall 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
| @@ -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.
|
it would be nice perhaps when the old method is still working for S1 users |
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.
No description provided.