@@ -16,6 +16,26 @@ import (
1616
1717// isValidFieldIdentifier checks if a field name matches the allowed pattern
1818func isValidFieldIdentifier (field string ) bool {
19+ // Check for labels.* pattern
20+ if strings .HasPrefix (field , "labels." ) {
21+ labelKey := field [7 :] // Remove "labels." prefix
22+ // K8s label keys: alphanumeric, hyphens, underscores, dots
23+ // Must start and end with alphanumeric character
24+ labelPattern := `^[a-zA-Z0-9]([a-zA-Z0-9\-_.]*[a-zA-Z0-9])?$`
25+ match , _ := regexp .MatchString (labelPattern , labelKey )
26+ return match
27+ }
28+
29+ // Check for annotations.* pattern
30+ if strings .HasPrefix (field , "annotations." ) {
31+ annotationKey := field [12 :] // Remove "annotations." prefix
32+ // K8s annotation keys: similar to labels but more flexible
33+ // Can contain alphanumeric, hyphens, underscores, dots, and slashes
34+ annotationPattern := `^[a-zA-Z0-9]([a-zA-Z0-9\-_./]*[a-zA-Z0-9])?$`
35+ match , _ := regexp .MatchString (annotationPattern , annotationKey )
36+ return match
37+ }
38+
1939 // Matches patterns like:
2040 // - simple: name, first_name, my.field
2141 // - array access: items[0], my.array[123]
0 commit comments