Skip to content

Commit

Permalink
Require signature only when signer configured
Browse files Browse the repository at this point in the history
As the docs state, signature verification should only be triggered if a keyid is present in the signing block of a bundle configuration. This was not actually the case though as merely the presence of keys in the config would force signatur verification, even if not referenced by the bundle configuration.

Fixes open-policy-agent#3028

Signed-off-by: Anders Eknert <anders@eknert.com>
  • Loading branch information
anderseknert committed Dec 22, 2020
1 parent ccac137 commit a3aa777
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func (r *Reader) checkSignaturesAndDescriptors(signatures SignaturesConfig) erro
return nil
}

if signatures.isEmpty() && r.verificationConfig != nil {
if signatures.isEmpty() && r.verificationConfig != nil && r.verificationConfig.KeyID != "" {
return fmt.Errorf("bundle missing .signatures.json file")
}

Expand Down
7 changes: 6 additions & 1 deletion bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,14 @@ func TestReadWithSignatures(t *testing.T) {
nil,
true, fmt.Errorf("verification key not provided"),
},
"no_signatures_file": {
"no_signatures_file_no_keyid": {
[][2]string{{"/.manifest", `{"revision": "quickbrownfaux"}`}},
NewVerificationConfig(map[string]*KeyConfig{}, "", "", nil),
false, nil,
},
"no_signatures_file": {
[][2]string{{"/.manifest", `{"revision": "quickbrownfaux"}`}},
NewVerificationConfig(map[string]*KeyConfig{}, "somekey", "", nil),
true, fmt.Errorf("bundle missing .signatures.json file"),
},
"no_signatures": {
Expand Down

0 comments on commit a3aa777

Please sign in to comment.