Skip to content
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

feat: add other policies in CEL expressions - Part 1 #946

Merged
merged 36 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d8d97d1
copy allowed-annotations
Chandan-DK Mar 17, 2024
694bee5
convert allowed-annotations to cel
Chandan-DK Mar 17, 2024
17544e1
add CI test for directories starting with a in other-cel folder
Chandan-DK Mar 18, 2024
bce06e1
Merge branch 'main' into other-policies-cel-part-1
Chandan-DK Mar 18, 2024
d479769
copy allowed-pod-priorities
Chandan-DK Mar 19, 2024
d88f1f0
convert allowed-pod-priorities to cel
Chandan-DK Mar 19, 2024
7252230
copy block-ephemeral-containers
Chandan-DK Mar 20, 2024
9d45ca0
convert block-ephemeral-containers to cel
Chandan-DK Mar 20, 2024
ea63ef2
add CI test for directories starting with b in other-cel folder
Chandan-DK Mar 20, 2024
8baf31d
copy check-env-vars
Chandan-DK Mar 21, 2024
e9f2716
convert check-env-vars to cel
Chandan-DK Mar 21, 2024
486cb1d
copy check-serviceaccount-secrets
Chandan-DK Mar 21, 2024
ceece5c
convert check-serviceaccount-secrets to cel
Chandan-DK Mar 21, 2024
d691d7b
add CI test for directories starting with b to d in other-cel folder
Chandan-DK Mar 21, 2024
f284a73
copy check-node-for-cve-2022-0185
Chandan-DK Mar 21, 2024
4a892f6
convert check-node-for-cve-2022-0185
Chandan-DK Mar 21, 2024
12cb860
copy deny-secret-service-account-token-type
Chandan-DK Mar 22, 2024
c6f9fbc
convert deny-secret-service-account-token-type to cel
Chandan-DK Mar 22, 2024
a4ad77c
copy disallow-all-secrets
Chandan-DK Mar 22, 2024
80f241c
convert disallow-all-secrets to cel
Chandan-DK Mar 23, 2024
a76048b
copy disallow-localhost-services
Chandan-DK Mar 23, 2024
ec7e6b6
convert disallow-localhost-services to cel
Chandan-DK Mar 23, 2024
2bcc5c3
copy disallow-secrets-from-env-vars
Chandan-DK Mar 24, 2024
107816e
convert disallow-secrets-from-env-vars to cel
Chandan-DK Mar 24, 2024
548d800
add ServiceAccount to the subject in annotations
Chandan-DK Mar 26, 2024
4cc921d
copy docker-socket-requires-label
Chandan-DK Mar 27, 2024
c410a45
convert docker-socket-requires-label to cel
Chandan-DK Mar 27, 2024
f9af000
rename files for clarity
Chandan-DK Mar 27, 2024
4b38e95
use autogen for higher level controllers
Chandan-DK Mar 27, 2024
3d0faf1
add kyverno tests for block-ephemeral-containers
Chandan-DK Mar 27, 2024
20563d9
use autogen in allowed-pod-priorities kyverno policy
Chandan-DK Mar 28, 2024
d5fac4f
Merge branch 'main' into other-policies-cel-part-1
Chandan-DK Mar 28, 2024
192245f
add new lines at the end of files
Chandan-DK Mar 30, 2024
55ca859
Merge branch 'main' into other-policies-cel-part-1
MariamFahmy98 Apr 22, 2024
dbb6f56
Merge branch 'main' into other-policies-cel-part-1
MariamFahmy98 May 13, 2024
065e052
Merge branch 'main' into other-policies-cel-part-1
Chandan-DK May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:
- ^other$/^re[c-q]
- ^other$/^res
- ^other$/^[s-z]
- ^other-cel$/^a
- ^other-cel$/^[b-d]
- ^other-cel$/^[m-q]
- ^pod-security$
- ^pod-security-cel$
Expand Down
39 changes: 39 additions & 0 deletions other-cel/allowed-annotations/.chainsaw-test/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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: allowed-annotations
spec:
steps:
- name: step-01
try:
- apply:
file: ../allowed-annotations.yaml
- patch:
resource:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: allowed-annotations
spec:
validationFailureAction: Enforce
- assert:
file: policy-ready.yaml
- name: step-02
try:
- apply:
file: pod-good.yaml
- apply:
file: podcontroller-good.yaml
- apply:
expect:
- check:
($error != null): true
file: pod-bad.yaml
- apply:
expect:
- check:
($error != null): true
file: podcontroller-bad.yaml

