Skip to content

Commit 01b121f

Browse files
committed
MEDIUM: respect strictly allowed annotations prefixes
1 parent acc5141 commit 01b121f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/store/convert.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,22 @@ func getIgClass(className *string) string {
196196
func CopyAnnotations(in map[string]string) map[string]string {
197197
out := make(map[string]string, len(in))
198198
for name, value := range in {
199-
split := strings.SplitN(name, "/", 2)
200-
out[split[len(split)-1]] = value
199+
out[cleanAnnotation(name)] = value
201200
}
202201
return out
203202
}
203+
204+
var annotationsPrefixes = []string{
205+
"haproxy.org/",
206+
"ingress.kubernetes.io/",
207+
"haproxy.com/",
208+
}
209+
210+
func cleanAnnotation(annotation string) string {
211+
for _, prefix := range annotationsPrefixes {
212+
if strings.HasPrefix(annotation, prefix) {
213+
return strings.TrimPrefix(annotation, prefix)
214+
}
215+
}
216+
return annotation
217+
}

0 commit comments

Comments
 (0)