# cicd-signals / github / t1 "Standard" # # The quick start's defaults and alert feed, plus: alerts switched on for # named existing repositories, a security team that sees every alert, a # limit on which actions workflows may use, and optionally a requirement that # actions be pinned by commit. resource "github_organization_settings" "this" { billing_email = var.billing_email dependency_graph_enabled_for_new_repositories = true dependabot_alerts_enabled_for_new_repositories = true dependabot_security_updates_enabled_for_new_repositories = true advanced_security_enabled_for_new_repositories = true secret_scanning_enabled_for_new_repositories = true secret_scanning_push_protection_enabled_for_new_repositories = true } resource "github_repository_vulnerability_alerts" "existing" { for_each = toset(var.existing_repositories) repository = each.value enabled = true } resource "github_repository_dependabot_security_updates" "existing" { for_each = toset(var.existing_repositories) repository = each.value enabled = true depends_on = [github_repository_vulnerability_alerts.existing] } # The security manager role lets a team see and manage every security alert # in every repository without admin rights on the repositories. data "github_organization_roles" "all" {} locals { security_manager_role = one([ for r in data.github_organization_roles.all.roles : r.role_id if replace(lower(r.name), " ", "_") == "security_manager" ]) } resource "github_organization_role_team" "security_manager" { count = var.security_team == "" ? 0 : 1 role_id = local.security_manager_role team_slug = var.security_team lifecycle { precondition { condition = local.security_manager_role != null error_message = "This organisation has no security manager role. Leave security_team empty, or check the organisation's plan." } } } resource "github_actions_organization_workflow_permissions" "this" { organization_slug = var.organization default_workflow_permissions = "read" can_approve_pull_request_reviews = false } # An action runs with the workflow's token and secrets, so which actions may # run is a supply chain decision. A tag can be moved to different code after # you reviewed it; a commit SHA cannot. resource "github_actions_organization_permissions" "this" { enabled_repositories = "all" allowed_actions = "selected" sha_pinning_required = var.require_sha_pinning allowed_actions_config { github_owned_allowed = true verified_allowed = true patterns_allowed = var.allowed_action_patterns } } resource "github_organization_webhook" "security" { active = true events = [ "secret_scanning_alert", "secret_scanning_alert_location", "dependabot_alert", "code_scanning_alert", "security_and_analysis", "repository", ] configuration { url = var.collector_url content_type = "json" secret = var.webhook_secret insecure_ssl = false } }