cnquery
cnquery copied to clipboard
filters in user.authorizedkeys are not working
i want to test that a ssh public key is configured for a user
user(name: "patrick").authorizedkeys.all( key == 'AA....NzaC1yc2EAAAADAQABAAABAQDgwD..../')
[failed] authorizedkeys.all()
error: Failed to create filter result resource: rpc error: code = Unknown desc = failed to add cached authorizedkeys (id: aEENANls7Gs=2), creation failed: [os] cannot set 'file' in resource 'authorizedkeys', type does not match
This bug impacts our GPG Key Checks (https://github.com/mondoohq/installer/actions/runs/6551199312/job/17791891853#step:5:18). The workflow will be disabled until this is resolved.
Spend some time looking into this
We seem to be failing here (providers-sdk/v1/plugin/runtime.go):
// RawToTValue converts a raw (interface{}) value into a typed value
// and returns true if the type was correct.
func RawToTValue[T any](value interface{}, err error) (TValue[T], bool) {
if value == nil {
return TValue[T]{State: StateIsNull | StateIsSet, Error: err}, true
}
tv, ok := value.(T)
if !ok {
return TValue[T]{}, false
}
return TValue[T]{Data: tv, State: StateIsSet, Error: err}, true
}
With T being mqlFile and value being &{file /home/marius/.ssh/authorized_keys} we end up with tv being nil.
Currently no idea how to fix this form here, maybe @arlimus can help?
Also, I noticed that if I type user(name: "marius").authorizedkeys.all() without a filter, I get a panic.
user(name: "marius").authorizedkeys.all(panic: runtime error: index out of range [4294967295] with length 2
goroutine 1 [running]:
go.mondoo.com/cnquery/v9/llx.(*CodeV2).Block(...)
/home/marius/mondoo/cnquery/llx/code.go:111
go.mondoo.com/cnquery/v9/llx.(*CodeV2).Chunk(...)
/home/marius/mondoo/cnquery/llx/code.go:106
go.mondoo.com/cnquery/v9/mqlc.(*compiler).addValueFieldChunks(0xc000a500a0, 0xc000298320?)
/home/marius/mondoo/cnquery/mqlc/mqlc.go:1793 +0x4bb
go.mondoo.com/cnquery/v9/mqlc.(*compiler).postCompile(0xc000a500a0)
/home/marius/mondoo/cnquery/mqlc/mqlc.go:1774 +0x239
go.mondoo.com/cnquery/v9/mqlc.(*compiler).CompileParsed(0xc000a500a0, 0xc00082e540?)
/home/marius/mondoo/cnquery/mqlc/mqlc.go:2149 +0x4b
go.mondoo.com/cnquery/v9/mqlc.CompileAST(0xc00041ae10?, 0x29?, {{0x2621b18, 0xc0003af308}, 0x0, {0x262a240, 0x385d160}})
/home/marius/mondoo/cnquery/mqlc/mqlc.go:2223 +0x445
go.mondoo.com/cnquery/v9/mqlc.compile({0xc00041ae10?, 0x29?}, 0xc000f7b330?, {{0x2621b18, 0xc0003af308}, 0x0, {0x262a240, 0x385d160}})
/home/marius/mondoo/cnquery/mqlc/mqlc.go:2244 +0xa5
go.mondoo.com/cnquery/v9/mqlc.Compile({0xc00041ae10?, 0x2?}, 0x8?, {{0x2621b18, 0xc0003af308}, 0x0, {0x262a240, 0x385d160}})
/home/marius/mondoo/cnquery/mqlc/mqlc.go:2270 +0x59
go.mondoo.com/cnquery/v9/cli/shell.(*Completer).CompletePrompt(0xc000690540, {{0xc000aaca50, 0x29}, 0x29, 0x56})
/home/marius/mondoo/cnquery/cli/shell/completer.go:43 +0x20b
github.com/c-bata/go-prompt.(*CompletionManager).Update(...)
/home/marius/go/pkg/mod/github.com/c-bata/[email protected]/completion.go:68
github.com/c-bata/go-prompt.(*Prompt).Run(0xc0002337a0)
/home/marius/go/pkg/mod/github.com/c-bata/[email protected]/prompt.go:99 +0x68d
go.mondoo.com/cnquery/v9/cli/shell.(*Shell).RunInteractive(0xc000797080, {0x0, 0x0})
/home/marius/mondoo/cnquery/cli/shell/shell.go:207 +0x92a
go.mondoo.com/cnquery/v9/apps/cnquery/cmd.StartShell(0xc0003af2b0, 0xc00082e720)
/home/marius/mondoo/cnquery/apps/cnquery/cmd/shell.go:165 +0x8e8
go.mondoo.com/cnquery/v9/apps/cnquery/cmd.glob..func26(0x3820860?, 0xc0003e8500?, 0x385d160?)
/home/marius/mondoo/cnquery/apps/cnquery/cmd/shell.go:47 +0x28
go.mondoo.com/cnquery/v9/cli/providers.setConnector.func2(0xc000118a00?, {0x385d160?, 0x0, 0x0})
/home/marius/mondoo/cnquery/cli/providers/providers.go:490 +0xa22
github.com/spf13/cobra.(*Command).execute(0x37f0f20, {0x385d160, 0x0, 0x0})
/home/marius/go/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x863
github.com/spf13/cobra.(*Command).ExecuteC(0x37f0680)
/home/marius/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
/home/marius/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
go.mondoo.com/cnquery/v9/apps/cnquery/cmd.Execute()
/home/marius/mondoo/cnquery/apps/cnquery/cmd/root.go:76 +0x7d
main.main()
/home/marius/mondoo/cnquery/apps/cnquery/cnquery.go:9 +0xf
not yet fixed