@@ -40,7 +40,7 @@ func TestPodSecurityContext(t *testing.T) {
40
40
// > non-critical applications.
41
41
t .Run ("Baseline" , func (t * testing.T ) {
42
42
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 .` )
44
44
45
45
assert .Assert (t , psc .Sysctls == nil ,
46
46
`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) {
56
56
`RunAsNonRoot should be delegated to the container-level v1.SecurityContext` )
57
57
}
58
58
59
+ assert .Assert (t , psc .RunAsUser == nil ,
60
+ `Containers must not set runAsUser to 0` )
61
+
62
+ // TODO(cbandy): delegate to v1.SecurityContext
59
63
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.` )
61
65
})
62
66
}
63
67
@@ -83,7 +87,7 @@ func TestRestrictedSecurityContext(t *testing.T) {
83
87
}
84
88
85
89
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 ." )
87
91
88
92
assert .Assert (t , sc .ProcMount == nil ,
89
93
"The default /proc masks are set up to reduce attack surface, and should be required." )
@@ -109,8 +113,16 @@ func TestRestrictedSecurityContext(t *testing.T) {
109
113
"Containers must be required to run as non-root users." )
110
114
}
111
115
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
112
124
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.` )
114
126
})
115
127
116
128
if assert .Check (t , sc .ReadOnlyRootFilesystem != nil ) {
0 commit comments