@@ -40,7 +40,7 @@ func TestPodSecurityContext(t *testing.T) {
4040 // > non-critical applications.
4141 t .Run ("Baseline" , func (t * testing.T ) {
4242 assert .Assert (t , psc .SELinuxOptions == nil ,
43- `Setting custom SELinux options should be disallowed .` )
43+ `Setting a custom SELinux user or role option is forbidden .` )
4444
4545 assert .Assert (t , psc .Sysctls == nil ,
4646 `Sysctls can disable security mechanisms or affect all containers on a host, and should be disallowed except for an allowed "safe" subset.` )
@@ -56,8 +56,12 @@ func TestPodSecurityContext(t *testing.T) {
5656 `RunAsNonRoot should be delegated to the container-level v1.SecurityContext` )
5757 }
5858
59+ assert .Assert (t , psc .RunAsUser == nil ,
60+ `Containers must not set runAsUser to 0` )
61+
62+ // TODO(cbandy): delegate to v1.SecurityContext
5963 assert .Assert (t , psc .SeccompProfile == nil ,
60- "The RuntimeDefault seccomp profile must be required, or allow specific additional profiles." )
64+ `Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.` )
6165 })
6266}
6367
@@ -83,7 +87,7 @@ func TestRestrictedSecurityContext(t *testing.T) {
8387 }
8488
8589 assert .Assert (t , sc .SELinuxOptions == nil ,
86- "Setting custom SELinux options should be disallowed ." )
90+ "Setting a custom SELinux user or role option is forbidden ." )
8791
8892 assert .Assert (t , sc .ProcMount == nil ,
8993 "The default /proc masks are set up to reduce attack surface, and should be required." )
@@ -109,8 +113,16 @@ func TestRestrictedSecurityContext(t *testing.T) {
109113 "Containers must be required to run as non-root users." )
110114 }
111115
116+ assert .Assert (t , sc .RunAsUser == nil ,
117+ `Containers must not set runAsUser to 0` )
118+
119+ // NOTE: The "restricted" Security Context Constraint (SCC) of OpenShift 4.10
120+ // and earlier does not allow any profile to be set. The "restricted-v2" SCC
121+ // of OpenShift 4.11 uses the "runtime/default" profile.
122+ // - https://docs.openshift.com/container-platform/4.10/security/seccomp-profiles.html
123+ // - https://docs.openshift.com/container-platform/4.11/security/seccomp-profiles.html
112124 assert .Assert (t , sc .SeccompProfile == nil ,
113- "The RuntimeDefault seccomp profile must be required, or allow specific additional profiles." )
125+ `Seccomp profile must be explicitly set to one of the allowed values. Both the Unconfined profile and the absence of a profile are prohibited.` )
114126 })
115127
116128 if assert .Check (t , sc .ReadOnlyRootFilesystem != nil ) {
0 commit comments