From ff449375daf72c2e3f4e81bb46f59a2df6dae66a Mon Sep 17 00:00:00 2001 From: Sam Stoelinga Date: Fri, 22 Jul 2022 07:38:04 -0700 Subject: [PATCH] Improve mutating annotation detection logic --- pspmutating.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pspmutating.go b/pspmutating.go index fc200ff..6c7a0ee 100644 --- a/pspmutating.go +++ b/pspmutating.go @@ -154,13 +154,14 @@ func IsPSPMutating(pspObj *v1beta1.PodSecurityPolicy) (mutating bool, fields, an fields = append(fields, "AllowPrivilegeEscalation") } - mutatingAnnotations := make(map[string]bool) - mutatingAnnotations["seccomp.security.alpha.kubernetes.io/defaultProfileName"] = true - mutatingAnnotations["apparmor.security.beta.kubernetes.io/defaultProfileName"] = true + mutatingAnnotations := []string{ + "seccomp.security.alpha.kubernetes.io/defaultProfileName", + "apparmor.security.beta.kubernetes.io/defaultProfileName", + } - for k, _ := range pspObj.Annotations { - if _, ok := mutatingAnnotations[k]; ok { - annotations = append(annotations, k) + for _, a := range mutatingAnnotations { + if _, ok := pspObj.Annotations[a]; ok { + annotations = append(annotations, a) } }