mondoohq / cnquery

open source, cloud-native, graph-based asset inventory

Home Page:https://cnquery.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`cnquery mock` panics

czunker opened this issue · comments

Describe the bug

cnquery run mock --use-recording /tmp/ubuntu_18.04.json -c "asset.platform" 
→ reported panic to Mondoo platform
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x108d5b1]

goroutine 1 [running]:
go.mondoo.com/cnquery/v10/providers-sdk/v1/upstream/health.ReportPanic({0x15a0042, 0x7}, {0x17aeee8, 0x7}, {0x17aef08, 0x9}, {0x0, 0x0, 0x0?})
        /home/christian/workspace/mondoo/github.com/cnquery/providers-sdk/v1/upstream/health/errors.go:30 +0x16c
panic({0x13738e0?, 0x22e6e50?})
        /home/christian/go1.22/go/src/runtime/panic.go:770 +0x132
go.mondoo.com/cnquery/v10/providers.(*mockProviderService).Init(...)
        /home/christian/workspace/mondoo/github.com/cnquery/providers/mock.go:128
go.mondoo.com/cnquery/v10/providers.(*coordinator).unsafeStartProvider(0xc0003311e0, {0x15d98ed, 0x28}, {0x28?, 0x15a0209?})
        /home/christian/workspace/mondoo/github.com/cnquery/providers/coordinator.go:299 +0x1d1
go.mondoo.com/cnquery/v10/providers.(*coordinator).GetRunningProvider(0xc0003311e0, {0x15d98ed, 0x28}, {0x0?, 0x15a674b?})
        /home/christian/workspace/mondoo/github.com/cnquery/providers/coordinator.go:280 +0x105
go.mondoo.com/cnquery/v10/providers.(*Runtime).addProvider(0xc00043d800, {0x15d98ed?, 0x15a9578?})
        /home/christian/workspace/mondoo/github.com/cnquery/providers/runtime.go:130 +0x35
go.mondoo.com/cnquery/v10/providers.(*Runtime).UseProvider(...)
        /home/christian/workspace/mondoo/github.com/cnquery/providers/runtime.go:115
go.mondoo.com/cnquery/v10/cli/providers.setConnector.func2(0xc000533b08, {0xc0005bde40, 0x0, 0x4})
        /home/christian/workspace/mondoo/github.com/cnquery/cli/providers/providers.go:442 +0x650
github.com/spf13/cobra.(*Command).execute(0xc000533b08, {0xc0005bde00, 0x4, 0x4})
        /home/christian/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0x2318720)
        /home/christian/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        /home/christian/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
go.mondoo.com/cnquery/v10/apps/cnquery/cmd.Execute()
        /home/christian/workspace/mondoo/github.com/cnquery/apps/cnquery/cmd/root.go:83 +0x7d
main.main()
        /home/christian/workspace/mondoo/github.com/cnquery/apps/cnquery/cnquery.go:14 +0x85

To Reproduce
Steps to reproduce the behavior:

  1. Create a recording
  2. Use recording with mock provider
  3. Note the error

Expected behavior
You should see the requested output

Desktop (please complete the following information):

  • cnquery latest main

Additional context
It worked with v10.3.4:

cnquery version 
cnquery 10.3.4 (f380756543, 2024-02-17T08:12:07Z)
cnquery run mock --use-recording /tmp/ubuntu_18.04.json -c "asset.platform" 
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
asset.platform: "ubuntu"