Skip to content
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

Merged

Conversation

Skarlso
Copy link
Member

@Skarlso Skarlso commented Oct 5, 2018

This deals with #120.

Instead of doing this bit:

gaia/security/vault.go

Lines 256 to 261 in 413494f

if len(d) < 2 {
// It is possible that if there is a password failure it's not caught
// 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")
}

Now there is a definitive way of checking if the decryption was successful or not.

@Skarlso Skarlso added the Ready To Merge PR is ready to be merged into master label Oct 5, 2018
@codecov-io
Copy link

codecov-io commented Oct 5, 2018

Codecov Report

Merging #121 into master will decrease coverage by 0.02%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
security/vault.go 77.37% <66.66%> (+0.68%) ⬆️
workers/scheduler/scheduler.go 73.57% <0%> (-0.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 413494f...b7a48d9. Read the comment docs.

@@ -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!")...)
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing! 😊

@@ -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!")) {
Copy link
Member

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? 😄

// 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")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same like above

@Skarlso Skarlso dismissed michelvocks’s stale review October 6, 2018 21:17

Addressed comments, please re-review. :)

Copy link
Member

@michelvocks michelvocks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ❤️

@michelvocks michelvocks merged commit bcaf623 into gaia-pipeline:master Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready To Merge PR is ready to be merged into master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants