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

parse checksum even when no EOL is found #285

Merged
merged 1 commit into from
Oct 20, 2020

Conversation

nixpanic
Copy link
Contributor

In case a checksum file does not end with '\n', the checksum can still
be valid. When hitting EOF, verify that the read line is non-empty, and
continue with parsing.

This addresses kubernetes/minikube#9470.

@hashicorp-cla
Copy link

hashicorp-cla commented Oct 20, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@azr azr left a comment

Choose a reason for hiding this comment

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

Hello there, nice one, this LGTM ! Could you please add a test case for this one as well ?

In case a checksum file does not end with '\n', the checksum can still
be valid. When hitting EOF, verify that the read line is non-empty, and
continue with parsing.
@nixpanic nixpanic force-pushed the checksum-missing-EOL branch from 6ae2302 to 512cb42 Compare October 20, 2020 12:46
@nixpanic
Copy link
Contributor Author

Testcase added, without the change it FAILS:

$ go test . -test.run TestGetFile_checksum_from_file
--- FAIL: TestGetFile_checksum_from_file (0.02s)
    --- FAIL: TestGetFile_checksum_from_file/?checksum=file:http://127.0.0.1:44575/sha512-p-EOF.sum (0.00s)
        get_test.go:444: append: ?checksum=file:http://127.0.0.1:44575/sha512-p-EOF.sum
            
            err: invalid checksum: no checksum found in: http://127.0.0.1:44575/sha512-p-EOF.sum
FAIL
FAIL	github.com/hashicorp/go-getter	0.027s
FAIL

And with the change it passes:

$ go test . -test.run TestGetFile_checksum_from_file
ok  	github.com/hashicorp/go-getter	0.019s

@azr azr merged commit 3d7b883 into hashicorp:master Oct 20, 2020
@azr
Copy link
Contributor

azr commented Oct 20, 2020

Good work, thanks !

@afbjorklund
Copy link

afbjorklund commented Oct 20, 2020

Sad that this is needed, but thanks for the workaround! The kubernetes releases still might not verify using other tools though

nickryand pushed a commit to nickryand/go-getter that referenced this pull request Jul 19, 2022
In case a checksum file does not end with '\n', the checksum can still
be valid. When hitting EOF, verify that the read line is non-empty, and
continue with parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants