Tree shaking
Tree shaking for kubernetes/admission/review keeps 48 lines, deletes 0 and adds 0. It keeps 2 files and removes 0.
admission.rego: 42 lines kept, 0 deleted, 0 added
1# A validating admission webhook for pods. The API server of Kubernetes sends an AdmissionReview as the input,
2# and the webhook answers with the AdmissionReview in `review`.
3package kubernetes.admission
4
5deny contains message if {
6 some container in containers
7 not trusted(container.image)
8 message := sprintf("container %q has the image %q from an untrusted registry", [container.name, container.image])
9}
10
11deny contains message if {
12 some container in containers
13 container.securityContext.privileged
14 message := sprintf("container %q is privileged", [container.name])
15}
16
17deny contains message if {
18 some container in containers
19 not container.resources.limits.memory
20 message := sprintf("container %q has no memory limit", [container.name])
21}
22
23# The containers and the init containers of the pod.
24containers contains container if some container in input.request.object.spec.containers
25
26containers contains container if some container in input.request.object.spec.initContainers
27
28trusted(image) if {
29 some registry in data.kubernetes.registries
30 startswith(image, registry)
31}
32
33# The AdmissionReview response that the API server expects.
34review := {
35 "apiVersion": "admission.k8s.io/v1",
36 "kind": "AdmissionReview",
37 "response": {
38 "uid": input.request.uid,
39 "allowed": count(deny) == 0,
40 "status": {"message": concat("; ", deny)},
41 },
42}
Counts
| Lines kept | 48 |
| Lines deleted | 0 |
| Lines added | 0 |
| Files kept | 2 |
| Files removed | 0 |
Builtins (5)
- concat
- count
- equal
- sprintf
- startswith
Legend
1A kept line: the shaken bundle has it.
2A deleted line: the shaken bundle does not have it.
+An added line: only the shaken bundle has it.
- policy.rego a removed file