Skip to content

Commit 2d408a3

Browse files
committed
fix: drop capability shoud be tested without case sensitivity
1 parent 59a0c82 commit 2d408a3

File tree

15 files changed

+420
-6
lines changed

15 files changed

+420
-6
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 1.1.2
2+
name: k8spspcapabilities
3+
displayName: Capabilities
4+
createdAt: "2025-07-25T08:00:24Z"
5+
description: Controls Linux capabilities on containers. Corresponds to the `allowedCapabilities` and `requiredDropCapabilities` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#capabilities
6+
digest: 4679f4bfad9c9b44a1eaf83b5b380e4e02c4c78689d12befc5432ec3139f1968
7+
license: Apache-2.0
8+
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/capabilities
9+
keywords:
10+
- gatekeeper
11+
- open-policy-agent
12+
- policies
13+
readme: |-
14+
# Capabilities
15+
Controls Linux capabilities on containers. Corresponds to the `allowedCapabilities` and `requiredDropCapabilities` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#capabilities
16+
install: |-
17+
### Usage
18+
```shell
19+
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/artifacthub/library/pod-security-policy/capabilities/1.1.2/template.yaml
20+
```
21+
provider:
22+
name: Gatekeeper Library
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
resources:
2+
- template.yaml
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: constraints.gatekeeper.sh/v1beta1
2+
kind: K8sPSPCapabilities
3+
metadata:
4+
name: capabilities-demo
5+
spec:
6+
match:
7+
kinds:
8+
- apiGroups: [""]
9+
kinds: ["Pod"]
10+
namespaces:
11+
- "default"
12+
parameters:
13+
allowedCapabilities: ["something"]
14+
requiredDropCapabilities: ["must_drop"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: opa-disallowed
5+
labels:
6+
owner: me.agilebank.demo
7+
spec:
8+
ephemeralContainers:
9+
- name: opa
10+
image: openpolicyagent/opa:0.9.2
11+
args:
12+
- "run"
13+
- "--server"
14+
- "--addr=localhost:8080"
15+
securityContext:
16+
capabilities:
17+
add: ["disallowedcapability"]
18+
resources:
19+
limits:
20+
cpu: "100m"
21+
memory: "30Mi"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: opa-allowed
5+
labels:
6+
owner: me.agilebank.demo
7+
spec:
8+
containers:
9+
- name: opa
10+
image: openpolicyagent/opa:0.9.2
11+
args:
12+
- "run"
13+
- "--server"
14+
- "--addr=localhost:8080"
15+
securityContext:
16+
capabilities:
17+
add: ["something"]
18+
drop: ["must_drop", "another_one"]
19+
resources:
20+
limits:
21+
cpu: "100m"
22+
memory: "30Mi"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: opa-disallowed
5+
labels:
6+
owner: me.agilebank.demo
7+
spec:
8+
containers:
9+
- name: opa
10+
image: openpolicyagent/opa:0.9.2
11+
args:
12+
- "run"
13+
- "--server"
14+
- "--addr=localhost:8080"
15+
securityContext:
16+
capabilities:
17+
add: ["disallowedcapability"]
18+
resources:
19+
limits:
20+
cpu: "100m"
21+
memory: "30Mi"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: opa-drop-all
5+
labels:
6+
owner: me.agilebank.demo
7+
spec:
8+
containers:
9+
- name: opa
10+
image: openpolicyagent/opa:0.9.2
11+
args:
12+
- "run"
13+
- "--server"
14+
- "--addr=localhost:8080"
15+
securityContext:
16+
capabilities:
17+
drop: ["ALL", "all"]
18+
resources:
19+
limits:
20+
cpu: "100m"
21+
memory: "30Mi"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
kind: AdmissionReview
2+
apiVersion: admission.k8s.io/v1beta1
3+
request:
4+
operation: "UPDATE"
5+
object:
6+
apiVersion: v1
7+
kind: Pod
8+
metadata:
9+
name: opa-disallowed
10+
labels:
11+
owner: me.agilebank.demo
12+
spec:
13+
containers:
14+
- name: opa
15+
image: openpolicyagent/opa:0.9.2
16+
args:
17+
- "run"
18+
- "--server"
19+
- "--addr=localhost:8080"
20+
securityContext:
21+
capabilities:
22+
add: ["disallowedcapability"]
23+
resources:
24+
limits:
25+
cpu: "100m"
26+
memory: "30Mi"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
kind: Suite
2+
apiVersion: test.gatekeeper.sh/v1alpha1
3+
metadata:
4+
name: capabilities
5+
tests:
6+
- name: capabilities
7+
template: template.yaml
8+
constraint: samples/capabilities-demo/constraint.yaml
9+
cases:
10+
- name: example-disallowed
11+
object: samples/capabilities-demo/example_disallowed.yaml
12+
assertions:
13+
- violations: yes
14+
- name: example-allowed
15+
object: samples/capabilities-demo/example_allowed.yaml
16+
assertions:
17+
- violations: no
18+
- name: disallowed-ephemeral
19+
object: samples/capabilities-demo/disallowed_ephemeral.yaml
20+
assertions:
21+
- violations: yes
22+
- name: update
23+
object: samples/capabilities-demo/update.yaml
24+
assertions:
25+
- violations: no

0 commit comments

Comments
 (0)