From f43f3d133e736ba37ce41228ad0811f003f50385 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 4 Oct 2023 23:35:21 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20find.files=20with=20no=20results?= =?UTF-8?q?=20fixed=20(#2091)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/builtin_dev.go | 36 ++++++++++++++++----------------- providers/os/resources/files.go | 7 ++++++- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/providers/builtin_dev.go b/providers/builtin_dev.go index 4deeebda87..408ec879d6 100644 --- a/providers/builtin_dev.go +++ b/providers/builtin_dev.go @@ -6,25 +6,25 @@ package providers -import ( - _ "embed" - // osconf "go.mondoo.com/cnquery/providers/os/config" - // os "go.mondoo.com/cnquery/providers/os/provider" -) +// import ( +// _ "embed" + +// osconf "go.mondoo.com/cnquery/providers/os/config" +// os "go.mondoo.com/cnquery/providers/os/provider" +// ) // //go:embed os/resources/os.resources.json // var osInfo []byte -func init() { - // builtinProviders[osconf.Config.ID] = &builtinProvider{ - // Runtime: &RunningProvider{ - // Name: osconf.Config.Name, - // ID: osconf.Config.ID, - // Plugin: os.Init(), - // Schema: MustLoadSchema("os", osInfo), - // isClosed: false, - // }, - // Config: &osconf.Config, - // } - -} +// func init() { +// builtinProviders[osconf.Config.ID] = &builtinProvider{ +// Runtime: &RunningProvider{ +// Name: osconf.Config.Name, +// ID: osconf.Config.ID, +// Plugin: os.Init(), +// Schema: MustLoadSchema("os", osInfo), +// isClosed: false, +// }, +// Config: &osconf.Config, +// } +// } diff --git a/providers/os/resources/files.go b/providers/os/resources/files.go index f0f609613e..34ff20c64d 100644 --- a/providers/os/resources/files.go +++ b/providers/os/resources/files.go @@ -131,7 +131,12 @@ func (l *mqlFilesFind) list() ([]interface{}, error) { return nil, out.Error } - foundFiles = strings.Split(strings.Trim(out.Data, " \t\n"), "\n") + lines := strings.TrimSpace(out.Data) + if lines == "" { + foundFiles = []string{} + } else { + foundFiles = strings.Split(lines, "\n") + } } else { return nil, errors.New("find is not supported for your platform") }