Fix nil pointer dereference segfault when passing "null" config json to cloudflared tunnel ingress validate (#1070)
This commit is contained in:
parent
a4a84bb27e
commit
f2c4fdb0ae
|
@ -85,7 +85,7 @@ type Ingress struct {
|
||||||
|
|
||||||
// ParseIngress parses ingress rules, but does not send HTTP requests to the origins.
|
// ParseIngress parses ingress rules, but does not send HTTP requests to the origins.
|
||||||
func ParseIngress(conf *config.Configuration) (Ingress, error) {
|
func ParseIngress(conf *config.Configuration) (Ingress, error) {
|
||||||
if len(conf.Ingress) == 0 {
|
if conf == nil || len(conf.Ingress) == 0 {
|
||||||
return Ingress{}, ErrNoIngressRules
|
return Ingress{}, ErrNoIngressRules
|
||||||
}
|
}
|
||||||
return validateIngress(conf.Ingress, originRequestFromConfig(conf.OriginRequest))
|
return validateIngress(conf.Ingress, originRequestFromConfig(conf.OriginRequest))
|
||||||
|
|
|
@ -43,6 +43,11 @@ ingress:
|
||||||
require.Equal(t, "https", s.scheme)
|
require.Equal(t, "https", s.scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseIngressNilConfig(t *testing.T) {
|
||||||
|
_, err := ParseIngress(nil)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestParseIngress(t *testing.T) {
|
func TestParseIngress(t *testing.T) {
|
||||||
localhost8000 := MustParseURL(t, "https://localhost:8000")
|
localhost8000 := MustParseURL(t, "https://localhost:8000")
|
||||||
localhost8001 := MustParseURL(t, "https://localhost:8001")
|
localhost8001 := MustParseURL(t, "https://localhost:8001")
|
||||||
|
|
Loading…
Reference in New Issue