Skip to content

sysdig_secure_ml_policy: Using the resource may crash the Terraform process #574

@r2bit

Description

@r2bit

Use of sysdig_secure_ml_policy causes a perpetual diff that cannot be resolved w/o deleting the resource from Terraform state:

Error: Rules not found
 
   with module.main.sysdig_secure_ml_policy.base,
   on ../../runtime.tf line 16, in resource "sysdig_secure_ml_policy" "base":
   16: resource "sysdig_secure_ml_policy" "base" {
 
Operation failed: failed running terraform plan (exit 1)

Once deleted from Sysdig, the plugin crashes:

Stack trace from the terraform-provider-sysdig_v1.37.2 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xdf1946]

goroutine 213 [running]:
github.com/draios/terraform-provider-sysdig/sysdig.setTFResourceBaseAttrs(0xc0000fa780, {0x0?, {0x0?, 0x3100000000eb4520?, 0xc000c14930?}})
github.com/draios/terraform-provider-sysdig/sysdig/tfresource.go:75 +0x26
github.com/draios/terraform-provider-sysdig/sysdig.Reduce[...](0xc0000fa780?, {0x0, {0x0?, 0xfd5eed?, 0x2?}}, {0xc000010f00?, 0x3, 0xc0000fa780})
github.com/draios/terraform-provider-sysdig/sysdig/tfresource.go:46 +0x74
github.com/draios/terraform-provider-sysdig/sysdig.init.Reducer[...].func10({0x0?, {0x0?, 0x9f03d2?, 0xc000807278?}})
github.com/draios/terraform-provider-sysdig/sysdig/tfresource.go:39 +0x45
github.com/draios/terraform-provider-sysdig/sysdig.mlPolicyToResourceData(...)
github.com/draios/terraform-provider-sysdig/sysdig/resource_sysdig_secure_ml_policy.go:88
github.com/draios/terraform-provider-sysdig/sysdig.resourceSysdigMLPolicyRead({0x1245368, 0xc000404bd0}, 0xc0000fa780, {0xf85ba0?, 0xc0005ae140?})
github.com/draios/terraform-provider-sysdig/sysdig/resource_sysdig_secure_ml_policy.go:155 +0x26c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0003d4380, {0x12452c0, 0xc00072fef0}, 0xc0000fa780, {0xf85ba0, 0xc0005ae140})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:724 +0x119
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0003d4380, {0x12452c0, 0xc00072fef0}, 0xc0007dc340, {0xf85ba0, 0xc0005ae140})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x51a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00020bec0, {0x12452c0?, 0xc00072fe30?}, 0xc00012f840)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x4aa
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0005af2c0, {0x12452c0?, 0xc00072f6b0?}, 0xc000a4df20)
github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:748 +0x46f
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xf9c000, 0xc0005af2c0}, {0x12452c0, 0xc00072f6b0}, 0xc000404690, 0x0)
github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00021e000, {0x124a6e0, 0xc000718000}, 0xc0007a2480, 0xc00062acf0, 0x19353f0, 0x0)
google.golang.org/[email protected]/server.go:1340 +0xd16
google.golang.org/grpc.(*Server).handleStream(0xc00021e000, {0x124a6e0, 0xc000718000}, 0xc0007a2480, 0x0)
google.golang.org/[email protected]/server.go:1713 +0x9da
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/[email protected]/server.go:965 +0x87
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 22
google.golang.org/[email protected]/server.go:963 +0x226

Error: The terraform-provider-sysdig_v1.37.2 plugin crashed!

Terraform code:

resource "sysdig_secure_ml_policy" "base" {
  name        = "Crypto Mining detection"
  description = "Policy that enables Crypto Mining detection using advanced ML capabilities"

  severity = 3
  enabled  = true

  scope = "kubernetes.cluster.name in (\"X\")"

  rule {
    description = "Crypto Mining detection"

    cryptomining_trigger {
      enabled   = true
      threshold = 1
    }
  }

  notification_channels = [Y]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleThis has become stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions