From c32a2dea36c841f89de957b481bf72144a593755 Mon Sep 17 00:00:00 2001 From: Preslav Gerchev Date: Wed, 20 Sep 2023 19:32:19 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Respect=20inventory-file=20if=20?= =?UTF-8?q?passed=20in.=20(#740)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Respects the `--inventory-file` flag if that's passed in. --- apps/cnspec/cmd/scan.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/cnspec/cmd/scan.go b/apps/cnspec/cmd/scan.go index 7362007c..037291dd 100644 --- a/apps/cnspec/cmd/scan.go +++ b/apps/cnspec/cmd/scan.go @@ -16,6 +16,7 @@ import ( "go.mondoo.com/cnquery" "go.mondoo.com/cnquery/cli/config" "go.mondoo.com/cnquery/cli/execruntime" + "go.mondoo.com/cnquery/cli/inventoryloader" "go.mondoo.com/cnquery/cli/theme" "go.mondoo.com/cnquery/providers" "go.mondoo.com/cnquery/providers-sdk/v1/inventory" @@ -164,14 +165,14 @@ func getCobraScanConfig(cmd *cobra.Command, runtime *providers.Runtime, cliRes * log.Fatal().Err(err).Msg("failed to parse props") } + inv, err := inventoryloader.ParseOrUse(cliRes.Asset, viper.GetBool("insecure")) + if err != nil { + log.Fatal().Err(err).Msg("failed to parse inventory") + } conf := scanConfig{ Features: opts.GetFeatures(), IsIncognito: viper.GetBool("incognito"), - Inventory: &inventory.Inventory{ - Spec: &inventory.InventorySpec{ - Assets: []*inventory.Asset{cliRes.Asset}, - }, - }, + Inventory: inv, PolicyPaths: viper.GetStringSlice("policy-bundle"), PolicyNames: viper.GetStringSlice("policies"), Props: props,