From 28d6ede1cde0c86ce03c23930fff8e947fc9f117 Mon Sep 17 00:00:00 2001 From: Devang Date: Fri, 16 Jul 2021 12:01:15 +0530 Subject: [PATCH 1/3] kustomize version should be v4 --- pkg/iac-providers/kustomize.go | 8 +++---- .../kustomize/{v3 => v4}/load-dir.go | 4 ++-- .../kustomize/{v3 => v4}/load-dir_test.go | 22 +++++++++---------- .../kustomize/{v3 => v4}/load-file.go | 4 ++-- .../kustomize/{v3 => v4}/load-file_test.go | 6 ++--- .../erroneous-deployment/deployment.yaml | 0 .../erroneous-deployment/kustomization.yaml | 0 .../testdata/erroneous-pod/kustomization.yaml | 0 .../testdata/erroneous-pod/pod.yaml | 0 .../kustomize-file-empty/configMap.yaml | 0 .../kustomize-file-empty/deployment.yaml | 0 .../kustomize-file-empty/kustomization.yaml | 0 .../kustomize-file-empty/service.yaml | 0 .../multibases/base/kustomization.yaml | 0 .../testdata/multibases/base/pod.yaml | 0 .../multibases/dev/kustomization.yaml | 0 .../testdata/multibases/kustomization.yaml | 0 .../multibases/prod/kustomization.yaml | 0 .../multibases/stage/kustomization.yaml | 0 .../zero-violation-base/kustomization.yaml | 0 .../multibases/zero-violation-base/pod.yaml | 0 .../testdata/no-kustomizefile/configMap.yaml | 0 .../testdata/no-kustomizefile/deployment.yaml | 0 .../testdata/no-kustomizefile/service.yaml | 0 .../testdata/simple-deployment/configMap.yaml | 0 .../simple-deployment/deployment.yaml | 0 .../simple-deployment/kustomization.yaml | 0 .../testdata/simple-deployment/service.yaml | 0 .../kustomize/{v3 => v4}/types.go | 6 ++--- pkg/policy/kustomize.go | 2 +- pkg/policy/types.go | 1 + pkg/runtime/executor_test.go | 4 ++-- test/e2e/help/golden/help_scan.txt | 2 +- 33 files changed, 30 insertions(+), 29 deletions(-) rename pkg/iac-providers/kustomize/{v3 => v4}/load-dir.go (98%) rename pkg/iac-providers/kustomize/{v3 => v4}/load-dir_test.go (93%) rename pkg/iac-providers/kustomize/{v3 => v4}/load-file.go (86%) rename pkg/iac-providers/kustomize/{v3 => v4}/load-file_test.go (92%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/erroneous-deployment/deployment.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/erroneous-deployment/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/erroneous-pod/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/erroneous-pod/pod.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/kustomize-file-empty/configMap.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/kustomize-file-empty/deployment.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/kustomize-file-empty/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/kustomize-file-empty/service.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/base/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/base/pod.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/dev/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/prod/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/stage/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/zero-violation-base/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/multibases/zero-violation-base/pod.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/no-kustomizefile/configMap.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/no-kustomizefile/deployment.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/no-kustomizefile/service.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/simple-deployment/configMap.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/simple-deployment/deployment.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/simple-deployment/kustomization.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/testdata/simple-deployment/service.yaml (100%) rename pkg/iac-providers/kustomize/{v3 => v4}/types.go (89%) diff --git a/pkg/iac-providers/kustomize.go b/pkg/iac-providers/kustomize.go index e4e405a00..fbcdcc128 100644 --- a/pkg/iac-providers/kustomize.go +++ b/pkg/iac-providers/kustomize.go @@ -19,18 +19,18 @@ package iacprovider import ( "reflect" - kustomizev3 "github.com/accurics/terrascan/pkg/iac-providers/kustomize/v3" + kustomizev4 "github.com/accurics/terrascan/pkg/iac-providers/kustomize/v4" ) // kustomize specific constants const ( kustomize supportedIacType = "kustomize" - kustomizeV3 supportedIacVersion = "v3" - kustomizeDefaultIacVersion = kustomizeV3 + kustomizeV4 supportedIacVersion = "v4" + kustomizeDefaultIacVersion = kustomizeV4 ) // register kustomize as an IaC provider with terrascan func init() { // register iac provider - RegisterIacProvider(kustomize, kustomizeV3, kustomizeDefaultIacVersion, reflect.TypeOf(kustomizev3.KustomizeV3{})) + RegisterIacProvider(kustomize, kustomizeV4, kustomizeDefaultIacVersion, reflect.TypeOf(kustomizev4.KustomizeV4{})) } diff --git a/pkg/iac-providers/kustomize/v3/load-dir.go b/pkg/iac-providers/kustomize/v4/load-dir.go similarity index 98% rename from pkg/iac-providers/kustomize/v3/load-dir.go rename to pkg/iac-providers/kustomize/v4/load-dir.go index 5963b3a02..efb11711d 100644 --- a/pkg/iac-providers/kustomize/v3/load-dir.go +++ b/pkg/iac-providers/kustomize/v4/load-dir.go @@ -1,4 +1,4 @@ -package kustomizev3 +package kustomizev4 import ( "fmt" @@ -23,8 +23,8 @@ var ( ) // LoadIacDir loads the kustomize directory and returns the ResourceConfig mapping which is evaluated by the policy engine -func (k *KustomizeV3) LoadIacDir(absRootDir string, options map[string]interface{}) (output.AllResourceConfigs, error) { +func (k *KustomizeV4) LoadIacDir(absRootDir string, options map[string]interface{}) (output.AllResourceConfigs, error) { allResourcesConfig := make(map[string][]output.ResourceConfig) files, err := utils.FindFilesBySuffixInDir(absRootDir, KustomizeFileNames()) diff --git a/pkg/iac-providers/kustomize/v3/load-dir_test.go b/pkg/iac-providers/kustomize/v4/load-dir_test.go similarity index 93% rename from pkg/iac-providers/kustomize/v3/load-dir_test.go rename to pkg/iac-providers/kustomize/v4/load-dir_test.go index 8c515a722..3986cd1f6 100644 --- a/pkg/iac-providers/kustomize/v3/load-dir_test.go +++ b/pkg/iac-providers/kustomize/v4/load-dir_test.go @@ -1,4 +1,4 @@ -package kustomizev3 +package kustomizev4 import ( "fmt" @@ -23,7 +23,7 @@ func TestLoadIacDir(t *testing.T) { table := []struct { name string dirPath string - kustomize KustomizeV3 + kustomize KustomizeV4 want output.AllResourceConfigs wantErr error resourceCount int @@ -32,58 +32,58 @@ func TestLoadIacDir(t *testing.T) { { name: "invalid dirPath", dirPath: "not-there", - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, wantErr: multierror.Append(&os.PathError{Err: syscall.ENOENT, Op: "open", Path: "not-there"}), resourceCount: 0, }, { name: "simple-deployment", dirPath: filepath.Join(testDataDir, "simple-deployment"), - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, resourceCount: 4, }, { name: "multibases", dirPath: filepath.Join(multibasesDir, "base"), - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, resourceCount: 2, }, { name: "multibases", dirPath: filepath.Join(multibasesDir, "dev"), - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, resourceCount: 2, }, { name: "multibases", dirPath: filepath.Join(multibasesDir, "prod"), - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, resourceCount: 2, }, { name: "multibases", dirPath: filepath.Join(multibasesDir, "stage"), - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, resourceCount: 2, }, { name: "multibases", dirPath: multibasesDir, - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, resourceCount: 4, }, { name: "no-kustomize-directory", dirPath: filepath.Join(testDataDir, "no-kustomizefile"), - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, wantErr: multierror.Append(fmt.Errorf("kustomization.y(a)ml file not found in the directory %s", filepath.Join(testDataDir, "no-kustomizefile"))), resourceCount: 0, }, { name: "kustomize-file-empty", dirPath: filepath.Join(testDataDir, "kustomize-file-empty"), - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, wantErr: multierror.Append(fmt.Errorf("unable to read the kustomization file in the directory %s, error: yaml file is empty", filepath.Join(testDataDir, "kustomize-file-empty"))), resourceCount: 0, }, diff --git a/pkg/iac-providers/kustomize/v3/load-file.go b/pkg/iac-providers/kustomize/v4/load-file.go similarity index 86% rename from pkg/iac-providers/kustomize/v3/load-file.go rename to pkg/iac-providers/kustomize/v4/load-file.go index 02967d5c0..f6e2477fd 100644 --- a/pkg/iac-providers/kustomize/v3/load-file.go +++ b/pkg/iac-providers/kustomize/v4/load-file.go @@ -1,4 +1,4 @@ -package kustomizev3 +package kustomizev4 import ( "fmt" @@ -12,7 +12,7 @@ var ( ) // LoadIacFile is not supported for kustomize. Only loading directories that have kustomization.y(a)ml file are supported -func (k *KustomizeV3) LoadIacFile(absRootPath string, options map[string]interface{}) (allResourcesConfig output.AllResourceConfigs, err error) { +func (k *KustomizeV4) LoadIacFile(absRootPath string, options map[string]interface{}) (allResourcesConfig output.AllResourceConfigs, err error) { zap.S().Error(errLoadIacFileNotSupported) return make(map[string][]output.ResourceConfig), errLoadIacFileNotSupported } diff --git a/pkg/iac-providers/kustomize/v3/load-file_test.go b/pkg/iac-providers/kustomize/v4/load-file_test.go similarity index 92% rename from pkg/iac-providers/kustomize/v3/load-file_test.go rename to pkg/iac-providers/kustomize/v4/load-file_test.go index b46553898..25174dbe7 100644 --- a/pkg/iac-providers/kustomize/v3/load-file_test.go +++ b/pkg/iac-providers/kustomize/v4/load-file_test.go @@ -1,4 +1,4 @@ -package kustomizev3 +package kustomizev4 import ( "reflect" @@ -13,7 +13,7 @@ func TestLoadIacFile(t *testing.T) { name string filePath string options map[string]interface{} - kustomize KustomizeV3 + kustomize KustomizeV4 typeOnly bool want output.AllResourceConfigs wantErr error @@ -21,7 +21,7 @@ func TestLoadIacFile(t *testing.T) { { name: "load iac file is not supported for kustomize", filePath: "/dummyfilepath.yaml", - kustomize: KustomizeV3{}, + kustomize: KustomizeV4{}, wantErr: errLoadIacFileNotSupported, }, } diff --git a/pkg/iac-providers/kustomize/v3/testdata/erroneous-deployment/deployment.yaml b/pkg/iac-providers/kustomize/v4/testdata/erroneous-deployment/deployment.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/erroneous-deployment/deployment.yaml rename to pkg/iac-providers/kustomize/v4/testdata/erroneous-deployment/deployment.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/erroneous-deployment/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/erroneous-deployment/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/erroneous-deployment/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/erroneous-deployment/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/erroneous-pod/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/erroneous-pod/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/erroneous-pod/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/erroneous-pod/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/erroneous-pod/pod.yaml b/pkg/iac-providers/kustomize/v4/testdata/erroneous-pod/pod.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/erroneous-pod/pod.yaml rename to pkg/iac-providers/kustomize/v4/testdata/erroneous-pod/pod.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/configMap.yaml b/pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/configMap.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/configMap.yaml rename to pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/configMap.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/deployment.yaml b/pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/deployment.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/deployment.yaml rename to pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/deployment.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/service.yaml b/pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/service.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/kustomize-file-empty/service.yaml rename to pkg/iac-providers/kustomize/v4/testdata/kustomize-file-empty/service.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/base/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/base/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/base/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/base/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/base/pod.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/base/pod.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/base/pod.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/base/pod.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/dev/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/dev/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/dev/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/dev/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/prod/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/prod/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/prod/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/prod/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/stage/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/stage/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/stage/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/stage/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/zero-violation-base/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/zero-violation-base/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/zero-violation-base/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/zero-violation-base/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/multibases/zero-violation-base/pod.yaml b/pkg/iac-providers/kustomize/v4/testdata/multibases/zero-violation-base/pod.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/multibases/zero-violation-base/pod.yaml rename to pkg/iac-providers/kustomize/v4/testdata/multibases/zero-violation-base/pod.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/no-kustomizefile/configMap.yaml b/pkg/iac-providers/kustomize/v4/testdata/no-kustomizefile/configMap.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/no-kustomizefile/configMap.yaml rename to pkg/iac-providers/kustomize/v4/testdata/no-kustomizefile/configMap.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/no-kustomizefile/deployment.yaml b/pkg/iac-providers/kustomize/v4/testdata/no-kustomizefile/deployment.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/no-kustomizefile/deployment.yaml rename to pkg/iac-providers/kustomize/v4/testdata/no-kustomizefile/deployment.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/no-kustomizefile/service.yaml b/pkg/iac-providers/kustomize/v4/testdata/no-kustomizefile/service.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/no-kustomizefile/service.yaml rename to pkg/iac-providers/kustomize/v4/testdata/no-kustomizefile/service.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/simple-deployment/configMap.yaml b/pkg/iac-providers/kustomize/v4/testdata/simple-deployment/configMap.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/simple-deployment/configMap.yaml rename to pkg/iac-providers/kustomize/v4/testdata/simple-deployment/configMap.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/simple-deployment/deployment.yaml b/pkg/iac-providers/kustomize/v4/testdata/simple-deployment/deployment.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/simple-deployment/deployment.yaml rename to pkg/iac-providers/kustomize/v4/testdata/simple-deployment/deployment.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/simple-deployment/kustomization.yaml b/pkg/iac-providers/kustomize/v4/testdata/simple-deployment/kustomization.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/simple-deployment/kustomization.yaml rename to pkg/iac-providers/kustomize/v4/testdata/simple-deployment/kustomization.yaml diff --git a/pkg/iac-providers/kustomize/v3/testdata/simple-deployment/service.yaml b/pkg/iac-providers/kustomize/v4/testdata/simple-deployment/service.yaml similarity index 100% rename from pkg/iac-providers/kustomize/v3/testdata/simple-deployment/service.yaml rename to pkg/iac-providers/kustomize/v4/testdata/simple-deployment/service.yaml diff --git a/pkg/iac-providers/kustomize/v3/types.go b/pkg/iac-providers/kustomize/v4/types.go similarity index 89% rename from pkg/iac-providers/kustomize/v3/types.go rename to pkg/iac-providers/kustomize/v4/types.go index af1c66a01..d924c57d7 100644 --- a/pkg/iac-providers/kustomize/v3/types.go +++ b/pkg/iac-providers/kustomize/v4/types.go @@ -1,12 +1,12 @@ -package kustomizev3 +package kustomizev4 import ( "github.com/accurics/terrascan/pkg/utils" "github.com/hashicorp/go-multierror" ) -// KustomizeV3 struct -type KustomizeV3 struct { +// KustomizeV4 struct +type KustomizeV4 struct { errIacLoadDirs *multierror.Error } diff --git a/pkg/policy/kustomize.go b/pkg/policy/kustomize.go index 6057149ae..3d371b34a 100644 --- a/pkg/policy/kustomize.go +++ b/pkg/policy/kustomize.go @@ -2,7 +2,7 @@ package policy const ( defaultKustomizeIacType supportedIacType = "kustomize" - defaultKustomizeIacVersion supportedIacVersion = version3 + defaultKustomizeIacVersion supportedIacVersion = version4 ) func init() { diff --git a/pkg/policy/types.go b/pkg/policy/types.go index cfa06f7ed..98ab9ea1f 100644 --- a/pkg/policy/types.go +++ b/pkg/policy/types.go @@ -12,6 +12,7 @@ const ( version12 = "v12" version1 = "v1" version3 = "v3" + version4 = "v4" ) // EngineInput Contains data used as input to the engine diff --git a/pkg/runtime/executor_test.go b/pkg/runtime/executor_test.go index dc1ba320e..dfce69d1b 100644 --- a/pkg/runtime/executor_test.go +++ b/pkg/runtime/executor_test.go @@ -30,7 +30,7 @@ import ( dockerv1 "github.com/accurics/terrascan/pkg/iac-providers/docker/v1" helmv3 "github.com/accurics/terrascan/pkg/iac-providers/helm/v3" k8sv1 "github.com/accurics/terrascan/pkg/iac-providers/kubernetes/v1" - kustomizev3 "github.com/accurics/terrascan/pkg/iac-providers/kustomize/v3" + kustomizev4 "github.com/accurics/terrascan/pkg/iac-providers/kustomize/v4" tfv12 "github.com/accurics/terrascan/pkg/iac-providers/terraform/v12" tfv14 "github.com/accurics/terrascan/pkg/iac-providers/terraform/v14" "github.com/accurics/terrascan/pkg/notifications/webhook" @@ -262,7 +262,7 @@ func TestInit(t *testing.T) { policyPath: []string{testPoliciesDir}, }, wantErr: nil, - wantIacProvider: []iacProvider.IacProvider{&armv1.ARMV1{}, &cftv1.CFTV1{}, &dockerv1.DockerV1{}, &helmv3.HelmV3{}, &k8sv1.K8sV1{}, &kustomizev3.KustomizeV3{}, &tfv15.TfV15{}}, + wantIacProvider: []iacProvider.IacProvider{&armv1.ARMV1{}, &cftv1.CFTV1{}, &dockerv1.DockerV1{}, &helmv3.HelmV3{}, &k8sv1.K8sV1{}, &kustomizev4.KustomizeV4{}, &tfv15.TfV15{}}, wantNotifiers: []notifications.Notifier{}, }, { diff --git a/test/e2e/help/golden/help_scan.txt b/test/e2e/help/golden/help_scan.txt index 8b444d480..7aa979780 100644 --- a/test/e2e/help/golden/help_scan.txt +++ b/test/e2e/help/golden/help_scan.txt @@ -12,7 +12,7 @@ Flags: -d, --iac-dir string path to a directory containing one or more IaC files (default ".") -f, --iac-file string path to a single IaC file -i, --iac-type string iac type (arm, cft, docker, helm, k8s, kustomize, terraform, tfplan) - --iac-version string iac version (arm: v1, cft: v1, docker: v1, helm: v3, k8s: v1, kustomize: v3, terraform: v12, v13, v14, v15, tfplan: v1) + --iac-version string iac version (arm: v1, cft: v1, docker: v1, helm: v3, k8s: v1, kustomize: v4, terraform: v12, v13, v14, v15, tfplan: v1) --non-recursive do not scan directories and modules recursively -p, --policy-path stringArray policy path directory -t, --policy-type strings policy type (all, aws, azure, docker, gcp, github, k8s) (default [all]) From 3a33134ffcf2a6c432b302fd6a5b9d62beae5e8b Mon Sep 17 00:00:00 2001 From: Devang Gaur Date: Fri, 13 Aug 2021 18:08:10 +0530 Subject: [PATCH 2/3] Update pkg/iac-providers/kustomize/v4/load-dir.go --- pkg/iac-providers/kustomize/v4/load-dir.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/iac-providers/kustomize/v4/load-dir.go b/pkg/iac-providers/kustomize/v4/load-dir.go index efb11711d..0b38a42ab 100644 --- a/pkg/iac-providers/kustomize/v4/load-dir.go +++ b/pkg/iac-providers/kustomize/v4/load-dir.go @@ -23,7 +23,7 @@ var ( ) // LoadIacDir loads the kustomize directory and returns the ResourceConfig mapping which is evaluated by the policy engine - +// LoadIacDir loads the kustomize directory and returns the ResourceConfig mapping which is evaluated by the policy engine func (k *KustomizeV4) LoadIacDir(absRootDir string, options map[string]interface{}) (output.AllResourceConfigs, error) { allResourcesConfig := make(map[string][]output.ResourceConfig) From 086fdf24418573c6ba6d6e5232b8c246fc33547f Mon Sep 17 00:00:00 2001 From: Devang Gaur Date: Fri, 13 Aug 2021 18:09:22 +0530 Subject: [PATCH 3/3] Update load-dir.go --- pkg/iac-providers/kustomize/v4/load-dir.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/iac-providers/kustomize/v4/load-dir.go b/pkg/iac-providers/kustomize/v4/load-dir.go index 0b38a42ab..d3f44abb5 100644 --- a/pkg/iac-providers/kustomize/v4/load-dir.go +++ b/pkg/iac-providers/kustomize/v4/load-dir.go @@ -22,7 +22,6 @@ var ( kustomizeErrMessage = "error from kustomization. error : %v" ) -// LoadIacDir loads the kustomize directory and returns the ResourceConfig mapping which is evaluated by the policy engine // LoadIacDir loads the kustomize directory and returns the ResourceConfig mapping which is evaluated by the policy engine func (k *KustomizeV4) LoadIacDir(absRootDir string, options map[string]interface{}) (output.AllResourceConfigs, error) { allResourcesConfig := make(map[string][]output.ResourceConfig)