From ebe46a48f30c34da4e6cbc7145aedf2a4ae8441b Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 25 Sep 2018 11:11:29 +0200 Subject: [PATCH] signer: allow space in passwords, improve error messsage --- signer/core/auditlog.go | 16 ++++++++-------- signer/core/validation.go | 4 ++-- signer/core/validation_test.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/signer/core/auditlog.go b/signer/core/auditlog.go index 1b9bca427a..1f9c909185 100644 --- a/signer/core/auditlog.go +++ b/signer/core/auditlog.go @@ -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") diff --git a/signer/core/validation.go b/signer/core/validation.go index f8b7f1c2ca..7c3ec42741 100644 --- a/signer/core/validation.go +++ b/signer/core/validation.go @@ -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 } diff --git a/signer/core/validation_test.go b/signer/core/validation_test.go index 1f5c1de9f0..155b25e92c 100644 --- a/signer/core/validation_test.go +++ b/signer/core/validation_test.go @@ -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}, }