feat(tvix/nar-bridge): stop parsing nixbase32 manually, validate
We have nixhash.FromHashTypeAndDigest now. Also, run Validate() on the PathInfo received from the remote PathInfoService. Change-Id: I14db0d9356c539c084afc9dd712314b56da2587e Reviewed-on: https://cl.tvl.fyi/c/depot/+/9652 Tested-by: BuildkiteCI Reviewed-by: Brian McGee <brian@bmcgee.ie>
This commit is contained in:
parent
98c17147c6
commit
673f5febbb
2 changed files with 24 additions and 10 deletions
|
|
@ -10,7 +10,6 @@ import (
|
|||
"code.tvl.fyi/tvix/nar-bridge/pkg/importer"
|
||||
"github.com/go-chi/chi/v5"
|
||||
nixhash "github.com/nix-community/go-nix/pkg/hash"
|
||||
"github.com/nix-community/go-nix/pkg/nixbase32"
|
||||
"github.com/sirupsen/logrus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
|
@ -101,11 +100,8 @@ func registerNarPut(s *Server) {
|
|||
}
|
||||
|
||||
// Compare the nar hash specified in the URL with the one that has been
|
||||
// calculated while processing the NAR file
|
||||
// TODO: bump go-nix and remove the parsing
|
||||
narHash, err := nixhash.ParseNixBase32(
|
||||
"sha256:" + nixbase32.EncodeToString(narSha256),
|
||||
)
|
||||
// calculated while processing the NAR file.
|
||||
narHash, err := nixhash.FromHashTypeAndDigest(0x12, narSha256)
|
||||
if err != nil {
|
||||
panic("must parse nixbase32")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue