Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

@cx-andre-pereira cx-andre-pereira commented Dec 10, 2025

Reason for Proposed Changes

  • Currently there is no query to ensure that a "google_container_cluster" resource allows support for a network policy.

  • Quoting CIS_Google_Kubernetes_Engine_(GKE)_Benchmark_v1.9.0 page 64: "There are a variety of CNI plugins available for Kubernetes. If the CNI in use does not support Network Policies it may not be possible to effectively restrict traffic in the cluster.

Proposed Changes

  • Implemented the missing query.

  • The remediation suggested in the Benchmark helps bridge the gap between CNI plugins and their compatibility with network policies and what we must actually check in the terraform IaC samples : "To use a CNI plugin with Network Policy, enable Network Policy in GKE, and the CNI plugin will be updated."

  • To ensure a given "google_container_cluster" resource supports use of a "network policy" it must be setup with the "network_policy.enabled" field set to true. The documentation seems to imply changing the "network_policy.provider" field can be done without the need to recreate the cluster whilst the "enabled" field would require said re creation.

  • With this the query will flag the target "google_container_cluster" if it:

    • Does not set a "network_policy" block
    • Sets a "network_policy" block where "enabled" is set to a value that is not true (since "enabled" is a required field the scenario of it missing was not included in the tests)

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions bot added feature New feature query New query feature labels Dec 10, 2025
@github-actions
Copy link
Contributor

kics-logo

KICS version: v2.1.17

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@github-actions github-actions bot added terraform Terraform query kubernetes Kubernetes query labels Dec 10, 2025
@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review December 10, 2025 17:36
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner December 10, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature kubernetes Kubernetes query query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant