Potential fix for code scanning alert no. 7: Clear-text logging of sensitive information#32
Merged
agntperfect merged 1 commit intomainfrom Sep 29, 2025
Merged
Conversation
…nsitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
agntperfect
commented
Sep 29, 2025
Member
Author
agntperfect
left a comment
There was a problem hiding this comment.
Clear-text logging of sensitive information
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.
Potential fix for https://github.com/FSU-Pulchowk/discord-bot/security/code-scanning/7
To fix the problem, instead of passing environment variables (such as
BIRTHDAY_ANNOUNCEMENT_CHANNEL_ID) or any potentially sensitive data directly to log functions, the code should ensure that only non-sensitive information is logged. The best way to prevent leaking sensitive data is to remove or redact such data before logging. Specifically, in src/bot.js, wherever an environment-derived value is logged, its actual value should be masked/redacted or omitted. As for keys where a reference is useful (such as a channel ID), only the existence, shape, or an obfuscated value (e.g., hash or partial) should be logged.For this case, the log call on line 1680 in src/bot.js is:
Instead of logging the actual channel ID, log only that the value is present (or missing), or, if really needed, a redacted form (first few/last few characters).
No library changes are needed; change only the argument to log in src/bot.js.
No change is required in src/utils/debug.js (the log method attempts sanitization, but as shown above, code that depends solely on this is not robust enough).
Suggested fixes powered by Copilot Autofix. Review carefully before merging.