-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): Handle changes from new Config Validator version w.r.t. Vio…
…lation format and k8s resource handling (#613) * update go.mod * cleanup test data * handle new Violation format from new CV wrt to constraint category and name, and minor lint changes * add gatekeeper test case Co-authored-by: Morgante Pell <[email protected]>
- Loading branch information
Showing
11 changed files
with
61 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,3 @@ func TestDataTypeTransformation(t *testing.T) { | |
} | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"name":"//storage.googleapis.com/test-project","asset_type":"storage.googleapis.com/Bucket","iam_policy":{"etag":"WwAAAaAaaaa=","bindings":[{"role":"roles/storage.legacyBucketOwner","members":["projectEditor:test-project","projectOwner:test-project"]},{"role":"roles/storage.objectViewer","members":["allAuthenticatedUsers"]}]},"ancestors":["projects/1234","folders/2345","organizations/56789"]} | ||
{"name":"//storage.googleapis.com/test-bucket-public","asset_type":"storage.googleapis.com/Bucket","iam_policy":{"etag":"WwAAAaAaaaa=","bindings":[{"role":"roles/storage.legacyBucketOwner","members":["projectEditor:test-project","projectOwner:test-project"]},{"role":"roles/storage.objectViewer","members":["allAuthenticatedUsers"]}]},"ancestors":["projects/1234","folders/2345","organizations/56789"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
{"name":"//storage.googleapis.com/test-bucket-public","asset_type":"storage.googleapis.com/Bucket","resource":{"version":"v1","discovery_document_uri":"https://www.googleapis.com/discovery/v1/apis/storage/v1/rest","discovery_name":"Bucket","parent":"//cloudresourcemanager.googleapis.com/projects/1234","data":{"acl":[],"billing":{},"cors":[],"defaultObjectAcl":[],"encryption":{},"etag":"CAU=","iamConfiguration":{"bucketPolicyOnly":{"enabled":true,"lockedTime":"2019-08-05T09:26:23.996Z"},"uniformBucketLevelAccess":{"enabled":true,"lockedTime":"2019-08-05T09:26:23.996Z"}},"id":"test-bucket-public","kind":"storage#bucket","labels":{},"lifecycle":{"rule":[]},"location":"US","locationType":"multi-region","logging":{},"metageneration":5,"name":"test-bucket-public","owner":{},"projectNumber":4567,"retentionPolicy":{},"selfLink":"https://www.googleapis.com/storage/v1/b/test-bucket-public","storageClass":"MULTI_REGIONAL","timeCreated":"2019-05-07T09:26:23.996Z","updated":"2019-05-07T15:11:21.219Z","versioning":{},"website":{}}},"ancestors":["projects/1234","folders/2345","organizations/56789"]} | ||
{"name":"//container.googleapis.com/projects/gke-networking/zones/us-central1-a/clusters/private-cluster-demo/k8s/namespaces/default/pods/hello-world-deploy-1234567d898-xqwf9","asset_type":"k8s.io/Pod","resource":{"version":"v1","discovery_document_uri":"https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json","discovery_name":"io.k8s.api.core.v1.Pod","parent":"//container.googleapis.com/projects/gke-networking/zones/us-central1-a/clusters/private-cluster-demo/k8s/namespaces/default","data":{"metadata":{"annotations":{"cni.projectcalico.org/podIP":"10.10.16.68/32","kubernetes.io/limit-ranger":"LimitRanger plugin set: cpu request for container hello-world"},"creationTimestamp":"2019-12-13T04:15:29Z","generateName":"hello-world-deploy-1234567d898-","labels":{"app":"hello-world-example","pod-template-hash":"598587d898"},"name":"hello-world-deploy-1234567d898-xqwf9","namespace":"default","ownerReferences":[{"apiVersion":"apps/v1","blockOwnerDeletion":true,"controller":true,"kind":"ReplicaSet","name":"hello-world-deploy-1234567d898","uid":"717b4db1-5a82-11e9-1111-12345a0a0fe3"}],"resourceVersion":"63643167","selfLink":"/api/v1/namespaces/default/pods/hello-world-deploy-1234567d898-xqwf9","uid":"1234567b-1d5f-11ea-9f3d-42010a0a0fe7"},"spec":{"containers":[{"image":"gcr.io/google-samples/hello-app:2.0","imagePullPolicy":"IfNotPresent","name":"hello-world","ports":[{"containerPort":8080,"protocol":"TCP"}],"resources":{"requests":{"cpu":"100m"}},"terminationMessagePath":"/dev/termination-log","terminationMessagePolicy":"File","volumeMounts":[{"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount","name":"default-token-123a4","readOnly":true}]}],"dnsPolicy":"ClusterFirst","hostname":"hello-world","nodeName":"gke-private-cluster-demo-default-pool-123456d1-87j0","priority":0,"restartPolicy":"Always","schedulerName":"default-scheduler","securityContext":{},"serviceAccount":"default","serviceAccountName":"default","terminationGracePeriodSeconds":30,"tolerations":[{"effect":"NoExecute","key":"node.kubernetes.io/not-ready","operator":"Exists","tolerationSeconds":300},{"effect":"NoExecute","key":"node.kubernetes.io/unreachable","operator":"Exists","tolerationSeconds":300}],"volumes":[{"name":"default-token-123a4","secret":{"defaultMode":420,"secretName":"default-token-123a4"}}]},"status":{"conditions":[{"lastProbeTime":null,"lastTransitionTime":"2019-12-13T04:15:29Z","status":"True","type":"Initialized"},{"lastProbeTime":null,"lastTransitionTime":"2019-12-13T04:15:36Z","status":"True","type":"Ready"},{"lastProbeTime":null,"lastTransitionTime":"2019-12-13T04:15:36Z","status":"True","type":"ContainersReady"},{"lastProbeTime":null,"lastTransitionTime":"2019-12-13T04:15:29Z","status":"True","type":"PodScheduled"}],"containerStatuses":[{"containerID":"docker://24964fc7e2905e2fe2f41f6ef6a81e746a49f75f00fded6168a36febfc644f14","image":"gcr.io/google-samples/hello-app:2.0","imageID":"docker-pullable://gcr.io/google-samples/hello-app@sha256:37e5287945774f27b418ce567cd77f4bbc9ef44a1bcd1a2312369f31f9cce567","lastState":{},"name":"hello-world","ready":true,"restartCount":0,"state":{"running":{"startedAt":"2019-12-13T04:15:33Z"}}}],"hostIP":"10.10.10.10","phase":"Running","podIP":"10.10.16.68","qosClass":"Burstable","startTime":"2019-12-13T04:15:29Z"}}},"ancestors":["projects/1188899998888","organizations/1234512341234"]} |
10 changes: 10 additions & 0 deletions
10
cli/testdata/scorecard/policy-library/policies/constraints/k8s_dump_review.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sDumpReview | ||
metadata: | ||
name: dump-review | ||
spec: | ||
enforcementAction: dryrun | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["*"] |
17 changes: 17 additions & 0 deletions
17
cli/testdata/scorecard/policy-library/policies/templates/k8s_dump_review_template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: templates.gatekeeper.sh/v1beta1 | ||
kind: ConstraintTemplate | ||
metadata: | ||
name: k8sdumpreview | ||
spec: | ||
crd: | ||
spec: | ||
names: | ||
kind: K8sDumpReview | ||
targets: | ||
- target: admission.k8s.gatekeeper.sh | ||
rego: | | ||
package k8sdumpreview | ||
violation[{"msg": msg}] { | ||
msg := sprintf("%v", [input.review]) | ||
} |