diff --git a/README.md b/README.md index c7f744a..099548a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Manage Gitea resources, teams, repos, and Woodpecker CI via Terraform. `config/github.com/IUCLabs/` feeds `modules/github_org` via `environments/github/iuclabs`, authenticated as a GitHub App (`kv/service/github/iuclabs/terraform`). Org membership invites are manual. -`modules/github_org` validates config, manages org-level settings, and calls `modules/team` (team + memberships) and `modules/repository` (repo, default branch, collaborators, CODEOWNERS, rulesets via `modules/ruleset`). +`modules/github_org` validates config, manages org-level settings, and calls `modules/team` (team + memberships), `modules/repository` (repo, default branch, collaborators, CODEOWNERS) and `modules/ruleset` once per effective `/` pair, after the repositories. `config.yaml` (optional) manages org settings: profile (`name`, `description`, `blog`, `location`, `email`, `twitter_username`, `company`), `default_repository_permission` (read, or none), `members_can_create_repositories` (false), `public_runners` (false; lets public repos use the Default runner group). Every other org setting is pinned in the module (no Pages, no repo projects, legacy security toggles off), and `GITHUB_TOKEN` is read-only and non-approving. `billing_email` comes from the `billing_email` field of the same Vault path (`TF_VAR_billing_email`). These resources are `prevent_destroy`, so deleting `config.yaml` fails the plan; to stop managing them, add `removed { from = ; lifecycle { destroy = false } }` blocks to `modules/github_org`. @@ -29,26 +29,29 @@ maintainers: [] # users or @team: maintain access, seed initial .gith codeowners: [] # push access, for adding to CODEOWNERS later merge_type: squash # squash | merge | rebase delete_branch_on_merge: true -branch_protection: !private # generated `branch-protection` ruleset on the default branch -tag_protection: !private # generated `tag-protection` ruleset: refs/tags/v* undeletable, immutable -required_checks: [] # generated `required-checks` ruleset (strict) -rulesets: [] # custom rulesets from ruleset/ +rulesets: [] # opt-in rulesets from ruleset/ (public repos only) +exclude_rulesets: [] # opt out of non-mandatory all_repos rulesets ``` -Public repositories always get generated `ref-names-branch` and `ref-names-tag` rulesets blocking creation of refs with a `+` path component, which would act as a wildcard in Vault policy paths templated from the GitHub OIDC `ref` claim. - -`ruleset/.yaml` (custom extras; `branch-protection`, `required-checks`, `tag-protection`, `ref-names-branch` and `ref-names-tag` are reserved): +`ruleset/.yaml` defines every ruleset: ```yaml -target: branch +all_repos: false # apply to every public repo (private repos are skipped) +mandatory: false # cannot be listed in exclude_rulesets +target: branch # branch | tag enforcement: active conditions: ref_name: include: ["refs/heads/release/*"] exclude: [] rules: + creation: false deletion: true non_fast_forward: true ``` -Private repositories cannot use `branch_protection`, `tag_protection`, `required_checks` or `rulesets` on the free plan; plan fails if they do. +`branch-protection` (PRs on the default branch) and `tag-protection` (`refs/tags/v*` undeletable, immutable) apply to all public repos. `ref-names-branch` and `ref-names-tag` are mandatory: they block refs with a `+` path component, which would act as a wildcard in Vault policy paths templated from the GitHub OIDC `ref` claim. + +Required status checks are a custom ruleset referenced via `rulesets:`, e.g. `rules: {required_status_checks: {contexts: [ci/woodpecker], strict: true}}`. + +Private repositories cannot list `rulesets` on the free plan; plan fails if they do. Unknown names, excluding a mandatory ruleset, or listing a ruleset in both lists also fail. diff --git a/config/github.com/IUCLabs/ruleset/branch-protection.yaml b/config/github.com/IUCLabs/ruleset/branch-protection.yaml new file mode 100644 index 0000000..6325543 --- /dev/null +++ b/config/github.com/IUCLabs/ruleset/branch-protection.yaml @@ -0,0 +1,16 @@ +all_repos: true +target: branch +enforcement: active +conditions: + ref_name: + include: ["~DEFAULT_BRANCH"] + exclude: [] +rules: + deletion: true + non_fast_forward: true + pull_request: + required_approving_review_count: 0 + dismiss_stale_reviews_on_push: true + require_code_owner_review: false + require_last_push_approval: false + required_review_thread_resolution: false diff --git a/config/github.com/IUCLabs/ruleset/ref-names-branch.yaml b/config/github.com/IUCLabs/ruleset/ref-names-branch.yaml new file mode 100644 index 0000000..19743e8 --- /dev/null +++ b/config/github.com/IUCLabs/ruleset/ref-names-branch.yaml @@ -0,0 +1,11 @@ +# a "+" ref component becomes a wildcard in Vault policy paths templated from the GitHub OIDC ref claim +all_repos: true +mandatory: true +target: branch +enforcement: active +conditions: + ref_name: + include: ["refs/heads/**/+", "refs/heads/**/+/**/*"] + exclude: [] +rules: + creation: true diff --git a/config/github.com/IUCLabs/ruleset/ref-names-tag.yaml b/config/github.com/IUCLabs/ruleset/ref-names-tag.yaml new file mode 100644 index 0000000..7938409 --- /dev/null +++ b/config/github.com/IUCLabs/ruleset/ref-names-tag.yaml @@ -0,0 +1,11 @@ +# a "+" ref component becomes a wildcard in Vault policy paths templated from the GitHub OIDC ref claim +all_repos: true +mandatory: true +target: tag +enforcement: active +conditions: + ref_name: + include: ["refs/tags/**/+", "refs/tags/**/+/**/*"] + exclude: [] +rules: + creation: true diff --git a/config/github.com/IUCLabs/ruleset/tag-protection.yaml b/config/github.com/IUCLabs/ruleset/tag-protection.yaml new file mode 100644 index 0000000..7566251 --- /dev/null +++ b/config/github.com/IUCLabs/ruleset/tag-protection.yaml @@ -0,0 +1,10 @@ +all_repos: true +target: tag +enforcement: active +conditions: + ref_name: + include: ["refs/tags/v*"] + exclude: [] +rules: + deletion: true + non_fast_forward: true diff --git a/modules/github_org/main.tf b/modules/github_org/main.tf index 7cb8179..a3dbe5a 100644 --- a/modules/github_org/main.tf +++ b/modules/github_org/main.tf @@ -15,14 +15,53 @@ module "repository" { for_each = var.repository - owner = var.owner - config = each.value - rulesets = { for rs in each.value.rulesets : rs => var.ruleset[rs] } + owner = var.owner + config = each.value team_slugs = { for e in concat(each.value.maintainers, each.value.codeowners) : trimprefix(e, "@") => module.team[trimprefix(e, "@")].slug if startswith(e, "@") } } +locals { + # rulesets are not enforced on private repositories on the GitHub free plan + ruleset_pairs = merge([for repo_name, repo in var.repository : { + for rs in setunion(repo.rulesets, repo.private ? [] : [for k, v in var.ruleset : k if v.all_repos && !contains(repo.exclude_rulesets, k)]) : + "${repo_name}/${rs}" => { repository = repo_name, ruleset = rs } + }]...) +} + +module "ruleset" { + source = "./modules/ruleset" + + for_each = local.ruleset_pairs + + repository = module.repository[each.value.repository].repository.name + ruleset = var.ruleset[each.value.ruleset] + + # CODEOWNERS must exist before pull_request rules land + depends_on = [module.repository] +} + +moved { + from = module.repository[".github"].module.ruleset["branch-protection"].github_repository_ruleset.this + to = module.ruleset[".github/branch-protection"].github_repository_ruleset.this +} + +moved { + from = module.repository[".github"].module.ruleset["tag-protection"].github_repository_ruleset.this + to = module.ruleset[".github/tag-protection"].github_repository_ruleset.this +} + +moved { + from = module.repository[".github"].module.ruleset["ref-names-branch"].github_repository_ruleset.this + to = module.ruleset[".github/ref-names-branch"].github_repository_ruleset.this +} + +moved { + from = module.repository[".github"].module.ruleset["ref-names-tag"].github_repository_ruleset.this + to = module.ruleset[".github/ref-names-tag"].github_repository_ruleset.this +} + resource "github_actions_organization_workflow_permissions" "this" { count = var.settings == null ? 0 : 1 diff --git a/modules/github_org/modules/repository/main.tf b/modules/github_org/modules/repository/main.tf index ca2e950..083f115 100644 --- a/modules/github_org/modules/repository/main.tf +++ b/modules/github_org/modules/repository/main.tf @@ -3,75 +3,6 @@ locals { { for e in var.config.codeowners : e => "push" }, { for e in var.config.maintainers : e => "maintain" }, ) - - default_branch_rules = { - target = "branch" - enforcement = "active" - conditions = { ref_name = { include = ["~DEFAULT_BRANCH"], exclude = [] } } - } - - generated_rulesets = { for k, v in { - branch-protection = { - enabled = coalesce(var.config.branch_protection, !var.config.private) - ruleset = merge(local.default_branch_rules, { - name = "branch-protection" - rules = { - deletion = true - non_fast_forward = true - pull_request = { - required_approving_review_count = 0 - dismiss_stale_reviews_on_push = true - require_code_owner_review = false - require_last_push_approval = false - required_review_thread_resolution = false - } - required_status_checks = null - } - }) - } - required-checks = { - enabled = length(var.config.required_checks) > 0 - ruleset = merge(local.default_branch_rules, { - name = "required-checks" - rules = { - deletion = false - non_fast_forward = false - pull_request = null - required_status_checks = { contexts = var.config.required_checks, strict = true } - } - }) - } - tag-protection = { - enabled = coalesce(var.config.tag_protection, !var.config.private) - ruleset = { - name = "tag-protection" - target = "tag" - enforcement = "active" - conditions = { ref_name = { include = ["refs/tags/v*"], exclude = [] } } - rules = { - deletion = true - non_fast_forward = true - pull_request = null - required_status_checks = null - } - } - } - } : k => v.ruleset if v.enabled } - - # a "+" ref component becomes a wildcard in Vault policy paths templated from the GitHub OIDC ref claim - ref_name_rulesets = var.config.private ? {} : { for t, prefix in { branch = "refs/heads", tag = "refs/tags" } : "ref-names-${t}" => { - name = "ref-names-${t}" - target = t - enforcement = "active" - conditions = { ref_name = { include = ["${prefix}/**/+", "${prefix}/**/+/**/*"], exclude = [] } } - rules = { - creation = true - deletion = false - non_fast_forward = false - pull_request = null - required_status_checks = null - } - } } } resource "github_repository" "this" { @@ -133,14 +64,3 @@ resource "github_repository_file" "codeowners" { ignore_changes = [content] } } - -module "ruleset" { - source = "../ruleset" - - for_each = merge(var.rulesets, local.generated_rulesets, local.ref_name_rulesets) - - repository = github_repository.this.name - ruleset = each.value - - depends_on = [github_repository_file.codeowners] -} diff --git a/modules/github_org/modules/repository/outputs.tf b/modules/github_org/modules/repository/outputs.tf index 1ac9d23..9708ebd 100644 --- a/modules/github_org/modules/repository/outputs.tf +++ b/modules/github_org/modules/repository/outputs.tf @@ -13,7 +13,3 @@ output "codeowners" { output "access" { value = local.access } - -output "rulesets" { - value = { for k, m in module.ruleset : k => m.ruleset } -} diff --git a/modules/github_org/modules/repository/variables.tf b/modules/github_org/modules/repository/variables.tf index 89f0771..61c6b51 100644 --- a/modules/github_org/modules/repository/variables.tf +++ b/modules/github_org/modules/repository/variables.tf @@ -12,18 +12,9 @@ variable "config" { codeowners = list(string) merge_type = string delete_branch_on_merge = bool - branch_protection = bool - tag_protection = bool - required_checks = list(string) }) } -variable "rulesets" { - description = "Custom ruleset definitions this repository references, keyed by name" - type = any - default = {} -} - variable "team_slugs" { description = "Slugs of the teams this repository references, keyed by team name" type = map(string) diff --git a/modules/github_org/tests/github_org.tftest.hcl b/modules/github_org/tests/github_org.tftest.hcl index c7061b7..7041859 100644 --- a/modules/github_org/tests/github_org.tftest.hcl +++ b/modules/github_org/tests/github_org.tftest.hcl @@ -11,7 +11,23 @@ variables { maintainers = { name = "maintainers", maintainers = ["alice"], members = ["bob"] } } ruleset = { + branch-protection = { + name = "branch-protection", all_repos = true + conditions = { ref_name = { include = ["~DEFAULT_BRANCH"] } } + rules = { deletion = true, non_fast_forward = true, pull_request = { dismiss_stale_reviews_on_push = true } } + } + tag-protection = { + name = "tag-protection", all_repos = true, target = "tag" + conditions = { ref_name = { include = ["refs/tags/v*"] } } + rules = { deletion = true, non_fast_forward = true } + } + ref-names-tag = { + name = "ref-names-tag", all_repos = true, mandatory = true, target = "tag" + conditions = { ref_name = { include = ["refs/tags/**/+", "refs/tags/**/+/**/*"] } } + rules = { creation = true } + } signed = { name = "signed", rules = { deletion = true, pull_request = {} } } + checks = { name = "checks", rules = { required_status_checks = { contexts = ["ci/woodpecker"], strict = true } } } } } @@ -35,30 +51,20 @@ run "public_repo_defaults" { } assert { - condition = keys(module.repository[".github"].rulesets) == ["branch-protection", "ref-names-branch", "ref-names-tag", "tag-protection"] && length(module.team["maintainers"].membership) == 2 - error_message = "public repo must get only the generated branch-protection, ref-names and tag-protection rulesets" - } - - assert { - condition = alltrue([for t, prefix in { branch = "refs/heads", tag = "refs/tags" } : ( - module.repository[".github"].rulesets["ref-names-${t}"].target == t && - module.repository[".github"].rulesets["ref-names-${t}"].enforcement == "active" && - module.repository[".github"].rulesets["ref-names-${t}"].conditions[0].ref_name[0].include == tolist(["${prefix}/**/+", "${prefix}/**/+/**/*"]) && - module.repository[".github"].rulesets["ref-names-${t}"].rules[0].creation && - !module.repository[".github"].rulesets["ref-names-${t}"].rules[0].deletion - )]) - error_message = "ref-names rulesets must block creating branches and tags with a + path component" + condition = keys(module.ruleset) == [".github/branch-protection", ".github/ref-names-tag", ".github/tag-protection"] && length(module.team["maintainers"].membership) == 2 + error_message = "public repo must get exactly the all_repos rulesets, keyed /" } assert { condition = ( - module.repository[".github"].rulesets["tag-protection"].target == "tag" && - module.repository[".github"].rulesets["tag-protection"].enforcement == "active" && - module.repository[".github"].rulesets["tag-protection"].conditions[0].ref_name[0].include == tolist(["refs/tags/v*"]) && - module.repository[".github"].rulesets["tag-protection"].rules[0].deletion && - module.repository[".github"].rulesets["tag-protection"].rules[0].non_fast_forward + module.ruleset[".github/ref-names-tag"].ruleset.name == "ref-names-tag" && + module.ruleset[".github/ref-names-tag"].ruleset.repository == ".github" && + module.ruleset[".github/ref-names-tag"].ruleset.target == "tag" && + module.ruleset[".github/ref-names-tag"].ruleset.conditions[0].ref_name[0].include == tolist(["refs/tags/**/+", "refs/tags/**/+/**/*"]) && + module.ruleset[".github/ref-names-tag"].ruleset.rules[0].creation && + !module.ruleset[".github/ref-names-tag"].ruleset.rules[0].deletion ) - error_message = "tag-protection ruleset must make refs/tags/v* undeletable and immutable" + error_message = "ruleset definition must be applied to the paired repository unchanged" } assert { @@ -81,8 +87,8 @@ run "private_repo_defaults" { } assert { - condition = length(module.repository["secret"].rulesets) == 0 && module.repository["secret"].codeowners != null - error_message = "private repo defaults to no rulesets but still gets CODEOWNERS" + condition = length(module.ruleset) == 0 && module.repository["secret"].codeowners != null + error_message = "private repo silently skips all_repos rulesets but still gets CODEOWNERS" } } @@ -117,93 +123,27 @@ run "invalid_merge_type_rejected" { expect_failures = [var.repository] } -run "generated_and_custom_rulesets" { +run "exclusions_and_custom_rulesets" { command = plan variables { repository = { - checked = { name = "checked", private = false, branch_protection = false, tag_protection = false, required_checks = ["ci/woodpecker"], rulesets = ["signed"] } + checked = { name = "checked", private = false, exclude_rulesets = ["branch-protection", "tag-protection"], rulesets = ["signed", "checks"] } } } assert { - condition = toset(keys(module.repository["checked"].rulesets)) == toset(["required-checks", "ref-names-branch", "ref-names-tag", "signed"]) - error_message = "required_checks with protections off yields only required-checks, ref-names plus custom rulesets" + condition = keys(module.ruleset) == ["checked/checks", "checked/ref-names-tag", "checked/signed"] + error_message = "exclude_rulesets drops non-mandatory all_repos rulesets; rulesets adds custom ones" } assert { - condition = module.repository["checked"].rulesets["required-checks"].rules[0].required_status_checks[0].strict_required_status_checks_policy - error_message = "required-checks ruleset must be strict" + condition = ( + module.ruleset["checked/checks"].ruleset.rules[0].required_status_checks[0].strict_required_status_checks_policy && + length(module.ruleset["checked/checks"].ruleset.rules[0].pull_request) == 0 + ) + error_message = "required status checks come from a custom ruleset" } - - assert { - condition = length(module.repository["checked"].rulesets["required-checks"].rules[0].pull_request) == 0 - error_message = "required-checks ruleset must not carry pull_request rules" - } -} - -run "private_branch_protection_rejected" { - command = plan - - variables { - repository = { - secret = { name = "secret", branch_protection = true } - } - } - - expect_failures = [var.repository] -} - -run "public_tag_protection_only" { - command = plan - - variables { - repository = { - tags = { name = "tags", private = false, branch_protection = false } - } - } - - assert { - condition = keys(module.repository["tags"].rulesets) == ["ref-names-branch", "ref-names-tag", "tag-protection"] - error_message = "tag_protection defaults on for public repos independently of branch_protection" - } -} - -run "private_tag_protection_rejected" { - command = plan - - variables { - repository = { - secret = { name = "secret", tag_protection = true } - } - } - - expect_failures = [var.repository] -} - -run "reserved_tag_protection_name_rejected" { - command = plan - - variables { - ruleset = { - tag-protection = { name = "tag-protection", target = "tag", rules = { deletion = true } } - } - repository = {} - } - - expect_failures = [var.ruleset] -} - -run "private_required_checks_rejected" { - command = plan - - variables { - repository = { - secret = { name = "secret", required_checks = ["ci/woodpecker"] } - } - } - - expect_failures = [var.repository] } run "private_rulesets_rejected" { @@ -218,30 +158,40 @@ run "private_rulesets_rejected" { expect_failures = [var.repository] } -run "reserved_ruleset_name_rejected" { +run "mandatory_exclusion_rejected" { command = plan variables { - ruleset = { - branch-protection = { name = "branch-protection", rules = { deletion = true } } + repository = { + public = { name = "public", private = false, exclude_rulesets = ["ref-names-tag"] } } - repository = {} } - expect_failures = [var.ruleset] + expect_failures = [var.repository] } -run "reserved_ref_names_rejected" { +run "applied_and_excluded_rejected" { command = plan variables { - ruleset = { - ref-names-tag = { name = "ref-names-tag", target = "tag", rules = { deletion = true } } + repository = { + public = { name = "public", private = false, rulesets = ["signed"], exclude_rulesets = ["signed"] } } - repository = {} } - expect_failures = [var.ruleset] + expect_failures = [var.repository] +} + +run "unknown_excluded_ruleset_rejected" { + command = plan + + variables { + repository = { + public = { name = "public", private = false, exclude_rulesets = ["missing"] } + } + } + + expect_failures = [var.repository] } run "unknown_ruleset_rejected" { diff --git a/modules/github_org/variables.tf b/modules/github_org/variables.tf index 1fa3fbc..1c7709d 100644 --- a/modules/github_org/variables.tf +++ b/modules/github_org/variables.tf @@ -16,9 +16,11 @@ variable "team" { } variable "ruleset" { - description = "Map of reusable repository ruleset definitions, keyed by name" + description = "Map of repository ruleset definitions, keyed by name" type = map(object({ name = string + all_repos = optional(bool, false) + mandatory = optional(bool, false) target = optional(string, "branch") enforcement = optional(string, "active") conditions = optional(object({ @@ -28,6 +30,7 @@ variable "ruleset" { }) })) rules = object({ + creation = optional(bool, false) deletion = optional(bool, false) non_fast_forward = optional(bool, false) pull_request = optional(object({ @@ -45,11 +48,6 @@ variable "ruleset" { })) default = {} - validation { - condition = length(setintersection(keys(var.ruleset), ["branch-protection", "required-checks", "tag-protection", "ref-names-branch", "ref-names-tag"])) == 0 - error_message = "Ruleset names branch-protection, required-checks, tag-protection, ref-names-branch and ref-names-tag are reserved for generated rulesets." - } - validation { condition = alltrue([for rs in var.ruleset : rs.target == "branch" || (rs.rules.pull_request == null && rs.rules.required_status_checks == null)]) error_message = "pull_request and required_status_checks are branch-only rules, not allowed on tag rulesets: ${join(", ", [for k, rs in var.ruleset : k if rs.target != "branch" && (rs.rules.pull_request != null || rs.rules.required_status_checks != null)])}." @@ -72,10 +70,8 @@ variable "repository" { codeowners = optional(list(string), []) merge_type = optional(string, "squash") delete_branch_on_merge = optional(bool, true) - branch_protection = optional(bool) - tag_protection = optional(bool) - required_checks = optional(list(string), []) rulesets = optional(list(string), []) + exclude_rulesets = optional(list(string), []) })) default = {} @@ -84,29 +80,24 @@ variable "repository" { error_message = "merge_type must be squash, merge or rebase: ${join(", ", [for name, repo in var.repository : name if !contains(["squash", "merge", "rebase"], repo.merge_type)])}." } - validation { - condition = alltrue([for repo in var.repository : !(repo.private && coalesce(repo.branch_protection, false))]) - error_message = "branch_protection is not enforced on private repositories on the GitHub free plan: ${join(", ", [for name, repo in var.repository : name if repo.private && coalesce(repo.branch_protection, false)])}." - } - - validation { - condition = alltrue([for repo in var.repository : !(repo.private && coalesce(repo.tag_protection, false))]) - error_message = "tag_protection is not enforced on private repositories on the GitHub free plan: ${join(", ", [for name, repo in var.repository : name if repo.private && coalesce(repo.tag_protection, false)])}." - } - - validation { - condition = alltrue([for repo in var.repository : !(repo.private && length(repo.required_checks) > 0)]) - error_message = "required_checks are not enforced on private repositories on the GitHub free plan: ${join(", ", [for name, repo in var.repository : name if repo.private && length(repo.required_checks) > 0])}." - } - validation { condition = alltrue([for repo in var.repository : !(repo.private && length(repo.rulesets) > 0)]) error_message = "rulesets are not enforced on private repositories on the GitHub free plan: ${join(", ", [for name, repo in var.repository : name if repo.private && length(repo.rulesets) > 0])}." } validation { - condition = alltrue(flatten([for repo in var.repository : [for rs in repo.rulesets : contains(keys(var.ruleset), rs)]])) - error_message = "Unknown rulesets referenced: ${join(", ", distinct(flatten([for name, repo in var.repository : [for rs in repo.rulesets : "${name}/${rs}" if !contains(keys(var.ruleset), rs)]])))}." + condition = alltrue(flatten([for repo in var.repository : [for rs in concat(repo.rulesets, repo.exclude_rulesets) : contains(keys(var.ruleset), rs)]])) + error_message = "Unknown rulesets referenced: ${join(", ", distinct(flatten([for name, repo in var.repository : [for rs in concat(repo.rulesets, repo.exclude_rulesets) : "${name}/${rs}" if !contains(keys(var.ruleset), rs)]])))}." + } + + validation { + condition = alltrue(flatten([for repo in var.repository : [for rs in repo.exclude_rulesets : !try(var.ruleset[rs].mandatory, false)]])) + error_message = "Mandatory rulesets cannot be excluded: ${join(", ", flatten([for name, repo in var.repository : [for rs in repo.exclude_rulesets : "${name}/${rs}" if try(var.ruleset[rs].mandatory, false)]]))}." + } + + validation { + condition = alltrue([for repo in var.repository : length(setintersection(repo.rulesets, repo.exclude_rulesets)) == 0]) + error_message = "Rulesets both applied and excluded: ${join(", ", flatten([for name, repo in var.repository : [for rs in setintersection(repo.rulesets, repo.exclude_rulesets) : "${name}/${rs}"]]))}." } validation {