Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 only use native registry key implementation if we are scanning local machine from windows #2979

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions providers/os/resources/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ func genericSearch(afs *afero.Afero) ([]python.PackageDetails, error) {
func darwinSearch(afs *afero.Afero) ([]python.PackageDetails, error) {
allResults := []python.PackageDetails{}

// TODO: this does not work properly, we need to use the connection here to determine if we are running on a
// local connection
if runtime.GOOS != "darwin" {
return allResults, nil
}
Expand Down
11 changes: 7 additions & 4 deletions providers/os/resources/registrykey.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"go.mondoo.com/cnquery/v9/llx"
"go.mondoo.com/cnquery/v9/providers-sdk/v1/plugin"
"go.mondoo.com/cnquery/v9/providers/os/connection/mock"
"go.mondoo.com/cnquery/v9/providers/os/connection/shared"
"go.mondoo.com/cnquery/v9/providers/os/resources/powershell"
"go.mondoo.com/cnquery/v9/providers/os/resources/windows"
"go.mondoo.com/ranger-rpc/codes"
Expand All @@ -22,8 +23,9 @@ func (k *mqlRegistrykey) id() (string, error) {
}

func (k *mqlRegistrykey) exists() (bool, error) {
conn := k.MqlRuntime.Connection.(shared.Connection)
// if we are running locally on windows, we can use native api
if runtime.GOOS == "windows" {
if conn.Type() == shared.Type_Local && runtime.GOOS == "windows" {
items, err := windows.GetNativeRegistryKeyItems(k.Path.Data)
if err == nil && len(items) > 0 {
return true, nil
Expand Down Expand Up @@ -69,7 +71,8 @@ func (k *mqlRegistrykey) exists() (bool, error) {
// GetEntries returns a list of registry key property resources
func (k *mqlRegistrykey) getEntries() ([]windows.RegistryKeyItem, error) {
// if we are running locally on windows, we can use native api
if runtime.GOOS == "windows" {
conn := k.MqlRuntime.Connection.(shared.Connection)
if conn.Type() == shared.Type_Local && runtime.GOOS == "windows" {
return windows.GetNativeRegistryKeyItems(k.Path.Data)
}

Expand Down Expand Up @@ -162,10 +165,10 @@ func (k *mqlRegistrykey) items() ([]interface{}, error) {
}

func (k *mqlRegistrykey) children() ([]interface{}, error) {
conn := k.MqlRuntime.Connection.(shared.Connection)
res := []interface{}{}

var children []windows.RegistryKeyChild
if runtime.GOOS == "windows" {
if conn.Type() == shared.Type_Local && runtime.GOOS == "windows" {
var err error
children, err = windows.GetNativeRegistryKeyChildren(k.Path.Data)
if err != nil {
Expand Down
Loading