47 changes: 47 additions & 0 deletions other-cel/allowed-annotations/.chainsaw-test/pod-bad.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: v1
kind: Pod
metadata:
annotations:
fluxcd.io/cat: meow
name: badpod01
spec:
containers:
- name: pod01-01
image: busybox:1.35
---
apiVersion: v1
kind: Pod
metadata:
annotations:
foo: bar
fluxcd.io/foo: bar
name: badpod02
spec:
containers:
- name: pod02-01
image: busybox:1.35
---
apiVersion: v1
kind: Pod
metadata:
annotations:
fluxcd.io/bar: foo
foo: bar
name: badpod03
spec:
containers:
- name: pod-01
image: busybox:1.35
---
apiVersion: v1
kind: Pod
metadata:
annotations:
fluxcd.io/bar: foo
fluxcd.io/cow: moo
name: badpod04
spec:
containers:
- name: pod-01
image: busybox:1.35

45 changes: 45 additions & 0 deletions other-cel/allowed-annotations/.chainsaw-test/pod-good.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: v1
kind: Pod
metadata:
name: goodpod01
spec:
containers:
- name: pod01-01
image: busybox:1.35
---
apiVersion: v1
kind: Pod
metadata:
annotations:
foo: bar
fluxcd.io/cow: ox
fluxcd.io/dog: cat
name: goodpod02
spec:
containers:
- name: pod02-01
image: busybox:1.35
---
apiVersion: v1
kind: Pod
metadata:
annotations:
foo: bar
name: goodpod03
spec:
containers:
- name: pod-01
image: busybox:1.35
---
apiVersion: v1
kind: Pod
metadata:
annotations:
fluxcd.io/cow: moo
foo: bar
name: goodpod04
spec:
containers:
- name: pod-01
image: busybox:1.35

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: busybox
name: baddeployment01
spec:
replicas: 1
selector:
matchLabels:
app: busybox
strategy: {}
template:
metadata:
annotations:
foo: bar
fluxcd.io/foo: bar
labels:
app: busybox
spec:
containers:
- name: bb-01
image: busybox:1.35
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: busybox
name: baddeployment02
spec:
replicas: 1
selector:
matchLabels:
app: busybox
strategy: {}
template:
metadata:
annotations:
fluxcd.io/cat: meow
fluxcd.io/cow: moo
labels:
app: busybox
spec:
containers:
- name: bb-01
image: busybox:1.35
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: badcronjob01
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
metadata:
annotations:
foo: bar
fluxcd.io/foo: bar
spec:
containers:
- name: hello
image: busybox:1.35
imagePullPolicy: IfNotPresent
command:
- "sleep"
- "3600"
restartPolicy: OnFailure
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: badcronjob02
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
metadata:
annotations:
fluxcd.io/cat: meow
fluxcd.io/cow: moo
spec:
containers:
- name: hello
image: busybox:1.35
imagePullPolicy: IfNotPresent
command:
- "sleep"
- "3600"
restartPolicy: OnFailure

132 changes: 132 additions & 0 deletions other-cel/allowed-annotations/.chainsaw-test/podcontroller-good.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: busybox
name: gooddeployment01
spec:
replicas: 1
selector:
matchLabels:
app: busybox
strategy: {}
template:
metadata:
annotations:
foo: bar
labels:
app: busybox
spec:
containers:
- name: bb-01
image: busybox:1.35
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: busybox
name: gooddeployment02
spec:
replicas: 1
selector:
matchLabels:
app: busybox
strategy: {}
template:
metadata:
annotations:
fluxcd.io/cow: moo
fluxcd.io/dog: bark
labels:
app: busybox
spec:
containers:
- name: bb-01
image: busybox:1.35
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: busybox
name: gooddeployment03
spec:
replicas: 1
selector:
matchLabels:
app: busybox
strategy: {}
template:
metadata:
labels:
app: busybox
spec:
containers:
- name: bb-01
image: busybox:1.35
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: goodcronjob01
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
metadata:
annotations:
foo: bar
spec:
containers:
- name: hello
image: busybox:1.35
imagePullPolicy: IfNotPresent
command:
- "sleep"
- "3600"
restartPolicy: OnFailure
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: goodcronjob02
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
metadata:
annotations:
fluxcd.io/cow: moo
fluxcd.io/dog: bark
spec:
containers:
- name: hello
image: busybox:1.35
imagePullPolicy: IfNotPresent
command:
- "sleep"
- "3600"
restartPolicy: OnFailure
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: goodcronjob03
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox:1.35
imagePullPolicy: IfNotPresent
command:
- "sleep"
- "3600"
restartPolicy: OnFailure

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: allowed-annotations
status:
ready: true

Loading
Loading