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

Crashing on snyk_project #13

Open
mkohn opened this issue Jan 25, 2023 · 1 comment
Open

Crashing on snyk_project #13

mkohn opened this issue Jan 25, 2023 · 1 comment

Comments

@mkohn
Copy link

mkohn commented Jan 25, 2023

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v1.2.9
on darwin_arm64

Affected Resource(s)

  • snyk_project

Terraform Configuration Files

resource "snyk_organization" "org" {
  name = var.project_name
}

data "snyk_integration" "example" {
  count = var.enable_projects ? 1 : 0
  orgid = snyk_organization.org.id
  type  = "bitbucket-connect-app"
}

resource "snyk_project" "repo" {
  for_each          = bitbucket_repository.infrastructure
  organization     = snyk_organization.org.id
  repository_owner = "lakesidesoftware"
  repository_name  = each.key
  branch           = "main"
  integration      = data.snyk_integration.example[0].id
}

Panic Output

Stack trace from the terraform-provider-snyk_0.4.1 plugin:

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

goroutine 55 [running]:
github.com/formstack/terraform-provider-snyk/snyk/api.ImportProject({{0x1400003c1e0, 0x24}, {0x1400003c1b0, 0x24}, {0x14000046310, 0x65}}, {0x1400051a360, 0x24}, {0x1400051a330, 0x24}, ...)
        github.com/formstack/terraform-provider-snyk/snyk/api/targets.go:66 +0x328
github.com/formstack/terraform-provider-snyk/snyk.resourceProjectCreate({0x102c1dca0?, 0x1400058b1a0?}, 0x0?, {0x102b96540?, 0x140000ab230?})
        github.com/formstack/terraform-provider-snyk/snyk/resource_project.go:72 +0x1bc
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x14000207340, {0x102c1dca0, 0x1400058b1a0}, 0xd?, {0x102b96540, 0x140000ab230})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:707 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x14000207340, {0x102c1dca0, 0x1400058b1a0}, 0x140005924e0, 0x14000577780, {0x102b96540, 0x140000ab230})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0x874
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x140002c8480, {0x102c1dca0?, 0x1400058b080?}, 0x14000511d60)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xb94
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x140002debe0, {0x102c1dca0?, 0x1400058a870?}, 0x140005330a0)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x3c0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x102bea680?, 0x140002debe0}, {0x102c1dca0, 0x1400058a870}, 0x14000533030, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002da1e0, {0x102c207c0, 0x140002e7520}, 0x1400057eea0, 0x14000434c60, 0x103076960, 0x0)
        google.golang.org/[email protected]/server.go:1340 +0xb90
google.golang.org/grpc.(*Server).handleStream(0x140002da1e0, {0x102c207c0, 0x140002e7520}, 0x1400057eea0, 0x0)
        google.golang.org/[email protected]/server.go:1713 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/[email protected]/server.go:965 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:963 +0x298
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x30 pc=0x10298293c]

goroutine 53 [running]:
github.com/formstack/terraform-provider-snyk/snyk.resourceProjectCreate({0x102dedca0?, 0x140005940c0?}, 0x0?, {0x102d66540?, 0x140005026c0?})
        github.com/formstack/terraform-provider-snyk/snyk/resource_project.go:78 +0x22c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x140001ff340, {0x102dedca0, 0x140005940c0}, 0xd?, {0x102d66540, 0x140005026c0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:707 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140001ff340, {0x102dedca0, 0x140005940c0}, 0x14000131d40, 0x14000590900, {0x102d66540, 0x140005026c0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0x874
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14000422480, {0x102dedca0?, 0x14000173f80?}, 0x1400013b720)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xb94
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x140002d6aa0, {0x102dedca0?, 0x14000173770?}, 0x1400014cd90)
        github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x3c0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x102dba680?, 0x140002d6aa0}, {0x102dedca0, 0x14000173770}, 0x1400014cd20, 0x0)
        github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002d21e0, {0x102df07c0, 0x140003964e0}, 0x14000586360, 0x1400042cc90, 0x103246960, 0x0)
        google.golang.org/[email protected]/server.go:1340 +0xb90
google.golang.org/grpc.(*Server).handleStream(0x140002d21e0, {0x102df07c0, 0x140003964e0}, 0x14000586360, 0x0)
        google.golang.org/[email protected]/server.go:1713 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/[email protected]/server.go:965 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:963 +0x298

Error: The terraform-provider-snyk_0.4.1 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Actual Behavior

Crashing

Steps to Reproduce

  1. terraform apply
@jay-lark
Copy link
Contributor

Hi @mkohn,

Thank you for the report. Right now this provider only supports targets/projects using the Github/Github Enterprise integrations.

We don't have access to Bitbucket at the moment so I'm not sure if responses from the Snyk API when importing are the same with Bitbucket as they are with GitHub or not. I do know that the current API from Snyk is very very limited on what you can do with targets and that the provider does some things to make it work with Formstack's GitHub naming convention (although it works with my personal repositories so this might be universal)

Snyk has a beta API that has a lot more functionality and may allow us to improve this provider by a lot, but I haven't been able to get a release date out of them for that.

If for whatever reason Bitbucket isn't the issue here, there is another known scenario in which this provider crashes. If you try to import a repository and that repository doesn't have a supported Snyk dependency or code file that Snyk can scan, the import will fail and crash this provider.

I'll try to get both of these issue mentioned in the documentation on an upcoming release as I don't really have an ETA on when they will be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants