feat(tvix/store/protos): validate NarSha256
Change-Id: I016d1b020b04850f0dca68c2ea96643230dada10 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9649 Reviewed-by: Brian McGee <brian@bmcgee.ie> Tested-by: BuildkiteCI
This commit is contained in:
parent
6dab608198
commit
8ced43f3c7
2 changed files with 17 additions and 1 deletions
|
|
@ -34,7 +34,7 @@ func genPathInfoSymlink() *storev1pb.PathInfo {
|
|||
References: [][]byte{exampleStorePathDigest},
|
||||
Narinfo: &storev1pb.NARInfo{
|
||||
NarSize: 0,
|
||||
NarSha256: []byte{},
|
||||
NarSha256: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
||||
Signatures: []*storev1pb.NARInfo_Signature{},
|
||||
ReferenceNames: []string{EXAMPLE_STORE_PATH},
|
||||
},
|
||||
|
|
@ -61,6 +61,16 @@ func TestValidate(t *testing.T) {
|
|||
assert.Equal(t, "00000000000000000000000000000000-dummy", storePath.String())
|
||||
})
|
||||
|
||||
t.Run("invalid nar_sha256", func(t *testing.T) {
|
||||
pi := genPathInfoSymlink()
|
||||
|
||||
// create broken references, where the reference digest is wrong
|
||||
pi.Narinfo.NarSha256 = []byte{0xbe, 0xef}
|
||||
|
||||
_, err := pi.Validate()
|
||||
assert.Error(t, err, "must not validate")
|
||||
})
|
||||
|
||||
t.Run("invalid reference digest", func(t *testing.T) {
|
||||
pi := genPathInfoSymlink()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue