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

fix: ensure hash function is available #314

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion internal/app/siftool/modif_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-2022, Sylabs Inc. All rights reserved.
// Copyright (c) 2021-2023, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -81,6 +81,16 @@ func TestApp_Add(t *testing.T) {
sif.OptSBOMMetadata(sif.SBOMFormatCycloneDXJSON),
},
},
{
name: "OCIRootIndex",
data: []byte("{}"),
dataType: sif.DataOCIRootIndex,
},
{
name: "OCIBlob",
data: []byte("{}"),
dataType: sif.DataOCIBlob,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/sif/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package sif
import (
"bytes"
"crypto"
"crypto/sha256"
"encoding"
"encoding/binary"
"encoding/hex"
Expand Down Expand Up @@ -82,7 +83,7 @@ type ociBlob struct {
// written to the returned ociBlob prior to calling MarshalBinary.
func newOCIBlobDigest() *ociBlob {
return &ociBlob{
hasher: crypto.SHA256.New(),
hasher: sha256.New(),
digest: v1.Hash{
Algorithm: "sha256",
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/siftool/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ func Test_command_getAdd(t *testing.T) {
"--datatype", "10",
},
},
{
name: "DataOCIBlob",
flags: []string{
"--datatype", "11",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Empty file.
Empty file.