Repository navigation
Potential fix for code scanning alert no. 72: Cleartext logging of sensitive information - #22
Merged
Merged
Conversation
…nsitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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/adityamukho/minigraf/security/code-scanning/72
In general, to fix cleartext logging of sensitive information, avoid logging raw untrusted data (like full user-provided values or IDs). If you need diagnostics, either (a) replace detailed messages with generic ones that don’t include user content, or (b) sanitize/redact before logging. For a REPL, generic high-level errors are usually sufficient.
For this specific case, the problematic behavior is that
parse_datalog_command(&command_buffer)returnsErr(String)where theStringmay contain user data, andrepl.rslogs that entire string to stderr. The least invasive fix that preserves functionality is to keep parse-time diagnostics in the Rust type system (theErr(String)), but avoid echoing the error details to the user. Instead, print a generic message like"Parse error"that reveals only that parsing failed, without including the inner stringe. This does not change control flow, error handling, or any non-logging behavior; it only reduces the information exposed over the logging channel.Concretely:
src/repl.rs, in theErr(e)arm of theparse_datalog_commandmatch (around lines 103–105), changeeprintln!("Parse error: {}", e);to a generic messageeprintln!("Parse error");.src/query/datalog/parser.rsorsrc/query/datalog/types.rs, because they don’t themselves perform logging; they only construct error strings.Suggested fixes powered by Copilot Autofix. Review carefully before merging.