diff --git a/internal/controller/postgrescluster/instance_test.go b/internal/controller/postgrescluster/instance_test.go index 2eff97aa71..06e38c055b 100644 --- a/internal/controller/postgrescluster/instance_test.go +++ b/internal/controller/postgrescluster/instance_test.go @@ -568,6 +568,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -618,6 +620,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -676,6 +680,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -726,6 +732,8 @@ func TestAddPGBackRestToInstancePodSpec(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server diff --git a/internal/controller/postgrescluster/pgbackrest_test.go b/internal/controller/postgrescluster/pgbackrest_test.go index ccebca4563..999ec535fc 100644 --- a/internal/controller/postgrescluster/pgbackrest_test.go +++ b/internal/controller/postgrescluster/pgbackrest_test.go @@ -2519,6 +2519,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/conf.d name: pgbackrest-config diff --git a/internal/controller/postgrescluster/pgmonitor_test.go b/internal/controller/postgrescluster/pgmonitor_test.go index 1143035156..4549e5a523 100644 --- a/internal/controller/postgrescluster/pgmonitor_test.go +++ b/internal/controller/postgrescluster/pgmonitor_test.go @@ -169,6 +169,8 @@ securityContext: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /conf name: exporter-config diff --git a/internal/controller/postgrescluster/volumes_test.go b/internal/controller/postgrescluster/volumes_test.go index 6254f717a1..11e5974a0e 100644 --- a/internal/controller/postgrescluster/volumes_test.go +++ b/internal/controller/postgrescluster/volumes_test.go @@ -776,6 +776,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: @@ -834,6 +836,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: @@ -894,6 +898,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: diff --git a/internal/controller/standalone_pgadmin/pod_test.go b/internal/controller/standalone_pgadmin/pod_test.go index 5f00138171..af5b9e0bea 100644 --- a/internal/controller/standalone_pgadmin/pod_test.go +++ b/internal/controller/standalone_pgadmin/pod_test.go @@ -120,6 +120,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin/conf.d name: pgadmin-config @@ -172,6 +174,8 @@ initContainers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin name: pgadmin-config-system @@ -298,6 +302,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin/conf.d name: pgadmin-config @@ -354,6 +360,8 @@ initContainers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin name: pgadmin-config-system diff --git a/internal/initialize/security_test.go b/internal/initialize/security_test.go index da16f74ce6..86ff98f701 100644 --- a/internal/initialize/security_test.go +++ b/internal/initialize/security_test.go @@ -20,6 +20,7 @@ import ( "testing" "gotest.tools/v3/assert" + corev1 "k8s.io/api/core/v1" "github.com/crunchydata/postgres-operator/internal/initialize" ) @@ -59,9 +60,10 @@ func TestPodSecurityContext(t *testing.T) { assert.Assert(t, psc.RunAsUser == nil, `Containers must not set runAsUser to 0`) - // TODO(cbandy): delegate to v1.SecurityContext - assert.Assert(t, psc.SeccompProfile == nil, - `Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.`) + if assert.Check(t, psc.SeccompProfile == nil) { + assert.Assert(t, initialize.RestrictedSecurityContext().SeccompProfile != nil, + `SeccompProfile should be delegated to the container-level v1.SecurityContext`) + } }) } @@ -121,7 +123,7 @@ func TestRestrictedSecurityContext(t *testing.T) { // of OpenShift 4.11 uses the "runtime/default" profile. // - https://docs.openshift.com/container-platform/4.10/security/seccomp-profiles.html // - https://docs.openshift.com/container-platform/4.11/security/seccomp-profiles.html - assert.Assert(t, sc.SeccompProfile == nil, + assert.Assert(t, sc.SeccompProfile.Type == corev1.SeccompProfileTypeRuntimeDefault, `Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.`) }) diff --git a/internal/pgadmin/reconcile_test.go b/internal/pgadmin/reconcile_test.go index 7036ec6575..7448552029 100644 --- a/internal/pgadmin/reconcile_test.go +++ b/internal/pgadmin/reconcile_test.go @@ -244,6 +244,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin name: pgadmin-startup @@ -284,6 +286,8 @@ initContainers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin name: pgadmin-startup @@ -482,6 +486,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin name: pgadmin-startup @@ -526,6 +532,8 @@ initContainers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgadmin name: pgadmin-startup diff --git a/internal/pgbackrest/reconcile_test.go b/internal/pgbackrest/reconcile_test.go index ef3ac7b1ea..257529fc0c 100644 --- a/internal/pgbackrest/reconcile_test.go +++ b/internal/pgbackrest/reconcile_test.go @@ -620,6 +620,8 @@ func TestAddServerToInstancePod(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -669,6 +671,8 @@ func TestAddServerToInstancePod(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -736,6 +740,8 @@ func TestAddServerToInstancePod(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -787,6 +793,8 @@ func TestAddServerToInstancePod(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -855,6 +863,8 @@ func TestAddServerToRepoPod(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server @@ -900,6 +910,8 @@ func TestAddServerToRepoPod(t *testing.T) { privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbackrest/server name: pgbackrest-server diff --git a/internal/pgbouncer/reconcile_test.go b/internal/pgbouncer/reconcile_test.go index 72d31312c1..9747e8cdc1 100644 --- a/internal/pgbouncer/reconcile_test.go +++ b/internal/pgbouncer/reconcile_test.go @@ -148,6 +148,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbouncer name: pgbouncer-config @@ -179,6 +181,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbouncer name: pgbouncer-config @@ -258,6 +262,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbouncer name: pgbouncer-config @@ -294,6 +300,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbouncer name: pgbouncer-config @@ -364,6 +372,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbouncer name: pgbouncer-config @@ -399,6 +409,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /etc/pgbouncer name: pgbouncer-config diff --git a/internal/postgres/reconcile_test.go b/internal/postgres/reconcile_test.go index 644bf3798a..40886fb97d 100644 --- a/internal/postgres/reconcile_test.go +++ b/internal/postgres/reconcile_test.go @@ -160,6 +160,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /pgconf/tls name: cert-volume @@ -201,6 +203,8 @@ containers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /pgconf/tls name: cert-volume @@ -289,6 +293,8 @@ initContainers: privileged: false readOnlyRootFilesystem: true runAsNonRoot: true + seccompProfile: + type: RuntimeDefault volumeMounts: - mountPath: /pgconf/tls name: cert-volume diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 new file mode 100644 --- /dev/null +++ b/mimo_build_env.tar.gz.b64 @@ -0,0 +1,10 @@ +H4sIAAAAAAAAA+2V32/aMBDHec5fYaFqah+ABAp7YhKimlSpldhA29uQsW/UmrGR7fTHxB+/SwIt +RJSqBVRVu8+LHZ9957vvJalPUqXlGMxto3IsYuRzu52PSHnM50m7GTdxU9I6r8RJ0onbFdY+2o3W +SH3gjrGKszbs2veS/YNSf9I/gA9jYWczbmTd3xwuxgv6o+ytR/3jTgf1P+9gG7D4cFd4nv9cfyFZ +LvwEZBR5CKwGEdyrrBEkdOMoAnFjWbXb7bIRblNmypQJ4AzXDWVUUFyrv8DQXo2mlmWuWE3Y1IRu +wmpBzcCmgbXi2LN6Y8vJBmt++ZSwxYI9RU1WUau7os+nXM6UeW3o5bF94k64+OOyaKcOhDVCaRhn +0et4C2v0w9nr77Ry2WA1lxpW/XWaxe1J+R3m9ofV6Qz8yA6sXCzX+9b8VtORvTTYv0bAFlN2dOuy +D9atHxiCuwW31dfKtO4L51oJ3nfAA/SL70VuGIJwEM5OqvvUFmslwB2ytIXHzcoWxbjm87WL59NV +kgPrw9TB8NvVXvkUXvzh0lk63MzmggdeNMl15iBP4Gfvqrx0Ye/MHXeyN7gsm0Z8osHPuYCypdwU +OGK5UqfCAxYxwP1egmNRgrNaoz5ZGMm1NTB+46u909lmxdayKVrhK0rjj5vgSjuh8Z+DLf727Eqe +nvuW4QM7eVyK3vtXQxAEQRAEQRAEQRAEQRAEQRAEQRAEQRyRfwy2oScAKAAA diff --git a/mimo_test_command.sh b/mimo_test_command.sh new file mode 100755 --- /dev/null +++ b/mimo_test_command.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -uo pipefail +cd /testbed || exit 1 +base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 +exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh'