Skip to content

Commit 0f9ada1

Browse files
committed
feat: publish more modules
Signed-off-by: peefy <[email protected]>
1 parent cef3df4 commit 0f9ada1

File tree

15 files changed

+102
-2
lines changed

15 files changed

+102
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Introduction
2+
3+
`add-privileged-existing-namespaces` is a KCL mutation module.
4+
5+
## Resource
6+
7+
The Code source and document are [here](https://github.com/kcl-lang/modules/tree/main/add-privileged-existing-namespaces)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
name = "add-privileged-existing-namespaces"
3+
version = "0.1.0"
4+
description = "`add-privileged-existing-namespaces` is a KCL mutation module"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
params = option("params") or {}
2+
names: [str] = params.names or []
3+
items = [item | {
4+
if item.kind == "Namespace" and item.metadata.name != "kube-system":
5+
metadata.labels: {
6+
"pod-security.kubernetes.io/enforce": "privileged"
7+
}
8+
} for item in option("items") or []]

deny-privileged-profile/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Introduction
2+
3+
`deny-privileged-profile` is a KCL validation package
4+
5+
## Resource
6+
7+
The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/deny-privileged-profile)

deny-privileged-profile/kcl.mod

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
name = "deny-privileged-profile"
3+
version = "0.1.1"
4+
description = "`deny-privileged-profile` is a KCL validation package"

deny-privileged-profile/main.k

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# Define the validation function
3+
validate = lambda item {
4+
if item.kind == "Namespace":
5+
assert item.metadata?.labels?["pod-security.kubernetes.io/enforce"] != "privileged", "Only cluster-admins may create Namespaces that allow setting the privileged level."
6+
item
7+
}
8+
9+
# Validate All resource
10+
items = [validate(i) for i in option("items") or []]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Introduction
2+
3+
`psp-restrict-adding-capabilities` is a KCL PSP validation package.
4+
5+
## Resource
6+
7+
The Code source and document are [here](https://github.com/kcl-lang/modules/tree/main/psp-restrict-adding-capabilities)
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[package]
2+
name = "psp-restrict-adding-capabilities"
3+
version = "0.0.1"
4+
description = "`psp-restrict-adding-capabilities` is a kcl validation package"
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
·
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
schema Params:
2+
capabilities: [str] = ["NET_BIND_SERVICE", "CAP_CHOWN"]
3+
4+
params: Params = option("params") or Params {}
5+
6+
# Define the validation function
7+
validate = lambda item: {str:} {
8+
if item.kind == "Pod":
9+
containers = (item.spec.containers or []) + (item.spec.phemeralContainers or []) + (item.spec.initContainers or [])
10+
assert all c in containers {
11+
all c in c.securityContext.capabilities.add {
12+
c not in params.capabilities
13+
}
14+
}, "Any capabilities added other than ${params.capabilities} are disallowed."
15+
# Return the resource
16+
item
17+
}
18+
# Validate All resource
19+
items = [validate(i) for i in option("items") or []]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Introduction
2+
3+
`svc-require-encryption-aws-load-balancers` is a KCL validation package
4+
5+
## Resource
6+
7+
The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/svc-require-encryption-aws-load-balancers)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
name = "svc-require-encryption-aws-load-balancers"
3+
version = "0.1.1"
4+
description = "`svc-require-encryption-aws-load-balancers` is a KCL validation package"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Services of type LoadBalancer when deployed inside AWS have support for
2+
transport encryption if it is enabled via an annotation. This policy requires
3+
that Services of type LoadBalancer contain the annotation
4+
service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
5+
"""
6+
7+
# Define the validation function
8+
validate = lambda item {
9+
if item.kind == "Service":
10+
assert item.metadata?.annotation?["service.beta.kubernetes.io/aws-load-balancer-ssl-cert"] if item?.spec?.type == "LoadBalancer", "Service of type LoadBalancer must carry the annotation service.beta.kubernetes.io/aws-load-balancer-ssl-cert."
11+
item
12+
}
13+
14+
# Validate All resource
15+
items = [validate(i) for i in option("items")]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Introduction
22

3+
`svc-require-encryption-aws-loadbalancers` is a kcl validation package
4+
35
## Resource
46

5-
The Code source and documents are [here](https://github.com/kcl-lang/artifacthub/tree/main/svc-require-encryption-aws-loadbalancers)
7+
The Code source and documents are [here](https://github.com/kcl-lang/modules/tree/main/svc-require-encryption-aws-loadbalancers)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[package]
22
name = "svc-require-encryption-aws-loadbalancers"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "`svc-require-encryption-aws-loadbalancers` is a kcl validation package"

0 commit comments

Comments
 (0)