Skip to content

Commit

Permalink
🐛 only use native registry key implementation if we are scanning loca…
Browse files Browse the repository at this point in the history
…l machine from windows (#2979)
  • Loading branch information
chris-rock authored Jan 8, 2024
1 parent 19ce10a commit 622f918
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 622f918

Please sign in to comment.