From 752236dbfe3bf8e70adf35f05be0c1ac40d60b7a Mon Sep 17 00:00:00 2001 From: Romeo Rosete Date: Tue, 20 May 2025 10:43:33 -0400 Subject: [PATCH] Potential fix for code scanning alert no. 7: Clear-text logging of sensitive information Romeo Rosete Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- signer/core/cliui.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/signer/core/cliui.go b/signer/core/cliui.go index e04077865d..fe7695d725 100644 --- a/signer/core/cliui.go +++ b/signer/core/cliui.go @@ -31,6 +31,12 @@ import ( "github.com/ethereum/go-ethereum/log" ) +// sanitizeMessage redacts sensitive information from the input string. +func sanitizeMessage(message string) string { + // Example: Replace occurrences of "password: " with "password: [REDACTED]" + return strings.ReplaceAll(message, "password:", "password: [REDACTED]") +} + type CommandlineUI struct { in *bufio.Reader mu sync.Mutex @@ -237,7 +243,8 @@ func (ui *CommandlineUI) ShowError(message string) { // ShowInfo displays info message to user func (ui *CommandlineUI) ShowInfo(message string) { - fmt.Printf("## Info \n%s\n", message) + sanitizedMessage := sanitizeMessage(message) + fmt.Printf("## Info \n%s\n", sanitizedMessage) } func (ui *CommandlineUI) OnApprovedTx(tx ethapi.SignTransactionResult) {