Skip to content

security_and_analysis segment not applying properly #1487

Closed as not planned
Closed as not planned
@halversonea

Description

@halversonea

I believe I've found a bug in the provider registry.terraform.io/integrations/github.
I'm able to create repos successfully with the following code:

resource "github_repository" "code_store" {
  name        = var.repository_name
  description = var.repository_description
  auto_init   = true
  allow_squash_merge = true
  allow_merge_commit = false
  allow_rebase_merge = false
  delete_branch_on_merge = true
}

But then when I try to update them in any way I get the following error:

Error: PATCH https://github.office.COMPANY_NAME.com/api/v3/repos/OWNER_NAME/repo-test-eric1a: 422 Secret Scanning is always enabled for public repos []

So I tried including the following security_and_analysis segment:

resource "github_repository" "code_store" {
  name        = var.repository_name
  description = var.repository_description
  auto_init   = true
  allow_squash_merge = true
  allow_merge_commit = false
  allow_rebase_merge = false
  delete_branch_on_merge = true

  security_and_analysis {
    advanced_security {
      status = "enabled"
    }

    secret_scanning {
      status = "enabled"
    }

    secret_scanning_push_protection {
      status = "enabled"
    }
  }
}

But this results in the following error:

Error: PATCH https://github.office.COMPANY_NAME.com/api/v3/repos/OWNER_NAME/repo-test-eric3a: 422 Enabling advanced security is restricted by a policy []

So I attempted to force-disable the extra security settings:

resource "github_repository" "code_store" {
  name        = var.repository_name
  description = var.repository_description
  auto_init   = true
  allow_squash_merge = true
  allow_merge_commit = false
  allow_rebase_merge = false
  delete_branch_on_merge = true

  security_and_analysis {
    advanced_security {
      status = "disabled"
    }

    secret_scanning {
      status = "disabled"
    }

    secret_scanning_push_protection {
      status = "disabled"
    }
  }
}

But this again gives the following error:

Error: PATCH https://github.office.COMPANY_NAME.com/api/v3/repos/OWNER_NAME/repo-test-eric1a: 422 Secret Scanning is always enabled for public repos []

All of these attempts were done fresh with a destroy cleaning up everything before attempting the create again and this is when creating a public repo.

I'm using Terraform v1.3.7 and provider registry.terraform.io/integrations/github v5.14.0 though I was getting the same errors on earlier versions of both terraform and the github provider.

Any suggestions would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleUsed by stalebot to clean houseStatus: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedType: SupportAny questions, information, or general needs around the SDK or GitHub APIs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions