Skip to content

feat(query): implements "Beta - Cluster Without Network Policy Support"#7907

Merged
cx-rui-araujo merged 12 commits into
masterfrom
AST-121531_53_ensure_that_the_cni_in_use_supports_network_policies
Jan 26, 2026
Merged

feat(query): implements "Beta - Cluster Without Network Policy Support"#7907
cx-rui-araujo merged 12 commits into
masterfrom
AST-121531_53_ensure_that_the_cni_in_use_supports_network_policies

Conversation

@cx-andre-pereira

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

Copy link
Copy Markdown
Contributor

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

github-actions Bot commented Dec 10, 2025

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.18

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
@cx-artur-ribeiro cx-artur-ribeiro self-assigned this Jan 14, 2026
@github-actions github-actions Bot added community Community contribution feature request Community: new feature request labels Jan 14, 2026

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cx-rui-araujo cx-rui-araujo merged commit b6f1331 into master Jan 26, 2026
29 checks passed
@cx-rui-araujo cx-rui-araujo deleted the AST-121531_53_ensure_that_the_cni_in_use_supports_network_policies branch January 26, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Community contribution feature request Community: new feature request 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.

5 participants