mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-24 04:02:16 +00:00
IsImageMatched interpolates the image name from kustomization images[].name straight into a regexp and discarded the compile error. When the name is not a valid regexp (for example "["), regexp.Compile returns a nil *Regexp and the following MatchString call dereferences it, so kustomize build crashes with a SIGSEGV. Capture the compile error and return false when it is set. A name that can't compile matches no image, which leaves the resource untouched (the same result you get for any name that doesn't match). Adds a unit test for the invalid name and a krusty end-to-end case that builds without panicking. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>