datadope-io / skydive

An open source real-time network topology and protocols analyzer
https://skydive.network
Apache License 2.0
1 stars 0 forks source link

Protect skydive from invalid TCPConn/TCPListen formats #5

Open adrianlzt opened 3 years ago

adrianlzt commented 3 years ago

If we try to create a node with Metadata.TCPConn with an invalid value:

2021-02-22 17:46:58.457917 I | http: panic serving 127.0.0.1:45500: interface conversion: interface {} is string, not *proccon.NetworkInfo
goroutine 1349 [running]:
net/http.(*conn).serve.func1(0xc001c86aa0)
        /usr/lib/go/src/net/http/server.go:1801 +0x147
panic(0x4e3e760, 0xc000954f00)
        /usr/lib/go/src/runtime/panic.go:975 +0x47a
github.com/skydive-project/skydive/topology/probes/procpeering.listenEndpointHasher(0xc0010095f0, 0xc000954db0)
        /home/adrian/go/src/github.com/skydive-project/skydive/topology/probes/procpeering/procpeering.go:183 +0x387
github.com/skydive-project/skydive/graffiti/graph.(*Indexer).OnNodeAdded(0xc000292060, 0xc0010095f0)
        /home/adrian/go/src/github.com/skydive-project/skydive/graffiti/graph/indexer.go:133 +0x34
adrianlzt commented 3 years ago

If I try to pass the correct value:

goroutine 230 [running]:
net/http.(*conn).serve.func1(0xc0003f2960)
        /usr/lib/go/src/net/http/server.go:1801 +0x147
panic(0x4e3e760, 0xc000cf29c0)
        /usr/lib/go/src/runtime/panic.go:975 +0x47a
github.com/skydive-project/skydive/topology/probes/procpeering.listenEndpointHasher(0xc0002d70e0, 0xc000cf2990)
        /home/adrian/go/src/github.com/skydive-project/skydive/topology/probes/procpeering/procpeering.go:183 +0x387