bl4ko / netbox-ssot

Microservice that synces objects from multiple sources into netbox and makes it automatic SSOT.
MIT License
29 stars 4 forks source link

vmware initialisation null pointer #140

Closed TaLoN1x closed 4 months ago

TaLoN1x commented 4 months ago

I found a case where host.Config is nil:

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x170 pc=0xa53c88]

goroutine 32 [running]: github.com/bl4ko/netbox-ssot/internal/source/vmware.(VmwareSource).InitHosts(0xc00128c000, {0xf3b910, 0xc0011d3d60}, 0xc001130f50) /Users/jurikononov/src/tmp/netbox-ssot/internal/source/vmware/vmware_init.go:140 +0x448 github.com/bl4ko/netbox-ssot/internal/source/vmware.(VmwareSource).Init(0xc00128c000) /Users/jurikononov/src/tmp/netbox-ssot/internal/source/vmware/vmware.go:175 +0x1439 main.main.func1({0xf3b8d8, 0xc00126f7d0}, {0xf39b90, 0xc00128c000}) /Users/jurikononov/src/tmp/netbox-ssot/cmd/netbox-ssot/main.go:87 +0x154 created by main.main in goroutine 1 /Users/jurikononov/src/tmp/netbox-ssot/cmd/netbox-ssot/main.go:78 +0x67e

I suggest that vmware_init.go:140 should be wither split into two ifs or second condition should be removed (a bit redundant). Got nullpointer for host.Config.Network when host.Config is nil.

vmware_init.go:140 if host.Config != nil && host.Config.Network != nil

TaLoN1x commented 4 months ago

created by mistake