diff --git a/.goreleaser.yml b/.goreleaser.yml index 7030ef78e4..ddaf00fccf 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,9 +5,6 @@ project_name: cnquery env: - CGO_ENABLED=0 -before: - hooks: - - make providers builds: - id: linux main: ./apps/cnquery/cnquery.go @@ -16,331 +13,8 @@ builds: - linux goarch: - amd64 - - 386 - - arm64 - - arm - - ppc64le - # ARM 6= Raspberry Pi A, A+, B, B+, Zero - # ARM 7= Raspberry Pi 2, 3, 4 - goarm: - - 6 - - 7 flags: - -tags="production netgo" ldflags: - "-extldflags=-static" - -s -w -X go.mondoo.com/cnquery.Version={{.Version}} -X go.mondoo.com/cnquery.Build={{.ShortCommit}} -X go.mondoo.com/cnquery.Date={{.Date}} - - id: macos - main: ./apps/cnquery/cnquery.go - binary: cnquery - goos: - - darwin - goarch: - - amd64 - - arm64 - flags: -tags production - ldflags: - # clang + macos does not support static: - -extldflags "-static" - - -s -w -X go.mondoo.com/cnquery.Version={{.Version}} -X go.mondoo.com/cnquery.Build={{.ShortCommit}} -X go.mondoo.com/cnquery.Date={{.Date}} - hooks: - post: - - cmd: /tmp/quill sign-and-notarize "{{ .Path }}" -vv || true - env: - - QUILL_LOG_FILE=/tmp/quill-{{ .Target }}.log - - id: windows - main: ./apps/cnquery/cnquery.go - binary: cnquery - goos: - - windows - goarch: - - amd64 - - arm64 - # -buildmode exe is required since go 1.15.0 https://github.com/golang/go/issues/40795 - flags: -tags production -buildmode exe - ldflags: - - "-extldflags -static" - - -s -w -X go.mondoo.com/cnquery.Version={{.Version}} -X go.mondoo.com/cnquery.Build={{.ShortCommit}} -X go.mondoo.com/cnquery.Date={{.Date}} - hooks: - post: - - cmd: ./scripts/windows-upx.sh "{{ .Path }}" - output: true - env: - - TARGET={{ .Target }} - - cmd: jsign --storetype DIGICERTONE --alias "{{ .Env.SM_CERT_ALIAS }}" --storepass "{{ .Env.SM_API_KEY }}|{{ .Env.SM_CLIENT_CERT_FILE}}|{{ .Env.SM_CLIENT_CERT_PASSWORD }}" --tsaurl "http://timestamp.digicert.com" '{{ .Path }}' -nfpms: - - - maintainer: Mondoo - description: Cloud-Native Asset Inventory Framework - homepage: https://mondoo.com/ - vendor: Mondoo, Inc - license: MPL-2.0 - formats: - - deb - - rpm - rpm: - signature: - key_file: '{{ .Env.GPG_KEY_PATH }}' -archives: - - id: releases - format_overrides: - - goos: windows - format: zip - files: - - none* -checksum: - name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS' - algorithm: sha256 -snapshot: - name_template: "{{ .Tag }}-snapshot" -changelog: - use: github-native -dockers: # https://goreleaser.com/customization/docker/ - # UBI containers - - use: buildx - goos: linux - goarch: amd64 - dockerfile: Dockerfile-ubi - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-amd64" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-amd64" - - "mondoo/{{ .ProjectName }}:latest-ubi-amd64" - build_flag_templates: - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=root" - - use: buildx - goos: linux - goarch: arm64 - dockerfile: Dockerfile-ubi - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-arm64" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-arm64" - - "mondoo/{{ .ProjectName }}:latest-ubi-arm64" - build_flag_templates: - - "--platform=linux/arm64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=root" - # Standard containers - - use: buildx - goos: linux - goarch: amd64 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-amd64" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-amd64" - - "mondoo/{{ .ProjectName }}:latest-amd64" - build_flag_templates: - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=root" - - use: buildx - goos: linux - goarch: arm64 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-arm64v8" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-arm64v8" - - "mondoo/{{ .ProjectName }}:latest-arm64v8" - build_flag_templates: - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=root" - - use: buildx - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-armv6" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-armv6" - - "mondoo/{{ .ProjectName }}:latest-armv6" - build_flag_templates: - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=root" - - use: buildx - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-armv7" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-armv7" - - "mondoo/{{ .ProjectName }}:latest-armv7" - build_flag_templates: - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=root" - # Rootless - # UBI containers - - use: buildx - goos: linux - goarch: amd64 - dockerfile: Dockerfile-ubi - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-amd64-rootless" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-amd64-rootless" - - "mondoo/{{ .ProjectName }}:latest-ubi-amd64-rootless" - build_flag_templates: - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=rootless" - - use: buildx - goos: linux - goarch: arm64 - dockerfile: Dockerfile-ubi - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-arm64-rootless" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-arm64-rootless" - - "mondoo/{{ .ProjectName }}:latest-ubi-arm64-rootless" - build_flag_templates: - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=rootless" - # Standard containers - - use: buildx - goos: linux - goarch: amd64 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-amd64-rootless" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-amd64-rootless" - - "mondoo/{{ .ProjectName }}:latest-amd64-rootless" - build_flag_templates: - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=rootless" - - use: buildx - goos: linux - goarch: arm64 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-arm64v8-rootless" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-arm64v8-rootless" - - "mondoo/{{ .ProjectName }}:latest-arm64v8-rootless" - build_flag_templates: - - "--platform=linux/arm64/v8" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=rootless" - - use: buildx - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-armv6-rootless" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-armv6-rootless" - - "mondoo/{{ .ProjectName }}:latest-armv6-rootless" - build_flag_templates: - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=rootless" - - use: buildx - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "mondoo/{{ .ProjectName }}:{{ .Version }}-armv7-rootless" - - "mondoo/{{ .ProjectName }}:{{ .Major }}-armv7-rootless" - - "mondoo/{{ .ProjectName }}:latest-armv7-rootless" - build_flag_templates: - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.title={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--target=rootless" -docker_manifests: # https://goreleaser.com/customization/docker_manifest/ - # UBI containers - - name_template: mondoo/{{ .ProjectName }}:{{ .Version }}-ubi - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-amd64 - - mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-arm64 - - name_template: mondoo/{{ .ProjectName }}:{{ .Major }}-ubi - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-amd64 - - mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-arm64 - - name_template: mondoo/{{ .ProjectName }}:latest - image_templates: - - mondoo/{{ .ProjectName }}:latest-amd64 - - mondoo/{{ .ProjectName }}:latest-arm64v8 - - mondoo/{{ .ProjectName }}:latest-armv6 - - mondoo/{{ .ProjectName }}:latest-armv7 - # Standard containers - - name_template: mondoo/{{ .ProjectName }}:{{ .Version }} - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Version }}-amd64 - - mondoo/{{ .ProjectName }}:{{ .Version }}-arm64v8 - - mondoo/{{ .ProjectName }}:{{ .Version }}-armv6 - - mondoo/{{ .ProjectName }}:{{ .Version }}-armv7 - - name_template: mondoo/{{ .ProjectName }}:{{ .Major }} - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Major }}-amd64 - - mondoo/{{ .ProjectName }}:{{ .Major }}-arm64v8 - - mondoo/{{ .ProjectName }}:{{ .Major }}-armv6 - - mondoo/{{ .ProjectName }}:{{ .Major }}-armv7 - - name_template: mondoo/{{ .ProjectName }}:latest - image_templates: - - mondoo/{{ .ProjectName }}:latest-amd64 - - mondoo/{{ .ProjectName }}:latest-arm64v8 - - mondoo/{{ .ProjectName }}:latest-armv6 - - mondoo/{{ .ProjectName }}:latest-armv7 - # Rootless - # UBI containers - - name_template: mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-rootless - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-amd64-rootless - - mondoo/{{ .ProjectName }}:{{ .Version }}-ubi-arm64-rootless - - name_template: mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-rootless - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-amd64-rootless - - mondoo/{{ .ProjectName }}:{{ .Major }}-ubi-arm64-rootless - - name_template: mondoo/{{ .ProjectName }}:latest-ubi-rootless - image_templates: - - mondoo/{{ .ProjectName }}:latest-ubi-amd64-rootless - - mondoo/{{ .ProjectName }}:latest-ubi-arm64-rootless - # Standard containers - - name_template: mondoo/{{ .ProjectName }}:{{ .Version }}-rootless - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Version }}-amd64-rootless - - mondoo/{{ .ProjectName }}:{{ .Version }}-arm64v8-rootless - - mondoo/{{ .ProjectName }}:{{ .Version }}-armv6-rootless - - mondoo/{{ .ProjectName }}:{{ .Version }}-armv7-rootless - - name_template: mondoo/{{ .ProjectName }}:{{ .Major }}-rootless - image_templates: - - mondoo/{{ .ProjectName }}:{{ .Major }}-amd64-rootless - - mondoo/{{ .ProjectName }}:{{ .Major }}-arm64v8-rootless - - mondoo/{{ .ProjectName }}:{{ .Major }}-armv6-rootless - - mondoo/{{ .ProjectName }}:{{ .Major }}-armv7-rootless - - name_template: mondoo/{{ .ProjectName }}:latest-rootless - image_templates: - - mondoo/{{ .ProjectName }}:latest-amd64-rootless - - mondoo/{{ .ProjectName }}:latest-arm64v8-rootless - - mondoo/{{ .ProjectName }}:latest-armv6-rootless - - mondoo/{{ .ProjectName }}:latest-armv7-rootless diff --git a/.vscode/launch.json b/.vscode/launch.json index b1de9a30d4..f6ede22b03 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,9 +9,17 @@ "type": "go", "request": "attach", "mode": "remote", + "debugAdapter": "dlv-dap", "remotePath": "${workspaceFolder}", - "port": 2345, - "host": "127.0.0.1" + "port": 12345, + "host": "34.78.60.75", + "substitutePath":[ + { + "from": "${workspaceFolder}", + "to": "/home/christian/workspace/cnquery" + } + ] + ] }, { "name": "Launch Package", diff --git a/_motor/providers/os/snapshot/localcmd.go b/_motor/providers/os/snapshot/localcmd.go deleted file mode 100644 index 54048b2c7c..0000000000 --- a/_motor/providers/os/snapshot/localcmd.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Mondoo, Inc. -// SPDX-License-Identifier: BUSL-1.1 - -package snapshot - -import ( - "go.mondoo.com/cnquery/motor/providers/os" - "go.mondoo.com/cnquery/motor/providers/os/cmd" -) - -type LocalCommandRunner struct { - shell []string -} - -func (r *LocalCommandRunner) RunCommand(command string) (*os.Command, error) { - c := cmd.CommandRunner{Shell: r.shell} - args := []string{} - - res, err := c.Exec(command, args) - return res, err -} diff --git a/apps/cnquery/cmd/plugin.go b/apps/cnquery/cmd/plugin.go index 08fad1c467..a83e6f5218 100644 --- a/apps/cnquery/cmd/plugin.go +++ b/apps/cnquery/cmd/plugin.go @@ -16,6 +16,7 @@ import ( "go.mondoo.com/cnquery/mqlc" "go.mondoo.com/cnquery/mqlc/parser" "go.mondoo.com/cnquery/providers" + "go.mondoo.com/cnquery/providers-sdk/v1/inventory" pp "go.mondoo.com/cnquery/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/providers-sdk/v1/upstream" "go.mondoo.com/cnquery/shared" @@ -78,13 +79,21 @@ func (c *cnqueryPlugin) RunQuery(conf *run.RunQueryConfig, runtime *providers.Ru return nil } - err := runtime.Connect(&pp.ConnectReq{ - Features: config.Features, - Asset: conf.Inventory.Spec.Assets[0], - Upstream: nil, - }) - if err != nil { - return err + assetList := []*inventory.Asset{} + assetList = append(assetList, conf.Inventory.Spec.Assets...) + + if conf.Inventory.Spec.Assets[0].Connections[0].Discover != nil { + err := runtime.Connect(&pp.ConnectReq{ + Features: config.Features, + Asset: conf.Inventory.Spec.Assets[0], + Upstream: nil, + }) + if err != nil { + return err + } + if runtime.Provider.Connection.Inventory != nil { + assetList = append(assetList, runtime.Provider.Connection.Inventory.Spec.Assets...) + } } if conf.Format == "json" { diff --git a/apps/provider-scaffold/template/provider/provider.go.template b/apps/provider-scaffold/template/provider/provider.go.template index 269eeac962..96796326fa 100644 --- a/apps/provider-scaffold/template/provider/provider.go.template +++ b/apps/provider-scaffold/template/provider/provider.go.template @@ -3,6 +3,7 @@ package provider import ( "errors" "strconv" + "context" "go.mondoo.com/cnquery/llx" "go.mondoo.com/cnquery/providers-sdk/v1/inventory" @@ -72,7 +73,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers-sdk/v1/plugin/interface.go b/providers-sdk/v1/plugin/interface.go index 5d99653215..aea096b5c3 100644 --- a/providers-sdk/v1/plugin/interface.go +++ b/providers-sdk/v1/plugin/interface.go @@ -32,7 +32,7 @@ type ProviderCallback interface { type ProviderPlugin interface { ParseCLI(req *ParseCLIReq) (*ParseCLIRes, error) Connect(req *ConnectReq, callback ProviderCallback) (*ConnectRes, error) - Shutdown(req *ShutdownReq) (*ShutdownRes, error) + Shutdown(ctx context.Context, req *ShutdownReq) (*ShutdownRes, error) GetData(req *DataReq) (*DataRes, error) StoreData(req *StoreReq) (*StoreRes, error) } diff --git a/providers/arista/provider/provider.go b/providers/arista/provider/provider.go index 1118f41f23..95f021ff77 100644 --- a/providers/arista/provider/provider.go +++ b/providers/arista/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "net/url" "strconv" @@ -112,7 +113,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/azure/provider/provider.go b/providers/azure/provider/provider.go index 3e17a6f662..f54b9c43ec 100644 --- a/providers/azure/provider/provider.go +++ b/providers/azure/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "strconv" "strings" @@ -134,7 +135,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/builtin.go b/providers/builtin.go index b05114897a..5b09f88189 100644 --- a/providers/builtin.go +++ b/providers/builtin.go @@ -17,8 +17,10 @@ import ( "go.mondoo.com/cnquery/providers-sdk/v1/resources" coreconf "go.mondoo.com/cnquery/providers/core/config" core "go.mondoo.com/cnquery/providers/core/provider" - // osconf "go.mondoo.com/cnquery/providers/os/config" - // os "go.mondoo.com/cnquery/providers/os/provider" + gcpconf "go.mondoo.com/cnquery/providers/gcp/config" + gcp "go.mondoo.com/cnquery/providers/gcp/provider" + osconf "go.mondoo.com/cnquery/providers/os/config" + os "go.mondoo.com/cnquery/providers/os/provider" ) var BuiltinCoreID = coreconf.Config.ID @@ -26,8 +28,11 @@ var BuiltinCoreID = coreconf.Config.ID //go:embed core/resources/core.resources.json var coreInfo []byte -// //go:embed os/resources/os.resources.json -// var osInfo []byte +//go:embed os/resources/os.resources.json +var osInfo []byte + +//go:embed gcp.resources.json +var gcpInfo []byte // //go:embed network/resources/network.resources.json // var networkInfo []byte @@ -49,16 +54,27 @@ var builtinProviders = map[string]*builtinProvider{ }, Config: &coreconf.Config, }, - // osconf.Config.ID: { - // Runtime: &RunningProvider{ - // Name: osconf.Config.Name, - // ID: osconf.Config.ID, - // Plugin: os.Init(), - // Schema: MustLoadSchema("os", osInfo), - // isClosed: false, - // }, - // Config: &osconf.Config, - // }, + osconf.Config.ID: { + Runtime: &RunningProvider{ + Name: osconf.Config.Name, + ID: osconf.Config.ID, + Plugin: os.Init(), + Schema: MustLoadSchema("os", osInfo), + isClosed: false, + }, + Config: &osconf.Config, + }, + gcpconf.Config.ID: { + Runtime: &RunningProvider{ + Name: gcpconf.Config.Name, + ID: gcpconf.Config.ID, + Plugin: gcp.Init(), + Schema: MustLoadSchema("gcp", gcpInfo), + isClosed: false, + }, + Config: &gcpconf.Config, + }, + // networkconf.Config.ID: { // Runtime: &RunningProvider{ // Name: networkconf.Config.Name, diff --git a/providers/core/provider/provider.go b/providers/core/provider/provider.go index 083269902e..6c85bf165f 100644 --- a/providers/core/provider/provider.go +++ b/providers/core/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "strconv" "strings" @@ -72,7 +73,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/equinix/provider/provider.go b/providers/equinix/provider/provider.go index 5d629d3f3a..8ab8eaabec 100644 --- a/providers/equinix/provider/provider.go +++ b/providers/equinix/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "os" "strconv" @@ -104,7 +105,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/gcp/config/config.go b/providers/gcp/config/config.go index 616f611ff8..fff111d3be 100644 --- a/providers/gcp/config/config.go +++ b/providers/gcp/config/config.go @@ -5,15 +5,19 @@ package config import ( "go.mondoo.com/cnquery/providers-sdk/v1/plugin" + "go.mondoo.com/cnquery/providers/gcp/connection/gcpinstancesnapshot" "go.mondoo.com/cnquery/providers/gcp/provider" "go.mondoo.com/cnquery/providers/gcp/resources" ) var Config = plugin.Provider{ - Name: "gcp", - ID: "go.mondoo.com/cnquery/providers/gcp", - Version: "9.0.0", - ConnectionTypes: []string{provider.ConnectionType}, + Name: "gcp", + ID: "go.mondoo.com/cnquery/providers/gcp", + Version: "9.0.0", + ConnectionTypes: []string{ + provider.ConnectionType, + string(gcpinstancesnapshot.SnapshotConnectionType), + }, Connectors: []plugin.Connector{ { Name: "gcp", @@ -41,6 +45,18 @@ var Config = plugin.Provider{ Default: "", Desc: "The path to the service account credentials to access the APIs with", }, + { + Long: "project-id", + Type: plugin.FlagType_String, + Default: "", + Desc: "specify the GCP project ID where the target instance is located (only used for snapshots)", + }, + { + Long: "zone", + Type: plugin.FlagType_String, + Default: "", + Desc: "specify the GCP zone where the target instance is located (only used for snapshots)", + }, }, }, }, diff --git a/providers/gcp/connection/connection.go b/providers/gcp/connection/connection.go index 2ed80d7580..ea003b7cf4 100644 --- a/providers/gcp/connection/connection.go +++ b/providers/gcp/connection/connection.go @@ -5,10 +5,16 @@ package connection import ( "errors" + "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/providers-sdk/v1/vault" + "go.mondoo.com/cnquery/providers/gcp/connection/shared" +) + +const ( + Gcp shared.ConnectionType = "gcp" ) type ResourceType int @@ -18,6 +24,7 @@ const ( Project Organization Folder + Snapshot ) type GcpConnection struct { @@ -47,10 +54,7 @@ func NewGcpConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) cred = conf.Credentials[0] } if conf.Type == "gcp" { - // FIXME: DEPRECATED, update in v8.0 vv - // The options "project" and "organization" have been deprecated in favor of project-id and organization-id - if conf.Options == nil || (conf.Options["project-id"] == "" && conf.Options["project"] == "" && conf.Options["organization-id"] == "" && conf.Options["organization"] == "" && conf.Options["folder-id"] == "") { - // ^^ + if conf.Options == nil || (conf.Options["project-id"] == "" && conf.Options["organization-id"] == "" && conf.Options["folder-id"] == "") { return nil, errors.New("google provider requires a gcp organization id, gcp project id or google workspace customer id. please set option `project-id` or `organization-id` or `customer-id` or `folder-id`") } } else { @@ -59,24 +63,18 @@ func NewGcpConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) var resourceType ResourceType var resourceID string - if conf.Options["project-id"] != "" { + if conf.Options["project-id"] != "" && conf.Options["snapshot-name"] == "" { resourceType = Project resourceID = conf.Options["project-id"] - - // FIXME: DEPRECATED, remove in v8.0 vv - // The options "project" and "organization" have been deprecated in favor of project-id and organization-id - } else if conf.Options["project"] != "" { - resourceType = Project - resourceID = conf.Options["project"] - // ^^ - } else if conf.Options["organization-id"] != "" { resourceType = Organization resourceID = conf.Options["organization-id"] - } else if conf.Options["folder-id"] != "" { resourceType = Folder resourceID = conf.Options["folder-id"] + } else if conf.Options["snapshot-name"] != "" { + resourceType = Snapshot + resourceID = conf.Options["snapshot-name"] } var override string @@ -119,3 +117,11 @@ func (c *GcpConnection) ID() uint32 { func (c *GcpConnection) Asset() *inventory.Asset { return c.asset } + +func (c *GcpConnection) Type() shared.ConnectionType { + return Gcp +} + +func (c *GcpConnection) Config() *inventory.Config { + return c.Conf +} diff --git a/_motor/providers/gcpinstancesnapshot/platform.go b/providers/gcp/connection/gcpinstancesnapshot/platform.go similarity index 100% rename from _motor/providers/gcpinstancesnapshot/platform.go rename to providers/gcp/connection/gcpinstancesnapshot/platform.go diff --git a/_motor/providers/gcpinstancesnapshot/provider.go b/providers/gcp/connection/gcpinstancesnapshot/provider.go similarity index 63% rename from _motor/providers/gcpinstancesnapshot/provider.go rename to providers/gcp/connection/gcpinstancesnapshot/provider.go index 2d7b47a757..45f14c8c3b 100644 --- a/_motor/providers/gcpinstancesnapshot/provider.go +++ b/providers/gcp/connection/gcpinstancesnapshot/provider.go @@ -9,24 +9,17 @@ import ( "github.com/cockroachdb/errors" "github.com/rs/zerolog/log" - "go.mondoo.com/cnquery/motor/motorid/gce" - "go.mondoo.com/cnquery/motor/platform/detector" - "go.mondoo.com/cnquery/motor/providers" - "go.mondoo.com/cnquery/motor/providers/fs" - "go.mondoo.com/cnquery/motor/providers/local" - "go.mondoo.com/cnquery/motor/providers/os" - "go.mondoo.com/cnquery/motor/providers/os/snapshot" "go.mondoo.com/cnquery/mrn" + "go.mondoo.com/cnquery/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/providers/gcp/connection/shared" + "go.mondoo.com/cnquery/providers/os/connection" + "go.mondoo.com/cnquery/providers/os/connection/snapshot" + "go.mondoo.com/cnquery/providers/os/detector" + "go.mondoo.com/cnquery/providers/os/id/gce" "go.mondoo.com/ranger-rpc/codes" "go.mondoo.com/ranger-rpc/status" ) -var ( - _ providers.Instance = (*Provider)(nil) - _ providers.PlatformIdentifier = (*Provider)(nil) - _ os.OperatingSystemProvider = (*Provider)(nil) -) - type scanTarget struct { TargetType string ProjectID string @@ -35,6 +28,10 @@ type scanTarget struct { SnapshotName string } +const ( + SnapshotConnectionType shared.ConnectionType = "gcp-snapshot" +) + type scannerInstance struct { projectID string zone string @@ -46,23 +43,20 @@ type mountInfo struct { diskUrl string } -func determineScannerInstanceInfo() (*scannerInstance, error) { - localProvider, err := local.New() - if err != nil { - return nil, err - } - localProviderDetector := detector.New(localProvider) - pf, err := localProviderDetector.Platform() - if err != nil { - return nil, err +func determineScannerInstanceInfo(id uint32, conf *inventory.Config, asset *inventory.Asset) (*scannerInstance, error) { + // FIXME: need to pass conf + localConn := connection.NewLocalConnection(id, conf, asset) + pf, detected := detector.DetectOS(localConn) + if !detected { + return nil, errors.New("could not detect platform") } - scannerInstanceInfo, err := gce.Resolve(localProvider, pf) + scannerInstanceInfo, err := gce.Resolve(localConn, pf) if err != nil { - return nil, errors.New("gcp snapshot provider needs to run on a gcp instance") + return nil, errors.New("GCP snapshot provider must run from a GCP VM instance") } identity, err := scannerInstanceInfo.Identify() if err != nil { - return nil, errors.New("gcp snapshot provider needs to run on a gcp instance") + return nil, errors.New("GCP snapshot provider must run from a GCP VM instance") } instanceID := identity.PlatformMrn @@ -92,21 +86,21 @@ func determineScannerInstanceInfo() (*scannerInstance, error) { }, nil } -func ParseTarget(pCfg *providers.Config) scanTarget { +func ParseTarget(conf *inventory.Config) scanTarget { return scanTarget{ - TargetType: pCfg.Options["type"], - ProjectID: pCfg.Options["project-id"], - Zone: pCfg.Options["zone"], - InstanceName: pCfg.Options["instance-name"], - SnapshotName: pCfg.Options["snapshot-name"], + TargetType: conf.Options["type"], + ProjectID: conf.Options["project-id"], + Zone: conf.Options["zone"], + InstanceName: conf.Options["instance-name"], + SnapshotName: conf.Options["snapshot-name"], } } -func New(pCfg *providers.Config) (*Provider, error) { - target := ParseTarget(pCfg) +func NewGcpSnapshotConnection(id uint32, conf *inventory.Config, asset *inventory.Asset) (*GcpSnapshotConnection, error) { + target := ParseTarget(conf) // check if we run on a gcp instance - scanner, err := determineScannerInstanceInfo() + scanner, err := determineScannerInstanceInfo(id, conf, asset) if err != nil { return nil, err } @@ -132,7 +126,7 @@ func New(pCfg *providers.Config) (*Provider, error) { return nil, fmt.Errorf("could not find boot disk for instance %s", target.InstanceName) } - if pCfg.Options["create-snapshot"] != "true" { + if conf.Options["create-snapshot"] != "true" { // search for the latest snapshot for this machine snapshotUrl, created, err := sc.searchLatestSnapshot(target.ProjectID, instanceInfo.BootDiskSourceURL) if status.Code(err) == codes.NotFound { @@ -215,35 +209,48 @@ func New(pCfg *providers.Config) (*Provider, error) { return nil, err } + conf.Options["path"] = volumeMounter.ScanDir // create and initialize fs provider - fsProvider, err := fs.New(&providers.Config{ + fsConn, err := connection.NewFileSystemConnection(id, &inventory.Config{ Path: volumeMounter.ScanDir, - Backend: providers.ProviderType_FS, - PlatformId: pCfg.PlatformId, - Options: pCfg.Options, - }) + Backend: "fs", + PlatformId: conf.PlatformId, + Options: conf.Options, + }, asset) if err != nil { errorHandler() return nil, err } - p := &Provider{ - Provider: fsProvider, - opts: pCfg.Options, - targetType: target.TargetType, - volumeMounter: volumeMounter, - snapshotCreator: sc, - target: target, - scanner: *scanner, - mountInfo: mi, - identifier: pCfg.PlatformId, + c := &GcpSnapshotConnection{ + FileSystemConnection: fsConn, + opts: conf.Options, + targetType: target.TargetType, + volumeMounter: volumeMounter, + snapshotCreator: sc, + target: target, + scanner: *scanner, + mountInfo: mi, + identifier: conf.PlatformId, } - return p, nil + var ok bool + asset.Platform, ok = detector.DetectOS(fsConn) + if !ok { + return nil, errors.New("failed to detect OS") + } + asset.Id = conf.Type + asset.Name = conf.Options["snapshot-name"] + asset.Platform.Kind = c.Kind() + asset.Platform.Runtime = c.Runtime() + platformId := fmt.Sprintf("//platformid.api.mondoo.app/runtime/gcp/compute/v1/projects/%s/snapshots/%s", conf.Options["project-id"], conf.Options["snapshot-name"]) + asset.PlatformIds = []string{platformId} + + return c, nil } -type Provider struct { - *fs.Provider +type GcpSnapshotConnection struct { + *connection.FileSystemConnection opts map[string]string // the type of object we're targeting (instance, disk, snapshot) targetType string @@ -255,60 +262,62 @@ type Provider struct { identifier string } -func (p *Provider) Close() { - if p == nil { +func (c *GcpSnapshotConnection) Close() { + log.Debug().Msg("closing gcp snapshot connection") + if c == nil { return } - if p.opts != nil { - if p.opts[snapshot.NoSetup] == "true" { + if c.opts != nil { + if c.opts[snapshot.NoSetup] == "true" { return } } - err := p.volumeMounter.UnmountVolumeFromInstance() + err := c.volumeMounter.UnmountVolumeFromInstance() if err != nil { log.Error().Err(err).Msg("unable to unmount volume") } - if p.snapshotCreator != nil { - err = p.snapshotCreator.detachDisk(p.scanner.projectID, p.scanner.zone, p.scanner.instanceName, p.mountInfo.deviceName) + if c.snapshotCreator != nil { + err = c.snapshotCreator.detachDisk(c.scanner.projectID, c.scanner.zone, c.scanner.instanceName, c.mountInfo.deviceName) if err != nil { log.Error().Err(err).Msg("unable to detach volume") } - err = p.snapshotCreator.deleteCreatedDisk(p.mountInfo.diskUrl) + err = c.snapshotCreator.deleteCreatedDisk(c.mountInfo.diskUrl) if err != nil { log.Error().Err(err).Msg("could not delete created disk") } } - err = p.volumeMounter.RemoveTempScanDir() + err = c.volumeMounter.RemoveTempScanDir() if err != nil { log.Error().Err(err).Msg("unable to remove dir") } } -func (p *Provider) Capabilities() providers.Capabilities { - return providers.Capabilities{ - providers.Capability_Aws_Ebs, - } +func (c *GcpSnapshotConnection) Capabilities() shared.Capabilities { + // FIXME: this looks strange in a gcp package, but it's C&P from v8 + return shared.Capability_Aws_Ebs } -func (p *Provider) Kind() providers.Kind { - return providers.Kind_KIND_API +func (c *GcpSnapshotConnection) Kind() string { + return "api" } -func (p *Provider) Runtime() string { - return providers.RUNTIME_GCP_COMPUTE +func (c *GcpSnapshotConnection) Runtime() string { + return "gcp-vm" } -func (p *Provider) PlatformIdDetectors() []providers.PlatformIdDetector { - return []providers.PlatformIdDetector{ - providers.TransportPlatformIdentifierDetector, - } +func (c *GcpSnapshotConnection) Identifier() (string, error) { + return c.identifier, nil +} + +func (c *GcpSnapshotConnection) Type() shared.ConnectionType { + return SnapshotConnectionType } -func (p *Provider) Identifier() (string, error) { - return p.identifier, nil +func (c *GcpSnapshotConnection) Config() *inventory.Config { + return c.FileSystemConnection.Conf } diff --git a/_motor/providers/gcpinstancesnapshot/snapshot.go b/providers/gcp/connection/gcpinstancesnapshot/snapshot.go similarity index 90% rename from _motor/providers/gcpinstancesnapshot/snapshot.go rename to providers/gcp/connection/gcpinstancesnapshot/snapshot.go index 0ceca4536a..caf48f13f1 100644 --- a/_motor/providers/gcpinstancesnapshot/snapshot.go +++ b/providers/gcp/connection/gcpinstancesnapshot/snapshot.go @@ -12,7 +12,7 @@ import ( "time" "github.com/rs/zerolog/log" - "go.mondoo.com/cnquery/motor/motorid/gce" + "go.mondoo.com/cnquery/providers/os/id/gce" "go.mondoo.com/ranger-rpc/codes" "go.mondoo.com/ranger-rpc/status" googleoauth "golang.org/x/oauth2/google" @@ -206,7 +206,12 @@ func (sc *SnapshotCreator) createDisk(disk *compute.Disk, projectID, zone, diskN } if operation.Status == "DONE" { if operation.Error != nil { - return clonedDiskUrl, fmt.Errorf("operation failed: %+v", operation.Error.Errors) + errMessage, _ := operation.Error.MarshalJSON() + log.Debug().Str("error", string(errMessage)).Msg("operation failed") + if len(operation.Error.Errors) > 0 { + errMessage = []byte(operation.Error.Errors[0].Message) + } + return clonedDiskUrl, fmt.Errorf("create disk failed: %s", errMessage) } clonedDiskUrl = operation.TargetLink break @@ -267,7 +272,12 @@ func (sc *SnapshotCreator) attachDisk(projectID, zone, instanceName, sourceDiskU } if operation.Status == "DONE" { if operation.Error != nil { - return fmt.Errorf("operation failed: %+v", operation.Error.Errors) + errMessage, _ := operation.Error.MarshalJSON() + log.Debug().Str("error", string(errMessage)).Msg("operation failed") + if len(operation.Error.Errors) > 0 { + errMessage = []byte(operation.Error.Errors[0].Message) + } + return fmt.Errorf("attach disk failed: %s", errMessage) } break } @@ -284,7 +294,7 @@ func (sc *SnapshotCreator) detachDisk(projectID, zone, instanceName, deviceName return err } - // attach the disk to the instance + // detach the disk from the instance op, err := computeService.Instances.DetachDisk(projectID, zone, instanceName, deviceName).Context(ctx).Do() if err != nil { return err @@ -298,7 +308,12 @@ func (sc *SnapshotCreator) detachDisk(projectID, zone, instanceName, deviceName } if operation.Status == "DONE" { if operation.Error != nil { - return fmt.Errorf("operation failed: %+v", operation.Error.Errors) + errMessage, _ := operation.Error.MarshalJSON() + log.Debug().Str("error", string(errMessage)).Msg("operation failed") + if len(operation.Error.Errors) > 0 { + errMessage = []byte(operation.Error.Errors[0].Message) + } + return fmt.Errorf("detach disk failed: %s", errMessage) } break } diff --git a/_motor/providers/gcpinstancesnapshot/snapshot_debug_test.go b/providers/gcp/connection/gcpinstancesnapshot/snapshot_debug_test.go similarity index 100% rename from _motor/providers/gcpinstancesnapshot/snapshot_debug_test.go rename to providers/gcp/connection/gcpinstancesnapshot/snapshot_debug_test.go diff --git a/_motor/providers/gcpinstancesnapshot/snapshot_test.go b/providers/gcp/connection/gcpinstancesnapshot/snapshot_test.go similarity index 100% rename from _motor/providers/gcpinstancesnapshot/snapshot_test.go rename to providers/gcp/connection/gcpinstancesnapshot/snapshot_test.go diff --git a/providers/gcp/connection/shared/shared.go b/providers/gcp/connection/shared/shared.go new file mode 100644 index 0000000000..e8ddba915f --- /dev/null +++ b/providers/gcp/connection/shared/shared.go @@ -0,0 +1,24 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package shared + +import ( + "go.mondoo.com/cnquery/providers-sdk/v1/inventory" +) + +type ConnectionType string + +type GcpConnection interface { + ID() uint32 + Name() string + Type() ConnectionType + Config() *inventory.Config + Asset() *inventory.Asset +} + +type Capabilities byte + +const ( + Capability_Aws_Ebs Capabilities = 1 << iota +) diff --git a/providers/gcp/go.mod b/providers/gcp/go.mod index b57a65683d..e1f7a5bb23 100644 --- a/providers/gcp/go.mod +++ b/providers/gcp/go.mod @@ -20,10 +20,12 @@ require ( cloud.google.com/go/run v1.2.0 cloud.google.com/go/serviceusage v1.7.1 github.com/aws/smithy-go v1.14.2 + github.com/cockroachdb/errors v1.9.1 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/rs/zerolog v1.30.0 github.com/stretchr/testify v1.8.4 go.mondoo.com/cnquery v0.0.0-00010101000000-000000000000 + go.mondoo.com/ranger-rpc v0.0.0-20230328135530-12135c17095f golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea golang.org/x/oauth2 v0.11.0 google.golang.org/api v0.138.0 @@ -34,17 +36,44 @@ require ( require ( cloud.google.com/go v0.110.6 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Masterminds/semver v1.5.0 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect github.com/andybalholm/brotli v1.0.4 // indirect github.com/apache/arrow/go/v12 v12.0.0 // indirect github.com/apache/thrift v0.16.0 // indirect + github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect + github.com/aws/aws-sdk-go-v2/config v1.18.37 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.13.35 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect + github.com/aws/aws-sdk-go-v2/service/ec2 v1.92.1 // indirect + github.com/aws/aws-sdk-go-v2/service/ec2instanceconnect v1.15.6 // indirect + github.com/aws/aws-sdk-go-v2/service/ecr v1.19.5 // indirect + github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.17.5 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect + github.com/aws/aws-sdk-go-v2/service/ssm v1.36.0 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 // indirect + github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20230823232655-ce48fc331ac7 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect github.com/cockroachdb/redact v1.1.3 // indirect + github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/docker/cli v24.0.0+incompatible // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/docker/docker v24.0.5+incompatible // indirect + github.com/docker/docker-credential-helpers v0.8.0 // indirect + github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/fatih/color v1.15.0 // indirect github.com/getsentry/sentry-go v0.13.0 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect github.com/goccy/go-json v0.9.11 // indirect github.com/gofrs/uuid v4.3.1+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -54,6 +83,7 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/flatbuffers v2.0.8+incompatible // indirect github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-containerregistry v0.16.1 // indirect github.com/google/s2a-go v0.1.5 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect @@ -61,10 +91,15 @@ require ( github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-plugin v1.4.8 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect + github.com/hnakamur/go-scp v1.0.2 // indirect github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/asmfmt v1.3.2 // indirect github.com/klauspost/compress v1.16.5 // indirect github.com/klauspost/cpuid/v2 v2.0.9 // indirect + github.com/kr/fs v0.1.0 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -73,19 +108,25 @@ require ( github.com/mattn/go-runewidth v0.0.14 // indirect github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/muesli/termenv v0.15.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc3 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/sftp v1.13.5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/segmentio/fasthash v1.0.3 // indirect github.com/segmentio/ksuid v1.0.4 // indirect + github.com/sethvargo/go-password v0.2.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.9.5 // indirect + github.com/vbatts/tar-split v0.11.3 // indirect github.com/zeebo/xxh3 v1.0.2 // indirect - go.mondoo.com/ranger-rpc v0.0.0-20230328135530-12135c17095f // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.12.0 // indirect golang.org/x/mod v0.10.0 // indirect diff --git a/providers/gcp/go.sum b/providers/gcp/go.sum index 6ee6f3f058..0e386bba22 100644 --- a/providers/gcp/go.sum +++ b/providers/gcp/go.sum @@ -71,7 +71,11 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMdUywE7VMo= @@ -79,7 +83,11 @@ github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c h1:RGWPOewvK github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= @@ -89,8 +97,47 @@ github.com/apache/arrow/go/v12 v12.0.0/go.mod h1:d+tV/eHZZ7Dz7RPrFKtPK02tpr+c9/P github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/aws/aws-sdk-go-v2 v1.17.7/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= +github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= +github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= +github.com/aws/aws-sdk-go-v2/config v1.18.37 h1:RNAfbPqw1CstCooHaTPhScz7z1PyocQj0UL+l95CgzI= +github.com/aws/aws-sdk-go-v2/config v1.18.37/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ= +github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8= +github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.31/go.mod h1:QT0BqUvX1Bh2ABdTGnjqEjvjzrCfIniM9Sc8zn9Yndo= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.25/go.mod h1:zBHOPwhBc3FlQjQJE/D3IfPWiWaQmT06Vq9aNukDo0k= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.92.1 h1:xn5CI639mnWvdiweqoRx/H221Ia9Asx9XxfIRhe0MPo= +github.com/aws/aws-sdk-go-v2/service/ec2 v1.92.1/go.mod h1:ZZLfkd1Y7fjXujjMg1CFqNmaTl314eCbShlHQO7VTWo= +github.com/aws/aws-sdk-go-v2/service/ec2instanceconnect v1.15.6 h1:KJnKe1kdcFBTroYoB9er25kadj+hdkuNb/s7WbdCnYU= +github.com/aws/aws-sdk-go-v2/service/ec2instanceconnect v1.15.6/go.mod h1:RCkBh2Z5n5/U74VwgoKB3jM7Bo9XzIT0bmnBL36LsY8= +github.com/aws/aws-sdk-go-v2/service/ecr v1.19.5 h1:hg2/a7rE9dwYr+/DPNzHQ+IsHXLNt1NsQVUecBtA8os= +github.com/aws/aws-sdk-go-v2/service/ecr v1.19.5/go.mod h1:pGwmNL8hN0jpBfKfTbmu+Rl0bJkDhaGl+9PQLrZ4KLo= +github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.17.5 h1:GCIkEQp+7Vt7NmBHB+/1qPYHl6Kg3L0Bg3DJ2v1Oi08= +github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.17.5/go.mod h1:uRNeiRoKCWT9aVtmX8mvUlDDgq+gmHLF6pGxVS7J6SY= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25/go.mod h1:/95IA+0lMnzW6XzqYJRpjjsAbKEORVeO0anQqjd2CNU= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= +github.com/aws/aws-sdk-go-v2/service/ssm v1.36.0 h1:L1gK0SF7Filotf8Jbhiq0Y+rKVs/W1av8MH0+AXPrAg= +github.com/aws/aws-sdk-go-v2/service/ssm v1.36.0/go.mod h1:nCdeJmEFby1HKwKhDdKdVxPOJQUNht7Ngw+ejzbzvDU= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0= +github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= +github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU= +github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.14.2 h1:MJU9hqBGbvWZdApzpvoF2WAIJDbtjK2NDJSiJP7HblQ= github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20230823232655-ce48fc331ac7 h1:Q9N/BxETE9cNhAA2EOIfl+VxTQScsNNBpC8536vwkJI= +github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20230823232655-ce48fc331ac7/go.mod h1:TfHDjqSwGGoCUCnvy2LBziYXrjh+G+GbdlPc4vbiENY= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= @@ -115,17 +162,34 @@ github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f/go.mod h1:Vz9D github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= +github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k= +github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/docker/cli v24.0.0+incompatible h1:0+1VshNwBQzQAx9lOl+OYCTCEAD8fKs/qeXMx3O0wqM= +github.com/docker/cli v24.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY= +github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker-credential-helpers v0.8.0 h1:YQFtbBQb4VrpoPxhFuzEBPQ9E16qz5SpHLS+uswaCp8= +github.com/docker/docker-credential-helpers v0.8.0/go.mod h1:UGFXcuoQ5TxPiB54nHOZ32AWRqQdECoh/Mg0AlEYb40= +github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -159,6 +223,10 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= @@ -228,6 +296,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-containerregistry v0.16.1 h1:rUEt426sR6nyrL3gt+18ibRcvYpKYdpsa5ZW7MA08dQ= +github.com/google/go-containerregistry v0.16.1/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= @@ -274,6 +344,10 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hnakamur/go-scp v1.0.2 h1:i2I0O0pjAaX4BXJFrp1blsIdjOBekc5QOaB0AbdO1d0= +github.com/hnakamur/go-scp v1.0.2/go.mod h1:Dh9GtPFBkiDI1KY1nmf+W7eVCWWmRjJitkCYgvWv+Zc= +github.com/hnakamur/go-sshd v0.0.0-20170228152141-dccc3399d26a h1:p8dbHRhXhPSwVZqk76FguLzyeCZuvCqFlaYSqXOzbyI= +github.com/hnakamur/go-sshd v0.0.0-20170228152141-dccc3399d26a/go.mod h1:R+6I3EdoV6ofbNqJsArhT9+Pnu57DxtmDJAQfxkCbGo= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -288,7 +362,9 @@ github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7Ua github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -302,6 +378,10 @@ github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYb github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4= @@ -313,12 +393,15 @@ github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -351,14 +434,17 @@ github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpsp github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 h1:+n/aFZefKZp7spd8DFdX7uMikMLXX4oubIzJF4kv/wI= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= @@ -371,6 +457,10 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.0-rc3 h1:fzg1mXZFj8YdPeNkRXMg+zb88BFV0Ys52cJydRwBkb8= +github.com/opencontainers/image-spec v1.1.0-rc3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= @@ -381,6 +471,8 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pkg/sftp v1.13.5 h1:a3RLUqkyjYRtBTZJZ1VRrKbN3zhuPLlUc3sphVz81go= +github.com/pkg/sftp v1.13.5/go.mod h1:wHDZ0IZX6JcBYRK1TH9bcVq8G7TLpVHYIGJRFnmPfxg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -398,6 +490,7 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM= @@ -405,7 +498,12 @@ github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KR github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c= github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sethvargo/go-password v0.2.0 h1:BTDl4CC/gjf/axHMaDQtw507ogrXLci6XRiLc7i/UHI= +github.com/sethvargo/go-password v0.2.0/go.mod h1:Ym4Mr9JXLBycr02MFuVQ/0JHidNetSgbzutTr3zsYXE= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= @@ -436,12 +534,15 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= +github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= +github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= @@ -480,9 +581,11 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= @@ -608,6 +711,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -625,6 +729,7 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200828081204-131dc92a58d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -638,14 +743,18 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -668,6 +777,7 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -866,6 +976,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/providers/gcp/provider/provider.go b/providers/gcp/provider/provider.go index 9455497af7..015713b4a8 100644 --- a/providers/gcp/provider/provider.go +++ b/providers/gcp/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "os" "strconv" @@ -16,10 +17,14 @@ import ( "go.mondoo.com/cnquery/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/providers-sdk/v1/upstream" "go.mondoo.com/cnquery/providers/gcp/connection" + "go.mondoo.com/cnquery/providers/gcp/connection/gcpinstancesnapshot" + "go.mondoo.com/cnquery/providers/gcp/connection/shared" "go.mondoo.com/cnquery/providers/gcp/resources" ) -const ConnectionType = "gcp" +const ( + ConnectionType = "gcp" +) type Service struct { runtimes map[uint32]*plugin.Runtime @@ -74,7 +79,7 @@ func (s *Service) ParseCLI(req *plugin.ParseCLIReq) (*plugin.ParseCLIRes, error) } if len(req.Args) != 2 { - return nil, errors.New("missing argument, use `gcp project id` or `gcp organization id` or `gcp folder id`") + return nil, errors.New("missing argument, use `gcp project id`, `gcp organization id`, `gcp folder id` or `gcp snapshot name`") } conf := &inventory.Config{ @@ -88,6 +93,18 @@ func (s *Service) ParseCLI(req *plugin.ParseCLIReq) (*plugin.ParseCLIRes, error) credentialsPath = string(x.Value) } + // these flags are currently only used for the snapshot sub-command + var projectId string + if x, ok := flags["project-id"]; ok && len(x.Value) != 0 { + projectId = string(x.Value) + } + + var zone string + if x, ok := flags["zone"]; ok && len(x.Value) != 0 { + zone = string(x.Value) + } + // ^^ snapshot flags + envVars := []string{ "GOOGLE_APPLICATION_CREDENTIALS", "GOOGLE_CREDENTIALS", @@ -102,19 +119,6 @@ func (s *Service) ParseCLI(req *plugin.ParseCLIReq) (*plugin.ParseCLIRes, error) }) } - switch req.Args[0] { - case "org": - conf.Options["organization-id"] = req.Args[1] - case "project": - conf.Options["project-id"] = req.Args[1] - case "folder": - conf.Options["folder-id"] = req.Args[1] - } - - asset := inventory.Asset{ - Connections: []*inventory.Config{conf}, - } - // parse discovery flags conf.Discover = &inventory.Discovery{ Targets: []string{}, @@ -128,6 +132,26 @@ func (s *Service) ParseCLI(req *plugin.ParseCLIReq) (*plugin.ParseCLIRes, error) conf.Discover.Targets = []string{resources.DiscoveryAuto} } + switch req.Args[0] { + case "org": + conf.Options["organization-id"] = req.Args[1] + case "project": + conf.Options["project-id"] = req.Args[1] + case "folder": + conf.Options["folder-id"] = req.Args[1] + case "snapshot": + conf.Options["snapshot-name"] = req.Args[1] + conf.Options["project-id"] = projectId + conf.Options["zone"] = zone + conf.Options["type"] = "snapshot" + conf.Type = string(gcpinstancesnapshot.SnapshotConnectionType) + conf.Discover = nil + } + + asset := inventory.Asset{ + Connections: []*inventory.Config{conf}, + } + return &plugin.ParseCLIRes{Asset: &asset}, nil } @@ -148,10 +172,13 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } } + var inventory *inventory.Inventory // discovery assets for further scanning - inventory, err := s.discover(conn) - if err != nil { - return nil, err + if conn.Config().Discover != nil { + inventory, err = s.discover(conn) + if err != nil { + return nil, err + } } return &plugin.ConnectRes{ @@ -165,21 +192,32 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { + for i := range s.runtimes { + runtime := s.runtimes[i] + sharedConn := runtime.Connection.(shared.GcpConnection) + if sharedConn.Type() == gcpinstancesnapshot.SnapshotConnectionType { + conn := runtime.Connection.(*gcpinstancesnapshot.GcpSnapshotConnection) + conn.Close() + } + } return &plugin.ShutdownRes{}, nil } -func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallback) (*connection.GcpConnection, error) { +func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallback) (shared.GcpConnection, error) { if len(req.Asset.Connections) == 0 { return nil, errors.New("no connection options for asset") } asset := req.Asset conf := asset.Connections[0] - var conn *connection.GcpConnection + var conn shared.GcpConnection var err error switch conf.Type { + case string(gcpinstancesnapshot.SnapshotConnectionType): + s.lastConnectionID++ + conn, err = gcpinstancesnapshot.NewGcpSnapshotConnection(s.lastConnectionID, conf, asset) default: s.lastConnectionID++ conn, err = connection.NewGcpConnection(s.lastConnectionID, asset, conf) @@ -209,25 +247,28 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba return conn, err } -func (s *Service) detect(asset *inventory.Asset, conn *connection.GcpConnection) error { +func (s *Service) detect(asset *inventory.Asset, conn shared.GcpConnection) error { // TODO: adjust asset detection - asset.Id = conn.Conf.Type - asset.Name = conn.Conf.Host + asset.Id = conn.Config().Type + asset.Name = conn.Config().Host - asset.Platform = &inventory.Platform{ - Name: "gcp", - Family: []string{"gcp"}, - Kind: "api", - Title: "GCP Cloud", + switch conn.Config().Type { + default: + asset.Platform = &inventory.Platform{ + Name: "gcp", + Family: []string{"gcp"}, + Kind: "api", + Title: "GCP Cloud", + } + // TODO: Add platform IDs + asset.PlatformIds = []string{"//platformid.api.mondoo.app/runtime/gcp/"} } - // TODO: Add platform IDs - asset.PlatformIds = []string{"//platformid.api.mondoo.app/runtime/gcp/"} return nil } -func (s *Service) discover(conn *connection.GcpConnection) (*inventory.Inventory, error) { - if conn.Conf.Discover == nil { +func (s *Service) discover(conn shared.GcpConnection) (*inventory.Inventory, error) { + if conn.Config().Discover == nil { return nil, nil } diff --git a/providers/github/provider/provider.go b/providers/github/provider/provider.go index 8818a8a020..ddebf64036 100644 --- a/providers/github/provider/provider.go +++ b/providers/github/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "os" "strconv" @@ -102,7 +103,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/gitlab/provider/provider.go b/providers/gitlab/provider/provider.go index 195cc7036a..f731f1ef98 100644 --- a/providers/gitlab/provider/provider.go +++ b/providers/gitlab/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "os" "strconv" @@ -99,7 +100,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/google-workspace/provider/provider.go b/providers/google-workspace/provider/provider.go index f81d57061e..f7ac1f65f2 100644 --- a/providers/google-workspace/provider/provider.go +++ b/providers/google-workspace/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "os" "strconv" @@ -155,7 +156,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/ipmi/provider/provider.go b/providers/ipmi/provider/provider.go index f01c0e542f..ab115a07bf 100644 --- a/providers/ipmi/provider/provider.go +++ b/providers/ipmi/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "net/url" "strconv" @@ -113,7 +114,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/k8s/provider/provider.go b/providers/k8s/provider/provider.go index 3351d73fa5..fc8b47283a 100644 --- a/providers/k8s/provider/provider.go +++ b/providers/k8s/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "strconv" "strings" @@ -127,7 +128,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/ms365/provider/provider.go b/providers/ms365/provider/provider.go index e4c740270a..800d0ac2d9 100644 --- a/providers/ms365/provider/provider.go +++ b/providers/ms365/provider/provider.go @@ -107,7 +107,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/network/provider/provider.go b/providers/network/provider/provider.go index 939ac8ef6d..800979ae9d 100644 --- a/providers/network/provider/provider.go +++ b/providers/network/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "net/url" "strconv" @@ -113,7 +114,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/oci/provider/provider.go b/providers/oci/provider/provider.go index fdefe3af50..059c9fe1de 100644 --- a/providers/oci/provider/provider.go +++ b/providers/oci/provider/provider.go @@ -132,7 +132,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/okta/provider/provider.go b/providers/okta/provider/provider.go index 188f3e5048..47291b57d3 100644 --- a/providers/okta/provider/provider.go +++ b/providers/okta/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "os" "strconv" @@ -112,7 +113,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/opcua/provider/provider.go b/providers/opcua/provider/provider.go index b47b92bc55..a443741faa 100644 --- a/providers/opcua/provider/provider.go +++ b/providers/opcua/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "strconv" "strings" @@ -88,7 +89,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/os/connection/filesystem.go b/providers/os/connection/filesystem.go index 96bd554e1b..9e30e6b7b8 100644 --- a/providers/os/connection/filesystem.go +++ b/providers/os/connection/filesystem.go @@ -35,7 +35,7 @@ func NewFileSystemConnectionWithClose(id uint32, conf *inventory.Config, assert return &FileSystemConnection{ id: id, - conf: conf, + Conf: conf, asset: assert, MountedDir: path, closeFN: closeFN, @@ -49,7 +49,7 @@ func NewFileSystemConnection(id uint32, conf *inventory.Config, assert *inventor type FileSystemConnection struct { id uint32 - conf *inventory.Config + Conf *inventory.Config asset *inventory.Asset MountedDir string diff --git a/providers/os/connection/local.go b/providers/os/connection/local.go index b7d7bd11dc..6187281fd0 100644 --- a/providers/os/connection/local.go +++ b/providers/os/connection/local.go @@ -77,7 +77,7 @@ func (p *LocalConnection) RunCommand(command string) (*shared.Command, error) { command = shared.BuildSudoCommand(p.Sudo, command) } log.Debug().Msgf("local> run command %s", command) - c := &commandRunner{Shell: p.shell} + c := &CommandRunner{Shell: p.shell} args := []string{} res, err := c.Exec(command, args) @@ -121,13 +121,13 @@ func (p *LocalConnection) Close() { // TODO: we need to close all commands and file handles } -type commandRunner struct { +type CommandRunner struct { shared.Command cmdExecutor *exec.Cmd Shell []string } -func (c *commandRunner) Exec(usercmd string, args []string) (*shared.Command, error) { +func (c *CommandRunner) Exec(usercmd string, args []string) (*shared.Command, error) { c.Command.Stats.Start = time.Now() var cmd string diff --git a/_motor/providers/os/snapshot/blockdevices.go b/providers/os/connection/snapshot/blockdevices.go similarity index 100% rename from _motor/providers/os/snapshot/blockdevices.go rename to providers/os/connection/snapshot/blockdevices.go diff --git a/_motor/providers/os/snapshot/blockdevices_test.go b/providers/os/connection/snapshot/blockdevices_test.go similarity index 100% rename from _motor/providers/os/snapshot/blockdevices_test.go rename to providers/os/connection/snapshot/blockdevices_test.go diff --git a/providers/os/connection/snapshot/localcmd.go b/providers/os/connection/snapshot/localcmd.go new file mode 100644 index 0000000000..1dbd5d0ebf --- /dev/null +++ b/providers/os/connection/snapshot/localcmd.go @@ -0,0 +1,21 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package snapshot + +import ( + "go.mondoo.com/cnquery/providers/os/connection" + "go.mondoo.com/cnquery/providers/os/connection/shared" +) + +type LocalCommandRunner struct { + shell []string +} + +func (r *LocalCommandRunner) RunCommand(command string) (*shared.Command, error) { + c := connection.CommandRunner{Shell: r.shell} + args := []string{} + + res, err := c.Exec(command, args) + return res, err +} diff --git a/_motor/providers/os/snapshot/mount_linux.go b/providers/os/connection/snapshot/mount_linux.go similarity index 100% rename from _motor/providers/os/snapshot/mount_linux.go rename to providers/os/connection/snapshot/mount_linux.go diff --git a/_motor/providers/os/snapshot/mount_other.go b/providers/os/connection/snapshot/mount_other.go similarity index 100% rename from _motor/providers/os/snapshot/mount_other.go rename to providers/os/connection/snapshot/mount_other.go diff --git a/_motor/providers/os/snapshot/testdata/rhel8.json b/providers/os/connection/snapshot/testdata/rhel8.json similarity index 100% rename from _motor/providers/os/snapshot/testdata/rhel8.json rename to providers/os/connection/snapshot/testdata/rhel8.json diff --git a/_motor/providers/os/snapshot/testdata/rhel8_nolabels.json b/providers/os/connection/snapshot/testdata/rhel8_nolabels.json similarity index 100% rename from _motor/providers/os/snapshot/testdata/rhel8_nolabels.json rename to providers/os/connection/snapshot/testdata/rhel8_nolabels.json diff --git a/_motor/providers/os/snapshot/volumemounter.go b/providers/os/connection/snapshot/volumemounter.go similarity index 96% rename from _motor/providers/os/snapshot/volumemounter.go rename to providers/os/connection/snapshot/volumemounter.go index 4f95054fb5..6d839eb017 100644 --- a/_motor/providers/os/snapshot/volumemounter.go +++ b/providers/os/connection/snapshot/volumemounter.go @@ -9,11 +9,10 @@ import ( "os" "strings" - "go.mondoo.com/cnquery/stringx" + "go.mondoo.com/cnquery/utils/stringx" "github.com/cockroachdb/errors" "github.com/rs/zerolog/log" - osProvider "go.mondoo.com/cnquery/motor/providers/os" ) const NoSetup = "no-setup" @@ -24,7 +23,7 @@ type VolumeMounter struct { // where we tell AWS to attach the volume; it doesn't necessarily get attached there, but we have to reference this same location when detaching VolumeAttachmentLoc string opts map[string]string - cmdRunner osProvider.CommandRunner + cmdRunner *LocalCommandRunner } func NewVolumeMounter(shell []string) *VolumeMounter { diff --git a/providers/os/provider/provider.go b/providers/os/provider/provider.go index e7ff99bd3b..1544ce67a3 100644 --- a/providers/os/provider/provider.go +++ b/providers/os/provider/provider.go @@ -225,7 +225,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/providers.go b/providers/providers.go index ac8bd5dee3..62300d76dc 100644 --- a/providers/providers.go +++ b/providers/providers.go @@ -156,6 +156,7 @@ func EnsureProvider(existing Providers, connectorName string, autoUpdate bool) ( upstream := DefaultProviders.ForConnection(connectorName) if upstream == nil { // we can't find any provider for this connector in our default set + // FIXME: This causes a panic in the CLI, we should handle this better return nil, nil } diff --git a/providers/slack/provider/provider.go b/providers/slack/provider/provider.go index 2b7988a90a..29d44de980 100644 --- a/providers/slack/provider/provider.go +++ b/providers/slack/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "os" "strconv" @@ -89,7 +90,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/terraform/provider/provider.go b/providers/terraform/provider/provider.go index 48705c275d..746d946c66 100644 --- a/providers/terraform/provider/provider.go +++ b/providers/terraform/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "strconv" "strings" @@ -119,7 +120,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/vcd/provider/provider.go b/providers/vcd/provider/provider.go index 24c76f9067..b3c679fefe 100644 --- a/providers/vcd/provider/provider.go +++ b/providers/vcd/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "fmt" "strconv" @@ -102,7 +103,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil } diff --git a/providers/vsphere/provider/provider.go b/providers/vsphere/provider/provider.go index 60684b56fb..b04f16ffd0 100644 --- a/providers/vsphere/provider/provider.go +++ b/providers/vsphere/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( + "context" "errors" "net/url" "strconv" @@ -115,7 +116,7 @@ func (s *Service) Connect(req *plugin.ConnectReq, callback plugin.ProviderCallba // Shutdown is automatically called when the shell closes. // It is not necessary to implement this method. // If you want to do some cleanup, you can do it here. -func (s *Service) Shutdown(req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { +func (s *Service) Shutdown(ctx context.Context, req *plugin.ShutdownReq) (*plugin.ShutdownRes, error) { return &plugin.ShutdownRes{}, nil }