harden IUCLabs org settings, actions token and runner access
This commit is contained in:
@@ -293,3 +293,63 @@ run "empty_status_check_contexts_rejected" {
|
||||
|
||||
expect_failures = [var.ruleset]
|
||||
}
|
||||
|
||||
run "org_settings_unmanaged_without_config" {
|
||||
command = plan
|
||||
|
||||
assert {
|
||||
condition = length(github_organization_settings.this) == 0 && length(github_actions_runner_group.default) == 0
|
||||
error_message = "org settings and the default runner group must stay unmanaged without config.yaml"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_actions_organization_workflow_permissions.this.default_workflow_permissions == "read" &&
|
||||
!github_actions_organization_workflow_permissions.this.can_approve_pull_request_reviews
|
||||
)
|
||||
error_message = "GITHUB_TOKEN must default to read-only and never approve PRs"
|
||||
}
|
||||
}
|
||||
|
||||
run "org_settings_from_config" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
settings = { billing_email = "ops@example.com", public_runners = true }
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
!github_organization_settings.this[0].members_can_create_repositories &&
|
||||
!github_organization_settings.this[0].members_can_create_public_repositories &&
|
||||
!github_organization_settings.this[0].members_can_create_private_repositories &&
|
||||
github_organization_settings.this[0].default_repository_permission == "read"
|
||||
)
|
||||
error_message = "repo creation must be blocked for every visibility, default permission read"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_actions_runner_group.default[0].name == "Default" &&
|
||||
github_actions_runner_group.default[0].allows_public_repositories
|
||||
)
|
||||
error_message = "public_runners must open the Default runner group to public repositories"
|
||||
}
|
||||
}
|
||||
|
||||
run "org_settings_allow_repo_creation" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
settings = { billing_email = "ops@example.com", members_can_create_repositories = true }
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
github_organization_settings.this[0].members_can_create_public_repositories &&
|
||||
github_organization_settings.this[0].members_can_create_private_repositories &&
|
||||
!github_actions_runner_group.default[0].allows_public_repositories
|
||||
)
|
||||
error_message = "per-visibility creation flags must follow members_can_create_repositories; public_runners defaults off"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user