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: handle empty trust policies #1431

Merged
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
3 changes: 2 additions & 1 deletion pkg/verifier/cosign/cosign.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ func (f *cosignVerifierFactory) Create(_ string, verifierConfig config.VerifierC

var trustPolicies *TrustPolicies
legacy := true
if config.KeyRef == "" && config.RekorURL == "" {
// if trustPolicies are provided and non-legacy, create the trust policies
if config.KeyRef == "" && config.RekorURL == "" && len(config.TrustPolicies) > 0 {
trustPolicies, err = CreateTrustPolicies(config.TrustPolicies, verifierName)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/verifier/cosign/cosign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func TestCreate(t *testing.T) {
wantErr: true,
},
{
name: "invalid trust policies config",
name: "valid trust policies config with no legacy config or trust policies",
config: config.VerifierConfig{
"name": "test",
"artifactTypes": "testtype",
"trustPolicies": []TrustPolicyConfig{},
},
wantErr: true,
wantErr: false,
},
{
name: "invalid config with legacy and trust policies",
Expand Down
Loading