diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-05T15·28+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-10-07T02·06+0000 |
commit | 9c0d66197bfa60a0c14109a471b6bcdfd61247e1 (patch) | |
tree | df705c367f6055d08d707e25215533ac9f90e462 /tvix/nar-bridge | |
parent | 4bf541109a9e0a918420a8be1b10564b30edf117 (diff) |
feat(tvix/nar-bridge): do pathInfo.Validate() as additional check r/6719
This should make it quite quick to spot writing code breaking some of the assumptions we have on PathInfo messages ourselves. Change-Id: I480caaec41f8ea5246c3c3081460c7ad12e78569 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9554 Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nar-bridge')
-rw-r--r-- | tvix/nar-bridge/default.nix | 2 | ||||
-rw-r--r-- | tvix/nar-bridge/go.mod | 6 | ||||
-rw-r--r-- | tvix/nar-bridge/go.sum | 7 | ||||
-rw-r--r-- | tvix/nar-bridge/pkg/pathinfosvc/server.go | 14 |
4 files changed, 20 insertions, 9 deletions
diff --git a/tvix/nar-bridge/default.nix b/tvix/nar-bridge/default.nix index 6e7468bf8888..d8688730dd59 100644 --- a/tvix/nar-bridge/default.nix +++ b/tvix/nar-bridge/default.nix @@ -6,5 +6,5 @@ pkgs.buildGoModule { name = "nar-bridge"; src = depot.third_party.gitignoreSource ./.; - vendorHash = "sha256-DiGK6Lb+DA46zjJUZpkMSecF3cVst7KoGhcLG3OxtOc="; + vendorHash = "sha256-PlmFiGQPHqc+4JG0HAWW+oj8ruL7PTmGNJe20ansrxg="; } diff --git a/tvix/nar-bridge/go.mod b/tvix/nar-bridge/go.mod index 628ceb8026c9..3fa9d568459e 100644 --- a/tvix/nar-bridge/go.mod +++ b/tvix/nar-bridge/go.mod @@ -2,14 +2,16 @@ module code.tvl.fyi/tvix/nar-bridge require ( code.tvl.fyi/tvix/castore/protos v0.0.0-20230922125121-72355662d742 - code.tvl.fyi/tvix/store/protos v0.0.0-20230922125121-4251671e09c1 + code.tvl.fyi/tvix/store/protos v0.0.0-20231005184258-5be346d3c195 github.com/alecthomas/kong v0.7.1 github.com/go-chi/chi v1.5.4 github.com/go-chi/chi/v5 v5.0.7 github.com/google/go-cmp v0.5.9 + github.com/multiformats/go-multihash v0.2.1 github.com/nix-community/go-nix v0.0.0-20231005143722-b0f8b73c06df github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.1 + github.com/ulikunitz/xz v0.5.11 google.golang.org/grpc v1.51.0 google.golang.org/protobuf v1.28.1 lukechampine.com/blake3 v1.1.7 @@ -21,11 +23,9 @@ require ( github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect - github.com/multiformats/go-multihash v0.2.1 // indirect github.com/multiformats/go-varint v0.0.6 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/ulikunitz/xz v0.5.11 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect golang.org/x/net v0.7.0 // indirect golang.org/x/sys v0.5.0 // indirect diff --git a/tvix/nar-bridge/go.sum b/tvix/nar-bridge/go.sum index 36b12c077d66..286978ea129e 100644 --- a/tvix/nar-bridge/go.sum +++ b/tvix/nar-bridge/go.sum @@ -1,8 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= code.tvl.fyi/tvix/castore/protos v0.0.0-20230922125121-72355662d742 h1:x7LsxggggaN3acnCMNDO5LZLAV+A+rZ+R8TXzr+Lgsk= code.tvl.fyi/tvix/castore/protos v0.0.0-20230922125121-72355662d742/go.mod h1:Ejhyvc0dJUWQMxtJxddfFuAF5N8IKIO94q5CP4czY8Y= -code.tvl.fyi/tvix/store/protos v0.0.0-20230922125121-4251671e09c1 h1:ttMO8cE4rVbqJlqLsoirePWEtXhT4MxrGvLMFyJ+UhA= -code.tvl.fyi/tvix/store/protos v0.0.0-20230922125121-4251671e09c1/go.mod h1:uOGlmwyEraDd9kzAWHdDeZdNgKrpOAmtWCdMeY+DVKs= +code.tvl.fyi/tvix/store/protos v0.0.0-20231005184258-5be346d3c195 h1:Phbmz5mjc2D5EYmiZy12l6yoh4NwZVWUg9eqsfJBJO0= +code.tvl.fyi/tvix/store/protos v0.0.0-20231005184258-5be346d3c195/go.mod h1:wY+2UywCYumr2lKLN8H+J/PvczD0mmsnU2dqotIxeLo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2ojoH/0= github.com/alecthomas/kong v0.7.1 h1:azoTh0IOfwlAX3qN9sHWTxACE2oV8Bg2gAwBsMwDQY4= @@ -51,11 +51,8 @@ github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= -github.com/nix-community/go-nix v0.0.0-20230825195510-c72199eca18e h1:15CPg2PQMyBl+TTEKuonrQqS9uOJyi7JcuU0FpvV088= -github.com/nix-community/go-nix v0.0.0-20230825195510-c72199eca18e/go.mod h1:y3eASc0gMh26jjoP9Xz+qqMKjTnqJgG1RG8xvKvFR8s= github.com/nix-community/go-nix v0.0.0-20231005143722-b0f8b73c06df h1:n4I26uXUST5vmdsDWPo9ikK57il4htQyhnsLWoHYFmY= github.com/nix-community/go-nix v0.0.0-20231005143722-b0f8b73c06df/go.mod h1:hHM9UK2zOCjvmiLgeaW4LVbOW/vBaRWFJGzfi31/slQ= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= diff --git a/tvix/nar-bridge/pkg/pathinfosvc/server.go b/tvix/nar-bridge/pkg/pathinfosvc/server.go index 464ca6f61b13..d5074a2f3267 100644 --- a/tvix/nar-bridge/pkg/pathinfosvc/server.go +++ b/tvix/nar-bridge/pkg/pathinfosvc/server.go @@ -264,6 +264,20 @@ func (p *PathInfoServiceServer) Get(ctx context.Context, getPathInfoRequest *sto panic("node may not be nil") } + // run Validate on the PathInfo, more as an additional sanity check our code is sound, + // to make sure we populated everything properly, before returning it. + validatedOutPath, err := pathInfo.Validate() + if err != nil { + panic("pathinfo failed validation") + } + if narInfo.StorePath != validatedOutPath.Absolute() { + panic(fmt.Sprintf( + "StorePath returned from Validate() mismatches the one from .narinfo (%s vs %s)", + validatedOutPath.Absolute(), + narInfo.StorePath), + ) + } + return pathInfo, nil // TODO: Deriver, System, CA |