Skip to content

Commit 49f9ea2

Browse files
danehansopenshift-cherrypick-robot
authored andcommitted
Fixes Bug 1753930: Adds support for trailing dot in noProxy domain names
1 parent 11cf5fc commit 49f9ea2

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

pkg/types/validation/installconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func validateProxy(p *types.Proxy, fldPath *field.Path) field.ErrorList {
268268
errDomain := validate.NoProxyDomainName(v)
269269
_, _, errCIDR := net.ParseCIDR(v)
270270
if errDomain != nil && errCIDR != nil {
271-
allErrs = append(allErrs, field.Invalid(field.NewPath("NoProxy"), v, "must be a CIDR or domain, without wildcard characters and without trailing dots ('.')"))
271+
allErrs = append(allErrs, field.Invalid(field.NewPath("NoProxy"), v, "must be a CIDR or domain, without wildcard characters"))
272272
}
273273
}
274274
}

pkg/types/validation/installconfig_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,10 @@ func TestValidateInstallConfig(t *testing.T) {
612612
name: "invalid NoProxy domain",
613613
installConfig: func() *types.InstallConfig {
614614
c := validInstallConfig()
615-
c.Proxy.NoProxy = "good-no-proxy.com, .bad-proxy."
615+
c.Proxy.NoProxy = "good-no-proxy.com, *.bad-proxy"
616616
return c
617617
}(),
618-
expectedError: `^\QNoProxy: Invalid value: ".bad-proxy.": must be a CIDR or domain, without wildcard characters and without trailing dots ('.')\E$`,
618+
expectedError: `^\QNoProxy: Invalid value: "*.bad-proxy": must be a CIDR or domain, without wildcard characters\E$`,
619619
},
620620
{
621621
name: "invalid NoProxy CIDR",
@@ -624,16 +624,16 @@ func TestValidateInstallConfig(t *testing.T) {
624624
c.Proxy.NoProxy = "good-no-proxy.com, 172.bad.CIDR.0/16"
625625
return c
626626
}(),
627-
expectedError: `^\QNoProxy: Invalid value: "172.bad.CIDR.0/16": must be a CIDR or domain, without wildcard characters and without trailing dots ('.')\E$`,
627+
expectedError: `^\QNoProxy: Invalid value: "172.bad.CIDR.0/16": must be a CIDR or domain, without wildcard characters\E$`,
628628
},
629629
{
630630
name: "invalid NoProxy domain & CIDR",
631631
installConfig: func() *types.InstallConfig {
632632
c := validInstallConfig()
633-
c.Proxy.NoProxy = "good-no-proxy.com, a-good-one, .bad-proxy., another, 172.bad.CIDR.0/16, good-end"
633+
c.Proxy.NoProxy = "good-no-proxy.com, a-good-one, *.bad-proxy., another, 172.bad.CIDR.0/16, good-end"
634634
return c
635635
}(),
636-
expectedError: `^\Q[NoProxy: Invalid value: ".bad-proxy.": must be a CIDR or domain, without wildcard characters and without trailing dots ('.'), NoProxy: Invalid value: "172.bad.CIDR.0/16": must be a CIDR or domain, without wildcard characters and without trailing dots ('.')]\E$`,
636+
expectedError: `^\Q[NoProxy: Invalid value: "*.bad-proxy.": must be a CIDR or domain, without wildcard characters, NoProxy: Invalid value: "172.bad.CIDR.0/16": must be a CIDR or domain, without wildcard characters]\E$`,
637637
},
638638
{
639639
name: "valid GCP platform",

pkg/validate/validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ func DomainName(v string, acceptTrailingDot bool) error {
6565

6666
// NoProxyDomainName checks if the given string is a valid proxy noProxy domain name
6767
// and returns an error if not. Example valid noProxy domains are ".foo.com", "bar.com",
68-
// but not "*.foo.com", "bar.com."
68+
// "bar.com." but not "*.foo.com".
6969
func NoProxyDomainName(v string) error {
70-
v = strings.TrimPrefix(v, ".")
70+
v = strings.TrimSuffix(strings.TrimPrefix(v, "."), ".")
7171
return validateSubdomain(v)
7272
}
7373

pkg/validate/validate_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ func TestNoProxyDomainName(t *testing.T) {
184184
{"1", true},
185185
{"0.0", true},
186186
{"1.2.3.4", true},
187-
{"1.2.3.4.", false},
188-
{"abc.", false},
187+
{"1.2.3.4.", true},
188+
{"abc.", true},
189189
{"abc.com", true},
190-
{"abc.com.", false},
190+
{"abc.com.", true},
191191
{"a.b.c.d.e.f", true},
192192
{".abc", true},
193193
{".abc.com", true},

0 commit comments

Comments
 (0)