signer: allow space in passwords, improve error messsage

This commit is contained in:
Martin Holst Swende 2018-09-25 11:11:29 +02:00
parent 626cf5de17
commit ebe46a48f3
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
3 changed files with 11 additions and 11 deletions

View file

@ -80,14 +80,14 @@ func (l *AuditLogger) Export(ctx context.Context, addr common.Address) (json.Raw
return j, e
}
func (l *AuditLogger) Import(ctx context.Context, keyJSON json.RawMessage) (Account, error) {
// Don't actually log the json contents
l.log.Info("Import", "type", "request", "metadata", MetadataFromContext(ctx).String(),
"keyJSON size", len(keyJSON))
a, e := l.api.Import(ctx, keyJSON)
l.log.Info("Import", "type", "response", "addr", a.String(), "error", e)
return a, e
}
//func (l *AuditLogger) Import(ctx context.Context, keyJSON json.RawMessage) (Account, error) {
// // Don't actually log the json contents
// l.log.Info("Import", "type", "request", "metadata", MetadataFromContext(ctx).String(),
// "keyJSON size", len(keyJSON))
// a, e := l.api.Import(ctx, keyJSON)
// l.log.Info("Import", "type", "response", "addr", a.String(), "error", e)
// return a, e
//}
func NewAuditLogger(path string, api ExternalAPI) (*AuditLogger, error) {
l := log.New("api", "signer")

View file

@ -156,7 +156,7 @@ func (v *Validator) ValidateTransaction(txArgs *SendTxArgs, methodSelector *stri
return msgs, v.validate(msgs, txArgs, methodSelector)
}
var Printable7BitAscii = regexp.MustCompile("^[A-Za-z0-9!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]+$")
var Printable7BitAscii = regexp.MustCompile("^[A-Za-z0-9!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ]+$")
// ValidatePasswordFormat returns an error if the password is too short, or consists of characters
// outside the range of the printable 7bit ascii set
@ -165,7 +165,7 @@ func ValidatePasswordFormat(password string) error {
return errors.New("password too short (<10 characters)")
}
if !Printable7BitAscii.MatchString(password) {
return errors.New("password contains invalid characters - allowed set (7bit printable ascii) is A-Z, a-z, 0-9, and !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~")
return errors.New("password contains invalid characters - only 7bit printable ascii allowed")
}
return nil
}

View file

@ -149,7 +149,7 @@ func TestPasswordValidation(t *testing.T) {
{"password\nwith\nlinebreak", true},
{"password\twith\vtabs", true},
// Ok passwords
{"passwordWhichIsOk", false},
{"password WhichIsOk", false},
{"passwordOk!@#$%^&*()", false},
{"12301203123012301230123012", false},
}