@@ -36,8 +36,6 @@ func (c *PodSecurityReadinessController) classifyViolatingNamespace(ctx context.
36
36
return nil
37
37
}
38
38
39
- // TODO@ibihim: increase log level
40
- klog .InfoS ("Checking for user violations" , "namespace" , ns .Name , "enforceLevel" , enforceLevel )
41
39
isUserViolation , err := c .isUserViolation (ctx , ns , enforceLevel )
42
40
if err != nil {
43
41
klog .V (2 ).ErrorS (err , "Error checking user violations" , "namespace" , ns .Name )
@@ -46,11 +44,7 @@ func (c *PodSecurityReadinessController) classifyViolatingNamespace(ctx context.
46
44
return err
47
45
}
48
46
49
- // TODO@ibihim: increase log level
50
- klog .InfoS ("User violation check result" , "namespace" , ns .Name , "isUserViolation" , isUserViolation )
51
47
if isUserViolation {
52
- // TODO@ibihim: increase log level
53
- klog .InfoS ("Adding namespace to user SCC violations" , "namespace" , ns .Name )
54
48
conditions .addViolatingUserSCC (ns )
55
49
return nil
56
50
}
@@ -87,10 +81,16 @@ func (c *PodSecurityReadinessController) isUserViolation(ctx context.Context, ns
87
81
88
82
var userPods []corev1.Pod
89
83
for _ , pod := range allPods .Items {
90
- // TODO@ibihim: we should exclude Pod that have restricted-v2.
91
- // restricted-v2 SCCs are allowed for all system:authenticated. ServiceAccounts
92
- // are able to use that, but they are not part of the group. So restricted-v2
93
- // will always result in user.
84
+ if strings .HasPrefix (pod .Annotations [securityv1 .ValidatedSCCAnnotation ], "restricted-v" ) {
85
+ // restricted-v2 is allowed for all system:authenticated, also for ServiceAccounts.
86
+ // But ServiceAccounts are not part of the group. So restricted-v2 will always
87
+ // result in user-based SCC. So we skip them as the user-based SCCs cause harm
88
+ // if they need a higher privileged than restricted.
89
+ // We watch for any restricted version above the first one. We might introduce
90
+ // restricted-v3 for user namespaces.
91
+ continue
92
+ }
93
+
94
94
if pod .Annotations [securityv1 .ValidatedSCCSubjectTypeAnnotation ] == "user" {
95
95
userPods = append (userPods , pod )
96
96
}
0 commit comments