Datasets:
Add pinned source: gatekeeper-library (part 6)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/artifacthub-pkg.yml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/kustomization.yaml +2 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/constraint.yaml +15 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/disallowed_ephemeral.yaml +16 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/example_allowed.yaml +16 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/example_disallowed.yaml +16 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/update.yaml +21 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/suite.yaml +25 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/template.yaml +144 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/artifacthub-pkg.yml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/kustomization.yaml +2 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/constraint.yaml +15 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/disallowed_ephemeral.yaml +15 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/example_allowed.yaml +13 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/example_disallowed.yaml +15 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/update.yaml +20 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/suite.yaml +25 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/template.yaml +145 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/artifacthub-pkg.yml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/kustomization.yaml +2 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/constraint.yaml +30 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/example_allowed.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/suite.yaml +21 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/template.yaml +282 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/artifacthub-pkg.yml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/kustomization.yaml +2 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/constraint.yaml +30 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/example_allowed.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/update.yaml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/suite.yaml +25 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/template.yaml +292 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/artifacthub-pkg.yml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/kustomization.yaml +2 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/constraint.yaml +30 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/example_allowed.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml +17 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/update.yaml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/suite.yaml +25 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/template.yaml +289 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/artifacthub-pkg.yml +22 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/kustomization.yaml +2 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/constraint.yaml +18 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml +13 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/example_allowed.yaml +15 -0
- source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml +13 -0
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/artifacthub-pkg.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 1.0.3
|
| 2 |
+
name: k8spspselinuxv2
|
| 3 |
+
displayName: SELinux V2
|
| 4 |
+
createdAt: "2024-03-20T21:15:11Z"
|
| 5 |
+
description: Defines an allow-list of seLinuxOptions configurations for pod containers. Corresponds to a PodSecurityPolicy requiring SELinux configs. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 6 |
+
digest: f66b071de52853a43ef0bcfda6fd88db1ed6d24e0c9536dd92ee92df6921e9c7
|
| 7 |
+
license: Apache-2.0
|
| 8 |
+
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/selinux
|
| 9 |
+
keywords:
|
| 10 |
+
- gatekeeper
|
| 11 |
+
- open-policy-agent
|
| 12 |
+
- policies
|
| 13 |
+
readme: |-
|
| 14 |
+
# SELinux V2
|
| 15 |
+
Defines an allow-list of seLinuxOptions configurations for pod containers. Corresponds to a PodSecurityPolicy requiring SELinux configs. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 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/selinux/1.0.3/template.yaml
|
| 20 |
+
```
|
| 21 |
+
provider:
|
| 22 |
+
name: Gatekeeper Library
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/kustomization.yaml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
resources:
|
| 2 |
+
- template.yaml
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/constraint.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: constraints.gatekeeper.sh/v1beta1
|
| 2 |
+
kind: K8sPSPSELinuxV2
|
| 3 |
+
metadata:
|
| 4 |
+
name: psp-selinux-v2
|
| 5 |
+
spec:
|
| 6 |
+
match:
|
| 7 |
+
kinds:
|
| 8 |
+
- apiGroups: [""]
|
| 9 |
+
kinds: ["Pod"]
|
| 10 |
+
parameters:
|
| 11 |
+
allowedSELinuxOptions:
|
| 12 |
+
- level: s0:c123,c456
|
| 13 |
+
role: object_r
|
| 14 |
+
type: svirt_sandbox_file_t
|
| 15 |
+
user: system_u
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/disallowed_ephemeral.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-selinux-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-selinux
|
| 7 |
+
spec:
|
| 8 |
+
ephemeralContainers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
seLinuxOptions:
|
| 13 |
+
level: s1:c234,c567
|
| 14 |
+
user: sysadm_u
|
| 15 |
+
role: sysadm_r
|
| 16 |
+
type: svirt_lxc_net_t
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/example_allowed.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-selinux-allowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-selinux
|
| 7 |
+
spec:
|
| 8 |
+
containers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
seLinuxOptions:
|
| 13 |
+
level: s0:c123,c456
|
| 14 |
+
role: object_r
|
| 15 |
+
type: svirt_sandbox_file_t
|
| 16 |
+
user: system_u
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/example_disallowed.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-selinux-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-selinux
|
| 7 |
+
spec:
|
| 8 |
+
containers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
seLinuxOptions:
|
| 13 |
+
level: s1:c234,c567
|
| 14 |
+
user: sysadm_u
|
| 15 |
+
role: sysadm_r
|
| 16 |
+
type: svirt_lxc_net_t
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/samples/psp-selinux-v2/update.yaml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: nginx-selinux-disallowed
|
| 10 |
+
labels:
|
| 11 |
+
app: nginx-selinux
|
| 12 |
+
spec:
|
| 13 |
+
containers:
|
| 14 |
+
- name: nginx
|
| 15 |
+
image: nginx
|
| 16 |
+
securityContext:
|
| 17 |
+
seLinuxOptions:
|
| 18 |
+
level: s1:c234,c567
|
| 19 |
+
user: sysadm_u
|
| 20 |
+
role: sysadm_r
|
| 21 |
+
type: svirt_lxc_net_t
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/suite.yaml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kind: Suite
|
| 2 |
+
apiVersion: test.gatekeeper.sh/v1alpha1
|
| 3 |
+
metadata:
|
| 4 |
+
name: selinux
|
| 5 |
+
tests:
|
| 6 |
+
- name: require-matching-selinux-options
|
| 7 |
+
template: template.yaml
|
| 8 |
+
constraint: samples/psp-selinux-v2/constraint.yaml
|
| 9 |
+
cases:
|
| 10 |
+
- name: example-disallowed
|
| 11 |
+
object: samples/psp-selinux-v2/example_disallowed.yaml
|
| 12 |
+
assertions:
|
| 13 |
+
- violations: yes
|
| 14 |
+
- name: example-allowed
|
| 15 |
+
object: samples/psp-selinux-v2/example_allowed.yaml
|
| 16 |
+
assertions:
|
| 17 |
+
- violations: no
|
| 18 |
+
- name: disallowed-ephemeral
|
| 19 |
+
object: samples/psp-selinux-v2/disallowed_ephemeral.yaml
|
| 20 |
+
assertions:
|
| 21 |
+
- violations: yes
|
| 22 |
+
- name: update
|
| 23 |
+
object: samples/psp-selinux-v2/update.yaml
|
| 24 |
+
assertions:
|
| 25 |
+
- violations: no
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.3/template.yaml
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: templates.gatekeeper.sh/v1
|
| 2 |
+
kind: ConstraintTemplate
|
| 3 |
+
metadata:
|
| 4 |
+
name: k8spspselinuxv2
|
| 5 |
+
annotations:
|
| 6 |
+
metadata.gatekeeper.sh/title: "SELinux V2"
|
| 7 |
+
metadata.gatekeeper.sh/version: 1.0.3
|
| 8 |
+
description: >-
|
| 9 |
+
Defines an allow-list of seLinuxOptions configurations for pod
|
| 10 |
+
containers. Corresponds to a PodSecurityPolicy requiring SELinux configs.
|
| 11 |
+
For more information, see
|
| 12 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 13 |
+
spec:
|
| 14 |
+
crd:
|
| 15 |
+
spec:
|
| 16 |
+
names:
|
| 17 |
+
kind: K8sPSPSELinuxV2
|
| 18 |
+
validation:
|
| 19 |
+
# Schema for the `parameters` field
|
| 20 |
+
openAPIV3Schema:
|
| 21 |
+
type: object
|
| 22 |
+
description: >-
|
| 23 |
+
Defines an allow-list of seLinuxOptions configurations for pod
|
| 24 |
+
containers. Corresponds to a PodSecurityPolicy requiring SELinux configs.
|
| 25 |
+
For more information, see
|
| 26 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 27 |
+
properties:
|
| 28 |
+
exemptImages:
|
| 29 |
+
description: >-
|
| 30 |
+
Any container that uses an image that matches an entry in this list will be excluded
|
| 31 |
+
from enforcement. Prefix-matching can be signified with `*`. For example: `my-image-*`.
|
| 32 |
+
|
| 33 |
+
It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name)
|
| 34 |
+
in order to avoid unexpectedly exempting images from an untrusted repository.
|
| 35 |
+
type: array
|
| 36 |
+
items:
|
| 37 |
+
type: string
|
| 38 |
+
allowedSELinuxOptions:
|
| 39 |
+
type: array
|
| 40 |
+
description: "An allow-list of SELinux options configurations."
|
| 41 |
+
items:
|
| 42 |
+
type: object
|
| 43 |
+
description: "An allowed configuration of SELinux options for a pod container."
|
| 44 |
+
properties:
|
| 45 |
+
level:
|
| 46 |
+
type: string
|
| 47 |
+
description: "An SELinux level."
|
| 48 |
+
role:
|
| 49 |
+
type: string
|
| 50 |
+
description: "An SELinux role."
|
| 51 |
+
type:
|
| 52 |
+
type: string
|
| 53 |
+
description: "An SELinux type."
|
| 54 |
+
user:
|
| 55 |
+
type: string
|
| 56 |
+
description: "An SELinux user."
|
| 57 |
+
targets:
|
| 58 |
+
- target: admission.k8s.gatekeeper.sh
|
| 59 |
+
rego: |
|
| 60 |
+
package k8spspselinux
|
| 61 |
+
|
| 62 |
+
import data.lib.exclude_update.is_update
|
| 63 |
+
import data.lib.exempt_container.is_exempt
|
| 64 |
+
|
| 65 |
+
# Disallow top level custom SELinux options
|
| 66 |
+
violation[{"msg": msg, "details": {}}] {
|
| 67 |
+
# spec.securityContext.seLinuxOptions field is immutable.
|
| 68 |
+
not is_update(input.review)
|
| 69 |
+
|
| 70 |
+
has_field(input.review.object.spec.securityContext, "seLinuxOptions")
|
| 71 |
+
not input_seLinuxOptions_allowed(input.review.object.spec.securityContext.seLinuxOptions)
|
| 72 |
+
msg := sprintf("SELinux options is not allowed, pod: %v. Allowed options: %v", [input.review.object.metadata.name, input.parameters.allowedSELinuxOptions])
|
| 73 |
+
}
|
| 74 |
+
# Disallow container level custom SELinux options
|
| 75 |
+
violation[{"msg": msg, "details": {}}] {
|
| 76 |
+
# spec.containers.securityContext.seLinuxOptions field is immutable.
|
| 77 |
+
not is_update(input.review)
|
| 78 |
+
|
| 79 |
+
c := input_security_context[_]
|
| 80 |
+
not is_exempt(c)
|
| 81 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 82 |
+
not input_seLinuxOptions_allowed(c.securityContext.seLinuxOptions)
|
| 83 |
+
msg := sprintf("SELinux options is not allowed, pod: %v, container: %v. Allowed options: %v", [input.review.object.metadata.name, c.name, input.parameters.allowedSELinuxOptions])
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
input_seLinuxOptions_allowed(options) {
|
| 87 |
+
params := input.parameters.allowedSELinuxOptions[_]
|
| 88 |
+
field_allowed("level", options, params)
|
| 89 |
+
field_allowed("role", options, params)
|
| 90 |
+
field_allowed("type", options, params)
|
| 91 |
+
field_allowed("user", options, params)
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
field_allowed(field, options, params) {
|
| 95 |
+
params[field] == options[field]
|
| 96 |
+
}
|
| 97 |
+
field_allowed(field, options, _) {
|
| 98 |
+
not has_field(options, field)
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
input_security_context[c] {
|
| 102 |
+
c := input.review.object.spec.containers[_]
|
| 103 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 104 |
+
}
|
| 105 |
+
input_security_context[c] {
|
| 106 |
+
c := input.review.object.spec.initContainers[_]
|
| 107 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 108 |
+
}
|
| 109 |
+
input_security_context[c] {
|
| 110 |
+
c := input.review.object.spec.ephemeralContainers[_]
|
| 111 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
# has_field returns whether an object has a field
|
| 115 |
+
has_field(object, field) = true {
|
| 116 |
+
object[field]
|
| 117 |
+
}
|
| 118 |
+
libs:
|
| 119 |
+
- |
|
| 120 |
+
package lib.exclude_update
|
| 121 |
+
|
| 122 |
+
is_update(review) {
|
| 123 |
+
review.operation == "UPDATE"
|
| 124 |
+
}
|
| 125 |
+
- |
|
| 126 |
+
package lib.exempt_container
|
| 127 |
+
|
| 128 |
+
is_exempt(container) {
|
| 129 |
+
exempt_images := object.get(object.get(input, "parameters", {}), "exemptImages", [])
|
| 130 |
+
img := container.image
|
| 131 |
+
exemption := exempt_images[_]
|
| 132 |
+
_matches_exemption(img, exemption)
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
_matches_exemption(img, exemption) {
|
| 136 |
+
not endswith(exemption, "*")
|
| 137 |
+
exemption == img
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
_matches_exemption(img, exemption) {
|
| 141 |
+
endswith(exemption, "*")
|
| 142 |
+
prefix := trim_suffix(exemption, "*")
|
| 143 |
+
startswith(img, prefix)
|
| 144 |
+
}
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/artifacthub-pkg.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 1.0.4
|
| 2 |
+
name: k8spspselinuxv2
|
| 3 |
+
displayName: SELinux V2
|
| 4 |
+
createdAt: "2026-01-08T18:35:12Z"
|
| 5 |
+
description: Defines an allow-list of seLinuxOptions configurations for pod containers. Corresponds to a PodSecurityPolicy requiring SELinux configs. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 6 |
+
digest: 6a9b290911d14e6561ba9d0c49c976d0e6fc999231dab02fdeec93fb0780885c
|
| 7 |
+
license: Apache-2.0
|
| 8 |
+
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/selinux
|
| 9 |
+
keywords:
|
| 10 |
+
- gatekeeper
|
| 11 |
+
- open-policy-agent
|
| 12 |
+
- policies
|
| 13 |
+
readme: |-
|
| 14 |
+
# SELinux V2
|
| 15 |
+
Defines an allow-list of seLinuxOptions configurations for pod containers. Corresponds to a PodSecurityPolicy requiring SELinux configs. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 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/selinux/1.0.4/template.yaml
|
| 20 |
+
```
|
| 21 |
+
provider:
|
| 22 |
+
name: Gatekeeper Library
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/kustomization.yaml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
resources:
|
| 2 |
+
- template.yaml
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/constraint.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: constraints.gatekeeper.sh/v1beta1
|
| 2 |
+
kind: K8sPSPSELinuxV2
|
| 3 |
+
metadata:
|
| 4 |
+
name: psp-selinux-v2
|
| 5 |
+
spec:
|
| 6 |
+
match:
|
| 7 |
+
kinds:
|
| 8 |
+
- apiGroups: [""]
|
| 9 |
+
kinds: ["Pod"]
|
| 10 |
+
parameters:
|
| 11 |
+
allowedSELinuxOptions:
|
| 12 |
+
- type: container_t
|
| 13 |
+
- type: container_init_t
|
| 14 |
+
- type: container_kvm_t
|
| 15 |
+
- type: container_engine_t
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/disallowed_ephemeral.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-selinux-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-selinux
|
| 7 |
+
spec:
|
| 8 |
+
ephemeralContainers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
seLinuxOptions:
|
| 13 |
+
type: svirt_lxc_net_t
|
| 14 |
+
user: sysadm_u
|
| 15 |
+
role: sysadm_r
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/example_allowed.yaml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-selinux-allowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-selinux
|
| 7 |
+
spec:
|
| 8 |
+
containers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
seLinuxOptions:
|
| 13 |
+
type: container_t
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/example_disallowed.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-selinux-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-selinux
|
| 7 |
+
spec:
|
| 8 |
+
containers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
seLinuxOptions:
|
| 13 |
+
type: svirt_lxc_net_t
|
| 14 |
+
user: sysadm_u
|
| 15 |
+
role: sysadm_r
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/samples/psp-selinux-v2/update.yaml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: nginx-selinux-disallowed
|
| 10 |
+
labels:
|
| 11 |
+
app: nginx-selinux
|
| 12 |
+
spec:
|
| 13 |
+
containers:
|
| 14 |
+
- name: nginx
|
| 15 |
+
image: nginx
|
| 16 |
+
securityContext:
|
| 17 |
+
seLinuxOptions:
|
| 18 |
+
type: svirt_lxc_net_t
|
| 19 |
+
user: sysadm_u
|
| 20 |
+
role: sysadm_r
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/suite.yaml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kind: Suite
|
| 2 |
+
apiVersion: test.gatekeeper.sh/v1alpha1
|
| 3 |
+
metadata:
|
| 4 |
+
name: selinux
|
| 5 |
+
tests:
|
| 6 |
+
- name: require-matching-selinux-options
|
| 7 |
+
template: template.yaml
|
| 8 |
+
constraint: samples/psp-selinux-v2/constraint.yaml
|
| 9 |
+
cases:
|
| 10 |
+
- name: example-disallowed
|
| 11 |
+
object: samples/psp-selinux-v2/example_disallowed.yaml
|
| 12 |
+
assertions:
|
| 13 |
+
- violations: yes
|
| 14 |
+
- name: example-allowed
|
| 15 |
+
object: samples/psp-selinux-v2/example_allowed.yaml
|
| 16 |
+
assertions:
|
| 17 |
+
- violations: no
|
| 18 |
+
- name: disallowed-ephemeral
|
| 19 |
+
object: samples/psp-selinux-v2/disallowed_ephemeral.yaml
|
| 20 |
+
assertions:
|
| 21 |
+
- violations: yes
|
| 22 |
+
- name: update
|
| 23 |
+
object: samples/psp-selinux-v2/update.yaml
|
| 24 |
+
assertions:
|
| 25 |
+
- violations: no
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/selinux/1.0.4/template.yaml
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: templates.gatekeeper.sh/v1
|
| 2 |
+
kind: ConstraintTemplate
|
| 3 |
+
metadata:
|
| 4 |
+
name: k8spspselinuxv2
|
| 5 |
+
annotations:
|
| 6 |
+
metadata.gatekeeper.sh/title: "SELinux V2"
|
| 7 |
+
metadata.gatekeeper.sh/version: 1.0.4
|
| 8 |
+
metadata.gatekeeper.sh/bundle: "pod-security-baseline, pod-security-restricted"
|
| 9 |
+
description: >-
|
| 10 |
+
Defines an allow-list of seLinuxOptions configurations for pod
|
| 11 |
+
containers. Corresponds to a PodSecurityPolicy requiring SELinux configs.
|
| 12 |
+
For more information, see
|
| 13 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 14 |
+
spec:
|
| 15 |
+
crd:
|
| 16 |
+
spec:
|
| 17 |
+
names:
|
| 18 |
+
kind: K8sPSPSELinuxV2
|
| 19 |
+
validation:
|
| 20 |
+
# Schema for the `parameters` field
|
| 21 |
+
openAPIV3Schema:
|
| 22 |
+
type: object
|
| 23 |
+
description: >-
|
| 24 |
+
Defines an allow-list of seLinuxOptions configurations for pod
|
| 25 |
+
containers. Corresponds to a PodSecurityPolicy requiring SELinux configs.
|
| 26 |
+
For more information, see
|
| 27 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#selinux
|
| 28 |
+
properties:
|
| 29 |
+
exemptImages:
|
| 30 |
+
description: >-
|
| 31 |
+
Any container that uses an image that matches an entry in this list will be excluded
|
| 32 |
+
from enforcement. Prefix-matching can be signified with `*`. For example: `my-image-*`.
|
| 33 |
+
|
| 34 |
+
It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name)
|
| 35 |
+
in order to avoid unexpectedly exempting images from an untrusted repository.
|
| 36 |
+
type: array
|
| 37 |
+
items:
|
| 38 |
+
type: string
|
| 39 |
+
allowedSELinuxOptions:
|
| 40 |
+
type: array
|
| 41 |
+
description: "An allow-list of SELinux options configurations."
|
| 42 |
+
items:
|
| 43 |
+
type: object
|
| 44 |
+
description: "An allowed configuration of SELinux options for a pod container."
|
| 45 |
+
properties:
|
| 46 |
+
level:
|
| 47 |
+
type: string
|
| 48 |
+
description: "An SELinux level."
|
| 49 |
+
role:
|
| 50 |
+
type: string
|
| 51 |
+
description: "An SELinux role."
|
| 52 |
+
type:
|
| 53 |
+
type: string
|
| 54 |
+
description: "An SELinux type."
|
| 55 |
+
user:
|
| 56 |
+
type: string
|
| 57 |
+
description: "An SELinux user."
|
| 58 |
+
targets:
|
| 59 |
+
- target: admission.k8s.gatekeeper.sh
|
| 60 |
+
rego: |
|
| 61 |
+
package k8spspselinux
|
| 62 |
+
|
| 63 |
+
import data.lib.exclude_update.is_update
|
| 64 |
+
import data.lib.exempt_container.is_exempt
|
| 65 |
+
|
| 66 |
+
# Disallow top level custom SELinux options
|
| 67 |
+
violation[{"msg": msg, "details": {}}] {
|
| 68 |
+
# spec.securityContext.seLinuxOptions field is immutable.
|
| 69 |
+
not is_update(input.review)
|
| 70 |
+
|
| 71 |
+
has_field(input.review.object.spec.securityContext, "seLinuxOptions")
|
| 72 |
+
not input_seLinuxOptions_allowed(input.review.object.spec.securityContext.seLinuxOptions)
|
| 73 |
+
msg := sprintf("SELinux options is not allowed, pod: %v. Allowed options: %v", [input.review.object.metadata.name, input.parameters.allowedSELinuxOptions])
|
| 74 |
+
}
|
| 75 |
+
# Disallow container level custom SELinux options
|
| 76 |
+
violation[{"msg": msg, "details": {}}] {
|
| 77 |
+
# spec.containers.securityContext.seLinuxOptions field is immutable.
|
| 78 |
+
not is_update(input.review)
|
| 79 |
+
|
| 80 |
+
c := input_security_context[_]
|
| 81 |
+
not is_exempt(c)
|
| 82 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 83 |
+
not input_seLinuxOptions_allowed(c.securityContext.seLinuxOptions)
|
| 84 |
+
msg := sprintf("SELinux options is not allowed, pod: %v, container: %v. Allowed options: %v", [input.review.object.metadata.name, c.name, input.parameters.allowedSELinuxOptions])
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
input_seLinuxOptions_allowed(options) {
|
| 88 |
+
params := input.parameters.allowedSELinuxOptions[_]
|
| 89 |
+
field_allowed("level", options, params)
|
| 90 |
+
field_allowed("role", options, params)
|
| 91 |
+
field_allowed("type", options, params)
|
| 92 |
+
field_allowed("user", options, params)
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
field_allowed(field, options, params) {
|
| 96 |
+
params[field] == options[field]
|
| 97 |
+
}
|
| 98 |
+
field_allowed(field, options, _) {
|
| 99 |
+
not has_field(options, field)
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
input_security_context[c] {
|
| 103 |
+
c := input.review.object.spec.containers[_]
|
| 104 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 105 |
+
}
|
| 106 |
+
input_security_context[c] {
|
| 107 |
+
c := input.review.object.spec.initContainers[_]
|
| 108 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 109 |
+
}
|
| 110 |
+
input_security_context[c] {
|
| 111 |
+
c := input.review.object.spec.ephemeralContainers[_]
|
| 112 |
+
has_field(c.securityContext, "seLinuxOptions")
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
# has_field returns whether an object has a field
|
| 116 |
+
has_field(object, field) = true {
|
| 117 |
+
object[field]
|
| 118 |
+
}
|
| 119 |
+
libs:
|
| 120 |
+
- |
|
| 121 |
+
package lib.exclude_update
|
| 122 |
+
|
| 123 |
+
is_update(review) {
|
| 124 |
+
review.operation == "UPDATE"
|
| 125 |
+
}
|
| 126 |
+
- |
|
| 127 |
+
package lib.exempt_container
|
| 128 |
+
|
| 129 |
+
is_exempt(container) {
|
| 130 |
+
exempt_images := object.get(object.get(input, "parameters", {}), "exemptImages", [])
|
| 131 |
+
img := container.image
|
| 132 |
+
exemption := exempt_images[_]
|
| 133 |
+
_matches_exemption(img, exemption)
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
_matches_exemption(img, exemption) {
|
| 137 |
+
not endswith(exemption, "*")
|
| 138 |
+
exemption == img
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
_matches_exemption(img, exemption) {
|
| 142 |
+
endswith(exemption, "*")
|
| 143 |
+
prefix := trim_suffix(exemption, "*")
|
| 144 |
+
startswith(img, prefix)
|
| 145 |
+
}
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/artifacthub-pkg.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 1.0.0
|
| 2 |
+
name: k8spspallowedusers
|
| 3 |
+
displayName: Allowed Users
|
| 4 |
+
createdAt: "2022-09-26T17:28:27Z"
|
| 5 |
+
description: Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 6 |
+
digest: 20622440dce047425e4e26b7442de4928d7b6f83f5f32d502259232940669b12
|
| 7 |
+
license: Apache-2.0
|
| 8 |
+
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/users
|
| 9 |
+
keywords:
|
| 10 |
+
- gatekeeper
|
| 11 |
+
- open-policy-agent
|
| 12 |
+
- policies
|
| 13 |
+
readme: |-
|
| 14 |
+
# Allowed Users
|
| 15 |
+
Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 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/users/1.0.0/template.yaml
|
| 20 |
+
```
|
| 21 |
+
provider:
|
| 22 |
+
name: Gatekeeper Library
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/kustomization.yaml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
resources:
|
| 2 |
+
- template.yaml
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/constraint.yaml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: constraints.gatekeeper.sh/v1beta1
|
| 2 |
+
kind: K8sPSPAllowedUsers
|
| 3 |
+
metadata:
|
| 4 |
+
name: psp-pods-allowed-user-ranges
|
| 5 |
+
spec:
|
| 6 |
+
match:
|
| 7 |
+
kinds:
|
| 8 |
+
- apiGroups: [""]
|
| 9 |
+
kinds: ["Pod"]
|
| 10 |
+
parameters:
|
| 11 |
+
runAsUser:
|
| 12 |
+
rule: MustRunAs # MustRunAsNonRoot # RunAsAny
|
| 13 |
+
ranges:
|
| 14 |
+
- min: 100
|
| 15 |
+
max: 200
|
| 16 |
+
runAsGroup:
|
| 17 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 18 |
+
ranges:
|
| 19 |
+
- min: 100
|
| 20 |
+
max: 200
|
| 21 |
+
supplementalGroups:
|
| 22 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 23 |
+
ranges:
|
| 24 |
+
- min: 100
|
| 25 |
+
max: 200
|
| 26 |
+
fsGroup:
|
| 27 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 28 |
+
ranges:
|
| 29 |
+
- min: 100
|
| 30 |
+
max: 200
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 250
|
| 11 |
+
fsGroup: 250
|
| 12 |
+
ephemeralContainers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 250
|
| 17 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/example_allowed.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-allowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 199
|
| 11 |
+
fsGroup: 199
|
| 12 |
+
containers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 199
|
| 17 |
+
runAsGroup: 199
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 250
|
| 11 |
+
fsGroup: 250
|
| 12 |
+
containers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 250
|
| 17 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/suite.yaml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kind: Suite
|
| 2 |
+
apiVersion: test.gatekeeper.sh/v1alpha1
|
| 3 |
+
metadata:
|
| 4 |
+
name: users
|
| 5 |
+
tests:
|
| 6 |
+
- name: users-and-groups-together
|
| 7 |
+
template: template.yaml
|
| 8 |
+
constraint: samples/psp-pods-allowed-user-ranges/constraint.yaml
|
| 9 |
+
cases:
|
| 10 |
+
- name: example-disallowed
|
| 11 |
+
object: samples/psp-pods-allowed-user-ranges/example_disallowed.yaml
|
| 12 |
+
assertions:
|
| 13 |
+
- violations: yes
|
| 14 |
+
- name: example-allowed
|
| 15 |
+
object: samples/psp-pods-allowed-user-ranges/example_allowed.yaml
|
| 16 |
+
assertions:
|
| 17 |
+
- violations: no
|
| 18 |
+
- name: disallowed-ephemeral
|
| 19 |
+
object: samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml
|
| 20 |
+
assertions:
|
| 21 |
+
- violations: yes
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.0/template.yaml
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: templates.gatekeeper.sh/v1
|
| 2 |
+
kind: ConstraintTemplate
|
| 3 |
+
metadata:
|
| 4 |
+
name: k8spspallowedusers
|
| 5 |
+
annotations:
|
| 6 |
+
metadata.gatekeeper.sh/title: "Allowed Users"
|
| 7 |
+
metadata.gatekeeper.sh/version: 1.0.0
|
| 8 |
+
description: >-
|
| 9 |
+
Controls the user and group IDs of the container and some volumes.
|
| 10 |
+
Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and
|
| 11 |
+
`fsGroup` fields in a PodSecurityPolicy. For more information, see
|
| 12 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 13 |
+
spec:
|
| 14 |
+
crd:
|
| 15 |
+
spec:
|
| 16 |
+
names:
|
| 17 |
+
kind: K8sPSPAllowedUsers
|
| 18 |
+
validation:
|
| 19 |
+
openAPIV3Schema:
|
| 20 |
+
type: object
|
| 21 |
+
description: >-
|
| 22 |
+
Controls the user and group IDs of the container and some volumes.
|
| 23 |
+
Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and
|
| 24 |
+
`fsGroup` fields in a PodSecurityPolicy. For more information, see
|
| 25 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 26 |
+
properties:
|
| 27 |
+
exemptImages:
|
| 28 |
+
description: >-
|
| 29 |
+
Any container that uses an image that matches an entry in this list will be excluded
|
| 30 |
+
from enforcement. Prefix-matching can be signified with `*`. For example: `my-image-*`.
|
| 31 |
+
|
| 32 |
+
It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name)
|
| 33 |
+
in order to avoid unexpectedly exempting images from an untrusted repository.
|
| 34 |
+
type: array
|
| 35 |
+
items:
|
| 36 |
+
type: string
|
| 37 |
+
runAsUser:
|
| 38 |
+
type: object
|
| 39 |
+
description: "Controls which user ID values are allowed in a Pod or container-level SecurityContext."
|
| 40 |
+
properties:
|
| 41 |
+
rule:
|
| 42 |
+
type: string
|
| 43 |
+
description: "A strategy for applying the runAsUser restriction."
|
| 44 |
+
enum:
|
| 45 |
+
- MustRunAs
|
| 46 |
+
- MustRunAsNonRoot
|
| 47 |
+
- RunAsAny
|
| 48 |
+
ranges:
|
| 49 |
+
type: array
|
| 50 |
+
description: "A list of user ID ranges affected by the rule."
|
| 51 |
+
items:
|
| 52 |
+
type: object
|
| 53 |
+
description: "The range of user IDs affected by the rule."
|
| 54 |
+
properties:
|
| 55 |
+
min:
|
| 56 |
+
type: integer
|
| 57 |
+
description: "The minimum user ID in the range, inclusive."
|
| 58 |
+
max:
|
| 59 |
+
type: integer
|
| 60 |
+
description: "The maximum user ID in the range, inclusive."
|
| 61 |
+
runAsGroup:
|
| 62 |
+
type: object
|
| 63 |
+
description: "Controls which group ID values are allowed in a Pod or container-level SecurityContext."
|
| 64 |
+
properties:
|
| 65 |
+
rule:
|
| 66 |
+
type: string
|
| 67 |
+
description: "A strategy for applying the runAsGroup restriction."
|
| 68 |
+
enum:
|
| 69 |
+
- MustRunAs
|
| 70 |
+
- MayRunAs
|
| 71 |
+
- RunAsAny
|
| 72 |
+
ranges:
|
| 73 |
+
type: array
|
| 74 |
+
description: "A list of group ID ranges affected by the rule."
|
| 75 |
+
items:
|
| 76 |
+
type: object
|
| 77 |
+
description: "The range of group IDs affected by the rule."
|
| 78 |
+
properties:
|
| 79 |
+
min:
|
| 80 |
+
type: integer
|
| 81 |
+
description: "The minimum group ID in the range, inclusive."
|
| 82 |
+
max:
|
| 83 |
+
type: integer
|
| 84 |
+
description: "The maximum group ID in the range, inclusive."
|
| 85 |
+
supplementalGroups:
|
| 86 |
+
type: object
|
| 87 |
+
description: "Controls the supplementalGroups values that are allowed in a Pod or container-level SecurityContext."
|
| 88 |
+
properties:
|
| 89 |
+
rule:
|
| 90 |
+
type: string
|
| 91 |
+
description: "A strategy for applying the supplementalGroups restriction."
|
| 92 |
+
enum:
|
| 93 |
+
- MustRunAs
|
| 94 |
+
- MayRunAs
|
| 95 |
+
- RunAsAny
|
| 96 |
+
ranges:
|
| 97 |
+
type: array
|
| 98 |
+
description: "A list of group ID ranges affected by the rule."
|
| 99 |
+
items:
|
| 100 |
+
type: object
|
| 101 |
+
description: "The range of group IDs affected by the rule."
|
| 102 |
+
properties:
|
| 103 |
+
min:
|
| 104 |
+
type: integer
|
| 105 |
+
description: "The minimum group ID in the range, inclusive."
|
| 106 |
+
max:
|
| 107 |
+
type: integer
|
| 108 |
+
description: "The maximum group ID in the range, inclusive."
|
| 109 |
+
fsGroup:
|
| 110 |
+
type: object
|
| 111 |
+
description: "Controls the fsGroup values that are allowed in a Pod or container-level SecurityContext."
|
| 112 |
+
properties:
|
| 113 |
+
rule:
|
| 114 |
+
type: string
|
| 115 |
+
description: "A strategy for applying the fsGroup restriction."
|
| 116 |
+
enum:
|
| 117 |
+
- MustRunAs
|
| 118 |
+
- MayRunAs
|
| 119 |
+
- RunAsAny
|
| 120 |
+
ranges:
|
| 121 |
+
type: array
|
| 122 |
+
description: "A list of group ID ranges affected by the rule."
|
| 123 |
+
items:
|
| 124 |
+
type: object
|
| 125 |
+
description: "The range of group IDs affected by the rule."
|
| 126 |
+
properties:
|
| 127 |
+
min:
|
| 128 |
+
type: integer
|
| 129 |
+
description: "The minimum group ID in the range, inclusive."
|
| 130 |
+
max:
|
| 131 |
+
type: integer
|
| 132 |
+
description: "The maximum group ID in the range, inclusive."
|
| 133 |
+
targets:
|
| 134 |
+
- target: admission.k8s.gatekeeper.sh
|
| 135 |
+
rego: |
|
| 136 |
+
package k8spspallowedusers
|
| 137 |
+
|
| 138 |
+
import data.lib.exempt_container.is_exempt
|
| 139 |
+
|
| 140 |
+
violation[{"msg": msg}] {
|
| 141 |
+
fields := ["runAsUser", "runAsGroup", "supplementalGroups", "fsGroup"]
|
| 142 |
+
field := fields[_]
|
| 143 |
+
container := input_containers[_]
|
| 144 |
+
not is_exempt(container)
|
| 145 |
+
msg := get_type_violation(field, container)
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
get_type_violation(field, container) = msg {
|
| 149 |
+
field == "runAsUser"
|
| 150 |
+
params := input.parameters[field]
|
| 151 |
+
msg := get_user_violation(params, container)
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
get_type_violation(field, container) = msg {
|
| 155 |
+
field != "runAsUser"
|
| 156 |
+
params := input.parameters[field]
|
| 157 |
+
msg := get_violation(field, params, container)
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
# RunAsUser (separate due to "MustRunAsNonRoot")
|
| 161 |
+
get_user_violation(params, container) = msg {
|
| 162 |
+
rule := params.rule
|
| 163 |
+
provided_user := get_field_value("runAsUser", container, input.review)
|
| 164 |
+
not accept_users(rule, provided_user)
|
| 165 |
+
msg := sprintf("Container %v is attempting to run as disallowed user %v. Allowed runAsUser: %v", [container.name, provided_user, params])
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
get_user_violation(params, container) = msg {
|
| 169 |
+
not get_field_value("runAsUser", container, input.review)
|
| 170 |
+
params.rule = "MustRunAs"
|
| 171 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/runAsUser", [container.name])
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
get_user_violation(params, container) = msg {
|
| 175 |
+
params.rule = "MustRunAsNonRoot"
|
| 176 |
+
not get_field_value("runAsUser", container, input.review)
|
| 177 |
+
not get_field_value("runAsNonRoot", container, input.review)
|
| 178 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/runAsNonRoot or securityContext/runAsUser != 0", [container.name])
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
accept_users("RunAsAny", provided_user) {true}
|
| 182 |
+
|
| 183 |
+
accept_users("MustRunAsNonRoot", provided_user) = res {res := provided_user != 0}
|
| 184 |
+
|
| 185 |
+
accept_users("MustRunAs", provided_user) = res {
|
| 186 |
+
ranges := input.parameters.runAsUser.ranges
|
| 187 |
+
res := is_in_range(provided_user, ranges)
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
# Group Options
|
| 191 |
+
get_violation(field, params, container) = msg {
|
| 192 |
+
rule := params.rule
|
| 193 |
+
provided_value := get_field_value(field, container, input.review)
|
| 194 |
+
not is_array(provided_value)
|
| 195 |
+
not accept_value(rule, provided_value, params.ranges)
|
| 196 |
+
msg := sprintf("Container %v is attempting to run as disallowed group %v. Allowed %v: %v", [container.name, provided_value, field, params])
|
| 197 |
+
}
|
| 198 |
+
# SupplementalGroups is array value
|
| 199 |
+
get_violation(field, params, container) = msg {
|
| 200 |
+
rule := params.rule
|
| 201 |
+
array_value := get_field_value(field, container, input.review)
|
| 202 |
+
is_array(array_value)
|
| 203 |
+
provided_value := array_value[_]
|
| 204 |
+
not accept_value(rule, provided_value, params.ranges)
|
| 205 |
+
msg := sprintf("Container %v is attempting to run with disallowed supplementalGroups %v. Allowed %v: %v", [container.name, array_value, field, params])
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
get_violation(field, params, container) = msg {
|
| 209 |
+
not get_field_value(field, container, input.review)
|
| 210 |
+
params.rule == "MustRunAs"
|
| 211 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/%v. Allowed %v: %v", [container.name, field, field, params])
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
accept_value("RunAsAny", provided_value, ranges) {true}
|
| 215 |
+
|
| 216 |
+
accept_value("MayRunAs", provided_value, ranges) = res { res := is_in_range(provided_value, ranges)}
|
| 217 |
+
|
| 218 |
+
accept_value("MustRunAs", provided_value, ranges) = res { res := is_in_range(provided_value, ranges)}
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
# If container level is provided, that takes precedence
|
| 222 |
+
get_field_value(field, container, review) = out {
|
| 223 |
+
container_value := get_seccontext_field(field, container)
|
| 224 |
+
out := container_value
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
# If no container level exists, use pod level
|
| 228 |
+
get_field_value(field, container, review) = out {
|
| 229 |
+
not has_seccontext_field(field, container)
|
| 230 |
+
review.kind.kind == "Pod"
|
| 231 |
+
pod_value := get_seccontext_field(field, review.object.spec)
|
| 232 |
+
out := pod_value
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
# Helper Functions
|
| 236 |
+
is_in_range(val, ranges) = res {
|
| 237 |
+
matching := {1 | val >= ranges[j].min; val <= ranges[j].max}
|
| 238 |
+
res := count(matching) > 0
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
has_seccontext_field(field, obj) {
|
| 242 |
+
get_seccontext_field(field, obj)
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
has_seccontext_field(field, obj) {
|
| 246 |
+
get_seccontext_field(field, obj) == false
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
get_seccontext_field(field, obj) = out {
|
| 250 |
+
out = obj.securityContext[field]
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
input_containers[c] {
|
| 254 |
+
c := input.review.object.spec.containers[_]
|
| 255 |
+
}
|
| 256 |
+
input_containers[c] {
|
| 257 |
+
c := input.review.object.spec.initContainers[_]
|
| 258 |
+
}
|
| 259 |
+
input_containers[c] {
|
| 260 |
+
c := input.review.object.spec.ephemeralContainers[_]
|
| 261 |
+
}
|
| 262 |
+
libs:
|
| 263 |
+
- |
|
| 264 |
+
package lib.exempt_container
|
| 265 |
+
|
| 266 |
+
is_exempt(container) {
|
| 267 |
+
exempt_images := object.get(object.get(input, "parameters", {}), "exemptImages", [])
|
| 268 |
+
img := container.image
|
| 269 |
+
exemption := exempt_images[_]
|
| 270 |
+
_matches_exemption(img, exemption)
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
_matches_exemption(img, exemption) {
|
| 274 |
+
not endswith(exemption, "*")
|
| 275 |
+
exemption == img
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
_matches_exemption(img, exemption) {
|
| 279 |
+
endswith(exemption, "*")
|
| 280 |
+
prefix := trim_suffix(exemption, "*")
|
| 281 |
+
startswith(img, prefix)
|
| 282 |
+
}
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/artifacthub-pkg.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 1.0.1
|
| 2 |
+
name: k8spspallowedusers
|
| 3 |
+
displayName: Allowed Users
|
| 4 |
+
createdAt: "2023-05-23T09:47:32Z"
|
| 5 |
+
description: Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 6 |
+
digest: 4145c820284a655c6dfded52eb983df65e0eb5f76c4086e4edf03cbe6da2caf2
|
| 7 |
+
license: Apache-2.0
|
| 8 |
+
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/users
|
| 9 |
+
keywords:
|
| 10 |
+
- gatekeeper
|
| 11 |
+
- open-policy-agent
|
| 12 |
+
- policies
|
| 13 |
+
readme: |-
|
| 14 |
+
# Allowed Users
|
| 15 |
+
Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 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/users/1.0.1/template.yaml
|
| 20 |
+
```
|
| 21 |
+
provider:
|
| 22 |
+
name: Gatekeeper Library
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/kustomization.yaml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
resources:
|
| 2 |
+
- template.yaml
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/constraint.yaml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: constraints.gatekeeper.sh/v1beta1
|
| 2 |
+
kind: K8sPSPAllowedUsers
|
| 3 |
+
metadata:
|
| 4 |
+
name: psp-pods-allowed-user-ranges
|
| 5 |
+
spec:
|
| 6 |
+
match:
|
| 7 |
+
kinds:
|
| 8 |
+
- apiGroups: [""]
|
| 9 |
+
kinds: ["Pod"]
|
| 10 |
+
parameters:
|
| 11 |
+
runAsUser:
|
| 12 |
+
rule: MustRunAs # MustRunAsNonRoot # RunAsAny
|
| 13 |
+
ranges:
|
| 14 |
+
- min: 100
|
| 15 |
+
max: 200
|
| 16 |
+
runAsGroup:
|
| 17 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 18 |
+
ranges:
|
| 19 |
+
- min: 100
|
| 20 |
+
max: 200
|
| 21 |
+
supplementalGroups:
|
| 22 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 23 |
+
ranges:
|
| 24 |
+
- min: 100
|
| 25 |
+
max: 200
|
| 26 |
+
fsGroup:
|
| 27 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 28 |
+
ranges:
|
| 29 |
+
- min: 100
|
| 30 |
+
max: 200
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 250
|
| 11 |
+
fsGroup: 250
|
| 12 |
+
ephemeralContainers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 250
|
| 17 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/example_allowed.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-allowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 199
|
| 11 |
+
fsGroup: 199
|
| 12 |
+
containers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 199
|
| 17 |
+
runAsGroup: 199
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 250
|
| 11 |
+
fsGroup: 250
|
| 12 |
+
containers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 250
|
| 17 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/samples/psp-pods-allowed-user-ranges/update.yaml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: nginx-users-disallowed
|
| 10 |
+
labels:
|
| 11 |
+
app: nginx-users
|
| 12 |
+
spec:
|
| 13 |
+
securityContext:
|
| 14 |
+
supplementalGroups:
|
| 15 |
+
- 250
|
| 16 |
+
fsGroup: 250
|
| 17 |
+
containers:
|
| 18 |
+
- name: nginx
|
| 19 |
+
image: nginx
|
| 20 |
+
securityContext:
|
| 21 |
+
runAsUser: 250
|
| 22 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/suite.yaml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kind: Suite
|
| 2 |
+
apiVersion: test.gatekeeper.sh/v1alpha1
|
| 3 |
+
metadata:
|
| 4 |
+
name: users
|
| 5 |
+
tests:
|
| 6 |
+
- name: users-and-groups-together
|
| 7 |
+
template: template.yaml
|
| 8 |
+
constraint: samples/psp-pods-allowed-user-ranges/constraint.yaml
|
| 9 |
+
cases:
|
| 10 |
+
- name: example-disallowed
|
| 11 |
+
object: samples/psp-pods-allowed-user-ranges/example_disallowed.yaml
|
| 12 |
+
assertions:
|
| 13 |
+
- violations: yes
|
| 14 |
+
- name: example-allowed
|
| 15 |
+
object: samples/psp-pods-allowed-user-ranges/example_allowed.yaml
|
| 16 |
+
assertions:
|
| 17 |
+
- violations: no
|
| 18 |
+
- name: disallowed-ephemeral
|
| 19 |
+
object: samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml
|
| 20 |
+
assertions:
|
| 21 |
+
- violations: yes
|
| 22 |
+
- name: update
|
| 23 |
+
object: samples/psp-pods-allowed-user-ranges/update.yaml
|
| 24 |
+
assertions:
|
| 25 |
+
- violations: no
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.1/template.yaml
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: templates.gatekeeper.sh/v1
|
| 2 |
+
kind: ConstraintTemplate
|
| 3 |
+
metadata:
|
| 4 |
+
name: k8spspallowedusers
|
| 5 |
+
annotations:
|
| 6 |
+
metadata.gatekeeper.sh/title: "Allowed Users"
|
| 7 |
+
metadata.gatekeeper.sh/version: 1.0.1
|
| 8 |
+
description: >-
|
| 9 |
+
Controls the user and group IDs of the container and some volumes.
|
| 10 |
+
Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and
|
| 11 |
+
`fsGroup` fields in a PodSecurityPolicy. For more information, see
|
| 12 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 13 |
+
spec:
|
| 14 |
+
crd:
|
| 15 |
+
spec:
|
| 16 |
+
names:
|
| 17 |
+
kind: K8sPSPAllowedUsers
|
| 18 |
+
validation:
|
| 19 |
+
openAPIV3Schema:
|
| 20 |
+
type: object
|
| 21 |
+
description: >-
|
| 22 |
+
Controls the user and group IDs of the container and some volumes.
|
| 23 |
+
Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and
|
| 24 |
+
`fsGroup` fields in a PodSecurityPolicy. For more information, see
|
| 25 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 26 |
+
properties:
|
| 27 |
+
exemptImages:
|
| 28 |
+
description: >-
|
| 29 |
+
Any container that uses an image that matches an entry in this list will be excluded
|
| 30 |
+
from enforcement. Prefix-matching can be signified with `*`. For example: `my-image-*`.
|
| 31 |
+
|
| 32 |
+
It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name)
|
| 33 |
+
in order to avoid unexpectedly exempting images from an untrusted repository.
|
| 34 |
+
type: array
|
| 35 |
+
items:
|
| 36 |
+
type: string
|
| 37 |
+
runAsUser:
|
| 38 |
+
type: object
|
| 39 |
+
description: "Controls which user ID values are allowed in a Pod or container-level SecurityContext."
|
| 40 |
+
properties:
|
| 41 |
+
rule:
|
| 42 |
+
type: string
|
| 43 |
+
description: "A strategy for applying the runAsUser restriction."
|
| 44 |
+
enum:
|
| 45 |
+
- MustRunAs
|
| 46 |
+
- MustRunAsNonRoot
|
| 47 |
+
- RunAsAny
|
| 48 |
+
ranges:
|
| 49 |
+
type: array
|
| 50 |
+
description: "A list of user ID ranges affected by the rule."
|
| 51 |
+
items:
|
| 52 |
+
type: object
|
| 53 |
+
description: "The range of user IDs affected by the rule."
|
| 54 |
+
properties:
|
| 55 |
+
min:
|
| 56 |
+
type: integer
|
| 57 |
+
description: "The minimum user ID in the range, inclusive."
|
| 58 |
+
max:
|
| 59 |
+
type: integer
|
| 60 |
+
description: "The maximum user ID in the range, inclusive."
|
| 61 |
+
runAsGroup:
|
| 62 |
+
type: object
|
| 63 |
+
description: "Controls which group ID values are allowed in a Pod or container-level SecurityContext."
|
| 64 |
+
properties:
|
| 65 |
+
rule:
|
| 66 |
+
type: string
|
| 67 |
+
description: "A strategy for applying the runAsGroup restriction."
|
| 68 |
+
enum:
|
| 69 |
+
- MustRunAs
|
| 70 |
+
- MayRunAs
|
| 71 |
+
- RunAsAny
|
| 72 |
+
ranges:
|
| 73 |
+
type: array
|
| 74 |
+
description: "A list of group ID ranges affected by the rule."
|
| 75 |
+
items:
|
| 76 |
+
type: object
|
| 77 |
+
description: "The range of group IDs affected by the rule."
|
| 78 |
+
properties:
|
| 79 |
+
min:
|
| 80 |
+
type: integer
|
| 81 |
+
description: "The minimum group ID in the range, inclusive."
|
| 82 |
+
max:
|
| 83 |
+
type: integer
|
| 84 |
+
description: "The maximum group ID in the range, inclusive."
|
| 85 |
+
supplementalGroups:
|
| 86 |
+
type: object
|
| 87 |
+
description: "Controls the supplementalGroups values that are allowed in a Pod or container-level SecurityContext."
|
| 88 |
+
properties:
|
| 89 |
+
rule:
|
| 90 |
+
type: string
|
| 91 |
+
description: "A strategy for applying the supplementalGroups restriction."
|
| 92 |
+
enum:
|
| 93 |
+
- MustRunAs
|
| 94 |
+
- MayRunAs
|
| 95 |
+
- RunAsAny
|
| 96 |
+
ranges:
|
| 97 |
+
type: array
|
| 98 |
+
description: "A list of group ID ranges affected by the rule."
|
| 99 |
+
items:
|
| 100 |
+
type: object
|
| 101 |
+
description: "The range of group IDs affected by the rule."
|
| 102 |
+
properties:
|
| 103 |
+
min:
|
| 104 |
+
type: integer
|
| 105 |
+
description: "The minimum group ID in the range, inclusive."
|
| 106 |
+
max:
|
| 107 |
+
type: integer
|
| 108 |
+
description: "The maximum group ID in the range, inclusive."
|
| 109 |
+
fsGroup:
|
| 110 |
+
type: object
|
| 111 |
+
description: "Controls the fsGroup values that are allowed in a Pod or container-level SecurityContext."
|
| 112 |
+
properties:
|
| 113 |
+
rule:
|
| 114 |
+
type: string
|
| 115 |
+
description: "A strategy for applying the fsGroup restriction."
|
| 116 |
+
enum:
|
| 117 |
+
- MustRunAs
|
| 118 |
+
- MayRunAs
|
| 119 |
+
- RunAsAny
|
| 120 |
+
ranges:
|
| 121 |
+
type: array
|
| 122 |
+
description: "A list of group ID ranges affected by the rule."
|
| 123 |
+
items:
|
| 124 |
+
type: object
|
| 125 |
+
description: "The range of group IDs affected by the rule."
|
| 126 |
+
properties:
|
| 127 |
+
min:
|
| 128 |
+
type: integer
|
| 129 |
+
description: "The minimum group ID in the range, inclusive."
|
| 130 |
+
max:
|
| 131 |
+
type: integer
|
| 132 |
+
description: "The maximum group ID in the range, inclusive."
|
| 133 |
+
targets:
|
| 134 |
+
- target: admission.k8s.gatekeeper.sh
|
| 135 |
+
rego: |
|
| 136 |
+
package k8spspallowedusers
|
| 137 |
+
|
| 138 |
+
import data.lib.exclude_update.is_update
|
| 139 |
+
import data.lib.exempt_container.is_exempt
|
| 140 |
+
|
| 141 |
+
violation[{"msg": msg}] {
|
| 142 |
+
# runAsUser, runAsGroup, supplementalGroups, fsGroup fields are immutable.
|
| 143 |
+
not is_update(input.review)
|
| 144 |
+
|
| 145 |
+
fields := ["runAsUser", "runAsGroup", "supplementalGroups", "fsGroup"]
|
| 146 |
+
field := fields[_]
|
| 147 |
+
container := input_containers[_]
|
| 148 |
+
not is_exempt(container)
|
| 149 |
+
msg := get_type_violation(field, container)
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
get_type_violation(field, container) = msg {
|
| 153 |
+
field == "runAsUser"
|
| 154 |
+
params := input.parameters[field]
|
| 155 |
+
msg := get_user_violation(params, container)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
get_type_violation(field, container) = msg {
|
| 159 |
+
field != "runAsUser"
|
| 160 |
+
params := input.parameters[field]
|
| 161 |
+
msg := get_violation(field, params, container)
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
# RunAsUser (separate due to "MustRunAsNonRoot")
|
| 165 |
+
get_user_violation(params, container) = msg {
|
| 166 |
+
rule := params.rule
|
| 167 |
+
provided_user := get_field_value("runAsUser", container, input.review)
|
| 168 |
+
not accept_users(rule, provided_user)
|
| 169 |
+
msg := sprintf("Container %v is attempting to run as disallowed user %v. Allowed runAsUser: %v", [container.name, provided_user, params])
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
get_user_violation(params, container) = msg {
|
| 173 |
+
not get_field_value("runAsUser", container, input.review)
|
| 174 |
+
params.rule = "MustRunAs"
|
| 175 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/runAsUser", [container.name])
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
get_user_violation(params, container) = msg {
|
| 179 |
+
params.rule = "MustRunAsNonRoot"
|
| 180 |
+
not get_field_value("runAsUser", container, input.review)
|
| 181 |
+
not get_field_value("runAsNonRoot", container, input.review)
|
| 182 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/runAsNonRoot or securityContext/runAsUser != 0", [container.name])
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
accept_users("RunAsAny", provided_user) {true}
|
| 186 |
+
|
| 187 |
+
accept_users("MustRunAsNonRoot", provided_user) = res {res := provided_user != 0}
|
| 188 |
+
|
| 189 |
+
accept_users("MustRunAs", provided_user) = res {
|
| 190 |
+
ranges := input.parameters.runAsUser.ranges
|
| 191 |
+
res := is_in_range(provided_user, ranges)
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
# Group Options
|
| 195 |
+
get_violation(field, params, container) = msg {
|
| 196 |
+
rule := params.rule
|
| 197 |
+
provided_value := get_field_value(field, container, input.review)
|
| 198 |
+
not is_array(provided_value)
|
| 199 |
+
not accept_value(rule, provided_value, params.ranges)
|
| 200 |
+
msg := sprintf("Container %v is attempting to run as disallowed group %v. Allowed %v: %v", [container.name, provided_value, field, params])
|
| 201 |
+
}
|
| 202 |
+
# SupplementalGroups is array value
|
| 203 |
+
get_violation(field, params, container) = msg {
|
| 204 |
+
rule := params.rule
|
| 205 |
+
array_value := get_field_value(field, container, input.review)
|
| 206 |
+
is_array(array_value)
|
| 207 |
+
provided_value := array_value[_]
|
| 208 |
+
not accept_value(rule, provided_value, params.ranges)
|
| 209 |
+
msg := sprintf("Container %v is attempting to run with disallowed supplementalGroups %v. Allowed %v: %v", [container.name, array_value, field, params])
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
get_violation(field, params, container) = msg {
|
| 213 |
+
not get_field_value(field, container, input.review)
|
| 214 |
+
params.rule == "MustRunAs"
|
| 215 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/%v. Allowed %v: %v", [container.name, field, field, params])
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
accept_value("RunAsAny", provided_value, ranges) {true}
|
| 219 |
+
|
| 220 |
+
accept_value("MayRunAs", provided_value, ranges) = res { res := is_in_range(provided_value, ranges)}
|
| 221 |
+
|
| 222 |
+
accept_value("MustRunAs", provided_value, ranges) = res { res := is_in_range(provided_value, ranges)}
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
# If container level is provided, that takes precedence
|
| 226 |
+
get_field_value(field, container, review) = out {
|
| 227 |
+
container_value := get_seccontext_field(field, container)
|
| 228 |
+
out := container_value
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
# If no container level exists, use pod level
|
| 232 |
+
get_field_value(field, container, review) = out {
|
| 233 |
+
not has_seccontext_field(field, container)
|
| 234 |
+
review.kind.kind == "Pod"
|
| 235 |
+
pod_value := get_seccontext_field(field, review.object.spec)
|
| 236 |
+
out := pod_value
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
# Helper Functions
|
| 240 |
+
is_in_range(val, ranges) = res {
|
| 241 |
+
matching := {1 | val >= ranges[j].min; val <= ranges[j].max}
|
| 242 |
+
res := count(matching) > 0
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
has_seccontext_field(field, obj) {
|
| 246 |
+
get_seccontext_field(field, obj)
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
has_seccontext_field(field, obj) {
|
| 250 |
+
get_seccontext_field(field, obj) == false
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
get_seccontext_field(field, obj) = out {
|
| 254 |
+
out = obj.securityContext[field]
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
input_containers[c] {
|
| 258 |
+
c := input.review.object.spec.containers[_]
|
| 259 |
+
}
|
| 260 |
+
input_containers[c] {
|
| 261 |
+
c := input.review.object.spec.initContainers[_]
|
| 262 |
+
}
|
| 263 |
+
input_containers[c] {
|
| 264 |
+
c := input.review.object.spec.ephemeralContainers[_]
|
| 265 |
+
}
|
| 266 |
+
libs:
|
| 267 |
+
- |
|
| 268 |
+
package lib.exclude_update
|
| 269 |
+
|
| 270 |
+
is_update(review) {
|
| 271 |
+
review.operation == "UPDATE"
|
| 272 |
+
}
|
| 273 |
+
- |
|
| 274 |
+
package lib.exempt_container
|
| 275 |
+
|
| 276 |
+
is_exempt(container) {
|
| 277 |
+
exempt_images := object.get(object.get(input, "parameters", {}), "exemptImages", [])
|
| 278 |
+
img := container.image
|
| 279 |
+
exemption := exempt_images[_]
|
| 280 |
+
_matches_exemption(img, exemption)
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
_matches_exemption(img, exemption) {
|
| 284 |
+
not endswith(exemption, "*")
|
| 285 |
+
exemption == img
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
_matches_exemption(img, exemption) {
|
| 289 |
+
endswith(exemption, "*")
|
| 290 |
+
prefix := trim_suffix(exemption, "*")
|
| 291 |
+
startswith(img, prefix)
|
| 292 |
+
}
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/artifacthub-pkg.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 1.0.2
|
| 2 |
+
name: k8spspallowedusers
|
| 3 |
+
displayName: Allowed Users
|
| 4 |
+
createdAt: "2023-10-30T21:00:02Z"
|
| 5 |
+
description: Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 6 |
+
digest: 485bfc85639175c748da7632863dd3c91ad7f4dbd2544d2579cb82732ee795ea
|
| 7 |
+
license: Apache-2.0
|
| 8 |
+
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/users
|
| 9 |
+
keywords:
|
| 10 |
+
- gatekeeper
|
| 11 |
+
- open-policy-agent
|
| 12 |
+
- policies
|
| 13 |
+
readme: |-
|
| 14 |
+
# Allowed Users
|
| 15 |
+
Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 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/users/1.0.2/template.yaml
|
| 20 |
+
```
|
| 21 |
+
provider:
|
| 22 |
+
name: Gatekeeper Library
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/kustomization.yaml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
resources:
|
| 2 |
+
- template.yaml
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/constraint.yaml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: constraints.gatekeeper.sh/v1beta1
|
| 2 |
+
kind: K8sPSPAllowedUsers
|
| 3 |
+
metadata:
|
| 4 |
+
name: psp-pods-allowed-user-ranges
|
| 5 |
+
spec:
|
| 6 |
+
match:
|
| 7 |
+
kinds:
|
| 8 |
+
- apiGroups: [""]
|
| 9 |
+
kinds: ["Pod"]
|
| 10 |
+
parameters:
|
| 11 |
+
runAsUser:
|
| 12 |
+
rule: MustRunAs # MustRunAsNonRoot # RunAsAny
|
| 13 |
+
ranges:
|
| 14 |
+
- min: 100
|
| 15 |
+
max: 200
|
| 16 |
+
runAsGroup:
|
| 17 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 18 |
+
ranges:
|
| 19 |
+
- min: 100
|
| 20 |
+
max: 200
|
| 21 |
+
supplementalGroups:
|
| 22 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 23 |
+
ranges:
|
| 24 |
+
- min: 100
|
| 25 |
+
max: 200
|
| 26 |
+
fsGroup:
|
| 27 |
+
rule: MustRunAs # MayRunAs # RunAsAny
|
| 28 |
+
ranges:
|
| 29 |
+
- min: 100
|
| 30 |
+
max: 200
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 250
|
| 11 |
+
fsGroup: 250
|
| 12 |
+
ephemeralContainers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 250
|
| 17 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/example_allowed.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-allowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 199
|
| 11 |
+
fsGroup: 199
|
| 12 |
+
containers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 199
|
| 17 |
+
runAsGroup: 199
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
supplementalGroups:
|
| 10 |
+
- 250
|
| 11 |
+
fsGroup: 250
|
| 12 |
+
containers:
|
| 13 |
+
- name: nginx
|
| 14 |
+
image: nginx
|
| 15 |
+
securityContext:
|
| 16 |
+
runAsUser: 250
|
| 17 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/samples/psp-pods-allowed-user-ranges/update.yaml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: nginx-users-disallowed
|
| 10 |
+
labels:
|
| 11 |
+
app: nginx-users
|
| 12 |
+
spec:
|
| 13 |
+
securityContext:
|
| 14 |
+
supplementalGroups:
|
| 15 |
+
- 250
|
| 16 |
+
fsGroup: 250
|
| 17 |
+
containers:
|
| 18 |
+
- name: nginx
|
| 19 |
+
image: nginx
|
| 20 |
+
securityContext:
|
| 21 |
+
runAsUser: 250
|
| 22 |
+
runAsGroup: 250
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/suite.yaml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
kind: Suite
|
| 2 |
+
apiVersion: test.gatekeeper.sh/v1alpha1
|
| 3 |
+
metadata:
|
| 4 |
+
name: users
|
| 5 |
+
tests:
|
| 6 |
+
- name: users-and-groups-together
|
| 7 |
+
template: template.yaml
|
| 8 |
+
constraint: samples/psp-pods-allowed-user-ranges/constraint.yaml
|
| 9 |
+
cases:
|
| 10 |
+
- name: example-disallowed
|
| 11 |
+
object: samples/psp-pods-allowed-user-ranges/example_disallowed.yaml
|
| 12 |
+
assertions:
|
| 13 |
+
- violations: yes
|
| 14 |
+
- name: example-allowed
|
| 15 |
+
object: samples/psp-pods-allowed-user-ranges/example_allowed.yaml
|
| 16 |
+
assertions:
|
| 17 |
+
- violations: no
|
| 18 |
+
- name: disallowed-ephemeral
|
| 19 |
+
object: samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml
|
| 20 |
+
assertions:
|
| 21 |
+
- violations: yes
|
| 22 |
+
- name: update
|
| 23 |
+
object: samples/psp-pods-allowed-user-ranges/update.yaml
|
| 24 |
+
assertions:
|
| 25 |
+
- violations: no
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.2/template.yaml
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: templates.gatekeeper.sh/v1
|
| 2 |
+
kind: ConstraintTemplate
|
| 3 |
+
metadata:
|
| 4 |
+
name: k8spspallowedusers
|
| 5 |
+
annotations:
|
| 6 |
+
metadata.gatekeeper.sh/title: "Allowed Users"
|
| 7 |
+
metadata.gatekeeper.sh/version: 1.0.2
|
| 8 |
+
description: >-
|
| 9 |
+
Controls the user and group IDs of the container and some volumes.
|
| 10 |
+
Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and
|
| 11 |
+
`fsGroup` fields in a PodSecurityPolicy. For more information, see
|
| 12 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 13 |
+
spec:
|
| 14 |
+
crd:
|
| 15 |
+
spec:
|
| 16 |
+
names:
|
| 17 |
+
kind: K8sPSPAllowedUsers
|
| 18 |
+
validation:
|
| 19 |
+
openAPIV3Schema:
|
| 20 |
+
type: object
|
| 21 |
+
description: >-
|
| 22 |
+
Controls the user and group IDs of the container and some volumes.
|
| 23 |
+
Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and
|
| 24 |
+
`fsGroup` fields in a PodSecurityPolicy. For more information, see
|
| 25 |
+
https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 26 |
+
properties:
|
| 27 |
+
exemptImages:
|
| 28 |
+
description: >-
|
| 29 |
+
Any container that uses an image that matches an entry in this list will be excluded
|
| 30 |
+
from enforcement. Prefix-matching can be signified with `*`. For example: `my-image-*`.
|
| 31 |
+
|
| 32 |
+
It is recommended that users use the fully-qualified Docker image name (e.g. start with a domain name)
|
| 33 |
+
in order to avoid unexpectedly exempting images from an untrusted repository.
|
| 34 |
+
type: array
|
| 35 |
+
items:
|
| 36 |
+
type: string
|
| 37 |
+
runAsUser:
|
| 38 |
+
type: object
|
| 39 |
+
description: "Controls which user ID values are allowed in a Pod or container-level SecurityContext."
|
| 40 |
+
properties:
|
| 41 |
+
rule:
|
| 42 |
+
type: string
|
| 43 |
+
description: "A strategy for applying the runAsUser restriction."
|
| 44 |
+
enum:
|
| 45 |
+
- MustRunAs
|
| 46 |
+
- MustRunAsNonRoot
|
| 47 |
+
- RunAsAny
|
| 48 |
+
ranges:
|
| 49 |
+
type: array
|
| 50 |
+
description: "A list of user ID ranges affected by the rule."
|
| 51 |
+
items:
|
| 52 |
+
type: object
|
| 53 |
+
description: "The range of user IDs affected by the rule."
|
| 54 |
+
properties:
|
| 55 |
+
min:
|
| 56 |
+
type: integer
|
| 57 |
+
description: "The minimum user ID in the range, inclusive."
|
| 58 |
+
max:
|
| 59 |
+
type: integer
|
| 60 |
+
description: "The maximum user ID in the range, inclusive."
|
| 61 |
+
runAsGroup:
|
| 62 |
+
type: object
|
| 63 |
+
description: "Controls which group ID values are allowed in a Pod or container-level SecurityContext."
|
| 64 |
+
properties:
|
| 65 |
+
rule:
|
| 66 |
+
type: string
|
| 67 |
+
description: "A strategy for applying the runAsGroup restriction."
|
| 68 |
+
enum:
|
| 69 |
+
- MustRunAs
|
| 70 |
+
- MayRunAs
|
| 71 |
+
- RunAsAny
|
| 72 |
+
ranges:
|
| 73 |
+
type: array
|
| 74 |
+
description: "A list of group ID ranges affected by the rule."
|
| 75 |
+
items:
|
| 76 |
+
type: object
|
| 77 |
+
description: "The range of group IDs affected by the rule."
|
| 78 |
+
properties:
|
| 79 |
+
min:
|
| 80 |
+
type: integer
|
| 81 |
+
description: "The minimum group ID in the range, inclusive."
|
| 82 |
+
max:
|
| 83 |
+
type: integer
|
| 84 |
+
description: "The maximum group ID in the range, inclusive."
|
| 85 |
+
supplementalGroups:
|
| 86 |
+
type: object
|
| 87 |
+
description: "Controls the supplementalGroups values that are allowed in a Pod or container-level SecurityContext."
|
| 88 |
+
properties:
|
| 89 |
+
rule:
|
| 90 |
+
type: string
|
| 91 |
+
description: "A strategy for applying the supplementalGroups restriction."
|
| 92 |
+
enum:
|
| 93 |
+
- MustRunAs
|
| 94 |
+
- MayRunAs
|
| 95 |
+
- RunAsAny
|
| 96 |
+
ranges:
|
| 97 |
+
type: array
|
| 98 |
+
description: "A list of group ID ranges affected by the rule."
|
| 99 |
+
items:
|
| 100 |
+
type: object
|
| 101 |
+
description: "The range of group IDs affected by the rule."
|
| 102 |
+
properties:
|
| 103 |
+
min:
|
| 104 |
+
type: integer
|
| 105 |
+
description: "The minimum group ID in the range, inclusive."
|
| 106 |
+
max:
|
| 107 |
+
type: integer
|
| 108 |
+
description: "The maximum group ID in the range, inclusive."
|
| 109 |
+
fsGroup:
|
| 110 |
+
type: object
|
| 111 |
+
description: "Controls the fsGroup values that are allowed in a Pod or container-level SecurityContext."
|
| 112 |
+
properties:
|
| 113 |
+
rule:
|
| 114 |
+
type: string
|
| 115 |
+
description: "A strategy for applying the fsGroup restriction."
|
| 116 |
+
enum:
|
| 117 |
+
- MustRunAs
|
| 118 |
+
- MayRunAs
|
| 119 |
+
- RunAsAny
|
| 120 |
+
ranges:
|
| 121 |
+
type: array
|
| 122 |
+
description: "A list of group ID ranges affected by the rule."
|
| 123 |
+
items:
|
| 124 |
+
type: object
|
| 125 |
+
description: "The range of group IDs affected by the rule."
|
| 126 |
+
properties:
|
| 127 |
+
min:
|
| 128 |
+
type: integer
|
| 129 |
+
description: "The minimum group ID in the range, inclusive."
|
| 130 |
+
max:
|
| 131 |
+
type: integer
|
| 132 |
+
description: "The maximum group ID in the range, inclusive."
|
| 133 |
+
targets:
|
| 134 |
+
- target: admission.k8s.gatekeeper.sh
|
| 135 |
+
rego: |
|
| 136 |
+
package k8spspallowedusers
|
| 137 |
+
|
| 138 |
+
import data.lib.exclude_update.is_update
|
| 139 |
+
import data.lib.exempt_container.is_exempt
|
| 140 |
+
|
| 141 |
+
violation[{"msg": msg}] {
|
| 142 |
+
# runAsUser, runAsGroup, supplementalGroups, fsGroup fields are immutable.
|
| 143 |
+
not is_update(input.review)
|
| 144 |
+
|
| 145 |
+
fields := ["runAsUser", "runAsGroup", "supplementalGroups", "fsGroup"]
|
| 146 |
+
field := fields[_]
|
| 147 |
+
container := input_containers[_]
|
| 148 |
+
not is_exempt(container)
|
| 149 |
+
msg := get_type_violation(field, container)
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
get_type_violation(field, container) = msg {
|
| 153 |
+
field == "runAsUser"
|
| 154 |
+
params := input.parameters[field]
|
| 155 |
+
msg := get_user_violation(params, container)
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
get_type_violation(field, container) = msg {
|
| 159 |
+
field != "runAsUser"
|
| 160 |
+
params := input.parameters[field]
|
| 161 |
+
msg := get_violation(field, params, container)
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
# RunAsUser (separate due to "MustRunAsNonRoot")
|
| 165 |
+
get_user_violation(params, container) = msg {
|
| 166 |
+
rule := params.rule
|
| 167 |
+
provided_user := get_field_value("runAsUser", container, input.review)
|
| 168 |
+
not accept_users(rule, provided_user)
|
| 169 |
+
msg := sprintf("Container %v is attempting to run as disallowed user %v. Allowed runAsUser: %v", [container.name, provided_user, params])
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
get_user_violation(params, container) = msg {
|
| 173 |
+
not get_field_value("runAsUser", container, input.review)
|
| 174 |
+
params.rule = "MustRunAs"
|
| 175 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/runAsUser", [container.name])
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
get_user_violation(params, container) = msg {
|
| 179 |
+
params.rule = "MustRunAsNonRoot"
|
| 180 |
+
not get_field_value("runAsUser", container, input.review)
|
| 181 |
+
not get_field_value("runAsNonRoot", container, input.review)
|
| 182 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/runAsNonRoot or securityContext/runAsUser != 0", [container.name])
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
accept_users("RunAsAny", _)
|
| 186 |
+
|
| 187 |
+
accept_users("MustRunAsNonRoot", provided_user) := provided_user != 0
|
| 188 |
+
|
| 189 |
+
accept_users("MustRunAs", provided_user) := res {
|
| 190 |
+
ranges := input.parameters.runAsUser.ranges
|
| 191 |
+
res := is_in_range(provided_user, ranges)
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
# Group Options
|
| 195 |
+
get_violation(field, params, container) = msg {
|
| 196 |
+
rule := params.rule
|
| 197 |
+
provided_value := get_field_value(field, container, input.review)
|
| 198 |
+
not is_array(provided_value)
|
| 199 |
+
not accept_value(rule, provided_value, params.ranges)
|
| 200 |
+
msg := sprintf("Container %v is attempting to run as disallowed group %v. Allowed %v: %v", [container.name, provided_value, field, params])
|
| 201 |
+
}
|
| 202 |
+
# SupplementalGroups is array value
|
| 203 |
+
get_violation(field, params, container) = msg {
|
| 204 |
+
rule := params.rule
|
| 205 |
+
array_value := get_field_value(field, container, input.review)
|
| 206 |
+
is_array(array_value)
|
| 207 |
+
provided_value := array_value[_]
|
| 208 |
+
not accept_value(rule, provided_value, params.ranges)
|
| 209 |
+
msg := sprintf("Container %v is attempting to run with disallowed supplementalGroups %v. Allowed %v: %v", [container.name, array_value, field, params])
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
get_violation(field, params, container) = msg {
|
| 213 |
+
not get_field_value(field, container, input.review)
|
| 214 |
+
params.rule == "MustRunAs"
|
| 215 |
+
msg := sprintf("Container %v is attempting to run without a required securityContext/%v. Allowed %v: %v", [container.name, field, field, params])
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
accept_value("RunAsAny", _, _)
|
| 219 |
+
|
| 220 |
+
accept_value("MayRunAs", provided_value, ranges) := is_in_range(provided_value, ranges)
|
| 221 |
+
|
| 222 |
+
accept_value("MustRunAs", provided_value, ranges) := is_in_range(provided_value, ranges)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
# If container level is provided, that takes precedence
|
| 226 |
+
get_field_value(field, container, _) := get_seccontext_field(field, container)
|
| 227 |
+
|
| 228 |
+
# If no container level exists, use pod level
|
| 229 |
+
get_field_value(field, container, review) = out {
|
| 230 |
+
not has_seccontext_field(field, container)
|
| 231 |
+
review.kind.kind == "Pod"
|
| 232 |
+
pod_value := get_seccontext_field(field, review.object.spec)
|
| 233 |
+
out := pod_value
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
# Helper Functions
|
| 237 |
+
is_in_range(val, ranges) = res {
|
| 238 |
+
matching := {1 | val >= ranges[j].min; val <= ranges[j].max}
|
| 239 |
+
res := count(matching) > 0
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
has_seccontext_field(field, obj) {
|
| 243 |
+
get_seccontext_field(field, obj)
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
has_seccontext_field(field, obj) {
|
| 247 |
+
get_seccontext_field(field, obj) == false
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
get_seccontext_field(field, obj) = out {
|
| 251 |
+
out = obj.securityContext[field]
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
input_containers[c] {
|
| 255 |
+
c := input.review.object.spec.containers[_]
|
| 256 |
+
}
|
| 257 |
+
input_containers[c] {
|
| 258 |
+
c := input.review.object.spec.initContainers[_]
|
| 259 |
+
}
|
| 260 |
+
input_containers[c] {
|
| 261 |
+
c := input.review.object.spec.ephemeralContainers[_]
|
| 262 |
+
}
|
| 263 |
+
libs:
|
| 264 |
+
- |
|
| 265 |
+
package lib.exclude_update
|
| 266 |
+
|
| 267 |
+
is_update(review) {
|
| 268 |
+
review.operation == "UPDATE"
|
| 269 |
+
}
|
| 270 |
+
- |
|
| 271 |
+
package lib.exempt_container
|
| 272 |
+
|
| 273 |
+
is_exempt(container) {
|
| 274 |
+
exempt_images := object.get(object.get(input, "parameters", {}), "exemptImages", [])
|
| 275 |
+
img := container.image
|
| 276 |
+
exemption := exempt_images[_]
|
| 277 |
+
_matches_exemption(img, exemption)
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
_matches_exemption(img, exemption) {
|
| 281 |
+
not endswith(exemption, "*")
|
| 282 |
+
exemption == img
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
_matches_exemption(img, exemption) {
|
| 286 |
+
endswith(exemption, "*")
|
| 287 |
+
prefix := trim_suffix(exemption, "*")
|
| 288 |
+
startswith(img, prefix)
|
| 289 |
+
}
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/artifacthub-pkg.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: 1.0.3
|
| 2 |
+
name: k8spspallowedusers
|
| 3 |
+
displayName: Allowed Users
|
| 4 |
+
createdAt: "2026-01-08T18:35:12Z"
|
| 5 |
+
description: Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 6 |
+
digest: 67262095158ebed7f44092b8267356ba0805c94e698e268c1d1cf69eb79c8569
|
| 7 |
+
license: Apache-2.0
|
| 8 |
+
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/users
|
| 9 |
+
keywords:
|
| 10 |
+
- gatekeeper
|
| 11 |
+
- open-policy-agent
|
| 12 |
+
- policies
|
| 13 |
+
readme: |-
|
| 14 |
+
# Allowed Users
|
| 15 |
+
Controls the user and group IDs of the container and some volumes. Corresponds to the `runAsUser`, `runAsGroup`, `supplementalGroups`, and `fsGroup` fields in a PodSecurityPolicy. For more information, see https://kubernetes.io/docs/concepts/policy/pod-security-policy/#users-and-groups
|
| 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/users/1.0.3/template.yaml
|
| 20 |
+
```
|
| 21 |
+
provider:
|
| 22 |
+
name: Gatekeeper Library
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/kustomization.yaml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
resources:
|
| 2 |
+
- template.yaml
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/constraint.yaml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: constraints.gatekeeper.sh/v1beta1
|
| 2 |
+
kind: K8sPSPAllowedUsers
|
| 3 |
+
metadata:
|
| 4 |
+
name: psp-pods-allowed-user-ranges
|
| 5 |
+
spec:
|
| 6 |
+
match:
|
| 7 |
+
kinds:
|
| 8 |
+
- apiGroups: [""]
|
| 9 |
+
kinds: ["Pod"]
|
| 10 |
+
parameters:
|
| 11 |
+
runAsUser:
|
| 12 |
+
rule: MustRunAsNonRoot
|
| 13 |
+
runAsGroup:
|
| 14 |
+
rule: RunAsAny
|
| 15 |
+
supplementalGroups:
|
| 16 |
+
rule: RunAsAny
|
| 17 |
+
fsGroup:
|
| 18 |
+
rule: RunAsAny
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/disallowed_ephemeral.yaml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
ephemeralContainers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
runAsUser: 0
|
| 13 |
+
runAsGroup: 0
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/example_allowed.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-allowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
securityContext:
|
| 9 |
+
runAsNonRoot: true
|
| 10 |
+
containers:
|
| 11 |
+
- name: nginx
|
| 12 |
+
image: nginx
|
| 13 |
+
securityContext:
|
| 14 |
+
runAsUser: 1000
|
| 15 |
+
runAsGroup: 1000
|
source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/artifacthub/library/pod-security-policy/users/1.0.3/samples/psp-pods-allowed-user-ranges/example_disallowed.yaml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: v1
|
| 2 |
+
kind: Pod
|
| 3 |
+
metadata:
|
| 4 |
+
name: nginx-users-disallowed
|
| 5 |
+
labels:
|
| 6 |
+
app: nginx-users
|
| 7 |
+
spec:
|
| 8 |
+
containers:
|
| 9 |
+
- name: nginx
|
| 10 |
+
image: nginx
|
| 11 |
+
securityContext:
|
| 12 |
+
runAsUser: 0
|
| 13 |
+
runAsGroup: 0
|