From 11da93152861a60988ba7dfb788a0394f2b90284 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 17 Aug 2023 13:15:37 -0700 Subject: [PATCH 01/13] Add repo config 'exposures' to support JAS --- pkg/xray/provider_test.go | 17 ++- pkg/xray/resource_xray_repository_config.go | 105 +++++++++++++- .../resource_xray_repository_config_test.go | 129 ++++++++++++------ pkg/xray/resource_xray_watch_test.go | 30 ++-- 4 files changed, 216 insertions(+), 65 deletions(-) diff --git a/pkg/xray/provider_test.go b/pkg/xray/provider_test.go index 4988f75b..a3c571cc 100644 --- a/pkg/xray/provider_test.go +++ b/pkg/xray/provider_test.go @@ -36,13 +36,14 @@ func testAccPreCheck(t *testing.T) { } // Create a repository with Xray indexing enabled. It will be used in the tests -func testAccCreateRepos(t *testing.T, repo, repoType string, projectKey string) { +func testAccCreateRepos(t *testing.T, repo, repoType, projectKey, packageType string) { restyClient := GetTestResty(t) type Repository struct { - Rclass string `json:"rclass"` - XrayIndex bool `json:"xrayIndex"` - Url string `json:"url,omitempty"` + Rclass string `json:"rclass"` + PackageType string `json:"packageType"` + XrayIndex bool `json:"xrayIndex"` + Url string `json:"url,omitempty"` } repository := Repository{ @@ -50,6 +51,12 @@ func testAccCreateRepos(t *testing.T, repo, repoType string, projectKey string) XrayIndex: true, } + if packageType == "" { + repository.PackageType = "generic" + } else { + repository.PackageType = packageType + } + if repoType == "remote" { repository.Url = "http://tempurl.org" } @@ -65,7 +72,7 @@ func testAccCreateRepos(t *testing.T, repo, repoType string, projectKey string) if len(projectKey) > 0 { path := fmt.Sprintf("access/api/v1/projects/_/attach/repositories/%s/%s", repo, projectKey) - res, err = req.Put(path) + _, err = req.Put(path) if err != nil { t.Error(err) } diff --git a/pkg/xray/resource_xray_repository_config.go b/pkg/xray/resource_xray_repository_config.go index 59f90512..bc09cb2c 100644 --- a/pkg/xray/resource_xray_repository_config.go +++ b/pkg/xray/resource_xray_repository_config.go @@ -14,8 +14,21 @@ import ( type RepoConfiguration struct { // Omitempty is used because 'vuln_contextual_analysis' is not supported by self-hosted Xray installation. - VulnContextualAnalysis bool `json:"vuln_contextual_analysis,omitempty"` - RetentionInDays int `json:"retention_in_days,omitempty"` + VulnContextualAnalysis bool `json:"vuln_contextual_analysis,omitempty"` + RetentionInDays int `json:"retention_in_days,omitempty"` + Exposures Exposures `json:"exposures"` +} + +type Exposures struct { + ScannersCategory ScannersCategory `json:"scanners_category"` +} + +type ScannersCategory struct { + MaliciousCode bool `json:"malicious_code_scan,omitempty"` + Services bool `json:"services_scan,omitempty"` + Secrets bool `json:"secrets_scan,omitempty"` + IAC bool `json:"iac_scan,omitempty"` + Applications bool `json:"applications_scan,omitempty"` } type PathsConfiguration struct { @@ -47,29 +60,75 @@ func resourceXrayRepositoryConfig() *schema.Resource { "repo_name": { Type: schema.TypeString, Required: true, - Description: `Repository name.`, + Description: "Repository name.", ValidateDiagFunc: validator.StringIsNotEmpty, }, "config": { Type: schema.TypeSet, Optional: true, MaxItems: 1, - Description: `Single repository configuration. Only one of 'config' or 'paths_config' can be set.`, + Description: "Single repository configuration. Only one of 'config' or 'paths_config' can be set.", ConflictsWith: []string{"paths_config"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "vuln_contextual_analysis": { Type: schema.TypeBool, Optional: true, - Description: `Only for SaaS instances, will be available after Xray 3.59. Enables vulnerability contextual analysis.`, + Description: "Only for SaaS instances, will be available after Xray 3.59. Enables vulnerability contextual analysis.", }, "retention_in_days": { Type: schema.TypeInt, Optional: true, Default: 90, - Description: `The artifact will be retained for the number of days you set here, after the artifact is scanned. This will apply to all artifacts in the repository.`, + Description: "The artifact will be retained for the number of days you set here, after the artifact is scanned. This will apply to all artifacts in the repository.", ValidateDiagFunc: validator.IntAtLeast(0), }, + "exposures": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: 1, + Description: "Enables Xray to perform scans for multiple categories that cover security issues in your configurations and the usage of open source libraries in your code. Available only to CLOUD (SaaS)/SELF HOSTED for ENTERPRISE X and ENTERPRISE+ with Advanced DevSecOps", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "scanners_category": { + Type: schema.TypeSet, + Optional: true, + MinItems: 1, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "malicious_code": { + Type: schema.TypeBool, + Optional: true, + Description: "", + }, + "services": { + Type: schema.TypeBool, + Optional: true, + Description: "Detect whether common OSS libraries and services are configured securely, so application can be easily hardened by default.", + }, + "secrets": { + Type: schema.TypeBool, + Optional: true, + Description: "Detect any secret left exposed in any containers stored in Artifactory to stop any accidental leak of internal tokens or credentials.", + }, + "iac": { + Type: schema.TypeBool, + Optional: true, + Description: "Scans IaC files stored in Artifactory for early detection of cloud and infrastructure misconfigurations to prevent attacks and data leak. Only support by Terraform Backend package type.", + }, + "applications": { + Type: schema.TypeBool, + Optional: true, + Description: "Detect whether common OSS libraries and services are used securely by the application.", + }, + }, + }, + }, + }, + }, + }, }, }, }, @@ -190,6 +249,22 @@ func resourceXrayRepositoryConfig() *schema.Resource { return repoPathsConfiguration } + var unpackExposures = func(config *schema.Set) Exposures { + exposures := Exposures{} + + e := config.List()[0].(map[string]interface{}) + s := e["scanners_category"].(*schema.Set) + category := s.List()[0].(map[string]interface{}) + + exposures.ScannersCategory.MaliciousCode = category["malicious_code"].(bool) + exposures.ScannersCategory.Services = category["services"].(bool) + exposures.ScannersCategory.Secrets = category["secrets"].(bool) + exposures.ScannersCategory.IAC = category["iac"].(bool) + exposures.ScannersCategory.Applications = category["applications"].(bool) + + return exposures + } + var unpackRepoConfig = func(config *schema.Set) *RepoConfiguration { repoConfig := new(RepoConfiguration) @@ -197,6 +272,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { data := config.List()[0].(map[string]interface{}) repoConfig.VulnContextualAnalysis = data["vuln_contextual_analysis"].(bool) repoConfig.RetentionInDays = data["retention_in_days"].(int) + repoConfig.Exposures = unpackExposures(data["exposures"].(*schema.Set)) } return repoConfig @@ -219,6 +295,22 @@ func resourceXrayRepositoryConfig() *schema.Resource { return repositoryConfig } + var packExposures = func(exposures Exposures) []interface{} { + return []interface{}{ + map[string]interface{}{ + "scanners_category": []interface{}{ + map[string]interface{}{ + "malicious_code": exposures.ScannersCategory.MaliciousCode, + "services": exposures.ScannersCategory.Services, + "secrets": exposures.ScannersCategory.Secrets, + "iac": exposures.ScannersCategory.IAC, + "applications": exposures.ScannersCategory.Applications, + }, + }, + }, + } + } + var packGeneralRepoConfig = func(repoConfig *RepoConfiguration) []interface{} { if repoConfig == nil { return []interface{}{} @@ -227,6 +319,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { m := map[string]interface{}{ "vuln_contextual_analysis": repoConfig.VulnContextualAnalysis, "retention_in_days": repoConfig.RetentionInDays, + "exposures": packExposures(repoConfig.Exposures), } return []interface{}{m} diff --git a/pkg/xray/resource_xray_repository_config_test.go b/pkg/xray/resource_xray_repository_config_test.go index f2d7c958..0c4d2670 100644 --- a/pkg/xray/resource_xray_repository_config_test.go +++ b/pkg/xray/resource_xray_repository_config_test.go @@ -54,7 +54,7 @@ func TestAccRepositoryConfigRepoConfigCreate(t *testing.T) { PreCheck: func() { testAccPreCheck(t) testAccDeleteRepo(t, testData["repo_name"]) - testAccCreateRepos(t, testData["repo_name"], "local", "") + testAccCreateRepos(t, testData["repo_name"], "local", "", "docker") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo_name"]) @@ -70,6 +70,10 @@ func TestAccRepositoryConfigRepoConfigCreate(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(fqrn, "repo_name", testData["repo_name"]), resource.TestCheckResourceAttr(fqrn, "config.0.retention_in_days", testData["retention_in_days"]), + resource.TestCheckResourceAttr(fqrn, "config.0.vuln_contextual_analysis", "true"), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.services", "true"), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", "true"), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.applications", "true"), ), }, { @@ -81,6 +85,37 @@ func TestAccRepositoryConfigRepoConfigCreate(t *testing.T) { }) } +func TestAccRepositoryConfigRepoConfigCreate_InvalidExposures(t *testing.T) { + _, fqrn, resourceName := test.MkNames("xray-repo-config-", "xray_repository_config") + var testData = map[string]string{ + "resource_name": resourceName, + "repo_name": "repo-config-test-repo", + "retention_in_days": "90", + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + testAccDeleteRepo(t, testData["repo_name"]) + testAccCreateRepos(t, testData["repo_name"], "local", "", "docker") + }, + CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { + testAccDeleteRepo(t, testData["repo_name"]) + err := fmt.Errorf("repo was deleted") + errorResp := dummyError() + return errorResp, err + }), + ProviderFactories: testAccProviders(), + + Steps: []resource.TestStep{ + { + Config: util.ExecuteTemplate(fqrn, TestDataRepoConfigInvalidExposuresTemplate, testData), + ExpectError: regexp.MustCompile(`.*Value for 'repo_config.exposure' parameter is invalid.*`), + }, + }, + }) +} + func TestAccRepositoryConfigRepoPathsCreate(t *testing.T) { _, fqrn, resourceName := test.MkNames("xray-repo-config-", "xray_repository_config") var testData = map[string]string{ @@ -102,7 +137,7 @@ func TestAccRepositoryConfigRepoPathsCreate(t *testing.T) { PreCheck: func() { testAccPreCheck(t) testAccDeleteRepo(t, testData["repo_name"]) - testAccCreateRepos(t, testData["repo_name"], "local", "") + testAccCreateRepos(t, testData["repo_name"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo_name"]) @@ -161,7 +196,7 @@ func TestAccRepositoryConfigRepoPathsUpdate(t *testing.T) { PreCheck: func() { testAccPreCheck(t) testAccDeleteRepo(t, testData["repo_name"]) - testAccCreateRepos(t, testData["repo_name"], "local", "") + testAccCreateRepos(t, testData["repo_name"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo_name"]) @@ -202,30 +237,28 @@ func verifyRepositoryConfig(fqrn string, testData map[string]string) resource.Te const TestDataRepoConfigErrorTemplate = ` resource "xray_repository_config" "{{ .resource_name }}" { - - repo_name = "{{ .repo_name }}" - + repo_name = "{{ .repo_name }}" + config { - retention_in_days = {{ .retention_in_days }} + retention_in_days = {{ .retention_in_days }} } - + paths_config { - pattern { - include = "{{ .pattern0_include }}" - exclude = "{{ .pattern0_exclude }}" - index_new_artifacts = {{ .pattern0_index_new_artifacts }} - retention_in_days = {{ .pattern0_retention_in_days }} + include = "{{ .pattern0_include }}" + exclude = "{{ .pattern0_exclude }}" + index_new_artifacts = {{ .pattern0_index_new_artifacts }} + retention_in_days = {{ .pattern0_retention_in_days }} } - pattern { - include = "{{ .pattern1_include }}" - exclude = "{{ .pattern1_exclude }}" - index_new_artifacts = {{ .pattern1_index_new_artifacts }} - retention_in_days = {{ .pattern1_retention_in_days }} + pattern { + include = "{{ .pattern1_include }}" + exclude = "{{ .pattern1_exclude }}" + index_new_artifacts = {{ .pattern1_index_new_artifacts }} + retention_in_days = {{ .pattern1_retention_in_days }} } - - all_other_artifacts { + + all_other_artifacts { index_new_artifacts = {{ .other_index_new_artifacts }} retention_in_days = {{ .other_retention_in_days }} } @@ -234,38 +267,56 @@ resource "xray_repository_config" "{{ .resource_name }}" { const TestDataRepoConfigTemplate = ` resource "xray_repository_config" "{{ .resource_name }}" { - - repo_name = "{{ .repo_name }}" - + repo_name = "{{ .repo_name }}" + config { - #vuln_contextual_analysis = true - retention_in_days = {{ .retention_in_days }} + vuln_contextual_analysis = true + retention_in_days = {{ .retention_in_days }} + exposures { + scanners_category { + services = true + secrets = true + applications = true + } + } } +}` + +const TestDataRepoConfigInvalidExposuresTemplate = ` +resource "xray_repository_config" "{{ .resource_name }}" { + repo_name = "{{ .repo_name }}" + config { + vuln_contextual_analysis = true + retention_in_days = {{ .retention_in_days }} + exposures { + scanners_category { + iac = true + } + } + } }` const TestDataRepoPathsConfigTemplate = ` resource "xray_repository_config" "{{ .resource_name }}" { - - repo_name = "{{ .repo_name }}" + repo_name = "{{ .repo_name }}" paths_config { - pattern { - include = "{{ .pattern0_include }}" - exclude = "{{ .pattern0_exclude }}" - index_new_artifacts = {{ .pattern0_index_new_artifacts }} - retention_in_days = {{ .pattern0_retention_in_days }} + include = "{{ .pattern0_include }}" + exclude = "{{ .pattern0_exclude }}" + index_new_artifacts = {{ .pattern0_index_new_artifacts }} + retention_in_days = {{ .pattern0_retention_in_days }} } - pattern { - include = "{{ .pattern1_include }}" - exclude = "{{ .pattern1_exclude }}" - index_new_artifacts = {{ .pattern1_index_new_artifacts }} - retention_in_days = {{ .pattern1_retention_in_days }} + pattern { + include = "{{ .pattern1_include }}" + exclude = "{{ .pattern1_exclude }}" + index_new_artifacts = {{ .pattern1_index_new_artifacts }} + retention_in_days = {{ .pattern1_retention_in_days }} } - - all_other_artifacts { + + all_other_artifacts { index_new_artifacts = {{ .other_index_new_artifacts }} retention_in_days = {{ .other_retention_in_days }} } diff --git a/pkg/xray/resource_xray_watch_test.go b/pkg/xray/resource_xray_watch_test.go index f2617b07..72d609aa 100644 --- a/pkg/xray/resource_xray_watch_test.go +++ b/pkg/xray/resource_xray_watch_test.go @@ -294,7 +294,7 @@ func makeSingleRepositoryTestCase(repoType string, t *testing.T) (*testing.T, re return t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], repoType, "") + testAccCreateRepos(t, testData["repo0"], repoType, "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -401,7 +401,7 @@ func TestAccWatch_singleRepositoryWithProjectKey(t *testing.T) { PreCheck: func() { testAccPreCheck(t) CreateProject(t, projectKey) - testAccCreateRepos(t, repoKey, "local", projectKey) + testAccCreateRepos(t, repoKey, "local", projectKey, "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, repoKey) @@ -447,7 +447,7 @@ func TestAccWatch_singleRepoMimeTypeFilter(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], repoType, "") + testAccCreateRepos(t, testData["repo0"], repoType, "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -492,7 +492,7 @@ func TestAccWatch_singleRepoKvFilter(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], repoType, "") + testAccCreateRepos(t, testData["repo0"], repoType, "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -534,7 +534,7 @@ func TestAccWatch_repositoryMissingRepoType(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], "local", "") + testAccCreateRepos(t, testData["repo0"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -568,8 +568,8 @@ func TestAccWatch_multipleRepositories(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], "local", "") - testAccCreateRepos(t, testData["repo1"], "local", "") + testAccCreateRepos(t, testData["repo0"], "local", "", "") + testAccCreateRepos(t, testData["repo1"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -613,9 +613,9 @@ func TestAccWatch_multipleRepositoriesPathAntPatterns(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], "local", "") - testAccCreateRepos(t, testData["repo1"], "local", "") - testAccCreateRepos(t, testData["repo2"], "local", "") + testAccCreateRepos(t, testData["repo0"], "local", "", "") + testAccCreateRepos(t, testData["repo1"], "local", "", "") + testAccCreateRepos(t, testData["repo2"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -668,8 +668,8 @@ func TestAccWatch_PathAntPatternsError(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], "local", "") - testAccCreateRepos(t, testData["repo1"], "local", "") + testAccCreateRepos(t, testData["repo0"], "local", "", "") + testAccCreateRepos(t, testData["repo1"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -708,8 +708,8 @@ func TestAccWatch_multipleRepositoriesKvFilter(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], "local", "") - testAccCreateRepos(t, testData["repo1"], "local", "") + testAccCreateRepos(t, testData["repo0"], "local", "", "") + testAccCreateRepos(t, testData["repo1"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) @@ -765,7 +765,7 @@ func TestAccWatch_KvFilterError(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) - testAccCreateRepos(t, testData["repo0"], "local", "") + testAccCreateRepos(t, testData["repo0"], "local", "", "") }, CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { testAccDeleteRepo(t, testData["repo0"]) From 87f7e6c2687e1b95b74bc830da6d7af7b88796bd Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 17 Aug 2023 13:18:11 -0700 Subject: [PATCH 02/13] Tidy up code --- pkg/xray/provider_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/xray/provider_test.go b/pkg/xray/provider_test.go index a3c571cc..84d9d0d7 100644 --- a/pkg/xray/provider_test.go +++ b/pkg/xray/provider_test.go @@ -47,13 +47,12 @@ func testAccCreateRepos(t *testing.T, repo, repoType, projectKey, packageType st } repository := Repository{ - Rclass: repoType, - XrayIndex: true, + Rclass: repoType, + PackageType: "generic", + XrayIndex: true, } - if packageType == "" { - repository.PackageType = "generic" - } else { + if packageType != "" { repository.PackageType = packageType } From 17df9f693a61efcf4a3236b454e34ecd7a317764 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 17 Aug 2023 13:20:51 -0700 Subject: [PATCH 03/13] Update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f724f3..4797972e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.15.0 (August 17, 2023) + +BUG FIXES: + +* resource/xray_repository_config: added `exposures` to `config` to support JFrog Advanced Security scanning. + +PR: [#133](https://github.com/jfrog/terraform-provider-xray/pull/133) + ## 1.14.2 (July 24, 2023). Tested on Artifactory 7.63.5 and Xray 3.78.10 BUG FIXES: From 915528ea78ed66762b3dae9c7ec7df8547af7944 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 17 Aug 2023 13:21:34 -0700 Subject: [PATCH 04/13] Update doc --- docs/resources/repository_config.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/resources/repository_config.md b/docs/resources/repository_config.md index e51a6d67..8d0dd740 100644 --- a/docs/resources/repository_config.md +++ b/docs/resources/repository_config.md @@ -67,9 +67,30 @@ resource "xray_repository_config" "xray-repo-config" { Optional: +- `exposures` (Block Set, Max: 1) Enables Xray to perform scans for multiple categories that cover security issues in your configurations and the usage of open source libraries in your code. Available only to CLOUD (SaaS)/SELF HOSTED for ENTERPRISE X and ENTERPRISE+ with Advanced DevSecOps (see [below for nested schema](#nestedblock--config--exposures)) - `retention_in_days` (Number) The artifact will be retained for the number of days you set here, after the artifact is scanned. This will apply to all artifacts in the repository. - `vuln_contextual_analysis` (Boolean) Only for SaaS instances, will be available after Xray 3.59. Enables vulnerability contextual analysis. + +### Nested Schema for `config.exposures` + +Optional: + +- `scanners_category` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--config--exposures--scanners_category)) + + +### Nested Schema for `config.exposures.scanners_category` + +Optional: + +- `applications` (Boolean) Detect whether common OSS libraries and services are used securely by the application. +- `iac` (Boolean) Scans IaC files stored in Artifactory for early detection of cloud and infrastructure misconfigurations to prevent attacks and data leak. Only support by Terraform Backend package type. +- `malicious_code` (Boolean) +- `secrets` (Boolean) Detect any secret left exposed in any containers stored in Artifactory to stop any accidental leak of internal tokens or credentials. +- `services` (Boolean) Detect whether common OSS libraries and services are configured securely, so application can be easily hardened by default. + + + ### Nested Schema for `paths_config` From 22ae41db28651627f47196f1bf43aa77a7289b67 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Thu, 17 Aug 2023 14:54:17 -0700 Subject: [PATCH 05/13] Update description --- docs/resources/repository_config.md | 2 +- pkg/xray/resource_xray_repository_config.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/repository_config.md b/docs/resources/repository_config.md index 8d0dd740..a18e627b 100644 --- a/docs/resources/repository_config.md +++ b/docs/resources/repository_config.md @@ -84,7 +84,7 @@ Optional: Optional: - `applications` (Boolean) Detect whether common OSS libraries and services are used securely by the application. -- `iac` (Boolean) Scans IaC files stored in Artifactory for early detection of cloud and infrastructure misconfigurations to prevent attacks and data leak. Only support by Terraform Backend package type. +- `iac` (Boolean) Scans IaC files stored in Artifactory for early detection of cloud and infrastructure misconfigurations to prevent attacks and data leak. Only supported by Terraform Backend package type. - `malicious_code` (Boolean) - `secrets` (Boolean) Detect any secret left exposed in any containers stored in Artifactory to stop any accidental leak of internal tokens or credentials. - `services` (Boolean) Detect whether common OSS libraries and services are configured securely, so application can be easily hardened by default. diff --git a/pkg/xray/resource_xray_repository_config.go b/pkg/xray/resource_xray_repository_config.go index bc09cb2c..c45e18e4 100644 --- a/pkg/xray/resource_xray_repository_config.go +++ b/pkg/xray/resource_xray_repository_config.go @@ -116,7 +116,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { "iac": { Type: schema.TypeBool, Optional: true, - Description: "Scans IaC files stored in Artifactory for early detection of cloud and infrastructure misconfigurations to prevent attacks and data leak. Only support by Terraform Backend package type.", + Description: "Scans IaC files stored in Artifactory for early detection of cloud and infrastructure misconfigurations to prevent attacks and data leak. Only supported by Terraform Backend package type.", }, "applications": { Type: schema.TypeBool, From fe40367fe31c0c7f9de741724306b5c5b9ccba63 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 18 Aug 2023 14:19:14 -0700 Subject: [PATCH 06/13] Upgrade terraform-provider-shared package to 1.17.0 --- go.mod | 57 ++-- go.sum | 275 +++++----------- pkg/xray/policies.go | 26 +- pkg/xray/provider.go | 20 +- pkg/xray/reports.go | 50 +-- pkg/xray/resource_xray_ignore_rule.go | 12 +- pkg/xray/resource_xray_ignore_rule_test.go | 60 ++-- pkg/xray/resource_xray_license_policy.go | 4 +- pkg/xray/resource_xray_license_policy_test.go | 98 +++--- ...ource_xray_operational_risk_policy_test.go | 48 +-- pkg/xray/resource_xray_report_test.go | 22 +- .../resource_xray_security_policy_test.go | 224 ++++++------- pkg/xray/resource_xray_settings.go | 8 +- pkg/xray/resource_xray_settings_test.go | 8 +- pkg/xray/resource_xray_watch.go | 4 +- pkg/xray/resource_xray_watch_test.go | 302 +++++++++--------- pkg/xray/resource_xray_workers_count.go | 10 +- pkg/xray/resource_xray_workers_count_test.go | 10 +- pkg/xray/util_test.go | 17 +- pkg/xray/watches.go | 14 +- 20 files changed, 580 insertions(+), 689 deletions(-) diff --git a/go.mod b/go.mod index 9bfbfb16..5caffa7b 100644 --- a/go.mod +++ b/go.mod @@ -7,24 +7,26 @@ require ( github.com/go-resty/resty/v2 v2.7.0 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/terraform-plugin-docs v0.13.0 - github.com/hashicorp/terraform-plugin-log v0.4.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.14.0 - github.com/jfrog/terraform-provider-shared v1.14.0 - golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d - golang.org/x/text v0.7.0 + github.com/hashicorp/terraform-plugin-log v0.9.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 + github.com/hashicorp/terraform-plugin-testing v1.4.0 + github.com/jfrog/terraform-provider-shared v1.17.0 + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 + golang.org/x/text v0.11.0 ) require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.1.1 // indirect github.com/Masterminds/sprig/v3 v3.2.2 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect github.com/agext/levenshtein v1.2.2 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/cloudflare/circl v1.3.3 // indirect github.com/fatih/color v1.13.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 // indirect @@ -32,28 +34,28 @@ require ( github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect - github.com/hashicorp/go-hclog v1.2.0 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.4.3 // indirect + github.com/hashicorp/go-plugin v1.4.10 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/hc-install v0.4.0 // indirect - github.com/hashicorp/hcl/v2 v2.11.1 // indirect + github.com/hashicorp/hc-install v0.5.2 // indirect + github.com/hashicorp/hcl/v2 v2.17.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.17.2 // indirect - github.com/hashicorp/terraform-json v0.14.0 // indirect - github.com/hashicorp/terraform-plugin-go v0.9.0 // indirect - github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 // indirect - github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect + github.com/hashicorp/terraform-exec v0.18.1 // indirect + github.com/hashicorp/terraform-json v0.17.1 // indirect + github.com/hashicorp/terraform-plugin-go v0.18.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.1 // indirect + github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect - github.com/mitchellh/cli v1.1.4 // indirect + github.com/mitchellh/cli v1.1.5 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect @@ -61,16 +63,17 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect - github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/zclconf/go-cty v1.10.0 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect + github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/zclconf/go-cty v1.13.2 // indirect + golang.org/x/crypto v0.11.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/net v0.11.0 // indirect + golang.org/x/sys v0.10.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect - google.golang.org/grpc v1.53.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/grpc v1.56.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/ldap.v2 v2.5.1 // indirect ) diff --git a/go.sum b/go.sum index c74ddc0c..48fd10c9 100644 --- a/go.sum +++ b/go.sum @@ -1,80 +1,49 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig/v3 v3.2.0/go.mod h1:tWhwTbUTndesPNeF0C900vKoq283u6zp4APT9vaF3SI= +github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= -github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= -github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= -github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= +github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= +github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= +github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= -github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= 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/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= -github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= -github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= -github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= +github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= +github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -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/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -89,270 +58,182 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= -github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM= -github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= +github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= +github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk= -github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= -github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc= -github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/hashicorp/hc-install v0.5.2 h1:SfwMFnEXVVirpwkDuSF5kymUOhrUxrTq3udEseZdOD0= +github.com/hashicorp/hc-install v0.5.2/go.mod h1:9QISwe6newMWIfEiXpzuu1k9HAGtQYgnSH8H9T8wmoI= +github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= +github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad8zszYZ73Go= -github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8= -github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= -github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= +github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX5H8XZxHlH4= +github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= +github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= +github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= -github.com/hashicorp/terraform-plugin-go v0.9.0 h1:FvLY/3z4SNVatPZdoFcyrlNbCar+WyyOTv5X4Tp+WZc= -github.com/hashicorp/terraform-plugin-go v0.9.0/go.mod h1:EawBkgjBWNf7jiKnVoyDyF39OSV+u6KUX+Y73EPj3oM= -github.com/hashicorp/terraform-plugin-log v0.4.0 h1:F3eVnm8r2EfQCe2k9blPIiF/r2TT01SHijXnS7bujvc= -github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.14.0 h1:GZ8NY74rxObB7QHE/JiuBW0ZEr04rlplR/TVrkgw3rw= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.14.0/go.mod h1:+m4FDQ8h1ulz7zpWtqmZn2JSZQDXUVibhUShbkQVId4= -github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= -github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= -github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hashicorp/terraform-plugin-go v0.18.0 h1:IwTkOS9cOW1ehLd/rG0y+u/TGLK9y6fGoBjXVUquzpE= +github.com/hashicorp/terraform-plugin-go v0.18.0/go.mod h1:l7VK+2u5Kf2y+A+742GX0ouLut3gttudmvMgN0PA74Y= +github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= +github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 h1:I8efBnjuDrgPjNF1MEypHy48VgcTIUY4X6rOFunrR3Y= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0/go.mod h1:cUEP4ly/nxlHy5HzD6YRrHydtlheGvGRJDhiWqqVik4= +github.com/hashicorp/terraform-plugin-testing v1.4.0 h1:DVIXxw7VHZvnwWVik4HzhpC2yytaJ5FpiHxz5debKmE= +github.com/hashicorp/terraform-plugin-testing v1.4.0/go.mod h1:b7Bha24iGrbZQjT+ZE8m9crck1YjdVOZ8mfGCQ19OxA= +github.com/hashicorp/terraform-registry-address v0.2.1 h1:QuTf6oJ1+WSflJw6WYOHhLgwUiQ0FrROpHPYFtwTYWM= +github.com/hashicorp/terraform-registry-address v0.2.1/go.mod h1:BSE9fIFzp0qWsJUUyGquo4ldV9k2n+psif6NYkBRS3Y= +github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= +github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= 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/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= -github.com/jfrog/terraform-provider-shared v1.14.0 h1:C9EGwZKLAtzts543zpXANjYYwM3/pX64H7oMbhimA8g= -github.com/jfrog/terraform-provider-shared v1.14.0/go.mod h1:n6855hIUDhypnXsJl8UrstVFkcnL2uW4FLLr3cKGXjU= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= -github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mitchellh/cli v1.1.4 h1:qj8czE26AU4PbiaPXK5uVmMSM+V5BYsFBiM9HhGRLUA= -github.com/mitchellh/cli v1.1.4/go.mod h1:vTLESy5mRhKOs9KDp0/RATawxP1UqBmdrpVRMnpcvKQ= +github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= +github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -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 v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= -github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= 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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= -github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= -github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= -github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= +github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= +github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/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-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d h1:vtUKgx8dahOomfFzLREU8nSv25YHnTgLBn4rDnWZdU0= -golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/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.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/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-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= +google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/ldap.v2 v2.5.1 h1:wiu0okdNfjlBzg6UWvd1Hn8Y+Ux17/u/4nlk4CQr6tU= gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/xray/policies.go b/pkg/xray/policies.go index 8a6dab72..643b9437 100644 --- a/pkg/xray/policies.go +++ b/pkg/xray/policies.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -91,7 +91,7 @@ var commonActionsSchema = map[string]*schema.Schema{ } var getPolicySchema = func(criteriaSchema map[string]*schema.Schema, actionsSchema map[string]*schema.Schema) map[string]*schema.Schema { - return util.MergeMaps( + return sdk.MergeMaps( getProjectKeySchema(false, ""), map[string]*schema.Schema{ "name": { @@ -314,7 +314,7 @@ func unpackSecurityCriteria(tfCriteria map[string]interface{}) *PolicyRuleCriter criteria.MaliciousPackage = v.(bool) } if v, ok := tfCriteria["vulnerability_ids"]; ok { - criteria.VulnerabilityIds = util.CastToStringArr(v.(*schema.Set).List()) + criteria.VulnerabilityIds = sdk.CastToStringArr(v.(*schema.Set).List()) } if _, ok := tfCriteria["exposures"]; ok { criteria.Exposures = unpackExposures(tfCriteria["exposures"].([]interface{})) @@ -333,7 +333,7 @@ func unpackSecurityCriteria(tfCriteria map[string]interface{}) *PolicyRuleCriter func unpackLicenseCriteria(tfCriteria map[string]interface{}) *PolicyRuleCriteria { criteria := new(PolicyRuleCriteria) if v, ok := tfCriteria["allow_unknown"]; ok { - criteria.AllowUnknown = util.BoolPtr(v.(bool)) + criteria.AllowUnknown = sdk.BoolPtr(v.(bool)) } if v, ok := tfCriteria["banned_licenses"]; ok { criteria.BannedLicenses = unpackLicenses(v.(*schema.Set)) @@ -342,7 +342,7 @@ func unpackLicenseCriteria(tfCriteria map[string]interface{}) *PolicyRuleCriteri criteria.AllowedLicenses = unpackLicenses(v.(*schema.Set)) } if v, ok := tfCriteria["multi_license_permissive"]; ok { - criteria.MultiLicensePermissive = util.BoolPtr(v.(bool)) + criteria.MultiLicensePermissive = sdk.BoolPtr(v.(bool)) } return criteria @@ -440,10 +440,10 @@ func unpackExposures(l []interface{}) *PolicyExposures { m := l[0].(map[string]interface{}) exposures := &PolicyExposures{ MinSeverity: StringPtr(m["min_severity"].(string)), - Secrets: util.BoolPtr(m["secrets"].(bool)), - Applications: util.BoolPtr(m["applications"].(bool)), - Services: util.BoolPtr(m["services"].(bool)), - Iac: util.BoolPtr(m["iac"].(bool)), + Secrets: sdk.BoolPtr(m["secrets"].(bool)), + Applications: sdk.BoolPtr(m["applications"].(bool)), + Services: sdk.BoolPtr(m["services"].(bool)), + Iac: sdk.BoolPtr(m["iac"].(bool)), } return exposures } @@ -716,7 +716,7 @@ func resourceXrayPolicyCreate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, policy.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, policy.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -734,7 +734,7 @@ func resourceXrayPolicyRead(ctx context.Context, d *schema.ResourceData, m inter policy := Policy{} projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -761,7 +761,7 @@ func resourceXrayPolicyUpdate(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, policy.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, policy.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -786,7 +786,7 @@ func resourceXrayPolicyDelete(ctx context.Context, d *schema.ResourceData, m int return diag.FromErr(err) } - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, policy.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, policy.ProjectKey) if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/provider.go b/pkg/xray/provider.go index f98a1ce7..71362c58 100644 --- a/pkg/xray/provider.go +++ b/pkg/xray/provider.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/jfrog/terraform-provider-shared/client" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -45,7 +45,7 @@ func Provider() *schema.Provider { }, }, - ResourcesMap: util.AddTelemetry( + ResourcesMap: sdk.AddTelemetry( productId, map[string]*schema.Resource{ "xray_security_policy": resourceXraySecurityPolicyV2(), @@ -97,23 +97,29 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, terraformVer checkLicense := d.Get("check_license").(bool) if checkLicense { - licenseErr := util.CheckArtifactoryLicense(restyBase, "Enterprise", "Commercial") + licenseErr := sdk.CheckArtifactoryLicense(restyBase, "Enterprise", "Commercial") if licenseErr != nil { return nil, licenseErr } } - version, err := util.GetArtifactoryVersion(restyBase) + artifactoryVersion, err := sdk.GetArtifactoryVersion(restyBase) + if err != nil { + return nil, diag.FromErr(err) + } + + xrayVersion, err := sdk.GetXrayVersion(restyBase) if err != nil { return nil, diag.FromErr(err) } featureUsage := fmt.Sprintf("Terraform/%s", terraformVersion) - util.SendUsage(ctx, restyBase, productId, featureUsage) + sdk.SendUsage(ctx, restyBase, productId, featureUsage) - return util.ProvderMetadata{ + return sdk.ProvderMetadata{ Client: restyBase, - ArtifactoryVersion: version, + ArtifactoryVersion: artifactoryVersion, + XrayVersion: xrayVersion, }, nil } diff --git a/pkg/xray/reports.go b/pkg/xray/reports.go index 0ae50795..16dd1a75 100644 --- a/pkg/xray/reports.go +++ b/pkg/xray/reports.go @@ -9,13 +9,13 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" "golang.org/x/exp/slices" ) var getReportSchema = func(filtersSchema map[string]*schema.Schema) map[string]*schema.Schema { - return util.MergeMaps( + return sdk.MergeMaps( getProjectKeySchema(false, ""), map[string]*schema.Schema{ "report_id": { @@ -353,8 +353,8 @@ func unpackRepository(d *schema.Set) *[]Repository { f := raw.(map[string]interface{}) repository := Repository{ Name: f["name"].(string), - IncludePathPatterns: util.CastToStringArr(f["include_path_patterns"].(*schema.Set).List()), - ExcludePathPatterns: util.CastToStringArr(f["exclude_path_patterns"].(*schema.Set).List()), + IncludePathPatterns: sdk.CastToStringArr(f["include_path_patterns"].(*schema.Set).List()), + ExcludePathPatterns: sdk.CastToStringArr(f["exclude_path_patterns"].(*schema.Set).List()), } repositories = append(repositories, repository) } @@ -369,9 +369,9 @@ func unpackBuilds(d *schema.Set) *Builds { var builds Builds f := d.List()[0].(map[string]interface{}) builds = Builds{ - Names: util.CastToStringArr(f["names"].(*schema.Set).List()), - IncludePatterns: util.CastToStringArr(f["include_patterns"].(*schema.Set).List()), - ExcludePatterns: util.CastToStringArr(f["exclude_patterns"].(*schema.Set).List()), + Names: sdk.CastToStringArr(f["names"].(*schema.Set).List()), + IncludePatterns: sdk.CastToStringArr(f["include_patterns"].(*schema.Set).List()), + ExcludePatterns: sdk.CastToStringArr(f["exclude_patterns"].(*schema.Set).List()), NumberOfLatestVersions: f["number_of_latest_versions"].(int), } return &builds @@ -385,9 +385,9 @@ func unpackReleaseBundles(d *schema.Set) *ReleaseBundles { var releaseBundles ReleaseBundles f := d.List()[0].(map[string]interface{}) releaseBundles = ReleaseBundles{ - Names: util.CastToStringArr(f["names"].(*schema.Set).List()), - IncludePatterns: util.CastToStringArr(f["include_patterns"].(*schema.Set).List()), - ExcludePatterns: util.CastToStringArr(f["exclude_patterns"].(*schema.Set).List()), + Names: sdk.CastToStringArr(f["names"].(*schema.Set).List()), + IncludePatterns: sdk.CastToStringArr(f["include_patterns"].(*schema.Set).List()), + ExcludePatterns: sdk.CastToStringArr(f["exclude_patterns"].(*schema.Set).List()), NumberOfLatestVersions: f["number_of_latest_versions"].(int), } return &releaseBundles @@ -401,8 +401,8 @@ func unpackProjects(d *schema.Set) *Projects { var projects Projects f := d.List()[0].(map[string]interface{}) projects = Projects{ - Names: util.CastToStringArr(f["names"].(*schema.Set).List()), - IncludeKeyPatterns: util.CastToStringArr(f["include_key_patterns"].(*schema.Set).List()), + Names: sdk.CastToStringArr(f["names"].(*schema.Set).List()), + IncludeKeyPatterns: sdk.CastToStringArr(f["include_key_patterns"].(*schema.Set).List()), NumberOfLatestVersions: f["number_of_latest_versions"].(int), } return &projects @@ -433,7 +433,7 @@ func unpackVulnerabilitiesFilters(filter *schema.Set) *Filters { filters.IssueId = m["issue_id"].(string) } - filters.Severities = util.CastToStringArr(m["severities"].(*schema.Set).List()) + filters.Severities = sdk.CastToStringArr(m["severities"].(*schema.Set).List()) if m["cvss_score"] != nil { filters.CvssScore = unpackCvssScore(m["cvss_score"].(*schema.Set)) @@ -465,8 +465,8 @@ func unpackLicensesFilters(filter *schema.Set) *Filters { filters.Unknown = m["unknown"].(bool) filters.Unrecognized = m["unrecognized"].(bool) - filters.LicenseNames = util.CastToStringArr(m["license_names"].(*schema.Set).List()) - filters.LicensePatterns = util.CastToStringArr(m["license_patterns"].(*schema.Set).List()) + filters.LicenseNames = sdk.CastToStringArr(m["license_names"].(*schema.Set).List()) + filters.LicensePatterns = sdk.CastToStringArr(m["license_patterns"].(*schema.Set).List()) if m["scan_date"] != nil { filters.ScanDate = unpackStartAndEndDate(m["scan_date"].(*schema.Set)) @@ -510,8 +510,8 @@ func unpackViolationsFilters(filter *schema.Set) *Filters { filters.Type = m["type"].(string) } - filters.WatchNames = util.CastToStringArr(m["watch_names"].(*schema.Set).List()) - filters.WatchPatterns = util.CastToStringArr(m["watch_patterns"].(*schema.Set).List()) + filters.WatchNames = sdk.CastToStringArr(m["watch_names"].(*schema.Set).List()) + filters.WatchPatterns = sdk.CastToStringArr(m["watch_patterns"].(*schema.Set).List()) if m["component"] != nil { filters.Component = m["component"].(string) @@ -521,8 +521,8 @@ func unpackViolationsFilters(filter *schema.Set) *Filters { filters.Artifact = m["artifact"].(string) } - filters.PolicyNames = util.CastToStringArr(m["policy_names"].(*schema.Set).List()) - filters.Severities = util.CastToStringArr(m["severities"].(*schema.Set).List()) + filters.PolicyNames = sdk.CastToStringArr(m["policy_names"].(*schema.Set).List()) + filters.Severities = sdk.CastToStringArr(m["severities"].(*schema.Set).List()) if m["updated"].(*schema.Set).Len() > 0 { filters.Updated = unpackStartAndEndDate(m["updated"].(*schema.Set)) @@ -548,8 +548,8 @@ func unpackViolationsLicensesFilters(filter *schema.Set) *LicenseFilter { filters.Unknown = m["unknown"].(bool) filters.Unrecognized = m["unrecognized"].(bool) - filters.LicenseNames = util.CastToStringArr(m["license_names"].(*schema.Set).List()) - filters.LicensePatterns = util.CastToStringArr(m["license_patterns"].(*schema.Set).List()) + filters.LicenseNames = sdk.CastToStringArr(m["license_names"].(*schema.Set).List()) + filters.LicensePatterns = sdk.CastToStringArr(m["license_patterns"].(*schema.Set).List()) return &filters } @@ -565,7 +565,7 @@ func unpackOperationalRisksFilters(filter *schema.Set) *Filters { filters.Artifact = m["artifact"].(string) } - filters.Risks = util.CastToStringArr(m["risks"].(*schema.Set).List()) + filters.Risks = sdk.CastToStringArr(m["risks"].(*schema.Set).List()) if m["scan_date"] != nil { filters.ScanDate = unpackStartAndEndDate(m["scan_date"].(*schema.Set)) @@ -628,7 +628,7 @@ func resourceXrayReportRead(ctx context.Context, d *schema.ResourceData, m inter report := Report{} projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -650,7 +650,7 @@ func resourceXrayReportRead(ctx context.Context, d *schema.ResourceData, m inter func resourceXrayReportDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -669,7 +669,7 @@ func resourceXrayReportDelete(_ context.Context, d *schema.ResourceData, m inter func createReport(reportType string, d *schema.ResourceData, m interface{}) diag.Diagnostics { report := unpackReport(d, reportType) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, report.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, report.ProjectKey) if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_ignore_rule.go b/pkg/xray/resource_xray_ignore_rule.go index da6929f7..240afc55 100644 --- a/pkg/xray/resource_xray_ignore_rule.go +++ b/pkg/xray/resource_xray_ignore_rule.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) type IgnoreRule struct { @@ -50,7 +50,7 @@ type IgnoreFilterNameVersionPath struct { } func resourceXrayIgnoreRule() *schema.Resource { - var ignoreRuleSchema = util.MergeMaps( + var ignoreRuleSchema = sdk.MergeMaps( getProjectKeySchema(true, ""), map[string]*schema.Schema{ "id": { @@ -417,7 +417,7 @@ func resourceXrayIgnoreRule() *schema.Resource { } ignoreFilters := IgnoreFilters{} - data := &util.ResourceData{ResourceData: d} + data := &sdk.ResourceData{ResourceData: d} vulnerabilities := data.GetSet("vulnerabilities") if len(vulnerabilities) > 0 { ignoreFilters.Vulnerabilities = vulnerabilities @@ -466,7 +466,7 @@ func resourceXrayIgnoreRule() *schema.Resource { ignoreRule := IgnoreRule{} projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -494,7 +494,7 @@ func resourceXrayIgnoreRule() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, ignoreRule.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, ignoreRule.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -533,7 +533,7 @@ func resourceXrayIgnoreRule() *schema.Resource { return diag.FromErr(err) } - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, ignoreRule.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, ignoreRule.ProjectKey) if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_ignore_rule_test.go b/pkg/xray/resource_xray_ignore_rule_test.go index 50180e0b..ec7d58bb 100644 --- a/pkg/xray/resource_xray_ignore_rule_test.go +++ b/pkg/xray/resource_xray_ignore_rule_test.go @@ -8,10 +8,10 @@ import ( "time" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/client" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) func TestAccIgnoreRule_objectives(t *testing.T) { @@ -23,10 +23,10 @@ func TestAccIgnoreRule_objectives(t *testing.T) { } func objectiveTestCase(objective string, t *testing.T) (*testing.T, resource.TestCase) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -64,10 +64,10 @@ func objectiveTestCase(objective string, t *testing.T) (*testing.T, resource.Tes } func TestAccIgnoreRule_operational_risk(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -108,10 +108,10 @@ func TestAccIgnoreRule_operational_risk(t *testing.T) { } func TestAccIgnoreRule_invalid_operational_risk(t *testing.T) { - _, _, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, _, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -139,10 +139,10 @@ func TestAccIgnoreRule_invalid_operational_risk(t *testing.T) { } func TestAccIgnoreRule_scopes_policies(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "fake_policy" { name = "fake-policy" description = "Security policy description" @@ -207,10 +207,10 @@ func TestAccIgnoreRule_scopes_policies(t *testing.T) { } func TestAccIgnoreRule_scopes_watches_policies(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "security" { name = "fake-policy" description = "Security policy description" @@ -294,9 +294,9 @@ func TestAccIgnoreRule_scopes_watches_policies(t *testing.T) { } func TestAccIgnoreRule_scopes_no_expiration_policies(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "security" { name = "fake-policy" description = "Security policy description" @@ -354,9 +354,9 @@ func TestAccIgnoreRule_scopes_no_expiration_policies(t *testing.T) { } func TestAccIgnoreRule_scopes_no_expiration_watches(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_security_policy" "security" { name = "fake-policy" description = "Security policy description" @@ -431,10 +431,10 @@ func TestAccIgnoreRule_scopes_no_expiration_watches(t *testing.T) { } func TestAccIgnoreRule_docker_layers(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -477,10 +477,10 @@ func TestAccIgnoreRule_docker_layers(t *testing.T) { } func TestAccIgnoreRule_invalid_docker_layers(t *testing.T) { - _, _, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, _, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -519,10 +519,10 @@ func TestAccIgnoreRule_sources(t *testing.T) { } func sourceTestCase(source string, t *testing.T) (*testing.T, resource.TestCase) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -565,10 +565,10 @@ func sourceTestCase(source string, t *testing.T) (*testing.T, resource.TestCase) } func TestAccIgnoreRule_artifact(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -613,10 +613,10 @@ func TestAccIgnoreRule_artifact(t *testing.T) { } func TestAccIgnoreRule_invalid_artifact_path(t *testing.T) { - _, _, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, _, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" @@ -646,11 +646,11 @@ func TestAccIgnoreRule_invalid_artifact_path(t *testing.T) { } func TestAccIgnoreRule_with_project_key(t *testing.T) { - _, fqrn, name := test.MkNames("ignore-rule-", "xray_ignore_rule") + _, fqrn, name := testutil.MkNames("ignore-rule-", "xray_ignore_rule") expirationDate := time.Now().Add(time.Hour * 48) - projectKey := fmt.Sprintf("testproj%d", test.RandSelect(1, 2, 3, 4, 5)) + projectKey := fmt.Sprintf("testproj%d", testutil.RandSelect(1, 2, 3, 4, 5)) - config := util.ExecuteTemplate("TestAccIgnoreRule", ` + config := sdk.ExecuteTemplate("TestAccIgnoreRule", ` resource "xray_ignore_rule" "{{ .name }}" { notes = "fake notes" expiration_date = "{{ .expirationDate }}" diff --git a/pkg/xray/resource_xray_license_policy.go b/pkg/xray/resource_xray_license_policy.go index 74c2dd25..0a9de836 100644 --- a/pkg/xray/resource_xray_license_policy.go +++ b/pkg/xray/resource_xray_license_policy.go @@ -2,7 +2,7 @@ package xray import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -38,7 +38,7 @@ func resourceXrayLicensePolicyV2() *schema.Resource { }, } - var actionsSchema = util.MergeMaps( + var actionsSchema = sdk.MergeMaps( commonActionsSchema, map[string]*schema.Schema{ "custom_severity": { diff --git a/pkg/xray/resource_xray_license_policy_test.go b/pkg/xray/resource_xray_license_policy_test.go index 0b9444ee..10d013fa 100644 --- a/pkg/xray/resource_xray_license_policy_test.go +++ b/pkg/xray/resource_xray_license_policy_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) var testDataLicense = map[string]string{ @@ -39,10 +39,10 @@ var testDataLicense = map[string]string{ // with specified cvss_range. The function unpackLicenseCriteria will ignore all the // fields except of "allow_unknown", "banned_licenses" and "allowed_licenses" if the Policy type is "license" func TestAccLicensePolicy_badLicenseCriteria(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - policyName := fmt.Sprintf("terraform-license-policy-1-%d", test.RandomInt()) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + policyName := fmt.Sprintf("terraform-license-policy-1-%d", testutil.RandomInt()) policyDesc := "policy created by xray acceptance tests" - ruleName := fmt.Sprintf("test-license-rule-1-%d", test.RandomInt()) + ruleName := fmt.Sprintf("test-license-rule-1-%d", testutil.RandomInt()) rangeTo := 5 resource.Test(t, resource.TestCase{ @@ -60,12 +60,12 @@ func TestAccLicensePolicy_badLicenseCriteria(t *testing.T) { // This test will try to create a license policy with failure grace period set, but without fail build turned on func TestAccLicensePolicy_badGracePeriod(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - testData := util.MergeMaps(testDataLicense) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-2-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-2-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-2-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-2-%d", testutil.RandomInt()) testData["fail_build"] = "false" testData["grace_period_days"] = "5" @@ -75,7 +75,7 @@ func TestAccLicensePolicy_badGracePeriod(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), ExpectError: regexp.MustCompile("Found Invalid Policy"), }, }, @@ -83,14 +83,14 @@ func TestAccLicensePolicy_badGracePeriod(t *testing.T) { } func TestAccLicensePolicy_withProjectKey(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - projectKey := fmt.Sprintf("testproj%d", test.RandSelect(1, 2, 3, 4, 5)) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + projectKey := fmt.Sprintf("testproj%d", testutil.RandSelect(1, 2, 3, 4, 5)) - testData := util.MergeMaps(testDataLicense) + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName testData["project_key"] = projectKey - testData["policy_name"] = fmt.Sprintf("terraform-license-policy-3-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-3-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-license-policy-3-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-3-%d", testutil.RandomInt()) testData["multi_license_permissive"] = "true" testData["allowedOrBanned"] = "allowed_licenses" @@ -126,11 +126,11 @@ func TestAccLicensePolicy_withProjectKey(t *testing.T) { } }` - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) - updatedTestData := util.MergeMaps(testData) + updatedTestData := sdk.MergeMaps(testData) updatedTestData["policy_description"] = "New description" - updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -165,12 +165,12 @@ func TestAccLicensePolicy_withProjectKey(t *testing.T) { } func TestAccLicensePolicy_createAllowedLic(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - testData := util.MergeMaps(testDataLicense) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-license-policy-3-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-3-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-license-policy-3-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-3-%d", testutil.RandomInt()) testData["multi_license_permissive"] = "true" testData["allowedOrBanned"] = "allowed_licenses" @@ -180,7 +180,7 @@ func TestAccLicensePolicy_createAllowedLic(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -193,12 +193,12 @@ func TestAccLicensePolicy_createAllowedLic(t *testing.T) { } func TestAccLicensePolicy_createAllowedLicCustom(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - testData := util.MergeMaps(testDataLicense) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-license-policy-3-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-3-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-license-policy-3-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-3-%d", testutil.RandomInt()) testData["multi_license_permissive"] = "true" testData["allowedOrBanned"] = "allowed_licenses" testData["license_1"] = "Custom-License" @@ -209,7 +209,7 @@ func TestAccLicensePolicy_createAllowedLicCustom(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -222,12 +222,12 @@ func TestAccLicensePolicy_createAllowedLicCustom(t *testing.T) { } func TestAccLicensePolicy_createBannedLic(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - testData := util.MergeMaps(testDataLicense) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-license-policy-4-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-4-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-license-policy-4-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-4-%d", testutil.RandomInt()) testData["allowedOrBanned"] = "banned_licenses" resource.Test(t, resource.TestCase{ @@ -236,7 +236,7 @@ func TestAccLicensePolicy_createBannedLic(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -250,12 +250,12 @@ func TestAccLicensePolicy_createBannedLic(t *testing.T) { } func TestAccLicensePolicy_createBannedLicCustom(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - testData := util.MergeMaps(testDataLicense) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-license-policy-4-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-4-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-license-policy-4-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-4-%d", testutil.RandomInt()) testData["allowedOrBanned"] = "banned_licenses" testData["license_1"] = "Custom-License" @@ -265,7 +265,7 @@ func TestAccLicensePolicy_createBannedLicCustom(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -279,12 +279,12 @@ func TestAccLicensePolicy_createBannedLicCustom(t *testing.T) { } func TestAccLicensePolicy_createMultiLicensePermissiveFalse(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - testData := util.MergeMaps(testDataLicense) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-license-policy-5-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-5-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-license-policy-5-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-5-%d", testutil.RandomInt()) testData["allowedOrBanned"] = "banned_licenses" resource.Test(t, resource.TestCase{ @@ -293,7 +293,7 @@ func TestAccLicensePolicy_createMultiLicensePermissiveFalse(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { @@ -307,12 +307,12 @@ func TestAccLicensePolicy_createMultiLicensePermissiveFalse(t *testing.T) { } func TestAccLicensePolicy_createBlockFalse(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_license_policy") - testData := util.MergeMaps(testDataLicense) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_license_policy") + testData := sdk.MergeMaps(testDataLicense) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-license-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-license-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-license-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-license-rule-6-%d", testutil.RandomInt()) testData["block_unscanned"] = "true" testData["block_active"] = "true" testData["allowedOrBanned"] = "banned_licenses" @@ -323,7 +323,7 @@ func TestAccLicensePolicy_createBlockFalse(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, licensePolicyTemplate, testData), Check: verifyLicensePolicy(fqrn, testData, testData["allowedOrBanned"]), }, { diff --git a/pkg/xray/resource_xray_operational_risk_policy_test.go b/pkg/xray/resource_xray_operational_risk_policy_test.go index 0a478180..f6ff41f8 100644 --- a/pkg/xray/resource_xray_operational_risk_policy_test.go +++ b/pkg/xray/resource_xray_operational_risk_policy_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) var testDataOperationalRisk = map[string]string{ @@ -28,8 +28,8 @@ var testDataOperationalRisk = map[string]string{ } func TestAccOperationalRiskPolicy_withProjectKey(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_operational_risk_policy") - projectKey := fmt.Sprintf("testproj%d", test.RandSelect(1, 2, 3, 4, 5)) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_operational_risk_policy") + projectKey := fmt.Sprintf("testproj%d", testutil.RandSelect(1, 2, 3, 4, 5)) template := `resource "xray_operational_risk_policy" "{{ .resource_name }}" { name = "{{ .policy_name }}" @@ -58,16 +58,16 @@ func TestAccOperationalRiskPolicy_withProjectKey(t *testing.T) { } }` - testData := util.MergeMaps(testDataOperationalRisk) + testData := sdk.MergeMaps(testDataOperationalRisk) testData["resource_name"] = resourceName testData["project_key"] = projectKey testData["op_risk_min_risk"] = "Medium" - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) - updatedTestData := util.MergeMaps(testData) + updatedTestData := sdk.MergeMaps(testData) updatedTestData["policy_description"] = "New description" - updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -102,7 +102,7 @@ func TestAccOperationalRiskPolicy_withProjectKey(t *testing.T) { } func TestAccOperationalRiskPolicy_minRiskCriteria(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_operational_risk_policy") + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_operational_risk_policy") const opertionalRiskPolicyMinRisk = `resource "xray_operational_risk_policy" "{{ .resource_name }}" { name = "{{ .policy_name }}" @@ -129,7 +129,7 @@ func TestAccOperationalRiskPolicy_minRiskCriteria(t *testing.T) { } }` - testData := util.MergeMaps(testDataOperationalRisk) + testData := sdk.MergeMaps(testDataOperationalRisk) testData["resource_name"] = resourceName testData["op_risk_min_risk"] = "Medium" @@ -139,7 +139,7 @@ func TestAccOperationalRiskPolicy_minRiskCriteria(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, opertionalRiskPolicyMinRisk, testData), + Config: sdk.ExecuteTemplate(fqrn, opertionalRiskPolicyMinRisk, testData), Check: resource.ComposeTestCheckFunc( verifyOpertionalRiskPolicy(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "rule.0.criteria.0.op_risk_min_risk", testData["op_risk_min_risk"]), @@ -155,7 +155,7 @@ func TestAccOperationalRiskPolicy_minRiskCriteria(t *testing.T) { } func TestAccOperationalRiskPolicy_customCriteria(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_operational_risk_policy") + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_operational_risk_policy") const opertionalRiskPolicyCustom = `resource "xray_operational_risk_policy" "{{ .resource_name }}" { name = "{{ .policy_name }}" @@ -191,16 +191,16 @@ func TestAccOperationalRiskPolicy_customCriteria(t *testing.T) { } }` - testData := util.MergeMaps(testDataOperationalRisk) + testData := sdk.MergeMaps(testDataOperationalRisk) testData["resource_name"] = resourceName testData["op_risk_custom_use_and_condition"] = "true" testData["op_risk_custom_is_eol"] = "false" - testData["op_risk_custom_release_date_greater_than_months"] = test.RandSelect("6", "12", "18", "24", "30", "36").(string) - testData["op_risk_custom_newer_versions_greater_than"] = test.RandSelect("1", "2", "3", "4", "5").(string) - testData["op_risk_custom_release_cadence_per_year_less_than"] = test.RandSelect("1", "2", "3", "4", "5").(string) - testData["op_risk_custom_commits_less_than"] = test.RandSelect("10", "25", "50", "100").(string) - testData["op_risk_custom_committers_less_than"] = test.RandSelect("1", "2", "3", "4", "5").(string) - testData["op_risk_custom_risk"] = test.RandSelect("high", "medium", "low").(string) + testData["op_risk_custom_release_date_greater_than_months"] = testutil.RandSelect("6", "12", "18", "24", "30", "36").(string) + testData["op_risk_custom_newer_versions_greater_than"] = testutil.RandSelect("1", "2", "3", "4", "5").(string) + testData["op_risk_custom_release_cadence_per_year_less_than"] = testutil.RandSelect("1", "2", "3", "4", "5").(string) + testData["op_risk_custom_commits_less_than"] = testutil.RandSelect("10", "25", "50", "100").(string) + testData["op_risk_custom_committers_less_than"] = testutil.RandSelect("1", "2", "3", "4", "5").(string) + testData["op_risk_custom_risk"] = testutil.RandSelect("high", "medium", "low").(string) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -208,7 +208,7 @@ func TestAccOperationalRiskPolicy_customCriteria(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), + Config: sdk.ExecuteTemplate(fqrn, opertionalRiskPolicyCustom, testData), Check: resource.ComposeTestCheckFunc( verifyOpertionalRiskPolicy(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "rule.0.criteria.0.op_risk_custom.0.use_and_condition", testData["op_risk_custom_use_and_condition"]), @@ -247,9 +247,9 @@ func verifyOpertionalRiskPolicy(fqrn string, testData map[string]string) resourc } func TestAccOperationalRiskPolicy_criteriaValidation(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_operational_risk_policy") + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_operational_risk_policy") - testData := util.MergeMaps(testDataOperationalRisk) + testData := sdk.MergeMaps(testDataOperationalRisk) testData["resource_name"] = resourceName template := ` @@ -282,7 +282,7 @@ func TestAccOperationalRiskPolicy_criteriaValidation(t *testing.T) { } }` - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/pkg/xray/resource_xray_report_test.go b/pkg/xray/resource_xray_report_test.go index 2924bc4b..2f7a7320 100644 --- a/pkg/xray/resource_xray_report_test.go +++ b/pkg/xray/resource_xray_report_test.go @@ -7,10 +7,10 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/client" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" "golang.org/x/text/cases" "golang.org/x/text/language" ) @@ -466,17 +466,17 @@ func TestAccReport_BadVulnerabilitiesFilter(t *testing.T) { func mkFilterTestCase(t *testing.T, resourceFields map[string]interface{}, filterFields map[string]interface{}, reportName string, resourceName string) (*testing.T, resource.TestCase) { - _, fqrn, name := test.MkNames(reportName, resourceName) + _, fqrn, name := testutil.MkNames(reportName, resourceName) - allFields := util.MergeMaps(filterFields, resourceFields) - allFieldsHcl := util.FmtMapToHcl(allFields) + allFields := sdk.MergeMaps(filterFields, resourceFields) + allFieldsHcl := sdk.FmtMapToHcl(allFields) const remoteRepoFull = ` resource "%s" "%s" { %s } ` - extraChecks := test.MapToTestChecks(fqrn, resourceFields) - defaultChecks := test.MapToTestChecks(fqrn, allFields) + extraChecks := testutil.MapToTestChecks(fqrn, resourceFields) + defaultChecks := testutil.MapToTestChecks(fqrn, allFields) checks := append(defaultChecks, extraChecks...) config := fmt.Sprintf(remoteRepoFull, resourceName, name, allFieldsHcl) @@ -496,10 +496,10 @@ func mkFilterTestCase(t *testing.T, resourceFields map[string]interface{}, filte func mkFilterNegativeTestCase(t *testing.T, resourceFields map[string]interface{}, filterFields map[string]interface{}, reportName string, resourceName string, expectedErrorMessage string) (*testing.T, resource.TestCase) { - _, _, name := test.MkNames(reportName, resourceName) + _, _, name := testutil.MkNames(reportName, resourceName) - allFields := util.MergeMaps(filterFields, resourceFields) - allFieldsHcl := util.FmtMapToHcl(allFields) + allFields := sdk.MergeMaps(filterFields, resourceFields) + allFieldsHcl := sdk.FmtMapToHcl(allFields) const remoteRepoFull = ` resource "%s" "%s" { %s diff --git a/pkg/xray/resource_xray_security_policy_test.go b/pkg/xray/resource_xray_security_policy_test.go index 858506df..645f605f 100644 --- a/pkg/xray/resource_xray_security_policy_test.go +++ b/pkg/xray/resource_xray_security_policy_test.go @@ -8,9 +8,9 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/go-version" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) const criteriaTypeCvss = "cvss" @@ -39,12 +39,12 @@ var testDataSecurity = map[string]string{ } func TestAccSecurityPolicy_unknownMinSeveritySecurityPolicy_beforeVersion3602(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-%d", testutil.RandomInt()) testData["min_severity"] = "All severities" var onOrAfterVersion3602 = func() (bool, error) { @@ -89,7 +89,7 @@ func TestAccSecurityPolicy_unknownMinSeveritySecurityPolicy_beforeVersion3602(t Steps: []resource.TestStep{ { SkipFunc: onOrAfterVersion3602, - Config: util.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, }, @@ -99,11 +99,11 @@ func TestAccSecurityPolicy_unknownMinSeveritySecurityPolicy_beforeVersion3602(t // The test will try to create a security policy with the type of "license" // The Policy criteria will be ignored in this case func TestAccSecurityPolicy_badTypeInSecurityPolicy(t *testing.T) { - policyName := fmt.Sprintf("terraform-security-policy-1-%d", test.RandomInt()) + policyName := fmt.Sprintf("terraform-security-policy-1-%d", testutil.RandomInt()) policyDesc := "policy created by xray acceptance tests" - ruleName := fmt.Sprintf("test-security-rule-1-%d", test.RandomInt()) + ruleName := fmt.Sprintf("test-security-rule-1-%d", testutil.RandomInt()) rangeTo := 5 - resourceName := "policy-" + strconv.Itoa(test.RandomInt()) + resourceName := "policy-" + strconv.Itoa(testutil.RandomInt()) fqrn := "xray_security_policy." + resourceName resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -121,11 +121,11 @@ func TestAccSecurityPolicy_badTypeInSecurityPolicy(t *testing.T) { // The test will try to use "allowed_licenses" in the security policy criteria // That field is acceptable only in license policy. No API call, expected to fail on the TF resource verification func TestAccSecurityPolicy_badSecurityCriteria(t *testing.T) { - policyName := fmt.Sprintf("terraform-security-policy-2-%d", test.RandomInt()) + policyName := fmt.Sprintf("terraform-security-policy-2-%d", testutil.RandomInt()) policyDesc := "policy created by xray acceptance tests" - ruleName := fmt.Sprintf("test-security-rule-2-%d", test.RandomInt()) + ruleName := fmt.Sprintf("test-security-rule-2-%d", testutil.RandomInt()) allowedLicense := "BSD-4-Clause" - resourceName := "policy-" + strconv.Itoa(test.RandomInt()) + resourceName := "policy-" + strconv.Itoa(testutil.RandomInt()) fqrn := "xray_security_policy." + resourceName resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -143,12 +143,12 @@ func TestAccSecurityPolicy_badSecurityCriteria(t *testing.T) { // This test will try to create a security policy with "build_failure_grace_period_in_days" set, // but with "fail_build" set to false, which conflicts with the field mentioned above. func TestAccSecurityPolicy_badGracePeriod(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-3-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-3-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-3-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-3-%d", testutil.RandomInt()) testData["fail_build"] = "false" testData["grace_period_days"] = "5" @@ -158,7 +158,7 @@ func TestAccSecurityPolicy_badGracePeriod(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), ExpectError: regexp.MustCompile("Found Invalid Policy"), }, }, @@ -166,14 +166,14 @@ func TestAccSecurityPolicy_badGracePeriod(t *testing.T) { } func TestAccSecurityPolicy_withProjectKey(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - projectKey := fmt.Sprintf("testproj%d", test.RandSelect(1, 2, 3, 4, 5)) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + projectKey := fmt.Sprintf("testproj%d", testutil.RandSelect(1, 2, 3, 4, 5)) - testData := util.MergeMaps(testDataSecurity) + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName testData["project_key"] = projectKey - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-4-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-4-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-4-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-4-%d", testutil.RandomInt()) template := `resource "xray_security_policy" "{{ .resource_name }}" { name = "{{ .policy_name }}" @@ -205,11 +205,11 @@ func TestAccSecurityPolicy_withProjectKey(t *testing.T) { } }` - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) - updatedTestData := util.MergeMaps(testData) + updatedTestData := sdk.MergeMaps(testData) updatedTestData["policy_description"] = "New description" - updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -245,12 +245,12 @@ func TestAccSecurityPolicy_withProjectKey(t *testing.T) { // CVSS criteria, block downloading of unscanned and active func TestAccSecurityPolicy_createBlockDownloadTrueCVSS(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-4-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-4-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-4-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-4-%d", testutil.RandomInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -258,7 +258,7 @@ func TestAccSecurityPolicy_createBlockDownloadTrueCVSS(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeCvss), }, { @@ -272,12 +272,12 @@ func TestAccSecurityPolicy_createBlockDownloadTrueCVSS(t *testing.T) { // CVSS criteria, allow downloading of unscanned and active func TestAccSecurityPolicy_createBlockDownloadFalseCVSS(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-5-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-5-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-5-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-5-%d", testutil.RandomInt()) testData["block_unscanned"] = "false" testData["block_active"] = "false" @@ -287,7 +287,7 @@ func TestAccSecurityPolicy_createBlockDownloadFalseCVSS(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeCvss), }, { @@ -301,12 +301,12 @@ func TestAccSecurityPolicy_createBlockDownloadFalseCVSS(t *testing.T) { // Min severity criteria, block downloading of unscanned and active func TestAccSecurityPolicy_createBlockDownloadTrueMinSeverity(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", testutil.RandomInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -314,7 +314,7 @@ func TestAccSecurityPolicy_createBlockDownloadTrueMinSeverity(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, { @@ -328,12 +328,12 @@ func TestAccSecurityPolicy_createBlockDownloadTrueMinSeverity(t *testing.T) { // Min severity criteria, block downloading of unscanned and active, fix_version_dependant = true func TestAccSecurityPolicy_createFixVersionDepMinSeverity(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", testutil.RandomInt()) testData["min_severity"] = "High" testData["fix_version_dependant"] = "true" @@ -343,7 +343,7 @@ func TestAccSecurityPolicy_createFixVersionDepMinSeverity(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyFixVersionDep, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyFixVersionDep, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, { @@ -358,12 +358,12 @@ func TestAccSecurityPolicy_createFixVersionDepMinSeverity(t *testing.T) { // Malicious package criteria, block downloading of unscanned and active, fix_version_dependant = false func TestAccSecurityPolicy_createMaliciousPackage(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", testutil.RandomInt()) testData["malicious_package"] = "true" testData["fix_version_dependant"] = "false" @@ -373,7 +373,7 @@ func TestAccSecurityPolicy_createMaliciousPackage(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeMaliciousPkg), }, { @@ -387,12 +387,12 @@ func TestAccSecurityPolicy_createMaliciousPackage(t *testing.T) { } func TestAccSecurityPolicy_createMaliciousPackageFail(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", testutil.RandomInt()) testData["malicious_package"] = "true" testData["fix_version_dependant"] = "true" @@ -402,7 +402,7 @@ func TestAccSecurityPolicy_createMaliciousPackageFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyMaliciousPkgFixVersionDep, testData), ExpectError: regexp.MustCompile("fix_version_dependant must be set to false if malicious_package is true"), }, }, @@ -410,12 +410,12 @@ func TestAccSecurityPolicy_createMaliciousPackageFail(t *testing.T) { } func TestAccSecurityPolicy_createMaliciousPackageCvssMinSeverityFail(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", testutil.RandomInt()) testData["malicious_package"] = "true" testData["min_severity"] = "High" @@ -425,7 +425,7 @@ func TestAccSecurityPolicy_createMaliciousPackageCvssMinSeverityFail(t *testing. ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), ExpectError: regexp.MustCompile("malicious_package can't be set together with min_severity and/or cvss_range"), }, }, @@ -433,12 +433,12 @@ func TestAccSecurityPolicy_createMaliciousPackageCvssMinSeverityFail(t *testing. } func TestAccSecurityPolicy_createCvssMinSeverityFail(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", testutil.RandomInt()) testData["malicious_package"] = "false" testData["min_severity"] = "High" @@ -448,7 +448,7 @@ func TestAccSecurityPolicy_createCvssMinSeverityFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSSMinSeverityMaliciousPkg, testData), ExpectError: regexp.MustCompile("min_severity can't be set together with cvss_range"), }, }, @@ -457,12 +457,12 @@ func TestAccSecurityPolicy_createCvssMinSeverityFail(t *testing.T) { // Min severity criteria, allow downloading of unscanned and active func TestAccSecurityPolicy_createBlockDownloadFalseMinSeverity(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-7-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-7-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-7-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-7-%d", testutil.RandomInt()) testData["block_unscanned"] = "false" testData["block_active"] = "false" @@ -472,7 +472,7 @@ func TestAccSecurityPolicy_createBlockDownloadFalseMinSeverity(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyMinSeverity, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeSeverity), }, { @@ -486,12 +486,12 @@ func TestAccSecurityPolicy_createBlockDownloadFalseMinSeverity(t *testing.T) { // CVSS criteria, use float values for CVSS range func TestAccSecurityPolicy_createCVSSFloat(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-8-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-8-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-8-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-8-%d", testutil.RandomInt()) testData["cvss_from"] = "1.5" testData["cvss_to"] = "5.3" @@ -501,7 +501,7 @@ func TestAccSecurityPolicy_createCVSSFloat(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeCvss), }, { @@ -515,12 +515,12 @@ func TestAccSecurityPolicy_createCVSSFloat(t *testing.T) { // Negative test, block unscanned cannot be set without blocking of download func TestAccSecurityPolicy_blockMismatchCVSS(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", testutil.RandomInt()) testData["block_unscanned"] = "true" testData["block_active"] = "false" @@ -530,7 +530,7 @@ func TestAccSecurityPolicy_blockMismatchCVSS(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyCVSS, testData), ExpectError: regexp.MustCompile("Found Invalid Policy"), }, }, @@ -538,12 +538,12 @@ func TestAccSecurityPolicy_blockMismatchCVSS(t *testing.T) { } func TestAccSecurityPolicy_noActions(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", testutil.RandomInt()) testData["block_unscanned"] = "false" testData["block_active"] = "false" testData["CVE_1"] = "CVE-2022-12345" @@ -556,7 +556,7 @@ func TestAccSecurityPolicy_noActions(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyNoActions, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyNoActions, testData), ExpectError: regexp.MustCompile("Insufficient actions blocks"), }, }, @@ -564,12 +564,12 @@ func TestAccSecurityPolicy_noActions(t *testing.T) { } func TestAccSecurityPolicy_vulnerabilityIds(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", testutil.RandomInt()) testData["block_unscanned"] = "false" testData["block_active"] = "false" testData["CVE_1"] = "CVE-2022-12345" @@ -582,7 +582,7 @@ func TestAccSecurityPolicy_vulnerabilityIds(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeVulnerabilityIds), }, { @@ -595,13 +595,13 @@ func TestAccSecurityPolicy_vulnerabilityIds(t *testing.T) { } func TestAccSecurityPolicy_vulnerabilityIdsIncorrectCVEFails(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) for _, invalidCVE := range []string{"CVE-20211-67890", "CVE-2021-678", "Xray-12345", "cve-2021-67890", "CVE-11-67890", "XRAY-1"} { testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", testutil.RandomInt()) testData["block_unscanned"] = "false" testData["block_active"] = "false" testData["CVE_1"] = invalidCVE @@ -614,7 +614,7 @@ func TestAccSecurityPolicy_vulnerabilityIdsIncorrectCVEFails(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIds, testData), ExpectError: regexp.MustCompile("invalid value for vulnerability_ids"), }, }, @@ -623,8 +623,8 @@ func TestAccSecurityPolicy_vulnerabilityIdsIncorrectCVEFails(t *testing.T) { } func TestAccSecurityPolicy_conflictingAttributesFail(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testAttributes := []string{ "vulnerability_ids = [\"CVE-2022-12345\", \"CVE-2021-67890\", \"XRAY-1234\"]", @@ -640,8 +640,8 @@ func TestAccSecurityPolicy_conflictingAttributesFail(t *testing.T) { continue } testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", testutil.RandomInt()) testData["block_unscanned"] = "false" testData["block_active"] = "false" testData["test_attribute"] = testAttribute @@ -654,7 +654,7 @@ func TestAccSecurityPolicy_conflictingAttributesFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIdsConflict, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIdsConflict, testData), ExpectError: regexp.MustCompile("can't be set together"), }, }, @@ -663,12 +663,12 @@ func TestAccSecurityPolicy_conflictingAttributesFail(t *testing.T) { } } func TestAccSecurityPolicy_vulnerabilityIdsLimitFail(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) CVEString := generateListOfNames("CVE-2022-", 101) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-9-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-9-%d", testutil.RandomInt()) testData["block_unscanned"] = "false" testData["block_active"] = "false" testData["CVEs"] = CVEString @@ -679,7 +679,7 @@ func TestAccSecurityPolicy_vulnerabilityIdsLimitFail(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyVulnIdsLimit, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyVulnIdsLimit, testData), ExpectError: regexp.MustCompile("Too many list items"), }, }, @@ -687,12 +687,12 @@ func TestAccSecurityPolicy_vulnerabilityIdsLimitFail(t *testing.T) { } func TestAccSecurityPolicy_exposures(t *testing.T) { - _, fqrn, resourceName := test.MkNames("policy-", "xray_security_policy") - testData := util.MergeMaps(testDataSecurity) + _, fqrn, resourceName := testutil.MkNames("policy-", "xray_security_policy") + testData := sdk.MergeMaps(testDataSecurity) testData["resource_name"] = resourceName - testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", test.RandomInt()) - testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", test.RandomInt()) + testData["policy_name"] = fmt.Sprintf("terraform-security-policy-6-%d", testutil.RandomInt()) + testData["rule_name"] = fmt.Sprintf("test-security-rule-6-%d", testutil.RandomInt()) testData["exposures_min_severity"] = "High" testData["exposures_secrets"] = "true" testData["exposures_applications"] = "true" @@ -705,7 +705,7 @@ func TestAccSecurityPolicy_exposures(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, securityPolicyExposures, testData), + Config: sdk.ExecuteTemplate(fqrn, securityPolicyExposures, testData), Check: verifySecurityPolicy(fqrn, testData, criteriaTypeExposures), }, { diff --git a/pkg/xray/resource_xray_settings.go b/pkg/xray/resource_xray_settings.go index 08eb77b2..523d5706 100644 --- a/pkg/xray/resource_xray_settings.go +++ b/pkg/xray/resource_xray_settings.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) func resourceXraySettings() *schema.Resource { @@ -38,7 +38,7 @@ type DbSyncDailyUpdatesTime struct { } func unpackDBSyncTime(s *schema.ResourceData) DbSyncDailyUpdatesTime { - d := &util.ResourceData{ResourceData: s} + d := &sdk.ResourceData{ResourceData: s} dbSyncTime := DbSyncDailyUpdatesTime{ DbSyncTime: d.GetString("db_sync_updates_time", false), } @@ -54,7 +54,7 @@ func packDBSyncTime(dbSyncTime DbSyncDailyUpdatesTime, d *schema.ResourceData) d func resourceXrayDbSyncTimeRead(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { dbSyncTime := DbSyncDailyUpdatesTime{} - resp, err := m.(util.ProvderMetadata).Client.R().SetResult(&dbSyncTime).Get("xray/api/v1/configuration/dbsync/time") + resp, err := m.(sdk.ProvderMetadata).Client.R().SetResult(&dbSyncTime).Get("xray/api/v1/configuration/dbsync/time") if err != nil { if resp != nil && resp.StatusCode() != http.StatusOK { log.Printf("Critical error. DB sync settings (%s) not found.", d.Id()) @@ -67,7 +67,7 @@ func resourceXrayDbSyncTimeRead(_ context.Context, d *schema.ResourceData, m int func resourceXrayDbSyncTimeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { dbSyncTime := unpackDBSyncTime(d) - _, err := m.(util.ProvderMetadata).Client.R().SetBody(dbSyncTime).Put("xray/api/v1/configuration/dbsync/time") + _, err := m.(sdk.ProvderMetadata).Client.R().SetBody(dbSyncTime).Put("xray/api/v1/configuration/dbsync/time") if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_settings_test.go b/pkg/xray/resource_xray_settings_test.go index 24827f0c..55bd8a3e 100644 --- a/pkg/xray/resource_xray_settings_test.go +++ b/pkg/xray/resource_xray_settings_test.go @@ -5,12 +5,12 @@ import ( "regexp" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/jfrog/terraform-provider-shared/testutil" ) func TestDbSyncTime(t *testing.T) { - _, fqrn, resourceName := test.MkNames("db_sync-", "xray_settings") + _, fqrn, resourceName := testutil.MkNames("db_sync-", "xray_settings") time := "18:45" resource.Test(t, resource.TestCase{ @@ -26,7 +26,7 @@ func TestDbSyncTime(t *testing.T) { } func TestDbSyncTimeNegative(t *testing.T) { - _, _, resourceName := test.MkNames("db_sync-", "xray_settings") + _, _, resourceName := testutil.MkNames("db_sync-", "xray_settings") var invalidTime = []string{"24:00", "24:55", "", "12:0", "string", "12pm", "9:00"} for _, time := range invalidTime { resource.Test(t, resource.TestCase{ diff --git a/pkg/xray/resource_xray_watch.go b/pkg/xray/resource_xray_watch.go index 35c8c138..8579bd51 100644 --- a/pkg/xray/resource_xray_watch.go +++ b/pkg/xray/resource_xray_watch.go @@ -2,7 +2,7 @@ package xray import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" ) @@ -20,7 +20,7 @@ func resourceXrayWatch() *schema.Resource { CustomizeDiff: watchResourceDiff, - Schema: util.MergeMaps( + Schema: sdk.MergeMaps( getProjectKeySchema(false, "Support repository and build watch resource types. When specifying individual repository or build they must be already assigned to the project. Build must be added as indexed resources."), map[string]*schema.Schema{ "name": { diff --git a/pkg/xray/resource_xray_watch_test.go b/pkg/xray/resource_xray_watch_test.go index 72d609aa..c89021c2 100644 --- a/pkg/xray/resource_xray_watch_test.go +++ b/pkg/xray/resource_xray_watch_test.go @@ -8,10 +8,10 @@ import ( "time" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/jfrog/terraform-provider-shared/client" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) var testDataWatch = map[string]string{ @@ -33,12 +33,12 @@ var testDataWatch = map[string]string{ } func TestAccWatch_allReposSinglePolicy(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -50,7 +50,7 @@ func TestAccWatch_allReposSinglePolicy(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, allReposSinglePolicyWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, allReposSinglePolicyWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -63,12 +63,12 @@ func TestAccWatch_allReposSinglePolicy(t *testing.T) { } func TestAccWatch_allReposPathAntFilter(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["exclude_patterns0"] = "**/*.md" testData["include_patterns0"] = "**/*.js" @@ -82,7 +82,7 @@ func TestAccWatch_allReposPathAntFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, allReposPathAntFilterWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, allReposPathAntFilterWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -95,12 +95,12 @@ func TestAccWatch_allReposPathAntFilter(t *testing.T) { } func TestAccWatch_allReposKvFilter(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["kv_filter_key0"] = "test-property-name" testData["kv_filter_value0"] = "test-property-value" @@ -114,7 +114,7 @@ func TestAccWatch_allReposKvFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, allReposKvFilterWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, allReposKvFilterWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -127,15 +127,15 @@ func TestAccWatch_allReposKvFilter(t *testing.T) { } func TestAccWatch_allReposWithProjectKey(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") projectKey := RandomProjectName() - testData := util.MergeMaps(testDataWatch) + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName testData["project_key"] = projectKey - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) template := `resource "xray_security_policy" "security" { name = "{{ .policy_name_0 }}" @@ -184,11 +184,11 @@ func TestAccWatch_allReposWithProjectKey(t *testing.T) { watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) - updatedTestData := util.MergeMaps(testData) + updatedTestData := sdk.MergeMaps(testData) updatedTestData["description"] = "New description" - updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -224,14 +224,14 @@ func TestAccWatch_allReposWithProjectKey(t *testing.T) { } func TestAccWatch_allReposMultiplePolicies(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-1%d", test.RandomInt()) - testData["policy_name_1"] = fmt.Sprintf("xray-policy-2%d", test.RandomInt()) - testData["policy_name_2"] = fmt.Sprintf("xray-policy-3%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-1%d", testutil.RandomInt()) + testData["policy_name_1"] = fmt.Sprintf("xray-policy-2%d", testutil.RandomInt()) + testData["policy_name_2"] = fmt.Sprintf("xray-policy-3%d", testutil.RandomInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -246,7 +246,7 @@ func TestAccWatch_allReposMultiplePolicies(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, allReposMultiplePoliciesWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, allReposMultiplePoliciesWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(fqrn, "name", testData["watch_name"]), resource.TestCheckResourceAttr(fqrn, "description", testData["description"]), @@ -281,15 +281,15 @@ func TestAccWatch_allReposMultiplePolicies(t *testing.T) { } func makeSingleRepositoryTestCase(repoType string, t *testing.T) (*testing.T, resource.TestCase) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" testData["repo_type"] = repoType - testData["repo0"] = fmt.Sprintf("libs-release-%s-0-%d", repoType, test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-%s-0-%d", repoType, testutil.RandomInt()) return t, resource.TestCase{ PreCheck: func() { @@ -306,7 +306,7 @@ func makeSingleRepositoryTestCase(repoType string, t *testing.T) (*testing.T, re ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemNestedAttrs(fqrn, "watch_resource.*.filter.*", map[string]string{ @@ -336,15 +336,15 @@ func TestAccWatch_singleRepository(t *testing.T) { } func TestAccWatch_singleRepositoryWithProjectKey(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - repoKey := fmt.Sprintf("local-%d", test.RandomInt()) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + repoKey := fmt.Sprintf("local-%d", testutil.RandomInt()) projectKey := RandomProjectName() - testData := util.MergeMaps(testDataWatch) + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName testData["project_key"] = projectKey - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" testData["repo_type"] = "local" testData["repo0"] = repoKey @@ -395,7 +395,7 @@ func TestAccWatch_singleRepositoryWithProjectKey(t *testing.T) { watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -430,16 +430,16 @@ func TestAccWatch_singleRepositoryWithProjectKey(t *testing.T) { } func TestAccWatch_singleRepoMimeTypeFilter(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) repoType := "local" testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" - testData["repo0"] = fmt.Sprintf("libs-release-%s-0-%d", repoType, test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-%s-0-%d", repoType, testutil.RandomInt()) testData["repo_type"] = repoType testData["filter_type_0"] = "mime-type" testData["filter_value_0"] = "application/json" @@ -458,7 +458,7 @@ func TestAccWatch_singleRepoMimeTypeFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, singleRepositoryWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemNestedAttrs(fqrn, "watch_resource.*.filter.*", map[string]string{ @@ -472,16 +472,16 @@ func TestAccWatch_singleRepoMimeTypeFilter(t *testing.T) { } func TestAccWatch_singleRepoKvFilter(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) repoType := "local" testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" - testData["repo0"] = fmt.Sprintf("libs-release-%s-0-%d", repoType, test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-%s-0-%d", repoType, testutil.RandomInt()) testData["repo_type"] = repoType testData["kv_filter_type"] = "property" testData["kv_filter_key_0"] = "test-key-1" @@ -502,7 +502,7 @@ func TestAccWatch_singleRepoKvFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, kvFilters, testData), + Config: sdk.ExecuteTemplate(fqrn, kvFilters, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemNestedAttrs(fqrn, "watch_resource.*.kv_filter.*", map[string]string{ @@ -522,14 +522,14 @@ func TestAccWatch_singleRepoKvFilter(t *testing.T) { } func TestAccWatch_repositoryMissingRepoType(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" - testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", testutil.RandomInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -546,7 +546,7 @@ func TestAccWatch_repositoryMissingRepoType(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, singleRepositoryInvalidWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, singleRepositoryInvalidWatchTemplate, testData), ExpectError: regexp.MustCompile(`attribute 'repo_type' not set when 'watch_resource\.type' is set to 'repository'`), }, }, @@ -554,16 +554,16 @@ func TestAccWatch_repositoryMissingRepoType(t *testing.T) { } func TestAccWatch_multipleRepositories(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" testData["repo_type"] = "local" - testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", test.RandomInt()) - testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", testutil.RandomInt()) + testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", testutil.RandomInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -581,7 +581,7 @@ func TestAccWatch_multipleRepositories(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, multipleRepositoriesWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, multipleRepositoriesWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -594,17 +594,17 @@ func TestAccWatch_multipleRepositories(t *testing.T) { } func TestAccWatch_multipleRepositoriesPathAntPatterns(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" testData["repo_type"] = "local" - testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", test.RandomInt()) - testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", test.RandomInt()) - testData["repo2"] = fmt.Sprintf("libs-release-local-1-%d", test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", testutil.RandomInt()) + testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", testutil.RandomInt()) + testData["repo2"] = fmt.Sprintf("libs-release-local-1-%d", testutil.RandomInt()) testData["include_patterns0"] = "**/*.js" testData["exclude_patterns1"] = "**/*.txt" testData["include_patterns2"] = "**/*.jar" @@ -628,7 +628,7 @@ func TestAccWatch_multipleRepositoriesPathAntPatterns(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, pathAntPatterns, testData), + Config: sdk.ExecuteTemplate(fqrn, pathAntPatterns, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "watch_resource.0.type", testData["watch_type"]), @@ -650,16 +650,16 @@ func TestAccWatch_multipleRepositoriesPathAntPatterns(t *testing.T) { } func TestAccWatch_PathAntPatternsError(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "build" testData["repo_type"] = "local" - testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", test.RandomInt()) - testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", testutil.RandomInt()) + testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", testutil.RandomInt()) testData["exclude_patterns0"] = "**/*.md" testData["include_patterns0"] = "**/*.js" testData["exclude_patterns1"] = "**/*.md" @@ -681,7 +681,7 @@ func TestAccWatch_PathAntPatternsError(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, pathAntPatterns, testData), + Config: sdk.ExecuteTemplate(fqrn, pathAntPatterns, testData), ExpectError: regexp.MustCompile("attribute 'path_ant_filter' is set when 'watch_resource.type' is not set to 'repository' or 'all-repos'"), }, }, @@ -689,16 +689,16 @@ func TestAccWatch_PathAntPatternsError(t *testing.T) { } func TestAccWatch_multipleRepositoriesKvFilter(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "repository" testData["repo_type"] = "local" - testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", test.RandomInt()) - testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", testutil.RandomInt()) + testData["repo1"] = fmt.Sprintf("libs-release-local-1-%d", testutil.RandomInt()) testData["kv_filter_type"] = "property" testData["kv_filter_key_0"] = "test-key-1" testData["kv_filter_value_0"] = "test-value-1" @@ -721,7 +721,7 @@ func TestAccWatch_multipleRepositoriesKvFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, multipleRepositoriesKvFilter, testData), + Config: sdk.ExecuteTemplate(fqrn, multipleRepositoriesKvFilter, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckResourceAttr(fqrn, "watch_resource.0.type", testData["watch_type"]), @@ -749,15 +749,15 @@ func TestAccWatch_multipleRepositoriesKvFilter(t *testing.T) { } func TestAccWatch_KvFilterError(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "build" testData["repo_type"] = "local" - testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", test.RandomInt()) + testData["repo0"] = fmt.Sprintf("libs-release-local-0-%d", testutil.RandomInt()) testData["kv_filter_type"] = "property" testData["kv_filter_key_0"] = "test-key-1" testData["kv_filter_value_0"] = "test-value-1" @@ -776,7 +776,7 @@ func TestAccWatch_KvFilterError(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, kvFilters, testData), + Config: sdk.ExecuteTemplate(fqrn, kvFilters, testData), ExpectError: regexp.MustCompile("attribute 'kv_filter' is set when 'watch_resource.type' is not set to 'repository' or 'all-repos'"), }, }, @@ -784,15 +784,15 @@ func TestAccWatch_KvFilterError(t *testing.T) { } func TestAccWatch_build(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "build" - testData["build_name0"] = fmt.Sprintf("release-pipeline-%d", test.RandomInt()) - testData["build_name1"] = fmt.Sprintf("release-pipeline1-%d", test.RandomInt()) + testData["build_name0"] = fmt.Sprintf("release-pipeline-%d", testutil.RandomInt()) + testData["build_name1"] = fmt.Sprintf("release-pipeline1-%d", testutil.RandomInt()) builds := []string{testData["build_name0"]} resource.Test(t, resource.TestCase{ @@ -804,7 +804,7 @@ func TestAccWatch_build(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, buildWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, buildWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -817,16 +817,16 @@ func TestAccWatch_build(t *testing.T) { } func TestAccWatch_buildWithProjectKey(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") projectKey := RandomProjectName() - testData := util.MergeMaps(testDataWatch) + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName testData["project_key"] = projectKey - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "build" - testData["build_name0"] = fmt.Sprintf("release-pipeline-%d", test.RandomInt()) + testData["build_name0"] = fmt.Sprintf("release-pipeline-%d", testutil.RandomInt()) template := `resource "xray_security_policy" "security" { name = "{{ .policy_name_0 }}" @@ -872,7 +872,7 @@ func TestAccWatch_buildWithProjectKey(t *testing.T) { } watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -905,14 +905,14 @@ func TestAccWatch_buildWithProjectKey(t *testing.T) { } func TestAccWatch_allBuildsWithProjectKey(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") projectKey := RandomProjectName() - testData := util.MergeMaps(testDataWatch) + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName testData["project_key"] = projectKey - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "all-builds" template := `resource "xray_security_policy" "security" { @@ -967,11 +967,11 @@ func TestAccWatch_allBuildsWithProjectKey(t *testing.T) { } watch_recipients = ["{{ .watch_recipient_0 }}", "{{ .watch_recipient_1 }}"] }` - config := util.ExecuteTemplate(fqrn, template, testData) + config := sdk.ExecuteTemplate(fqrn, template, testData) - updatedTestData := util.MergeMaps(testData) + updatedTestData := sdk.MergeMaps(testData) updatedTestData["description"] = "New description" - updatedConfig := util.ExecuteTemplate(fqrn, template, updatedTestData) + updatedConfig := sdk.ExecuteTemplate(fqrn, template, updatedTestData) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -1007,15 +1007,15 @@ func TestAccWatch_allBuildsWithProjectKey(t *testing.T) { } func TestAccWatch_multipleBuilds(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "build" - testData["build_name0"] = fmt.Sprintf("release-pipeline-%d", test.RandomInt()) - testData["build_name1"] = fmt.Sprintf("release-pipeline1-%d", test.RandomInt()) + testData["build_name0"] = fmt.Sprintf("release-pipeline-%d", testutil.RandomInt()) + testData["build_name1"] = fmt.Sprintf("release-pipeline1-%d", testutil.RandomInt()) builds := []string{testData["build_name0"], testData["build_name1"]} resource.Test(t, resource.TestCase{ @@ -1027,7 +1027,7 @@ func TestAccWatch_multipleBuilds(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, multipleBuildsWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, multipleBuildsWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -1040,12 +1040,12 @@ func TestAccWatch_multipleBuilds(t *testing.T) { } func TestAccWatch_allBuilds(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "all-builds" resource.Test(t, resource.TestCase{ @@ -1056,7 +1056,7 @@ func TestAccWatch_allBuilds(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, allBuildsWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, allBuildsWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemAttr(fqrn, "watch_resource.*.ant_filter.*.exclude_patterns.*", "a*"), @@ -1077,12 +1077,12 @@ func TestAccWatch_allBuilds(t *testing.T) { } func TestAccWatch_invalidBuildFilter(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -1092,7 +1092,7 @@ func TestAccWatch_invalidBuildFilter(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, invalidBuildsWatchFilterTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, invalidBuildsWatchFilterTemplate, testData), ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource\.type' is not set to 'all-builds' or 'all-projects'`), }, }, @@ -1100,12 +1100,12 @@ func TestAccWatch_invalidBuildFilter(t *testing.T) { } func TestAccWatch_allProjects(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "all-projects" resource.Test(t, resource.TestCase{ @@ -1116,7 +1116,7 @@ func TestAccWatch_allProjects(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, allProjectsWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, allProjectsWatchTemplate, testData), Check: resource.ComposeTestCheckFunc( verifyXrayWatch(fqrn, testData), resource.TestCheckTypeSetElemAttr(fqrn, "watch_resource.*.ant_filter.*.exclude_patterns.*", "a*"), @@ -1135,15 +1135,15 @@ func TestAccWatch_allProjects(t *testing.T) { //goland:noinspection GoErrorStringFormat func TestAccWatch_singleProject(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "project" - testData["project_name_0"] = fmt.Sprintf("test-project-%d", test.RandomInt()) - testData["project_name_1"] = fmt.Sprintf("test-project-%d", test.RandomInt()) + testData["project_name_0"] = fmt.Sprintf("test-project-%d", testutil.RandomInt()) + testData["project_name_1"] = fmt.Sprintf("test-project-%d", testutil.RandomInt()) testData["project_key_0"] = "test1" testData["project_key_1"] = "test2" @@ -1172,7 +1172,7 @@ func TestAccWatch_singleProject(t *testing.T) { ProviderFactories: testAccProviders(), Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, singleProjectWatchTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, singleProjectWatchTemplate, testData), Check: verifyXrayWatch(fqrn, testData), }, { @@ -1185,12 +1185,12 @@ func TestAccWatch_singleProject(t *testing.T) { } func TestAccWatch_invalidProjectFilter(t *testing.T) { - _, fqrn, resourceName := test.MkNames("watch-", "xray_watch") - testData := util.MergeMaps(testDataWatch) + _, fqrn, resourceName := testutil.MkNames("watch-", "xray_watch") + testData := sdk.MergeMaps(testDataWatch) testData["resource_name"] = resourceName - testData["watch_name"] = fmt.Sprintf("xray-watch-%d", test.RandomInt()) - testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", test.RandomInt()) + testData["watch_name"] = fmt.Sprintf("xray-watch-%d", testutil.RandomInt()) + testData["policy_name_0"] = fmt.Sprintf("xray-policy-%d", testutil.RandomInt()) testData["watch_type"] = "project" resource.Test(t, resource.TestCase{ @@ -1202,7 +1202,7 @@ func TestAccWatch_invalidProjectFilter(t *testing.T) { Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, invalidProjectWatchFilterTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, invalidProjectWatchFilterTemplate, testData), ExpectError: regexp.MustCompile(`attribute 'ant_filter' is set when 'watch_resource\.type' is not set to 'all-builds' or 'all-projects'`), }, }, diff --git a/pkg/xray/resource_xray_workers_count.go b/pkg/xray/resource_xray_workers_count.go index cc557940..84d41c88 100644 --- a/pkg/xray/resource_xray_workers_count.go +++ b/pkg/xray/resource_xray_workers_count.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) func resourceXrayWorkersCount() *schema.Resource { @@ -19,7 +19,7 @@ func resourceXrayWorkersCount() *schema.Resource { }, } - newExistingContentSchema := util.MergeMaps( + newExistingContentSchema := sdk.MergeMaps( newContentSchema, map[string]*schema.Schema{ "existing_content": { @@ -150,7 +150,7 @@ func resourceXrayWorkersCount() *schema.Resource { } var packContent = func(d *schema.ResourceData, attr string, src interface{}, hclContentConstructor func(src interface{}) map[string]interface{}) []error { - setValue := util.MkLens(d) + setValue := sdk.MkLens(d) resource := workersCountSchema[attr].Elem.(*schema.Resource) content := hclContentConstructor(src) @@ -219,7 +219,7 @@ func resourceXrayWorkersCount() *schema.Resource { var resourceXrayWorkersCountRead = func(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { workersCount := WorkersCount{} - resp, err := m.(util.ProvderMetadata).Client.R(). + resp, err := m.(sdk.ProvderMetadata).Client.R(). SetResult(&workersCount). Get("xray/api/v1/configuration/workersCount") if err != nil { @@ -234,7 +234,7 @@ func resourceXrayWorkersCount() *schema.Resource { var resourceXrayWorkersCountUpdate = func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { workersCount := unpackWorkersCount(d) - _, err := m.(util.ProvderMetadata).Client.R(). + _, err := m.(sdk.ProvderMetadata).Client.R(). SetBody(workersCount). Put("xray/api/v1/configuration/workersCount") diff --git a/pkg/xray/resource_xray_workers_count_test.go b/pkg/xray/resource_xray_workers_count_test.go index ea8c5ade..d8965b1a 100644 --- a/pkg/xray/resource_xray_workers_count_test.go +++ b/pkg/xray/resource_xray_workers_count_test.go @@ -4,18 +4,18 @@ import ( "regexp" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) func TestAccWorkersCount_create(t *testing.T) { - _, _, resourceName := test.MkNames("workers-count-", "xray_workers_count") + _, _, resourceName := testutil.MkNames("workers-count-", "xray_workers_count") params := map[string]interface{}{ "workersCountName": resourceName, } - workersCountConfig := util.ExecuteTemplate("TestAccWorkersCount_create", ` + workersCountConfig := sdk.ExecuteTemplate("TestAccWorkersCount_create", ` resource "xray_workers_count" "{{ .workersCountName }}" { index { new_content = 4 diff --git a/pkg/xray/util_test.go b/pkg/xray/util_test.go index 963ba7f9..a4e60a58 100644 --- a/pkg/xray/util_test.go +++ b/pkg/xray/util_test.go @@ -8,9 +8,10 @@ import ( "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + tf "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/jfrog/terraform-provider-shared/client" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) func checkPolicy(id string, request *resty.Request) (*resty.Response, error) { @@ -31,15 +32,15 @@ func testCheckPolicyDeleted(id string, t *testing.T, request *resty.Request) *re type CheckFun func(id string, request *resty.Request) (*resty.Response, error) -func verifyDeleted(id string, check CheckFun) func(*terraform.State) error { - return func(s *terraform.State) error { +func verifyDeleted(id string, check CheckFun) func(*tf.State) error { + return func(s *tf.State) error { rs, ok := s.RootModule().Resources[id] if !ok { return fmt.Errorf("error: Resource id [%s] not found", id) } provider, _ := testAccProviders()["xray"]() provider.Configure(context.Background(), terraform.NewResourceConfigRaw(nil)) - c := provider.Meta().(util.ProvderMetadata).Client + c := provider.Meta().(sdk.ProvderMetadata).Client resp, err := check(rs.Primary.ID, c.R()) if err != nil { if resp != nil { @@ -55,13 +56,13 @@ func verifyDeleted(id string, check CheckFun) func(*terraform.State) error { } func GetTestResty(t *testing.T) *resty.Client { - artifactoryUrl := test.GetEnvVarWithFallback(t, "XRAY_URL", "JFROG_URL") + artifactoryUrl := testutil.GetEnvVarWithFallback(t, "XRAY_URL", "JFROG_URL") restyClient, err := client.Build(artifactoryUrl, "") if err != nil { t.Fatal(err) } - accessToken := test.GetEnvVarWithFallback(t, "XRAY_ACCESS_TOKEN", "JFROG_ACCESS_TOKEN") + accessToken := testutil.GetEnvVarWithFallback(t, "XRAY_ACCESS_TOKEN", "JFROG_ACCESS_TOKEN") restyClient, err = client.AddAuth(restyClient, "", accessToken) if err != nil { t.Fatal(err) @@ -116,7 +117,7 @@ func generateListOfNames(prefix string, number int) string { var CVEs []string n := 0 for n < number { - CVEs = append(CVEs, fmt.Sprintf("\"%s%d\",", prefix, test.RandomInt())) + CVEs = append(CVEs, fmt.Sprintf("\"%s%d\",", prefix, testutil.RandomInt())) n++ } return fmt.Sprintf("%s", CVEs) diff --git a/pkg/xray/watches.go b/pkg/xray/watches.go index 73949bfb..5d888805 100644 --- a/pkg/xray/watches.go +++ b/pkg/xray/watches.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "golang.org/x/exp/slices" ) @@ -178,8 +178,8 @@ func unpackAntFilters(d *schema.Set, filterType string) []WatchFilter { // create JSON string from slice: // from []string{"a", "b"} to `["ExcludePatterns": ["a", "b"]]` - excludePatterns, _ := json.Marshal(util.CastToStringArr(antValue["exclude_patterns"].([]interface{}))) - includePatterns, _ := json.Marshal(util.CastToStringArr(antValue["include_patterns"].([]interface{}))) + excludePatterns, _ := json.Marshal(sdk.CastToStringArr(antValue["exclude_patterns"].([]interface{}))) + includePatterns, _ := json.Marshal(sdk.CastToStringArr(antValue["include_patterns"].([]interface{}))) filterJsonString := fmt.Sprintf( `{"ExcludePatterns": %s, "IncludePatterns": %s}`, excludePatterns, @@ -397,7 +397,7 @@ func packWatch(ctx context.Context, watch Watch, d *schema.ResourceData) diag.Di func resourceXrayWatchCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { watch := unpackWatch(d) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, watch.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, watch.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -427,7 +427,7 @@ func resourceXrayWatchRead(ctx context.Context, d *schema.ResourceData, m interf watch := Watch{} projectKey := d.Get("project_key").(string) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, projectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, projectKey) if err != nil { return diag.FromErr(err) } @@ -452,7 +452,7 @@ func resourceXrayWatchRead(ctx context.Context, d *schema.ResourceData, m interf func resourceXrayWatchUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { watch := unpackWatch(d) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, watch.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, watch.ProjectKey) if err != nil { return diag.FromErr(err) } @@ -478,7 +478,7 @@ func resourceXrayWatchUpdate(ctx context.Context, d *schema.ResourceData, m inte func resourceXrayWatchDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { watch := unpackWatch(d) - req, err := getRestyRequest(m.(util.ProvderMetadata).Client, watch.ProjectKey) + req, err := getRestyRequest(m.(sdk.ProvderMetadata).Client, watch.ProjectKey) if err != nil { return diag.FromErr(err) } From 001f5f0857fcd7280830b9fd9057c412a072b0b6 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 18 Aug 2023 14:21:56 -0700 Subject: [PATCH 07/13] Make repository_config's scanners_category a map And fills in the fields based on package type (and Xray version) Apply the same logic to vulnerability contextual analysis. --- pkg/xray/resource_xray_repository_config.go | 198 +++++++++++----- .../resource_xray_repository_config_test.go | 212 +++++++++++++----- 2 files changed, 297 insertions(+), 113 deletions(-) diff --git a/pkg/xray/resource_xray_repository_config.go b/pkg/xray/resource_xray_repository_config.go index c45e18e4..656ee829 100644 --- a/pkg/xray/resource_xray_repository_config.go +++ b/pkg/xray/resource_xray_repository_config.go @@ -5,30 +5,24 @@ import ( "fmt" "net/http" + "github.com/go-resty/resty/v2" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/jfrog/terraform-provider-shared/util/sdk" "github.com/jfrog/terraform-provider-shared/validator" + "golang.org/x/exp/slices" ) type RepoConfiguration struct { // Omitempty is used because 'vuln_contextual_analysis' is not supported by self-hosted Xray installation. - VulnContextualAnalysis bool `json:"vuln_contextual_analysis,omitempty"` - RetentionInDays int `json:"retention_in_days,omitempty"` - Exposures Exposures `json:"exposures"` + VulnContextualAnalysis *bool `json:"vuln_contextual_analysis,omitempty"` + RetentionInDays int `json:"retention_in_days,omitempty"` + Exposures *Exposures `json:"exposures,omitempty"` } type Exposures struct { - ScannersCategory ScannersCategory `json:"scanners_category"` -} - -type ScannersCategory struct { - MaliciousCode bool `json:"malicious_code_scan,omitempty"` - Services bool `json:"services_scan,omitempty"` - Secrets bool `json:"secrets_scan,omitempty"` - IAC bool `json:"iac_scan,omitempty"` - Applications bool `json:"applications_scan,omitempty"` + ScannersCategory map[string]bool `json:"scanners_category"` } type PathsConfiguration struct { @@ -55,6 +49,26 @@ type RepositoryConfiguration struct { RepoPathsConfig *PathsConfiguration `json:"repo_paths_config,omitempty"` } +var exposuresPackageTypes = func(xrayVersion string) []string { + packageTypes := []string{"docker", "terraformbackend"} + + if ok, err := sdk.CheckVersion(xrayVersion, "3.78.9"); err == nil && ok { + packageTypes = append(packageTypes, "maven", "npm", "pypi") + } + + return packageTypes +} + +var vulnContextualAnalysisPackageTypes = func(xrayVersion string) []string { + packageTypes := []string{"docker"} + + if ok, err := sdk.CheckVersion(xrayVersion, "3.77.4"); err == nil && ok { + packageTypes = append(packageTypes, "maven") + } + + return packageTypes +} + func resourceXrayRepositoryConfig() *schema.Resource { var repositoryConfigSchema = map[string]*schema.Schema{ "repo_name": { @@ -74,7 +88,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { "vuln_contextual_analysis": { Type: schema.TypeBool, Optional: true, - Description: "Only for SaaS instances, will be available after Xray 3.59. Enables vulnerability contextual analysis.", + Description: "Only for SaaS instances, will be available after Xray 3.59. Enables vulnerability contextual analysis. Must be set together with `exposures`. Supported for Docker, OCI, and Maven package types.", }, "retention_in_days": { Type: schema.TypeInt, @@ -88,7 +102,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { Optional: true, MinItems: 1, MaxItems: 1, - Description: "Enables Xray to perform scans for multiple categories that cover security issues in your configurations and the usage of open source libraries in your code. Available only to CLOUD (SaaS)/SELF HOSTED for ENTERPRISE X and ENTERPRISE+ with Advanced DevSecOps", + Description: "Enables Xray to perform scans for multiple categories that cover security issues in your configurations and the usage of open source libraries in your code. Available only to CLOUD (SaaS)/SELF HOSTED for ENTERPRISE X and ENTERPRISE+ with Advanced DevSecOps. Must be set together with `vuln_contextual_analysis`. Supported for Docker, Maven, NPM, PyPi, and Terraform Backend package type.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "scanners_category": { @@ -98,11 +112,6 @@ func resourceXrayRepositoryConfig() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "malicious_code": { - Type: schema.TypeBool, - Optional: true, - Description: "", - }, "services": { Type: schema.TypeBool, Optional: true, @@ -249,77 +258,113 @@ func resourceXrayRepositoryConfig() *schema.Resource { return repoPathsConfiguration } - var unpackExposures = func(config *schema.Set) Exposures { - exposures := Exposures{} + var unpackExposures = func(config *schema.Set, xrayVersion, packageType string) *Exposures { + if !slices.Contains(exposuresPackageTypes(xrayVersion), packageType) { + return nil + } + + if len(config.List()) == 0 { + return nil + } e := config.List()[0].(map[string]interface{}) s := e["scanners_category"].(*schema.Set) + if len(s.List()) == 0 { + return nil + } + category := s.List()[0].(map[string]interface{}) - exposures.ScannersCategory.MaliciousCode = category["malicious_code"].(bool) - exposures.ScannersCategory.Services = category["services"].(bool) - exposures.ScannersCategory.Secrets = category["secrets"].(bool) - exposures.ScannersCategory.IAC = category["iac"].(bool) - exposures.ScannersCategory.Applications = category["applications"].(bool) + exposures := Exposures{} + + switch packageType { + case "docker", "maven", "npm", "pypi": + exposures.ScannersCategory = map[string]bool{ + "services_scan": category["services"].(bool), + "secrets_scan": category["secrets"].(bool), + "applications_scan": category["applications"].(bool), + } + case "terraformbackend": + exposures.ScannersCategory = map[string]bool{ + "iac_scan": category["iac"].(bool), + } + } - return exposures + return &exposures } - var unpackRepoConfig = func(config *schema.Set) *RepoConfiguration { + var unpackRepoConfig = func(config *schema.Set, xrayVersion, packageType string) *RepoConfiguration { repoConfig := new(RepoConfiguration) if config != nil { data := config.List()[0].(map[string]interface{}) - repoConfig.VulnContextualAnalysis = data["vuln_contextual_analysis"].(bool) + if slices.Contains(vulnContextualAnalysisPackageTypes(xrayVersion), packageType) { + vulnContextualAnalysis := data["vuln_contextual_analysis"].(bool) + repoConfig.VulnContextualAnalysis = &vulnContextualAnalysis + } repoConfig.RetentionInDays = data["retention_in_days"].(int) - repoConfig.Exposures = unpackExposures(data["exposures"].(*schema.Set)) + repoConfig.Exposures = unpackExposures(data["exposures"].(*schema.Set), xrayVersion, packageType) } return repoConfig } - var unpackRepositoryConfig = func(s *schema.ResourceData) RepositoryConfiguration { - d := &util.ResourceData{ResourceData: s} + var unpackRepositoryConfig = func(s *schema.ResourceData, xrayVersion, packageType string) RepositoryConfiguration { + d := &sdk.ResourceData{ResourceData: s} repositoryConfig := RepositoryConfiguration{ RepoName: d.GetString("repo_name", false), } - if _, ok := s.GetOk("config"); ok { - repositoryConfig.RepoConfig = unpackRepoConfig(s.Get("config").(*schema.Set)) + if v, ok := s.GetOk("config"); ok { + repositoryConfig.RepoConfig = unpackRepoConfig(v.(*schema.Set), xrayVersion, packageType) } - if _, ok := s.GetOk("paths_config"); ok { - repositoryConfig.RepoPathsConfig = unpackRepoPathConfig(s.Get("paths_config").(*schema.Set)) + if v, ok := s.GetOk("paths_config"); ok { + repositoryConfig.RepoPathsConfig = unpackRepoPathConfig(v.(*schema.Set)) } return repositoryConfig } - var packExposures = func(exposures Exposures) []interface{} { + var packExposures = func(exposures *Exposures, packageType string) []interface{} { + scannersCategory := map[string]bool{ + "services": false, + "secrets": false, + "iac": false, + "applications": false, + } + + switch packageType { + case "docker", "maven", "npm", "pypi": + scannersCategory["services"] = exposures.ScannersCategory["services_scan"] + scannersCategory["secrets"] = exposures.ScannersCategory["secrets_scan"] + scannersCategory["applications"] = exposures.ScannersCategory["applications_scan"] + case "terraformbackend": + scannersCategory["iac"] = exposures.ScannersCategory["iac_scan"] + } + return []interface{}{ - map[string]interface{}{ - "scanners_category": []interface{}{ - map[string]interface{}{ - "malicious_code": exposures.ScannersCategory.MaliciousCode, - "services": exposures.ScannersCategory.Services, - "secrets": exposures.ScannersCategory.Secrets, - "iac": exposures.ScannersCategory.IAC, - "applications": exposures.ScannersCategory.Applications, - }, - }, + map[string][]map[string]bool{ + "scanners_category": {scannersCategory}, }, } } - var packGeneralRepoConfig = func(repoConfig *RepoConfiguration) []interface{} { + var packGeneralRepoConfig = func(repoConfig *RepoConfiguration, xrayVersion, packageType string) []interface{} { if repoConfig == nil { return []interface{}{} } m := map[string]interface{}{ - "vuln_contextual_analysis": repoConfig.VulnContextualAnalysis, - "retention_in_days": repoConfig.RetentionInDays, - "exposures": packExposures(repoConfig.Exposures), + "retention_in_days": repoConfig.RetentionInDays, + } + + if slices.Contains(vulnContextualAnalysisPackageTypes(xrayVersion), packageType) { + m["vuln_contextual_analysis"] = *repoConfig.VulnContextualAnalysis + } + + if slices.Contains(exposuresPackageTypes(xrayVersion), packageType) { + m["exposures"] = packExposures(repoConfig.Exposures, packageType) } return []interface{}{m} @@ -364,11 +409,11 @@ func resourceXrayRepositoryConfig() *schema.Resource { return []interface{}{m} } - var packRepositoryConfig = func(ctx context.Context, repositoryConfig RepositoryConfiguration, d *schema.ResourceData) diag.Diagnostics { + var packRepositoryConfig = func(ctx context.Context, repositoryConfig RepositoryConfiguration, d *schema.ResourceData, xrayVersion, packageType string) diag.Diagnostics { if err := d.Set("repo_name", repositoryConfig.RepoName); err != nil { return diag.FromErr(err) } - if err := d.Set("config", packGeneralRepoConfig(repositoryConfig.RepoConfig)); err != nil { + if err := d.Set("config", packGeneralRepoConfig(repositoryConfig.RepoConfig, xrayVersion, packageType)); err != nil { return diag.FromErr(err) } if err := d.Set("paths_config", packRepoPathsConfigList(repositoryConfig.RepoPathsConfig)); err != nil { @@ -378,29 +423,62 @@ func resourceXrayRepositoryConfig() *schema.Resource { return nil } + var getPackageType = func(client *resty.Client, repoKey string) (repoType string, err error) { + type Repository struct { + PackageType string `json:"packageType"` + } + + repo := Repository{} + + _, err = client.R(). + SetResult(&repo). + SetPathParam("repoKey", repoKey). + Get("artifactory/api/repositories/{repoKey}") + if err != nil { + fmt.Printf("err: %v\n", err) + return "", err + } + + return repo.PackageType, nil + } + var resourceXrayRepositoryConfigRead = func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { repositoryConfig := RepositoryConfiguration{} + repoName := d.Id() + + metadata := m.(sdk.ProvderMetadata) - resp, err := m.(util.ProvderMetadata).Client.R(). + resp, err := metadata.Client.R(). SetResult(&repositoryConfig). - SetPathParam("repo_name", d.Id()). + SetPathParam("repo_name", repoName). Get("xray/api/v1/repos_config/{repo_name}") if err != nil { if resp != nil && resp.StatusCode() != http.StatusOK { - tflog.Error(ctx, fmt.Sprintf("Repo (%s) is either not indexed or does not exist", d.Id())) + tflog.Error(ctx, fmt.Sprintf("Repo (%s) is either not indexed or does not exist", repoName)) d.SetId("") } return diag.FromErr(err) } - return packRepositoryConfig(ctx, repositoryConfig, d) + packageType, err := getPackageType(metadata.Client, repoName) + if err != nil { + return diag.FromErr(err) + } + + return packRepositoryConfig(ctx, repositoryConfig, d, metadata.XrayVersion, packageType) } var resourceXrayRepositoryConfigCreate = func(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - repositoryConfig := unpackRepositoryConfig(d) + metadata := m.(sdk.ProvderMetadata) + packageType, err := getPackageType(metadata.Client, d.Get("repo_name").(string)) + if err != nil { + return diag.FromErr(err) + } + + repositoryConfig := unpackRepositoryConfig(d, metadata.XrayVersion, packageType) - _, err := m.(util.ProvderMetadata).Client.R().SetBody(&repositoryConfig).Put("xray/api/v1/repos_config") + _, err = metadata.Client.R().SetBody(&repositoryConfig).Put("xray/api/v1/repos_config") if err != nil { return diag.FromErr(err) } diff --git a/pkg/xray/resource_xray_repository_config_test.go b/pkg/xray/resource_xray_repository_config_test.go index 0c4d2670..09751f81 100644 --- a/pkg/xray/resource_xray_repository_config_test.go +++ b/pkg/xray/resource_xray_repository_config_test.go @@ -6,13 +6,13 @@ import ( "testing" "github.com/go-resty/resty/v2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/jfrog/terraform-provider-shared/test" - "github.com/jfrog/terraform-provider-shared/util" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util/sdk" ) func TestAccRepositoryConfigRepoConfigNegative(t *testing.T) { - _, fqrn, resourceName := test.MkNames("xray-repo-config-", "xray_repository_config") + _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") var testData = map[string]string{ "resource_name": resourceName, "repo_name": "repo-config-test-repo", @@ -35,58 +35,164 @@ func TestAccRepositoryConfigRepoConfigNegative(t *testing.T) { Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, TestDataRepoConfigErrorTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, TestDataRepoConfigErrorTemplate, testData), ExpectError: regexp.MustCompile("Conflicting configuration arguments"), }, }, }) } -func TestAccRepositoryConfigRepoConfigCreate(t *testing.T) { - _, fqrn, resourceName := test.MkNames("xray-repo-config-", "xray_repository_config") - var testData = map[string]string{ - "resource_name": resourceName, - "repo_name": "repo-config-test-repo", - "retention_in_days": "90", +func TestAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T) { + testCase := []struct { + packageType string + validVersion string + }{ + {"docker", "3.67.9"}, + {"maven", "3.77.4"}, } - resource.Test(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - testAccDeleteRepo(t, testData["repo_name"]) - testAccCreateRepos(t, testData["repo_name"], "local", "", "docker") - }, - CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { - testAccDeleteRepo(t, testData["repo_name"]) - err := fmt.Errorf("repo was deleted") - errorResp := dummyError() - return errorResp, err - }), - ProviderFactories: testAccProviders(), + version, err := sdk.GetXrayVersion(GetTestResty(t)) + if err != nil { + t.Fail() + return + } - Steps: []resource.TestStep{ - { - Config: util.ExecuteTemplate(fqrn, TestDataRepoConfigTemplate, testData), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fqrn, "repo_name", testData["repo_name"]), - resource.TestCheckResourceAttr(fqrn, "config.0.retention_in_days", testData["retention_in_days"]), - resource.TestCheckResourceAttr(fqrn, "config.0.vuln_contextual_analysis", "true"), - resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.services", "true"), - resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", "true"), - resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.applications", "true"), - ), + for _, tc := range testCase { + t.Run(tc.packageType, testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t, tc.packageType, tc.validVersion, version)) + } +} + +func testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T, packageType, validVersion, xrayVersion string) func(t *testing.T) { + return func(t *testing.T) { + _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") + var testData = map[string]string{ + "resource_name": resourceName, + "repo_name": "repo-config-test-repo", + "retention_in_days": "90", + "vuln_contextual_analysis": "true", + "services_scan": "false", + "secrets_scan": "false", + "applications_scan": "false", + } + + valid, _ := sdk.CheckVersion(xrayVersion, validVersion) + if !valid { + t.Skipf("xray version %s does not support %s for exposures scanning", xrayVersion, packageType) + return + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + testAccDeleteRepo(t, testData["repo_name"]) + testAccCreateRepos(t, testData["repo_name"], "local", "", packageType) }, - { - ResourceName: fqrn, - ImportState: true, - ImportStateVerify: true, + CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { + testAccDeleteRepo(t, testData["repo_name"]) + err := fmt.Errorf("repo was deleted") + errorResp := dummyError() + return errorResp, err + }), + ProviderFactories: testAccProviders(), + + Steps: []resource.TestStep{ + { + Config: sdk.ExecuteTemplate(fqrn, TestDataRepoConfigTemplate, testData), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "repo_name", testData["repo_name"]), + resource.TestCheckResourceAttr(fqrn, "config.0.retention_in_days", testData["retention_in_days"]), + resource.TestCheckResourceAttr(fqrn, "config.0.vuln_contextual_analysis", testData["vuln_contextual_analysis"]), + ), + }, + { + ResourceName: fqrn, + ImportState: true, + ImportStateVerify: true, + }, }, - }, - }) + }) + } +} + +func TestAccRepositoryConfigRepoConfigCreate_Exposure(t *testing.T) { + testCase := []struct { + packageType string + validVersion string + }{ + {"docker", "3.67.9"}, + {"maven", "3.78.9"}, + {"npm", "3.78.9"}, + {"pypi", "3.78.9"}, + } + + version, err := sdk.GetXrayVersion(GetTestResty(t)) + if err != nil { + t.Fail() + return + } + + for _, tc := range testCase { + t.Run(tc.packageType, testAccRepositoryConfigRepoConfigCreate(t, tc.packageType, tc.validVersion, version)) + } +} + +func testAccRepositoryConfigRepoConfigCreate(t *testing.T, packageType, validVersion, xrayVersion string) func(t *testing.T) { + return func(t *testing.T) { + _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") + var testData = map[string]string{ + "resource_name": resourceName, + "repo_name": "repo-config-test-repo", + "retention_in_days": "90", + "vuln_contextual_analysis": "false", + "services_scan": "true", + "secrets_scan": "true", + "applications_scan": "false", + } + + valid, _ := sdk.CheckVersion(xrayVersion, validVersion) + if !valid { + t.Skipf("xray version %s does not support %s for exposures scanning", xrayVersion, packageType) + return + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + testAccDeleteRepo(t, testData["repo_name"]) + testAccCreateRepos(t, testData["repo_name"], "local", "", packageType) + }, + CheckDestroy: verifyDeleted(fqrn, func(id string, request *resty.Request) (*resty.Response, error) { + testAccDeleteRepo(t, testData["repo_name"]) + err := fmt.Errorf("repo was deleted") + errorResp := dummyError() + return errorResp, err + }), + ProviderFactories: testAccProviders(), + + Steps: []resource.TestStep{ + { + Config: sdk.ExecuteTemplate(fqrn, TestDataRepoConfigTemplate, testData), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "repo_name", testData["repo_name"]), + resource.TestCheckResourceAttr(fqrn, "config.0.retention_in_days", testData["retention_in_days"]), + resource.TestCheckResourceAttr(fqrn, "config.0.vuln_contextual_analysis", testData["vuln_contextual_analysis"]), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.services", testData["services_scan"]), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", testData["secrets_scan"]), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.applications", testData["applications_scan"]), + ), + }, + { + ResourceName: fqrn, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) + } } func TestAccRepositoryConfigRepoConfigCreate_InvalidExposures(t *testing.T) { - _, fqrn, resourceName := test.MkNames("xray-repo-config-", "xray_repository_config") + _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") var testData = map[string]string{ "resource_name": resourceName, "repo_name": "repo-config-test-repo", @@ -109,15 +215,15 @@ func TestAccRepositoryConfigRepoConfigCreate_InvalidExposures(t *testing.T) { Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, TestDataRepoConfigInvalidExposuresTemplate, testData), - ExpectError: regexp.MustCompile(`.*Value for 'repo_config.exposure' parameter is invalid.*`), + Config: sdk.ExecuteTemplate(fqrn, TestDataRepoConfigInvalidExposuresTemplate, testData), + ExpectNonEmptyPlan: true, }, }, }) } func TestAccRepositoryConfigRepoPathsCreate(t *testing.T) { - _, fqrn, resourceName := test.MkNames("xray-repo-config-", "xray_repository_config") + _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") var testData = map[string]string{ "resource_name": resourceName, "repo_name": "repo-config-test-repo", @@ -149,7 +255,7 @@ func TestAccRepositoryConfigRepoPathsCreate(t *testing.T) { Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), Check: resource.ComposeTestCheckFunc(verifyRepositoryConfig(fqrn, testData)), }, { @@ -162,7 +268,7 @@ func TestAccRepositoryConfigRepoPathsCreate(t *testing.T) { } func TestAccRepositoryConfigRepoPathsUpdate(t *testing.T) { - _, fqrn, resourceName := test.MkNames("xray-repo-config-", "xray_repository_config") + _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") var testData = map[string]string{ "resource_name": resourceName, "repo_name": "repo-config-test-repo", @@ -208,11 +314,11 @@ func TestAccRepositoryConfigRepoPathsUpdate(t *testing.T) { Steps: []resource.TestStep{ { - Config: util.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testData), Check: resource.ComposeTestCheckFunc(verifyRepositoryConfig(fqrn, testData)), }, { - Config: util.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testDataUpdated), + Config: sdk.ExecuteTemplate(fqrn, TestDataRepoPathsConfigTemplate, testDataUpdated), Check: resource.ComposeTestCheckFunc(verifyRepositoryConfig(fqrn, testDataUpdated)), }, }, @@ -270,13 +376,13 @@ resource "xray_repository_config" "{{ .resource_name }}" { repo_name = "{{ .repo_name }}" config { - vuln_contextual_analysis = true + vuln_contextual_analysis = {{ .vuln_contextual_analysis }} retention_in_days = {{ .retention_in_days }} exposures { scanners_category { - services = true - secrets = true - applications = true + services = {{ .services_scan }} + secrets = {{ .secrets_scan }} + applications = {{ .applications_scan }} } } } From bbc6ebfc3e31096cacda942e0f08c93714790364 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 18 Aug 2023 14:29:52 -0700 Subject: [PATCH 08/13] Update terraform-provider-shared to 1.18.0 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5caffa7b..efb36419 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 github.com/hashicorp/terraform-plugin-testing v1.4.0 - github.com/jfrog/terraform-provider-shared v1.17.0 + github.com/jfrog/terraform-provider-shared v1.18.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 golang.org/x/text v0.11.0 ) diff --git a/go.sum b/go.sum index 48fd10c9..43dbf5e4 100644 --- a/go.sum +++ b/go.sum @@ -107,6 +107,8 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jfrog/terraform-provider-shared v1.18.0 h1:wH+cCL7DPmIp1bQlSfrMG+67tDExMj/MlCQOQgFZuQQ= +github.com/jfrog/terraform-provider-shared v1.18.0/go.mod h1:JvTKRAXMQyX6gQjESY+YK2lJLeW8uKTVHar5HDTnvp0= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= From 3b1185f2e61e47f9e088e477e1f0af3b6259907f Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 18 Aug 2023 14:38:51 -0700 Subject: [PATCH 09/13] Update doc --- docs/resources/repository_config.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/resources/repository_config.md b/docs/resources/repository_config.md index a18e627b..82dc2633 100644 --- a/docs/resources/repository_config.md +++ b/docs/resources/repository_config.md @@ -67,9 +67,9 @@ resource "xray_repository_config" "xray-repo-config" { Optional: -- `exposures` (Block Set, Max: 1) Enables Xray to perform scans for multiple categories that cover security issues in your configurations and the usage of open source libraries in your code. Available only to CLOUD (SaaS)/SELF HOSTED for ENTERPRISE X and ENTERPRISE+ with Advanced DevSecOps (see [below for nested schema](#nestedblock--config--exposures)) +- `exposures` (Block Set, Max: 1) Enables Xray to perform scans for multiple categories that cover security issues in your configurations and the usage of open source libraries in your code. Available only to CLOUD (SaaS)/SELF HOSTED for ENTERPRISE X and ENTERPRISE+ with Advanced DevSecOps. Must be set together with `vuln_contextual_analysis`. Supported for Docker, Maven, NPM, PyPi, and Terraform Backend package type. (see [below for nested schema](#nestedblock--config--exposures)) - `retention_in_days` (Number) The artifact will be retained for the number of days you set here, after the artifact is scanned. This will apply to all artifacts in the repository. -- `vuln_contextual_analysis` (Boolean) Only for SaaS instances, will be available after Xray 3.59. Enables vulnerability contextual analysis. +- `vuln_contextual_analysis` (Boolean) Only for SaaS instances, will be available after Xray 3.59. Enables vulnerability contextual analysis. Must be set together with `exposures`. Supported for Docker, OCI, and Maven package types. ### Nested Schema for `config.exposures` @@ -85,7 +85,6 @@ Optional: - `applications` (Boolean) Detect whether common OSS libraries and services are used securely by the application. - `iac` (Boolean) Scans IaC files stored in Artifactory for early detection of cloud and infrastructure misconfigurations to prevent attacks and data leak. Only supported by Terraform Backend package type. -- `malicious_code` (Boolean) - `secrets` (Boolean) Detect any secret left exposed in any containers stored in Artifactory to stop any accidental leak of internal tokens or credentials. - `services` (Boolean) Detect whether common OSS libraries and services are configured securely, so application can be easily hardened by default. From efb75b103780766bdc272fc7b38cde7ab3b50883 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Mon, 28 Aug 2023 14:05:30 -0700 Subject: [PATCH 10/13] Fix exposures tests --- pkg/xray/resource_xray_repository_config.go | 21 ++- .../resource_xray_repository_config_test.go | 123 ++++++++++++++---- 2 files changed, 113 insertions(+), 31 deletions(-) diff --git a/pkg/xray/resource_xray_repository_config.go b/pkg/xray/resource_xray_repository_config.go index 656ee829..3f735847 100644 --- a/pkg/xray/resource_xray_repository_config.go +++ b/pkg/xray/resource_xray_repository_config.go @@ -107,8 +107,7 @@ func resourceXrayRepositoryConfig() *schema.Resource { Schema: map[string]*schema.Schema{ "scanners_category": { Type: schema.TypeSet, - Optional: true, - MinItems: 1, + Required: true, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -278,12 +277,21 @@ func resourceXrayRepositoryConfig() *schema.Resource { exposures := Exposures{} switch packageType { - case "docker", "maven", "npm", "pypi": + case "docker": exposures.ScannersCategory = map[string]bool{ "services_scan": category["services"].(bool), "secrets_scan": category["secrets"].(bool), "applications_scan": category["applications"].(bool), } + case "maven": + exposures.ScannersCategory = map[string]bool{ + "secrets_scan": category["secrets"].(bool), + } + case "npm", "pypi": + exposures.ScannersCategory = map[string]bool{ + "secrets_scan": category["secrets"].(bool), + "applications_scan": category["applications"].(bool), + } case "terraformbackend": exposures.ScannersCategory = map[string]bool{ "iac_scan": category["iac"].(bool), @@ -335,10 +343,15 @@ func resourceXrayRepositoryConfig() *schema.Resource { } switch packageType { - case "docker", "maven", "npm", "pypi": + case "docker": scannersCategory["services"] = exposures.ScannersCategory["services_scan"] scannersCategory["secrets"] = exposures.ScannersCategory["secrets_scan"] scannersCategory["applications"] = exposures.ScannersCategory["applications_scan"] + case "maven": + scannersCategory["secrets"] = exposures.ScannersCategory["secrets_scan"] + case "npm", "pypi": + scannersCategory["secrets"] = exposures.ScannersCategory["secrets_scan"] + scannersCategory["applications"] = exposures.ScannersCategory["applications_scan"] case "terraformbackend": scannersCategory["iac"] = exposures.ScannersCategory["iac_scan"] } diff --git a/pkg/xray/resource_xray_repository_config_test.go b/pkg/xray/resource_xray_repository_config_test.go index 09751f81..5df1e862 100644 --- a/pkg/xray/resource_xray_repository_config_test.go +++ b/pkg/xray/resource_xray_repository_config_test.go @@ -45,10 +45,11 @@ func TestAccRepositoryConfigRepoConfigNegative(t *testing.T) { func TestAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T) { testCase := []struct { packageType string + template string validVersion string }{ - {"docker", "3.67.9"}, - {"maven", "3.77.4"}, + {"docker", TestDataRepoConfigDockerTemplate, "3.67.9"}, + {"maven", TestDataRepoConfigMavenTemplate, "3.77.4"}, } version, err := sdk.GetXrayVersion(GetTestResty(t)) @@ -58,11 +59,11 @@ func TestAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T } for _, tc := range testCase { - t.Run(tc.packageType, testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t, tc.packageType, tc.validVersion, version)) + t.Run(tc.packageType, testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t, tc.packageType, tc.template, tc.validVersion, version)) } } -func testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T, packageType, validVersion, xrayVersion string) func(t *testing.T) { +func testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T, packageType, template, validVersion, xrayVersion string) func(t *testing.T) { return func(t *testing.T) { _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") var testData = map[string]string{ @@ -97,7 +98,7 @@ func testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, TestDataRepoConfigTemplate, testData), + Config: sdk.ExecuteTemplate(fqrn, template, testData), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(fqrn, "repo_name", testData["repo_name"]), resource.TestCheckResourceAttr(fqrn, "config.0.retention_in_days", testData["retention_in_days"]), @@ -117,12 +118,54 @@ func testAccRepositoryConfigRepoConfigCreate_VulnContextualAnalysis(t *testing.T func TestAccRepositoryConfigRepoConfigCreate_Exposure(t *testing.T) { testCase := []struct { packageType string + template string validVersion string + checkFunc func(fqrn string, testData map[string]string) resource.TestCheckFunc }{ - {"docker", "3.67.9"}, - {"maven", "3.78.9"}, - {"npm", "3.78.9"}, - {"pypi", "3.78.9"}, + { + "docker", + TestDataRepoConfigDockerTemplate, + "3.67.9", + func(fqrn string, testData map[string]string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.services", testData["services_scan"]), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", testData["secrets_scan"]), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.applications", testData["applications_scan"]), + ) + }, + }, + { + "maven", + TestDataRepoConfigMavenTemplate, + "3.78.9", + func(fqrn string, testData map[string]string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", testData["secrets_scan"]), + ) + }, + }, + { + "npm", + TestDataRepoConfigNpmPyPiTemplate, + "3.78.9", + func(fqrn string, testData map[string]string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", testData["secrets_scan"]), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.applications", testData["applications_scan"]), + ) + }, + }, + { + "pypi", + TestDataRepoConfigNpmPyPiTemplate, + "3.78.9", + func(fqrn string, testData map[string]string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", testData["secrets_scan"]), + resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.applications", testData["applications_scan"]), + ) + }, + }, } version, err := sdk.GetXrayVersion(GetTestResty(t)) @@ -132,11 +175,11 @@ func TestAccRepositoryConfigRepoConfigCreate_Exposure(t *testing.T) { } for _, tc := range testCase { - t.Run(tc.packageType, testAccRepositoryConfigRepoConfigCreate(t, tc.packageType, tc.validVersion, version)) + t.Run(tc.packageType, testAccRepositoryConfigRepoConfigCreate(t, tc.packageType, tc.template, tc.validVersion, version, tc.checkFunc)) } } -func testAccRepositoryConfigRepoConfigCreate(t *testing.T, packageType, validVersion, xrayVersion string) func(t *testing.T) { +func testAccRepositoryConfigRepoConfigCreate(t *testing.T, packageType, template, validVersion, xrayVersion string, checkFunc func(fqrn string, testData map[string]string) resource.TestCheckFunc) func(t *testing.T) { return func(t *testing.T) { _, fqrn, resourceName := testutil.MkNames("xray-repo-config-", "xray_repository_config") var testData = map[string]string{ @@ -146,7 +189,7 @@ func testAccRepositoryConfigRepoConfigCreate(t *testing.T, packageType, validVer "vuln_contextual_analysis": "false", "services_scan": "true", "secrets_scan": "true", - "applications_scan": "false", + "applications_scan": "true", } valid, _ := sdk.CheckVersion(xrayVersion, validVersion) @@ -171,15 +214,8 @@ func testAccRepositoryConfigRepoConfigCreate(t *testing.T, packageType, validVer Steps: []resource.TestStep{ { - Config: sdk.ExecuteTemplate(fqrn, TestDataRepoConfigTemplate, testData), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(fqrn, "repo_name", testData["repo_name"]), - resource.TestCheckResourceAttr(fqrn, "config.0.retention_in_days", testData["retention_in_days"]), - resource.TestCheckResourceAttr(fqrn, "config.0.vuln_contextual_analysis", testData["vuln_contextual_analysis"]), - resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.services", testData["services_scan"]), - resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.secrets", testData["secrets_scan"]), - resource.TestCheckResourceAttr(fqrn, "config.0.exposures.0.scanners_category.0.applications", testData["applications_scan"]), - ), + Config: sdk.ExecuteTemplate(fqrn, template, testData), + Check: checkFunc(fqrn, testData), }, { ResourceName: fqrn, @@ -371,20 +407,53 @@ resource "xray_repository_config" "{{ .resource_name }}" { } }` -const TestDataRepoConfigTemplate = ` +const TestDataRepoConfigDockerTemplate = ` resource "xray_repository_config" "{{ .resource_name }}" { repo_name = "{{ .repo_name }}" config { + retention_in_days = {{ .retention_in_days }} vuln_contextual_analysis = {{ .vuln_contextual_analysis }} + + exposures { + scanners_category { + services = true + secrets = true + applications = true + } + } + } +}` + +const TestDataRepoConfigMavenTemplate = ` +resource "xray_repository_config" "{{ .resource_name }}" { + repo_name = "{{ .repo_name }}" + + config { retention_in_days = {{ .retention_in_days }} - exposures { + vuln_contextual_analysis = {{ .vuln_contextual_analysis }} + + exposures { scanners_category { - services = {{ .services_scan }} - secrets = {{ .secrets_scan }} - applications = {{ .applications_scan }} + secrets = true } - } + } + } +}` + +const TestDataRepoConfigNpmPyPiTemplate = ` +resource "xray_repository_config" "{{ .resource_name }}" { + repo_name = "{{ .repo_name }}" + + config { + retention_in_days = {{ .retention_in_days }} + + exposures { + scanners_category { + secrets = true + applications = true + } + } } }` From fc5a00f2a303012c2b60c7fa623ea715147875c6 Mon Sep 17 00:00:00 2001 From: JFrog CI Date: Mon, 28 Aug 2023 21:42:24 +0000 Subject: [PATCH 11/13] JFrog Pipelines - Add Artifactory and Xray versions to CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4797972e..3619eef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.15.0 (August 17, 2023) +## 1.15.0 (August 17, 2023). Tested on Artifactory 7.63.14 and Xray 3.80.9 BUG FIXES: From ed17530fb9565391ea39467c97bc4b3a50fcacdd Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Mon, 28 Aug 2023 14:53:08 -0700 Subject: [PATCH 12/13] Update CHANGELOG date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3619eef4..9aa761cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.15.0 (August 17, 2023). Tested on Artifactory 7.63.14 and Xray 3.80.9 +## 1.15.0 (August 29, 2023). Tested on Artifactory 7.63.14 and Xray 3.80.9 BUG FIXES: From 04de45ea6f4e5c61d0e94685bd5acf372c010069 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Mon, 28 Aug 2023 14:53:48 -0700 Subject: [PATCH 13/13] Update doc for exposures --- docs/resources/repository_config.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/repository_config.md b/docs/resources/repository_config.md index 82dc2633..fc1a39df 100644 --- a/docs/resources/repository_config.md +++ b/docs/resources/repository_config.md @@ -74,9 +74,9 @@ Optional: ### Nested Schema for `config.exposures` -Optional: +Required: -- `scanners_category` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--config--exposures--scanners_category)) +- `scanners_category` (Block Set, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--config--exposures--scanners_category)) ### Nested Schema for `config.exposures.scanners_category`