jfrog / terraform-provider-xray

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

Validation fails for custom license in `allowed_licenses` for `xray_license_policy` #121

Closed nbaju1 closed 1 year ago

nbaju1 commented 1 year ago

Describe the bug A custom license has been added through the portal: Xray Settings -> Compliance Licenses.

Attempting to validate the terraform configuration where this license is added to allowed_licenses of the xray_license_policy resource does not work.

resource "xray_license_policy" "allowed_licenses" {
  name = "allowed-licenses"
  type = "license"
  rule {
    name     = "allowed-licenses"
    priority = 1
    criteria {
      allowed_licenses = ["custom license"]
      allow_unknown    = false
    }
    actions {
      custom_severity = "Medium"
      block_download {
        active    = false
        unscanned = false
      }
    }
  }

}
Error: expected allowed_licenses to be one of ...

Artifactory version: suggested url does not work, getting "Authentication is required" Xray version: {"xray_version":"3.73.8","xray_revision":"b9b2c47"} Terraform version: 1.4.2

Requirements for and issue

Expected behavior Able to allow usage of a custom license.

danielmkn commented 1 year ago

Hi @nbaju1! It's a known issue, since we don't have a public API to get a list of licenses from the Artifactory instance, we had to verify the license against the default list of licenses, saved directly in the code beforehand. The workaround would be to allow users to put free text in that attribute, but the implications are not clear to me. I've reached out to the Xray team and will update you here.

danielmkn commented 1 year ago

Released in v1.14.0, restrictions are removed from the banned and allowed licenses attributes.