Skip to content

fix(google): skip GCP-0061 for GKE clusters with IP-based endpoints disabled - #674

Draft
les2 wants to merge 1 commit into
aquasecurity:mainfrom
les2:fix/gke-dns-endpoint-authorized-networks
Draft

les2 wants to merge 1 commit into
aquasecurity:mainfrom
les2:fix/gke-dns-endpoint-authorized-networks

Conversation

@les2

@les2 les2 commented Nov 26, 2026 •

Copy link
Copy Markdown

Description

GCP-0061 (master authorized networks) fails for a GKE cluster whose control plane is reachable only through the DNS-based endpoint:

control_plane_endpoints_config {
  dns_endpoint_config { allow_external_traffic = true }
  ip_endpoints_config { enabled = false }
}

Authorized networks apply only to the IP-based endpoints, and the provider leaves master_authorized_networks_config out of the request when they are disabled (magic-modules#20134).

The check now reports a cluster only when value.is_true(cluster.controlplaneendpoints.ipendpoints.enabled). A disabled or unresolvable value (such as enabled = var.x) gives no finding. Trivy sets the value to true when the attribute or its blocks are not set, so those clusters are checked as before. minimum_trivy_version is 0.77.0, the first release that will include aquasecurity/trivy#11769. (TODO confirm the version number before merging if this is required in the commit. There's no guarantee which version will contain the required commit.)

  • Tests: true → finding, false → passes, unresolvable → passes. The existing deny test now sets the field to true.
  • Examples: a good example with enabled = false and a bad example with enabled = true.

This depends on aquasecurity/trivy#11769, which adds the field. Until it is on Trivy main, TestInputsConformToSchema fails because the latest schema does not have controlplaneendpoints.

Checked with a build of the Trivy branch and a bundle from this branch (--checks-bundle-repository on a local registry), on the two folders from https://github.com/les2/trivy-gcp-0061-repro plus four more configurations:

Configuration Trivy 0.76.2, published bundle Trivy branch, this bundle
ip_endpoints_config { enabled = false } GCP-0061 passes
ip_endpoints_config { enabled = true }, without authorized networks GCP-0061 GCP-0061
ip_endpoints_config {}, without authorized networks GCP-0061 GCP-0061
control_plane_endpoints_config not set, without authorized networks GCP-0061 GCP-0061
enabled = var.x (no value), without authorized networks GCP-0061 passes
enabled = false plus an empty master_authorized_networks_config {} passes passes

With the Trivy branch schema as schemas/latest: opa fmt, opa check --strict, make test-rego and go test ./... pass. TRIVY_BINARY=<branch build> go test -tags=integration -run TestScanCheckExamples ./integration/ passes, including the GCP-0061 examples.

Related PRs

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • Confirm minimum_trivy_version is 0.77.0 or update docs, commit message, and PR message with the correct version after upstream merges and is released.

@CLAassistant

CLAassistant commented Nov 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@les2
les2 force-pushed the fix/gke-dns-endpoint-authorized-networks branch 3 times, most recently from a5c6c24 to 12fe02f Compare November 26, 2026 22:42
@les2
les2 marked this pull request as ready for review November 26, 2026 22:43

@nikpivkin nikpivkin 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.

Convert this PR to a draft until aquasecurity/trivy#11769 is merged. The schema test reads the schema from Trivy main, and the field path may still change there.

deny contains res if {
some cluster in input.google.gke.clusters
isManaged(cluster)
not ip_endpoints_disabled(cluster)

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.

Replace not ip_endpoints_disabled(cluster) with value.is_true. With not, an unresolvable value such as enabled = var.x gives a finding.

	value.is_true(cluster.controlplaneendpoints.ipendpointsenabled)

Add "controlplaneendpoints": {"ipendpointsenabled": {"value": true}} to the deny test inputs and make test_deny_ip_endpoints_unresolvable an allow test.

@les2
les2 marked this pull request as draft November 28, 2026 02:13
@les2
les2 force-pushed the fix/gke-dns-endpoint-authorized-networks branch 3 times, most recently from e1d48d0 to c845568 Compare November 28, 2026 02:24
…isabled

Master authorized networks apply only to the IP-based endpoints of the
GKE control plane, so the check now requires
controlplaneendpoints.ipendpoints.enabled to be true. A disabled or
unresolvable value gives no finding. Requires Trivy 0.77.0.

Refs: aquasecurity/trivy#11753
@les2
les2 force-pushed the fix/gke-dns-endpoint-authorized-networks branch from c845568 to 6e03ad8 Compare November 28, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants