Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider produced inconsistent result after apply on xray_security_policy resources after provider upgrade to 2.11.1 #248

Closed
3 tasks done
mymasse opened this issue Sep 20, 2024 · 2 comments · Fixed by #249
Assignees
Labels
bug Something isn't working

Comments

@mymasse
Copy link

mymasse commented Sep 20, 2024

Describe the bug
After a provider upgrade from 2.11.0 to 2.11.1 we started getting error when applying xray_security_policy resources even if they have not changed.

Terraform configuration:

resource "xray_security_policy" "high_severity_cve" {
  name        = "high-severity-cve"
  description = "This security policy generates a violation for high-severity CVEs with a CVSS score of 7.0-10.0"
  type        = "security"

  rule {
    name     = "high-severity-cve"
    priority = 1

    criteria {
      cvss_range {
        from = 7.0
        to   = 10.0
      }
    }
    actions {
      block_download {
        active = false
      }
    }
  }
}

Terraform apply output

# xray_security_policy.high_severity_cve will be updated in-place
  ~ resource "xray_security_policy" "high_severity_cve" {
      ~ author      = "terraform" -> (known after apply)
      ~ created     = "2024-06-05T12:58:20.859Z" -> (known after apply)
      ~ id          = "high-severity-cve" -> (known after apply)
      ~ modified    = "2024-09-20T17:40:14.042Z" -> (known after apply)
        name        = "high-severity-cve"
        # (2 unchanged attributes hidden)

      - rule {
          - name     = "high-severity-cve" -> null
          - priority = 1 -> null

          - actions {
              - block_release_bundle_distribution  = false -> null
              - block_release_bundle_promotion     = false -> null
              - build_failure_grace_period_in_days = 0 -> null
              - create_ticket_enabled              = false -> null
              - fail_build                         = false -> null
              - notify_deployer                    = false -> null
              - notify_watch_recipients            = false -> null

              - block_download {
                  - active    = false -> null
                  - unscanned = false -> null
                }
            }

          - criteria {
              - applicable_cves_only  = false -> null
              - fix_version_dependant = false -> null
              - malicious_package     = false -> null

              - cvss_range {
                  - from = 7 -> null
                  - to   = 10 -> null
                }
            }
        }
      + rule {
          + name     = "high-severity-cve"
          + priority = 1

          + actions {
              + block_release_bundle_distribution = false
              + block_release_bundle_promotion    = false
              + create_ticket_enabled             = false
              + fail_build                        = false
              + notify_deployer                   = false
              + notify_watch_recipients           = false

              + block_download {
                  + active    = false
                  + unscanned = false
                }
            }

          + criteria {
              + applicable_cves_only  = false
              + fix_version_dependant = false
              + malicious_package     = false

              + cvss_range {
                  + from = 7
                  + to   = 10
                }
            }
        }
    }

Error:

Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to xray_security_policy.high_severity_cve, provider "provider[\"registry.terraform.io/jfrog/xray\"]" produced an unexpected new value: .rule: planned set
│ element
│ cty.ObjectVal(map[string]cty.Value{"actions":cty.SetVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"block_download":cty.SetVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"active":cty.False,
│ "unscanned":cty.False})}), "block_release_bundle_distribution":cty.False, "block_release_bundle_promotion":cty.False, "build_failure_grace_period_in_days":cty.NullVal(cty.Number),
│ "create_ticket_enabled":cty.False, "fail_build":cty.False, "mails":cty.NullVal(cty.Set(cty.String)), "notify_deployer":cty.False, "notify_watch_recipients":cty.False,
│ "webhooks":cty.NullVal(cty.Set(cty.String))})}), "criteria":cty.SetVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"applicable_cves_only":cty.False,
│ "cvss_range":cty.ListVal([]cty.Value{cty.ObjectVal(map[string]cty.Value{"from":cty.NumberIntVal(7), "to":cty.NumberIntVal(10)})}),
│ "exposures":cty.ListValEmpty(cty.Object(map[string]cty.Type{"applications":cty.Bool, "iac":cty.Bool, "min_severity":cty.String, "secrets":cty.Bool, "services":cty.Bool})),
│ "fix_version_dependant":cty.False, "malicious_package":cty.False, "min_severity":cty.NullVal(cty.String), "package_name":cty.NullVal(cty.String),
│ "package_type":cty.NullVal(cty.String), "package_versions":cty.NullVal(cty.Set(cty.String)), "vulnerability_ids":cty.NullVal(cty.Set(cty.String))})}),
│ "name":cty.StringVal("high-severity-cve"), "priority":cty.NumberIntVal(1)}) does not correlate with any element in actual.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Requirements for and issue

  • A fully functioning terraform snippet that can be copy&pasted (no outside files or ENV vars unless that's part of the issue)
  • Your version of Artifactory and Xray (you can curl Artifactory version at $host/artifactory/api/system/version and Xray version at $host/xray/api/v1/system/version
    Artifactory: 7.90.10
    Xray: 3.104.11
    
  • Your version of terraform
    Terraform v1.9.5
    on linux_amd64
    + provider registry.terraform.io/hashicorp/aws v5.68.0
    + provider registry.terraform.io/jfrog/artifactory v12.0.0
    + provider registry.terraform.io/jfrog/platform v1.12.0
    + provider registry.terraform.io/jfrog/xray v2.11.1
    

Expected behavior
We expected either no changes since the resource actually didn't change and definitly don't expect an error when it tries to change id

Additional context
N/A

@mymasse mymasse added the bug Something isn't working label Sep 20, 2024
@alexhung
Copy link
Member

@mymasse Thanks for the report. I'll add this to our plan to fix.

alexhung added a commit that referenced this issue Sep 23, 2024
Fix inconsistent result/state drift in policy resources
@mymasse
Copy link
Author

mymasse commented Sep 24, 2024

Thanks for the quick turnaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants