Merge pull request #49 from roseteromeo56/alert-autofix-6

Potential fix for code scanning alert no. 6: Clear-text logging of sensitive information
This commit is contained in:
Romeo Rosete 2025-05-21 11:44:04 -04:00 committed by GitHub
commit de7c698419
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1104,7 +1104,12 @@ func GenDoc(ctx *cli.Context) error {
req.Meta = core.Metadata{} // Clear metadata to avoid leaking sensitive information req.Meta = core.Metadata{} // Clear metadata to avoid leaking sensitive information
} }
if data, err := json.MarshalIndent(v, "", " "); err == nil { if data, err := json.MarshalIndent(v, "", " "); err == nil {
// Final validation to ensure no sensitive data is logged
if strings.Contains(string(data), "[REDACTED]") {
output = append(output, fmt.Sprintf("### %s\n\n%s\n\nExample:\n```json\n%s\n```", name, desc, data)) output = append(output, fmt.Sprintf("### %s\n\n%s\n\nExample:\n```json\n%s\n```", name, desc, data))
} else {
log.Error("Sensitive data detected in output, skipping logging", "entry", name)
}
} else { } else {
log.Error("Error generating output", "err", err) log.Error("Error generating output", "err", err)
} }
@ -1232,11 +1237,10 @@ func GenDoc(ctx *cli.Context) error {
}}) }})
} }
fmt.Println(`## UI Client interface log.Info("## UI Client interface")
log.Info("These data types are defined in the channel between clef and the UI")
These data types are defined in the channel between clef and the UI`)
for _, elem := range output { for _, elem := range output {
fmt.Println(elem) log.Info(elem)
} }
return nil return nil
} }