id: gcloud-gke-release-channel-disabled

info:
  name: GKE Clusters Without Release Channel Configuration
  author: princechaddha
  severity: medium
  description: |
    Ensure that your Google Kubernetes Engine (GKE) clusters are subscribed to either Regular or Stable release channels to automate version management and upgrades. Release channels automatically select cluster versions to provide a balance between new features and stability, while ensuring critical security patches are delivered.
  impact: |
    Without a proper release channel configured, clusters may miss important security patches and version upgrades, potentially exposing them to known vulnerabilities and missing out on critical feature updates.
  remediation: |
    Configure a release channel for your GKE clusters using:
    gcloud container clusters update CLUSTER_NAME --region=REGION --release-channel regular
  reference:
    - https://cloud.google.com/kubernetes-engine/docs/concepts/release-channels
    - https://www.trendmicro.com/cloudoneconformity/knowledge-base/gcp/GKE/automate-version-upgrades.html
  tags: cloud,devops,gcp,gcloud,gke,kubernetes,security,updates,maintenance,gcp-cloud-config

flow: |
  code(1)
  for(let projectId of iterate(template.projectIds)){
    set("projectId", projectId)
    code(2)
    for(let cluster of iterate(template.clusters)){
      cluster = JSON.parse(cluster)
      set("clusterName", cluster.name)
      set("location", cluster.location)
      code(3)
    }
  }

self-contained: true

code:
  - engine:
      - sh
      - bash
    source: |
      gcloud projects list --format="json(projectId)"

    extractors:
      - type: json
        name: projectIds
        internal: true
        json:
          - '.[].projectId'

  - engine:
      - sh
      - bash
    source: |
      gcloud container clusters list --project $projectId --format="json(name,location)"

    extractors:
      - type: json
        name: clusters
        internal: true
        json:
          - '.[]'

  - engine:
      - sh
      - bash
    source: |
      gcloud container clusters describe $clusterName --location $location --project $projectId --format="value(releaseChannel.channel)"

    matchers:
      - type: word
        words:
          - "RAPID"
          - "null"
        condition: or

    extractors:
      - type: dsl
        dsl:
          - '"GKE cluster " + clusterName + " in " + location + " of project " + projectId + " is not configured with Regular or Stable release channel"'
# digest: 4a0a004730450221008c9f7b2b208b173d69c6d13aae09ac4ccb2f97e2ed3071db66d415f1d4be25f20220212a589e436f40508bdd69433a658ac11c9cce334a498a63f953cf5d5bd72370:922c64590222798bb761d5b6d8e72950