mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-30 19:35:06 +00:00
fmt
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
This commit is contained in:
parent
0bb35aa302
commit
676bd5f4be
6 changed files with 23 additions and 29 deletions
|
@ -9,7 +9,7 @@ import (
|
|||
var client Cosign = &driver{}
|
||||
|
||||
type Cosign interface {
|
||||
Verify(ctx context.Context, signedImgRef name.Reference, co *cosign.CheckOpts) ([]cosign.SignedPayload, error)
|
||||
Verify(ctx context.Context, signedImgRef name.Reference, co *cosign.CheckOpts) ([]cosign.SignedPayload, error)
|
||||
}
|
||||
|
||||
type driver struct {
|
||||
|
@ -18,5 +18,3 @@ type driver struct {
|
|||
func (d *driver) Verify(ctx context.Context, signedImgRef name.Reference, co *cosign.CheckOpts) ([]cosign.SignedPayload, error) {
|
||||
return cosign.Verify(ctx, signedImgRef, co)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -166,19 +166,19 @@ func decodeStatement(payloadBase64 string) (map[string]interface{}, error) {
|
|||
return nil, errors.Wrapf(err, "failed to base64 decode payload for %v", statementRaw)
|
||||
}
|
||||
|
||||
var statement in_toto.Statement
|
||||
if err := json.Unmarshal(statementRaw, &statement); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var statement in_toto.Statement
|
||||
if err := json.Unmarshal(statementRaw, &statement); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if statement.PredicateType != attestation.CosignCustomProvenanceV01 {
|
||||
// This assumes that the following statements are JSON objects:
|
||||
// - in_toto.PredicateSLSAProvenanceV01
|
||||
// - in_toto.PredicateLinkV1
|
||||
// - in_toto.PredicateSPDX
|
||||
// any other custom predicate
|
||||
return common.ToMap(statement)
|
||||
}
|
||||
if statement.PredicateType != attestation.CosignCustomProvenanceV01 {
|
||||
// This assumes that the following statements are JSON objects:
|
||||
// - in_toto.PredicateSLSAProvenanceV01
|
||||
// - in_toto.PredicateLinkV1
|
||||
// - in_toto.PredicateSPDX
|
||||
// any other custom predicate
|
||||
return common.ToMap(statement)
|
||||
}
|
||||
|
||||
return decodeCosignCustomProvenanceV01(statement)
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ func SetMock(image string, data [][]byte) error {
|
|||
payloads := make([]cosign.SignedPayload, len(data))
|
||||
for i, p := range data {
|
||||
payloads[i] = cosign.SignedPayload{
|
||||
Payload: p,
|
||||
Payload: p,
|
||||
}
|
||||
}
|
||||
|
||||
client = &mock{data: map[string][]cosign.SignedPayload {
|
||||
client = &mock{data: map[string][]cosign.SignedPayload{
|
||||
imgRef.String(): payloads,
|
||||
}}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func SetMock(image string, data [][]byte) error {
|
|||
}
|
||||
|
||||
type mock struct {
|
||||
data map[string] []cosign.SignedPayload
|
||||
data map[string][]cosign.SignedPayload
|
||||
}
|
||||
|
||||
func (m *mock) Verify(_ context.Context, signedImgRef name.Reference, _ *cosign.CheckOpts) ([]cosign.SignedPayload, error) {
|
||||
|
@ -39,4 +39,3 @@ func (m *mock) Verify(_ context.Context, signedImgRef name.Reference, _ *cosign.
|
|||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ func (iv *imageVerifier) attestImage(repository, key string, imageInfo *context.
|
|||
return ruleResponse(iv.rule, msg, response.RuleStatusPass)
|
||||
}
|
||||
|
||||
func (iv *imageVerifier) checkAttestations(a *v1.Attestation, s map[string]interface{}, img *context.ImageInfo ) (bool, error) {
|
||||
func (iv *imageVerifier) checkAttestations(a *v1.Attestation, s map[string]interface{}, img *context.ImageInfo) (bool, error) {
|
||||
if len(a.Conditions) == 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
@ -221,13 +221,13 @@ func (iv *imageVerifier) checkAttestations(a *v1.Attestation, s map[string]inte
|
|||
}
|
||||
|
||||
imgMap := map[string]interface{}{
|
||||
"image": map[string]interface{}{
|
||||
"image": img.String(),
|
||||
"image": map[string]interface{}{
|
||||
"image": img.String(),
|
||||
"registry": img.Registry,
|
||||
"path": img.Path,
|
||||
"name": img.Name,
|
||||
"tag": img.Tag,
|
||||
"digest": img.Digest,
|
||||
"path": img.Path,
|
||||
"name": img.Name,
|
||||
"tag": img.Tag,
|
||||
"digest": img.Digest,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,6 @@ var test_policy_bad = `{
|
|||
}
|
||||
}`
|
||||
|
||||
|
||||
var test_resource = `{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Pod",
|
||||
|
@ -180,4 +179,3 @@ func buildContext(t *testing.T, policy, resource string) *PolicyContext {
|
|||
}
|
||||
return policyContext
|
||||
}
|
||||
|
||||
|
|
|
@ -128,4 +128,3 @@ func (t *Traversal) traverseList(list []interface{}, path string) ([]interface{}
|
|||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue