-
Notifications
You must be signed in to change notification settings - Fork 463
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
Scorecard - handle changes from new Config Validator version w.r.t. Violation format and k8s resource handling #613
Merged
morgante
merged 5 commits into
GoogleCloudPlatform:master
from
katze120:new-config-validator
Apr 7, 2020
+61
−24
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fefaaf8
update go.mod
katze120 1748c88
cleanup test data
katze120 1bf0c13
handle new Violation format from new CV wrt to constraint category an…
katze120 14bfa30
add gatekeeper test case
katze120 dbb2288
Merge branch 'master' into new-config-validator
morgante File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the future, it would be good to add a test which actually looks at data so we can be sure it passes through properly.