mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-01 09:32:08 +00:00
ipn/serve: validate service paths in HasPathHandler
Fixes #17839 Signed-off-by: Sachin Iyer <siyer@detail.dev>
This commit is contained in:
committed by
Adrian Dewhurst
parent
c54d243690
commit
53476ce872
14
ipn/serve.go
14
ipn/serve.go
@@ -238,6 +238,20 @@ func (sc *ServeConfig) HasPathHandler() bool {
|
||||
}
|
||||
}
|
||||
|
||||
if sc.Services != nil {
|
||||
for _, serviceConfig := range sc.Services {
|
||||
if serviceConfig.Web != nil {
|
||||
for _, webServerConfig := range serviceConfig.Web {
|
||||
for _, httpHandler := range webServerConfig.Handlers {
|
||||
if httpHandler.Path != "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if sc.Foreground != nil {
|
||||
for _, fgConfig := range sc.Foreground {
|
||||
if fgConfig.HasPathHandler() {
|
||||
|
||||
@@ -117,6 +117,36 @@ func TestHasPathHandler(t *testing.T) {
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "with-service-path-handler",
|
||||
cfg: ServeConfig{
|
||||
Services: map[tailcfg.ServiceName]*ServiceConfig{
|
||||
"svc:foo": {
|
||||
Web: map[HostPort]*WebServerConfig{
|
||||
"foo.test.ts.net:443": {Handlers: map[string]*HTTPHandler{
|
||||
"/": {Path: "/tmp"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "with-service-proxy-handler",
|
||||
cfg: ServeConfig{
|
||||
Services: map[tailcfg.ServiceName]*ServiceConfig{
|
||||
"svc:foo": {
|
||||
Web: map[HostPort]*WebServerConfig{
|
||||
"foo.test.ts.net:443": {Handlers: map[string]*HTTPHandler{
|
||||
"/": {Proxy: "http://127.0.0.1:3000"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user