mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
Potential fix for code scanning alert no. 11: 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>
This commit is contained in:
parent
de7c698419
commit
cc4031775c
1 changed files with 4 additions and 2 deletions
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
|
@ -33,8 +34,9 @@ import (
|
||||||
|
|
||||||
// sanitizeMessage redacts sensitive information from the input string.
|
// sanitizeMessage redacts sensitive information from the input string.
|
||||||
func sanitizeMessage(message string) string {
|
func sanitizeMessage(message string) string {
|
||||||
// Example: Replace occurrences of "password: <value>" with "password: [REDACTED]"
|
// Use regular expressions to redact sensitive information.
|
||||||
return strings.ReplaceAll(message, "password:", "password: [REDACTED]")
|
re := regexp.MustCompile(`(?i)(password\s*:\s*\S+|private\s*key\s*:\s*\S+|email\s*:\s*\S+@\S+)`)
|
||||||
|
return re.ReplaceAllString(message, "[REDACTED]")
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandlineUI struct {
|
type CommandlineUI struct {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue