Skip to content
Open
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
2 changes: 1 addition & 1 deletion acceptance/crypto/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func SignerWithKey(ctx context.Context, keyName string) (signature.SignerVerifie
return nil, err
}

return cosign.LoadPrivateKey(key.PrivateBytes, key.Password())
return cosign.LoadPrivateKey(key.PrivateBytes, key.Password(), nil)
}

// PublicKeysFrom returns a map of all public keys encoded in PEM format
Expand Down
163 changes: 82 additions & 81 deletions acceptance/go.mod

Large diffs are not rendered by default.

742 changes: 320 additions & 422 deletions acceptance/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/inspect/inspect_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package inspect

import (
"bytes"
"context"
"fmt"
"testing"

Expand All @@ -29,7 +30,6 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"golang.org/x/net/context"

"github.com/conforma/cli/cmd/root"
"github.com/conforma/cli/internal/policy/source"
Expand Down
10 changes: 5 additions & 5 deletions cmd/validate/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ func TestValidateImageCommand_VSAUpload_Success(t *testing.T) {
originalLoadPrivateKey := vsa.LoadPrivateKey
defer func() { vsa.LoadPrivateKey = originalLoadPrivateKey }()

vsa.LoadPrivateKey = func(keyBytes, password []byte) (signature.SignerVerifier, error) {
vsa.LoadPrivateKey = func(keyBytes, password []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return &simpleFakeSigner{}, nil
}

Expand Down Expand Up @@ -1499,7 +1499,7 @@ func TestValidateImageCommand_VSAUpload_NoStorageBackends(t *testing.T) {
originalLoadPrivateKey := vsa.LoadPrivateKey
defer func() { vsa.LoadPrivateKey = originalLoadPrivateKey }()

vsa.LoadPrivateKey = func(keyBytes, password []byte) (signature.SignerVerifier, error) {
vsa.LoadPrivateKey = func(keyBytes, password []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return &simpleFakeSigner{}, nil
}

Expand Down Expand Up @@ -1643,7 +1643,7 @@ func TestValidateImageCommand_VSAFormat_DSSE(t *testing.T) {
originalLoadPrivateKey := vsa.LoadPrivateKey
defer func() { vsa.LoadPrivateKey = originalLoadPrivateKey }()

vsa.LoadPrivateKey = func(keyBytes, password []byte) (signature.SignerVerifier, error) {
vsa.LoadPrivateKey = func(keyBytes, password []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return &simpleFakeSigner{}, nil
}

Expand Down Expand Up @@ -1992,7 +1992,7 @@ func TestGenerateVSAsDSSE_Errors(t *testing.T) {
originalLoadPrivateKey := vsa.LoadPrivateKey
defer func() { vsa.LoadPrivateKey = originalLoadPrivateKey }()

vsa.LoadPrivateKey = func(keyBytes, password []byte) (signature.SignerVerifier, error) {
vsa.LoadPrivateKey = func(keyBytes, password []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return &simpleFakeSigner{}, nil
}

Expand Down Expand Up @@ -2118,7 +2118,7 @@ func TestVSAGeneration_WithOutputDir(t *testing.T) {
originalLoadPrivateKey := vsa.LoadPrivateKey
defer func() { vsa.LoadPrivateKey = originalLoadPrivateKey }()

vsa.LoadPrivateKey = func(keyBytes, password []byte) (signature.SignerVerifier, error) {
vsa.LoadPrivateKey = func(keyBytes, password []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return &simpleFakeSigner{}, nil
}

Expand Down
299 changes: 157 additions & 142 deletions go.mod

Large diffs are not rendered by default.

783 changes: 400 additions & 383 deletions go.sum

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions internal/validate/vsa/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const (
)

// LoadPrivateKey is aliased to allow easy testing.
var LoadPrivateKey = cosign.LoadPrivateKey
var LoadPrivateKey = func(key, pass []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return cosign.LoadPrivateKey(key, pass, defaultLoadOptions)
}

type Attestor struct {
PredicatePath string // path to the raw VSA (predicate) JSON
Expand Down Expand Up @@ -71,7 +73,7 @@ func NewSigner(ctx context.Context, keyRef string, fs afero.Fs) (*Signer, error)
return nil, fmt.Errorf("resolve private key password: %w", err)
}

signerVerifier, err := LoadPrivateKey(keyBytes, password)
signerVerifier, err := LoadPrivateKey(keyBytes, password, nil)
if err != nil {
return nil, fmt.Errorf("load private key %q: %w", keyRef, err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/validate/vsa/attest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func TestNewSigner(t *testing.T) {
originalLoadPrivateKey := LoadPrivateKey
defer func() { LoadPrivateKey = originalLoadPrivateKey }()

LoadPrivateKey = func(keyBytes, password []byte) (signature.SignerVerifier, error) {
LoadPrivateKey = func(keyBytes, password []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return &fakeSigner{}, nil
}

Expand Down Expand Up @@ -373,7 +373,7 @@ func TestNewSigner_Comprehensive(t *testing.T) {
originalLoadPrivateKey := LoadPrivateKey
defer func() { LoadPrivateKey = originalLoadPrivateKey }()

LoadPrivateKey = func(keyBytes, password []byte) (signature.SignerVerifier, error) {
LoadPrivateKey = func(keyBytes, password []byte, defaultLoadOptions *[]signature.LoadOption) (signature.SignerVerifier, error) {
return &fakeSigner{}, nil
}

Expand Down
Loading