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

narinfo: more validation + underlying data structures #12

Merged
merged 7 commits into from
Apr 12, 2021

Conversation

flokli
Copy link
Collaborator

@flokli flokli commented Apr 11, 2021

This teaches go-nix how to parse signature lines and checksums, and provides the parsed version them it in the NarInfo.

For this to work, the hash.Hash and nar.narinfo.Signature structs, surrounding functions and corresponding tests were introduced.

There's also a path package now, which provides some basic sanity-checking for store paths.

Together with the nar.narinfo.NarInfo.Validate()function, this provides some pretty good coverage in checking for invalid.narinfo` files.

Instead of returning strings, which need to be parsed again, return a
struct containing the key name and digest.
This also takes care of nixbase64 decoding/encoding.
@flokli flokli requested a review from zimbatm April 11, 2021 16:57
hash/hash.go Outdated Show resolved Hide resolved
hash/hash.go Outdated Show resolved Hide resolved
nar/narinfo/validate.go Outdated Show resolved Hide resolved
path/nixpath.go Outdated Show resolved Hide resolved
path/nixpath.go Outdated Show resolved Hide resolved
flokli and others added 6 commits April 12, 2021 19:53
This adds a Hash struct, holding HashType and Digest []byte, and
provides functions to parse from and output a "nix-style" hash string.

Co-Authored-By: edef <edef@edef.eu>
This just being called test.go won't execute the test - which is why
this error wasn't spotted.
This provides some more sanity checking, and ensures hashes are in an
easy-to consume format.
This adds functions to parse and render nix paths.

Co-Authored-By: edef <edef@edef.eu>
This provides some more sanity checking on parsed .narinfo files,
ensuring the paths in StorePath, References and Deriver are syntactically valid
when no compression is present, ensuring File{Hash,Size} and Nar{Hash,Size} are equal

This is also added to the narinfo unit test, ensuring our example
narfile passes the validation.
nameRe isn't really used anywhere else currently, so this can be
skipped.
@flokli
Copy link
Collaborator Author

flokli commented Apr 12, 2021

Thanks for the review! I addressed all the remarks.

@zimbatm zimbatm merged commit 3492afc into nix-community:master Apr 12, 2021
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.

2 participants