diff --git a/pkg/cosign/client.go b/pkg/cosign/client.go index 39bdfb3432..c9d2b07888 100644 --- a/pkg/cosign/client.go +++ b/pkg/cosign/client.go @@ -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) } - - diff --git a/pkg/cosign/cosign.go b/pkg/cosign/cosign.go index 52c39cd580..4b466461e2 100644 --- a/pkg/cosign/cosign.go +++ b/pkg/cosign/cosign.go @@ -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) } diff --git a/pkg/cosign/mock.go b/pkg/cosign/mock.go index f5d698c79c..6cce307e7e 100644 --- a/pkg/cosign/mock.go +++ b/pkg/cosign/mock.go @@ -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 } - diff --git a/pkg/engine/imageVerify.go b/pkg/engine/imageVerify.go index 731f4e0434..4d5c71f685 100644 --- a/pkg/engine/imageVerify.go +++ b/pkg/engine/imageVerify.go @@ -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, }, } diff --git a/pkg/engine/imageVerify_test.go b/pkg/engine/imageVerify_test.go index 2a1c2d5c3e..fea9f62929 100644 --- a/pkg/engine/imageVerify_test.go +++ b/pkg/engine/imageVerify_test.go @@ -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 } - diff --git a/pkg/engine/json-utils/traverse.go b/pkg/engine/json-utils/traverse.go index 4c4207b58c..0f06043a8d 100644 --- a/pkg/engine/json-utils/traverse.go +++ b/pkg/engine/json-utils/traverse.go @@ -128,4 +128,3 @@ func (t *Traversal) traverseList(list []interface{}, path string) ([]interface{} } return list, nil } -