-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a definitive check for possible password errors. #121
Added a definitive check for possible password errors. #121
Conversation
Codecov Report
@@ Coverage Diff @@
## master #121 +/- ##
==========================================
- Coverage 64.61% 64.58% -0.03%
==========================================
Files 24 24
Lines 2063 2067 +4
==========================================
+ Hits 1333 1335 +2
- Misses 580 581 +1
- Partials 150 151 +1
Continue to review full report at Codecov.
|
security/vault.go
Outdated
@@ -190,6 +190,7 @@ func (v *Vault) encrypt(data []byte) (string, error) { | |||
// User has deleted all the secrets. the file will be empty. | |||
return "", nil | |||
} | |||
data = append(data, []byte("\nGAIA_CHECK=!CHECK_ME!")...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks a bit magic to me. What do you think about moving this to constant variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing! 😊
security/vault.go
Outdated
@@ -241,6 +242,10 @@ func (v *Vault) decrypt(data []byte) ([]byte, error) { | |||
if err != nil { | |||
return []byte{}, err | |||
} | |||
|
|||
if !bytes.Contains(unpadMsg, []byte("!CHECK_ME!")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. A bit magic. Maybe move that to a separate constant with a tiny description? 😄
security/vault.go
Outdated
// by the padding process. Here it will be caught because we can't | ||
// marshal the data into proper k/v pairs. | ||
return errors.New("possible mistyped password") | ||
if bytes.Equal(d[0], []byte("GAIA_CHECK")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same like above
Addressed comments, please re-review. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ❤️
This deals with #120.
Instead of doing this bit:
gaia/security/vault.go
Lines 256 to 261 in 413494f
Now there is a definitive way of checking if the decryption was successful or not.