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

Change saltLen to unit8 and add some tests #2117

Merged
merged 2 commits into from
Jan 18, 2022

Conversation

dominikschulz
Copy link
Member

Fixes #2116

RELEASE_NOTES=n/a

Signed-off-by: Dominik Schulz dominik.schulz@gauner.org

Fixes gopasspw#2116

RELEASE_NOTES=n/a

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
@dominikschulz dominikschulz added the cleanup Code hygiene label Jan 17, 2022
@dominikschulz dominikschulz added this to the 1.14.0 milestone Jan 17, 2022
AnomalRoil
AnomalRoil previously approved these changes Jan 17, 2022
Copy link
Member

@AnomalRoil AnomalRoil left a comment

Choose a reason for hiding this comment

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

Are we sure we have the proper tests for saltLen as well?

internal/tpl/funcs.go Show resolved Hide resolved
@dominikschulz dominikschulz marked this pull request as draft January 18, 2022 06:21
RELEASE_NOTES=[BUGFIX] Fix template func arg order

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
@AnomalRoil
Copy link
Member

It does seem like it was wrong already, but then isn't that really a breaking change that could change the resulting hashes for people?

@dominikschulz
Copy link
Member Author

Do you mean "breaking change" in the context of semver?
If so I'd argue no, because it was broken before and did not work as intended. So this is a fix, not a breaking change.

The previously generated hashes were just invalid. They would use a random salt of length 32 (depending on the function) and either an empty string or the requested salt length as the password.

I don't know why this did never occur to anyone. Maybe nobody is using this?

I certainly did use it before, but not sure when. If I have some time I might bisect to find the breaking change. But not right now.

@AnomalRoil
Copy link
Member

AnomalRoil commented Jan 18, 2022

Yeah, I meant "breaking" as in "this could lead to different hashes now that we have patched".
But having now looked at its references in the code, it seems we are only using it to generate new values, so it's not going to cause different values on existing entries.

My guess is that it's dating from when we stopped using fixed size salts to use this saltLen function instead last year in that commit.

@dominikschulz dominikschulz merged commit 15b56d3 into gopasspw:master Jan 18, 2022
@dominikschulz dominikschulz deleted the fix/issue-2116 branch January 18, 2022 10:08
@dominikschulz
Copy link
Member Author

Wow, good find.

Yes, indeed. That must be it.

I don't think I have used the feature since then.

Leaves the question how useful it is.
But I need it from time to time ...

@AnomalRoil
Copy link
Member

AnomalRoil commented Jan 18, 2022

@dominikschulz Wow, seems this just broke our CI on master 😱

https://github.com/gopasspw/gopass/runs/4851609036?check_suite_focus=true

@dominikschulz
Copy link
Member Author

Why would that fail after the tests ran successfully on the PR? 🤔

@AnomalRoil
Copy link
Member

I just ran it twice locally and it failed once and worked once...

@AnomalRoil
Copy link
Member

$ go test ./internal/tpl/... -v   
    template_test.go:290: 
        	Error Trace:	template_test.go:290
        	Error:      	Received unexpected error:
        	            	can't validate: hash does not match password
        	Test:       	TestVars/{{.Content_|_md5crypt_"7"}}
        	Messages:   	{{.Content | md5crypt "7"}}
--- FAIL: TestVars (0.00s)

@dominikschulz
Copy link
Member Author

So it's a flaky test. Hmm, I didn't expect that. Need to take a look later. #2121

kpitt pushed a commit to kpitt/gopass that referenced this pull request Jul 21, 2022
* Change saltLen to unit8 and add some tests

Fixes gopasspw#2116

RELEASE_NOTES=n/a

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>

* Fix arguemnt order for the template funcs and add tests

RELEASE_NOTES=[BUGFIX] Fix template func arg order

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code hygiene
Projects
None yet
Development

Successfully merging this pull request may close these issues.

saltLen should return uint8
2 participants