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

Visibility not set correctly when repository is created from a template. #758

Closed
jgreat opened this issue Apr 13, 2021 · 5 comments
Closed
Labels
r/repository Type: Bug Something isn't working as documented

Comments

@jgreat
Copy link

jgreat commented Apr 13, 2021

The /repos/{template_owner}/{template_repo}/generate takes a "private": <bool> option. This option is not getting set correctly leading to a repo with a "public" visibility.

https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template

This issue should be considered a security bug. It could lead to unintentional exposure of an organizations sensitive or proprietary information.

Terraform Version

Terraform v0.14.8
+ provider registry.terraform.io/integrations/github v4.8.0

Affected Resource(s)

  • github_repository

Terraform Configuration Files

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "4.8.0"
    }
  }
  required_version = ">= 0.14"
}

locals {
  owner    = "jgreat"
  repo     = "tf-test-repo"
  template = "tf-manifest-template"
}

provider "github" {
  token = var.github_mobilecoin_tf_oauth_token
  owner = local.owner
}

resource "github_repository" "repo" {
  name        = local.repo
  description = "Github Provider Test"

  visibility = "private"

  template {
    owner      = local.owner
    repository = local.template
  }
}

Debug

private should be set to true for a visablity = "private" repo.

2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: ---[ REQUEST ]---------------------------------------
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: POST /repos/jgreat/tf-manifest-template/generate HTTP/1.1
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: Host: api.github.com
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: User-Agent: go-github
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: Content-Length: 106
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: Accept: application/vnd.github.baptiste-preview+json
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: Content-Type: application/json
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: Accept-Encoding: gzip
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: 
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: {
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0:  "name": "tf-test-repo",
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0:  "owner": "jgreat",
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0:  "description": "Github Provider Test",
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0:  "private": false
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: }
2021-04-13T11:58:19.556-0500 [DEBUG] plugin.terraform-provider-github_v4.8.0: 

Expected Behavior

GitHub repository is created from a template repository and visibility is set to "Private"

Actual Behavior

GitHub repository is created from a template repository with visibility set to "Public"

Steps to Reproduce

  1. terraform apply
@EduardoRT
Copy link

EduardoRT commented Apr 14, 2021

I'm experiencing the same issue.

btw, if you re-run Terraform again the repo changes to private as expected.

@jcudit
Copy link
Contributor

jcudit commented Apr 15, 2021

Thanks for reporting this ❤️.

We're iterating on a fix and I'll update the changelog with a regression note to make this more visible.

@jcudit
Copy link
Contributor

jcudit commented Apr 18, 2021

v4.9.2 addresses this issue. Can anyone confirm the issue is resolved?

@jgreat
Copy link
Author

jgreat commented Apr 20, 2021

Tested and confirmed that the repo is private on creation. Thanks for addressing this so quickly!

@jgreat jgreat closed this as completed Apr 20, 2021
@EduardoRT
Copy link

Sorry for the delay; I had an issue with my pipelines; I've tested it in the same place where I had the issue, and the repositories are now being created as private as expected — thanks for the help, @jcudit !

@jcudit jcudit added Type: Bug Something isn't working as documented r/repository regression labels Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r/repository Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

3 participants