Harden IUCLabs org settings and actions #119

Closed
unkin-agent wants to merge 8 commits from benvin/github-iuclabs-hardening into main
Member

The IUCLabs org (free plan) leaves members able to create repos and Pages, and GITHUB_TOKEN defaults are unmanaged. Every org field is pinned so the full policy is declared in code.

  • add optional config.yaml for billing email, profile, repo creation, default repo permission (read or none) and public runners
  • pin all other org settings: no Pages, no private forks or internal repos, org projects only, legacy security toggles off
  • set GITHUB_TOKEN to read-only and non-approving
  • manage org-level resources in github_org itself, beside the team/repository submodules
  • import org settings and the Default runner group only when config.yaml exists
  • protect all org-level resources with prevent_destroy; unmanage via removed blocks
The IUCLabs org (free plan) leaves members able to create repos and Pages, and GITHUB_TOKEN defaults are unmanaged. Every org field is pinned so the full policy is declared in code. - add optional `config.yaml` for billing email, profile, repo creation, default repo permission (read or none) and public runners - pin all other org settings: no Pages, no private forks or internal repos, org projects only, legacy security toggles off - set GITHUB_TOKEN to read-only and non-approving - manage org-level resources in `github_org` itself, beside the team/repository submodules - import org settings and the Default runner group only when `config.yaml` exists - protect all org-level resources with prevent_destroy; unmanage via `removed` blocks
Author
Member
  • modules/github_org/main.tf:222 — github_organization_settings leaves members_can_create_pages / members_can_create_public_pages unset; provider default true flips both false→true (CI plan shows it), widening org state beyond the stated hardening → set both false explicitly (also resolves the contradictory "private_pages = false" comment).
  • modules/github_org/main.tf:222 — other unset fields are also sent on update with provider defaults (has_organization_projects, has_repository_projects, web_commit_signoff_required, members_can_fork_private_repositories, advanced_security/dependabot/secret_scanning_*_for_new_repositories, and company/blog/email/twitter_username/location/description/name if non-empty today) → check the plan for every diff on the imported resource and pin each to its current or intended free-plan-valid value; any plan drift beyond billing_email/default_repository_permission/repo-creation must be explained or pinned.
  • modules/github_org/main.tf:212 — github_actions_organization_workflow_permissions has no prevent_destroy and is not imported/gated by settings, unlike the other org resources the PR body implies are protected → add prevent_destroy (and an import if the org already has non-default values).
  • environments/github/iuclabs/terragrunt.hcl:31 — imports.tf targets ...[0] of count resources; if config.yaml is removed (settings=null, count=0) the import blocks reference non-existent instances and plan errors → generate imports only when settings exist, or drop the imports after first apply.
  • nit: PR body lists "prevent_destroy on org resources" nowhere and the ≤10-line body is fine, but state public_runners: true opt-in default (false) in config as the why for public repos.
- modules/github_org/main.tf:222 — github_organization_settings leaves members_can_create_pages / members_can_create_public_pages unset; provider default true flips both false→true (CI plan shows it), widening org state beyond the stated hardening → set both false explicitly (also resolves the contradictory "private_pages = false" comment). - modules/github_org/main.tf:222 — other unset fields are also sent on update with provider defaults (has_organization_projects, has_repository_projects, web_commit_signoff_required, members_can_fork_private_repositories, advanced_security/dependabot/secret_scanning_*_for_new_repositories, and company/blog/email/twitter_username/location/description/name if non-empty today) → check the plan for every diff on the imported resource and pin each to its current or intended free-plan-valid value; any plan drift beyond billing_email/default_repository_permission/repo-creation must be explained or pinned. - modules/github_org/main.tf:212 — github_actions_organization_workflow_permissions has no prevent_destroy and is not imported/gated by settings, unlike the other org resources the PR body implies are protected → add prevent_destroy (and an import if the org already has non-default values). - environments/github/iuclabs/terragrunt.hcl:31 — imports.tf targets `...[0]` of count resources; if config.yaml is removed (settings=null, count=0) the import blocks reference non-existent instances and plan errors → generate imports only when settings exist, or drop the imports after first apply. - nit: PR body lists "prevent_destroy on org resources" nowhere and the ≤10-line body is fine, but state `public_runners: true` opt-in default (false) in config as the why for public repos.
Author
Member
  • modules/github_org/main.tf:241 — members_can_create_internal_repositories is the one settable field not pinned, so the provider sends its own default for it → add members_can_create_internal_repositories = false, and add it to the pinned-false list in the org_settings_pinned test.
  • modules/github_org/variables.tf:124 — default_repository_permission accepts any string, so write/admin in config.yaml silently loosens the org → add a validation block limiting it to read/none (or drop the knob and pin "read"), plus a expect_failures test.
- modules/github_org/main.tf:241 — `members_can_create_internal_repositories` is the one settable field not pinned, so the provider sends its own default for it → add `members_can_create_internal_repositories = false`, and add it to the pinned-false list in the `org_settings_pinned` test. - modules/github_org/variables.tf:124 — `default_repository_permission` accepts any string, so `write`/`admin` in config.yaml silently loosens the org → add a `validation` block limiting it to `read`/`none` (or drop the knob and pin `"read"`), plus a `expect_failures` test.
Author
Member
  • nit: modules/github_org/main.tf:26 — prevent_destroy on the count resources means deleting config.yaml makes plan fail ("cannot be destroyed"), contradicting README "Without it, none of this is managed" → state in README that removal needs a removed { lifecycle { destroy = false } } block, or drop the claim.
  • nit: modules/github_org/tests/github_org.tftest.hcl:398 — validation is only tested for rejection ("write") → add a run asserting default_repository_permission = "none" is accepted and planned as none.
- nit: modules/github_org/main.tf:26 — `prevent_destroy` on the `count` resources means deleting `config.yaml` makes plan fail ("cannot be destroyed"), contradicting README "Without it, none of this is managed" → state in README that removal needs a `removed { lifecycle { destroy = false } }` block, or drop the claim. - nit: modules/github_org/tests/github_org.tftest.hcl:398 — validation is only tested for rejection ("write") → add a run asserting `default_repository_permission = "none"` is accepted and planned as `none`.
Author
Member

No findings.

No findings.
benvin changed target branch from benvin/github-iuclabs to main 2026-11-10 22:49:23 +11:00
benvin added 7 commits 2026-11-10 22:49:23 +11:00
harden IUCLabs org settings, actions token and runner access
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
b002fa2917
keep private pages off on the free plan
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
be7aa54856
pin every github org setting and gate org resources on config.yaml
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
02d39c43e7
# Conflicts:
#	README.md
#	modules/github_org/main.tf
pin internal repo creation off and restrict default repo permission to read or none
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
467c69dd02
document removed blocks for unmanaging org settings and test permission none
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
b6260a91d9
unkin-agent added 1 commit 2026-11-10 22:50:42 +11:00
Merge remote-tracking branch 'origin/main' into benvin/github-iuclabs-hardening
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
d344404fba
unkin-agent closed this pull request 2026-11-10 23:10:08 +11:00
This repo is archived. You cannot comment on pull requests.