-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kyverno:main' into simplify-cel-sysctls-policy
- Loading branch information
Showing
88 changed files
with
3,190 additions
and
2 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
6 changes: 6 additions & 0 deletions
6
...role-mutating-validating-admission-webhooks/.chainsaw-test/chainsaw-step-01-assert-1.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,6 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: restrict-clusterrole-mutating-validating-admission-webhooks | ||
status: | ||
ready: true |
31 changes: 31 additions & 0 deletions
31
...rict-clusterrole-mutating-validating-admission-webhooks/.chainsaw-test/chainsaw-test.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,31 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
creationTimestamp: null | ||
name: restrict-clusterrole-mutating-validating-admission-webhooks | ||
spec: | ||
steps: | ||
- name: step-01 | ||
try: | ||
- apply: | ||
file: ../restrict-clusterrole-mutating-validating-admission-webhooks.yaml | ||
- patch: | ||
resource: | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: restrict-clusterrole-mutating-validating-admission-webhooks | ||
spec: | ||
validationFailureAction: Enforce | ||
- assert: | ||
file: chainsaw-step-01-assert-1.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: non-violating-clusterrole.yaml | ||
- apply: | ||
expect: | ||
- check: | ||
($error != null): true | ||
file: violating-clusterrole.yaml |
11 changes: 11 additions & 0 deletions
11
...role-mutating-validating-admission-webhooks/.chainsaw-test/non-violating-clusterrole.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,11 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: non-violating-clusterrole | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["admissionregistration.k8s.io"] | ||
resources: ["mutatingwebhookconfigurations", "validatingwebhookconfigurations"] | ||
verbs: ["get", "list", "watch"] |
11 changes: 11 additions & 0 deletions
11
...sterrole-mutating-validating-admission-webhooks/.chainsaw-test/violating-clusterrole.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,11 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: violating-clusterrole | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["admissionregistration.k8s.io"] | ||
resources: ["mutatingwebhookconfigurations", "validatingwebhookconfigurations"] | ||
verbs: ["create", "update", "patch"] |
21 changes: 21 additions & 0 deletions
21
...strict-clusterrole-mutating-validating-admission-webhooks/.kyverno-test/kyverno-test.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,21 @@ | ||
apiVersion: cli.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: restrict-clusterrole-mutating-validating-admission-webhooks | ||
policies: | ||
- ../restrict-clusterrole-mutating-validating-admission-webhooks.yaml | ||
resources: | ||
- resource.yaml | ||
results: | ||
- kind: ClusterRole | ||
policy: restrict-clusterrole-mutating-validating-admission-webhooks | ||
resources: | ||
- non-violating-clusterrole | ||
result: pass | ||
rule: restrict-clusterrole | ||
- kind: ClusterRole | ||
policy: restrict-clusterrole-mutating-validating-admission-webhooks | ||
resources: | ||
- violating-clusterrole | ||
result: fail | ||
rule: restrict-clusterrole |
25 changes: 25 additions & 0 deletions
25
...r/restrict-clusterrole-mutating-validating-admission-webhooks/.kyverno-test/resource.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,25 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: non-violating-clusterrole | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["admissionregistration.k8s.io"] | ||
resources: ["mutatingwebhookconfigurations", "validatingwebhookconfigurations"] | ||
verbs: ["get", "list", "watch"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: violating-clusterrole | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["admissionregistration.k8s.io"] | ||
resources: ["mutatingwebhookconfigurations", "validatingwebhookconfigurations"] | ||
verbs: ["create", "update", "patch"] | ||
|
21 changes: 21 additions & 0 deletions
21
other/restrict-clusterrole-mutating-validating-admission-webhooks/artifacthub-pkg.yml
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,21 @@ | ||
name: restrict-clusterrole-mutating-validating-admission-webhooks | ||
version: 1.0.0 | ||
displayName: Restrict Clusterrole for Mutating and Validating Admission Webhooks | ||
createdAt: "2024-05-19T20:30:05.000Z" | ||
description: >- | ||
ClusterRoles that grant write permissions over admission webhook should be minimized to reduce powerful identities in the cluster. This policy checks to ensure write permissions are not provided to admission webhooks. | ||
install: |- | ||
```shell | ||
kubectl apply -f https://raw.githubusercontent.com/kyverno/policies/main/other/restrict-clusterrole-mutating-validating-admission-webhooks/restrict-clusterrole-mutating-validating-admission-webhooks.yaml | ||
``` | ||
keywords: | ||
- kyverno | ||
- Other | ||
readme: | | ||
ClusterRoles that grant write permissions over admission webhook should be minimized to reduce powerful identities in the cluster. This policy checks to ensure write permissions are not provided to admission webhooks. | ||
Refer to the documentation for more details on Kyverno annotations: https://artifacthub.io/docs/topics/annotations/kyverno/ | ||
annotations: | ||
kyverno/category: "Other" | ||
kyverno/subject: "ClusterRole" | ||
digest: 3ebafd2ea6b0db34271461525d00cb97805c3ba8a97e928db056bb6e65dbf01b |
50 changes: 50 additions & 0 deletions
50
...ating-admission-webhooks/restrict-clusterrole-mutating-validating-admission-webhooks.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,50 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: restrict-clusterrole-mutating-validating-admission-webhooks | ||
annotations: | ||
policies.kyverno.io/title: Restrict Clusterrole for Mutating and Validating Admission Webhooks | ||
policies.kyverno.io/category: Other | ||
policies.kyverno.io/severity: medium | ||
kyverno.io/kyverno-version: 1.10.7 | ||
kyverno.io/kubernetes-version: "1.27" | ||
policies.kyverno.io/subject: ClusterRole | ||
policies.kyverno.io/description: >- | ||
ClusterRoles that grant write permissions over admission webhook should be minimized to reduce powerful identities in the cluster. This policy checks to ensure write permissions are not provided to admission webhooks. | ||
spec: | ||
validationFailureAction: Audit | ||
background: true | ||
rules: | ||
- name: restrict-clusterrole | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- ClusterRole | ||
validate: | ||
message: "Use of verbs `create`, `update`, and `patch` are forbidden for mutating and validating admission webhooks" | ||
foreach: | ||
- list: "request.object.rules[]" | ||
deny: | ||
conditions: | ||
all: | ||
- key: "{{ element.apiGroups || '' }}" | ||
operator: AnyIn | ||
value: | ||
- admissionregistration.k8s.io | ||
- key: "{{ element.resources || '' }}" | ||
operator: AnyIn | ||
value: | ||
- mutatingwebhookconfigurations | ||
- validatingwebhookconfigurations | ||
any: | ||
- key: "{{ element.verbs }}" | ||
operator: AnyIn | ||
value: | ||
- create | ||
- update | ||
- patch | ||
- key: "{{ contains(element.verbs[], '*') }}" | ||
operator: Equals | ||
value: true | ||
|
38 changes: 38 additions & 0 deletions
38
psp-migration-cel/check-supplemental-groups/.chainsaw-test/chainsaw-test.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,38 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
creationTimestamp: null | ||
name: check-supplemental-groups | ||
spec: | ||
steps: | ||
- name: step-01 | ||
try: | ||
- apply: | ||
file: ../check-supplemental-groups.yaml | ||
- patch: | ||
resource: | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: psp-check-supplemental-groups | ||
spec: | ||
validationFailureAction: Enforce | ||
- assert: | ||
file: policy-ready.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: pod-good.yaml | ||
- apply: | ||
expect: | ||
- check: | ||
($error != null): true | ||
file: pod-bad.yaml | ||
- apply: | ||
file: podcontroller-good.yaml | ||
- apply: | ||
expect: | ||
- check: | ||
($error != null): true | ||
file: podcontroller-bad.yaml |
55 changes: 55 additions & 0 deletions
55
psp-migration-cel/check-supplemental-groups/.chainsaw-test/pod-bad.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,55 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: badpod01 | ||
spec: | ||
securityContext: | ||
supplementalGroups: | ||
- 120 | ||
- 230 | ||
- 550 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: badpod02 | ||
spec: | ||
securityContext: | ||
supplementalGroups: | ||
- 1000 | ||
- 120 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: badpod03 | ||
spec: | ||
securityContext: | ||
runAsGroup: 0 | ||
supplementalGroups: | ||
- 580 | ||
- 0 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: badpod04 | ||
spec: | ||
securityContext: | ||
supplementalGroups: | ||
- 100 | ||
- 601 | ||
- 600 | ||
runAsGroup: 0 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 |
60 changes: 60 additions & 0 deletions
60
psp-migration-cel/check-supplemental-groups/.chainsaw-test/pod-good.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,60 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: goodpod01 | ||
spec: | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: goodpod02 | ||
spec: | ||
securityContext: | ||
supplementalGroups: | ||
- 150 | ||
- 100 | ||
- 500 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: goodpod03 | ||
spec: | ||
securityContext: | ||
supplementalGroups: | ||
- 550 | ||
- 600 | ||
- 120 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: goodpod04 | ||
spec: | ||
securityContext: | ||
runAsGroup: 0 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: goodpod05 | ||
spec: | ||
securityContext: | ||
supplementalGroups: | ||
- 600 | ||
runAsGroup: 0 | ||
containers: | ||
- name: busybox01 | ||
image: busybox:1.35 |
Oops, something went wrong.