jfrog / terraform-provider-xray

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

dates are parsed in UTC #237

Closed ritzk closed 3 weeks ago

ritzk commented 3 weeks ago

Describe the bug tz is parsed in UTC, regardless of local tz on alpine.

When running apply for ignore rules

Error: Provider produced inconsistent result after apply

When applying changes to module.app.xray_ignore_rule.ignore-rule-1, provider
"provider[\"registry.opentofu.org/jfrog/xray\"]" produced an unexpected new value: .expiration_date: was
cty.StringVal("2024-12-31"), but now cty.StringVal("2024-12-30").

This is a bug in the provider, which should be reported in the provider's own issue tracker.

Requirements for and issue

ignore rules

resource "xray_watch" "watch-rule-1" {
  name        = "${var.app_name}"
  description = ""
  active      = true

  watch_resource {
    bin_mgr_id = "default"
    name       = "repo-name"
    repo_type  = "local"
    type       = "repository"

    path_ant_filter {
      exclude_patterns = []
      include_patterns = [
        "${var.app_name}/**/**",
      ]
    }
  }

resource "xray_ignore_rule" "ignore-rule-1" {
  cves            = ["CVE-XXX"]
  expiration_date = "2024-12-31"
  watches         = [xray_watch.watch-rule-1.name]
  notes           = " Waiver Granted XXX"
}

Expected behavior tz should parsed in local tz, or provide the option to specify time with tz ( 2024-11-01T13:00-04:00/ 2024-11-01T13:00Z/...)

alexhung commented 3 weeks ago

@ritzk Thanks for the report. I'll investigate. This is odd since the resource doesn't validate or transform this value. It passes the value straight to the REST API.

alexhung commented 3 weeks ago

@ritzk I wonder if this is timezone related. Where are you located vs the location of your JFrog instance?

ritzk commented 3 weeks ago

@alexhung Everything is on EST (America/New_York).

ritzk commented 3 weeks ago

@alexhung API needs zulu time - https://jfrog.com/help/r/xray-rest-apis/create-ignore-rule

curl ...
"expires_at":"2024-12-31T00:00:00Z"

tofu api does not except z time.

alexhung commented 3 weeks ago

@ritzk Thanks for the hint! I'll fix the timestamp formating.

ritzk commented 3 weeks ago

running this with go. I see the same timestamp in xray.

Time in EST: 2024-12-30 19:00:00 -0500 EST