diff --git a/pkg/registries/registries.go b/pkg/registries/registries.go index cdb752c..62d24f0 100644 --- a/pkg/registries/registries.go +++ b/pkg/registries/registries.go @@ -221,6 +221,9 @@ func EditRegistriesConfig(config *sysregistriesv2.V2RegistriesConf, insecureScop // This function can be used to validate the registries entries prior to calling EditRegistriesConfig // in the MCO or builds code func IsValidRegistriesConfScope(scope string) bool { + if scope == "" { + return false + } // If scope does not contain the wildcard character, we will assume it is a regular registry entry, which is valid if !strings.Contains(scope, "*") { return true diff --git a/pkg/registries/registries_test.go b/pkg/registries/registries_test.go index 9292be5..5957794 100644 --- a/pkg/registries/registries_test.go +++ b/pkg/registries/registries_test.go @@ -69,6 +69,7 @@ func TestIsValidRegistriesConfScope(t *testing.T) { {"*example.com", false}, {"*/example.com", false}, {"*.*example.com", false}, + {"", false}, // Invalid empty string entry } { t.Run(fmt.Sprintf("%#v", tt.scope), func(t *testing.T) { res := IsValidRegistriesConfScope(tt.scope)