Skip to content

Commit

Permalink
fix(backup): appropriate warning messages for credential data
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 7159

Signed-off-by: James Lu <james.lu@suse.com>
  • Loading branch information
mantissahz authored and derekbit committed May 10, 2024
1 parent e1a2b4c commit 01b8448
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion datastore/longhorn.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,17 @@ func (s *DataStore) ValidateSetting(name, value string) (err error) {
for _, checkKey := range checkKeyList {
if value, ok := secret.Data[checkKey]; ok {
if strings.TrimSpace(string(value)) != string(value) {
return fmt.Errorf("there is space or new line in %s", checkKey)
switch {
case strings.TrimLeft(string(value), " ") != string(value):
return fmt.Errorf("invalid leading white space in %s", checkKey)
case strings.TrimRight(string(value), " ") != string(value):
return fmt.Errorf("invalid trailing white space in %s", checkKey)
case strings.TrimLeft(string(value), "\n") != string(value):
return fmt.Errorf("invalid leading new line in %s", checkKey)
case strings.TrimRight(string(value), "\n") != string(value):
return fmt.Errorf("invalid trailing new line in %s", checkKey)
}
return fmt.Errorf("invalid white space or new line in %s", checkKey)
}
}
}
Expand Down

0 comments on commit 01b8448

Please sign in to comment.