jfrog / terraform-provider-xray

Terraform provider to manage JFrog Xray
https://jfrog.com/xray/
Apache License 2.0
151 stars 12 forks source link

Project key with hyphen support #75

Closed oallauddin closed 2 years ago

oallauddin commented 2 years ago

Describe the bug Project key with a hyphen is throwing an error.

@alexhung I am testing https://github.com/jfrog/terraform-provider-shared/issues/21. The project provider does not have an issue with a project key with a hyphen. The xray provider does not like it and throws a 500 error on the terraform apply.

500 POST https://artifactory-server.com/xray/api/v2/policies?projectKey=tst-test
{"error":"Failed to create Policy"}

Requirements for and issue

resource "project" "tst_project" {
  key          = "tst-test"
  display_name = "Test Project"

  admin_privileges {
    manage_members   = true
    manage_resources = true
    index_resources  = true
  }

}

resource "xray_security_policy" "tst_security_policy" {
  name        = "tst-security-policy"
  description = "Test Security Policy"
  type        = "security"
  project_key = "tst-test"

  rule {
    name     = "tst-severity-rule"
    priority = 1

    criteria {
      cvss_range {
        from = 7.0
        to   = 10.0
      }
    }

    actions {
      webhooks                          = []
      mails                             = []
      block_release_bundle_distribution = false
      fail_build                        = false
      notify_watch_recipients           = false
      notify_deployer                   = false
      create_ticket_enabled             = false // set to true only if Jira integration is enabled
      //build_failure_grace_period_in_days = 5     // use only if fail_build is enabled

      block_download {
        unscanned = false
        active    = false
      }
    }
  }

  depends_on = [
    project.tst_project
  ]
}

Expected behavior Project key with a hyphen does not cause an error.

alexhung commented 2 years ago

@oallauddin Which version of the xray provider are you using?

Version 1.5.1 is updated with the new hyphen support.

oallauddin commented 2 years ago

@alexhung Looks like issue is with my version of Artifactory and Xray. I see you tested on newer versions than what we have setup. I will ask our admins when they plan to upgrade Artifactory and Xray.

Versions Artifactory version: 7.35.2 Xray version: 3.32.2 Terraform version: 1.2.5 Xray Provider version: 1.5.1 Project Provider version: 1.1.6 Artifactory Provider: 6.14.1