Improve mutating annotation detection logic

This commit is contained in:
Sam Stoelinga 2022-07-22 07:38:04 -07:00
parent 136426f326
commit ff449375da

View File

@ -154,13 +154,14 @@ func IsPSPMutating(pspObj *v1beta1.PodSecurityPolicy) (mutating bool, fields, an
fields = append(fields, "AllowPrivilegeEscalation") fields = append(fields, "AllowPrivilegeEscalation")
} }
mutatingAnnotations := make(map[string]bool) mutatingAnnotations := []string{
mutatingAnnotations["seccomp.security.alpha.kubernetes.io/defaultProfileName"] = true "seccomp.security.alpha.kubernetes.io/defaultProfileName",
mutatingAnnotations["apparmor.security.beta.kubernetes.io/defaultProfileName"] = true "apparmor.security.beta.kubernetes.io/defaultProfileName",
}
for k, _ := range pspObj.Annotations { for _, a := range mutatingAnnotations {
if _, ok := mutatingAnnotations[k]; ok { if _, ok := pspObj.Annotations[a]; ok {
annotations = append(annotations, k) annotations = append(annotations, a)
} }
} }