---
policy: /ce/ca/google/gke/cluster-private-access
logic: /ce/ca/google/gke/cluster-private-access/prod.logic.yaml
executionTime: 2025-10-25T12:02:45.332020056Z
generationMs: 66
executionMs: 563
rows:
  - id: '001'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10G1__subnetwork__r.CA10__privateGoogleAccess__c') == 'Enabled'
      actual: extract('CA10G1__subnetwork__r.CA10__privateGoogleAccess__c') == 'Enabled'
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/google/gke/cluster-private-access/policy.yaml
    md5Hash: 98B398FC23087362CB90D68438BC640B
    content: "---\nnames: \n  full: \"Google GKE Cluster Private Google Access is\
      \ not enabled.\"\n  contextual: \"Cluster Private Google Access is not enabled.\"\
      \ndescription: \"Ensure that GKE clusters are configured to use Private Google\
      \ Access.\\\n  \\ Private Google Access allows cluster hosts in a subnet to\
      \ reach Google APIs and\\\n  \\ services using an internal IP address rather\
      \ than an external IP address.\"\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n\
      \  - \"SECURITY\"\nframeworkMappings:\n  - \"/frameworks/pci-dss-v3.2.1/01/03\"\
      \n  - \"/frameworks/cloudaware/resource-security/secure-access\"\n"
  - path: /ce/ca/google/gke/cluster-private-access/prod.logic.yaml
    md5Hash: AF610E3ECCC7FCD9D7F352F35F221844
    content: |-
      ---

      inputType: "CA10G1__CaGoogleGkeCluster__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10G1__CaGoogleGkeCluster__c/object.extracts.yaml"
        - file: "/types/CA10__CaGoogleGceSubnetwork__c/object.extracts.yaml"
      conditions:
        - status: "UNDETERMINED"
          currentStateMessage: "The subnetwork for this GKE cluster could not be found in the CMDB."
          check:
            IS_EMPTY_LOOKUP: "CA10G1__subnetwork__r"
        - status: "COMPLIANT"
          currentStateMessage: "Private Google Access is enabled for the cluster's subnetwork."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10G1__subnetwork__r.CA10__privateGoogleAccess__c"
              right:
                TEXT: "Enabled"
      otherwise:
        status: "INCOMPLIANT"
        currentStateMessage: "Private Google Access is not enabled for the cluster's subnetwork."
        remediationMessage: "Enable Private Google Access on the subnetwork used by the GKE cluster."
  - path: /ce/ca/google/gke/cluster-private-access/test-data.json
    md5Hash: 72DB81D77B658842CF05B6EEB2C2D438
    content: |
      [
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10G1__subnetwork__r.CA10__privateGoogleAccess__c') == 'Enabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-09-08T10:28:58Z" },
          "Id": "001",
          "CA10G1__disappearanceTime__c": null,
          "CA10G1__subnetwork__c": "01-1",
          "CA10G1__subnetworkUniqueId__c": "projects/subnetworks/default",
          "CA10G1__subnetwork__r": {
            "Id": "01-1",
            "CA10__disappearanceTime__c": null,
            "CA10__privateGoogleAccess__c": "Enabled"
          }
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "300",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-09-08T10:28:58Z" },
          "Id": "002",
          "CA10G1__disappearanceTime__c": null,
          "CA10G1__subnetwork__c": "02-1",
          "CA10G1__subnetworkUniqueId__c": "projects/subnetworks/ids-cluster-subnet",
          "CA10G1__subnetwork__r": {
            "Id": "02-1",
            "CA10__disappearanceTime__c": null,
            "CA10__privateGoogleAccess__c": "Disabled"
          }
        }
      ]
  - path: /types/CA10G1__CaGoogleGkeCluster__c/object.extracts.yaml
    md5Hash: 27F9CD44BA08A855B08C82AB034505CA
    content: "---\nextracts:\n# Nullable\n  - name: \"CA10G1__kubernetesAlpha__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10G1__kubernetesAlpha__c\"\n\
      \  - name: \"CA10G1__loggingService__c\"\n    value: \n      FIELD:\n      \
      \  path: \"CA10G1__loggingService__c\"\n  - name: \"CA10G1__monitoringService__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10G1__monitoringService__c\"\n\
      \  - name: \"CA10G1__useIpAliases__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10G1__useIpAliases__c\"\n  - name: \"CA10G1__legacyAbac__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10G1__legacyAbac__c\"\n  - name: \"CA10G1__masterAuthorizedNetworks__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10G1__masterAuthorizedNetworks__c\"\
      \n  - name: \"CA10G1__privateNodes__c\"\n    value: \n      FIELD:\n       \
      \ path: \"CA10G1__privateNodes__c\"\n  - name: \"CA10G1__addonsKubernetesDashboard__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10G1__addonsKubernetesDashboard__c\"\
      \n# Text. Nullable. Values: ENABLED, DISABLED\n  - name: \"CA10G1__networkPolicy__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10G1__networkPolicy__c\"\n# Text.\
      \ Nullable. Values: ENABLED, DISABLED\n  - name: \"CA10G1__addonsNetworkPolicyConfig__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10G1__addonsNetworkPolicyConfig__c\"\
      \n"
  - path: /types/CA10__CaGoogleGceSubnetwork__c/object.extracts.yaml
    md5Hash: 65153110FC179823DA5BE13AA3694874
    content: "---\nextracts:\n  - name: \"CA10__logConfigState__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__logConfigState__c\"\n  - name: \"CA10__logConfigMetadataFields__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__logConfigMetadataFields__c\"\
      \n  - name: \"CA10__logConfigMetadata__c\"\n    value: \n      FIELD:\n    \
      \    path: \"CA10__logConfigMetadata__c\"\n  - name: \"CA10__logConfigFlowSampling__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__logConfigFlowSampling__c\"\
      \n  - name: \"CA10__logConfigFilterExpr__c\"\n    value: \n      FIELD:\n  \
      \      path: \"CA10__logConfigFilterExpr__c\"\n  - name: \"CA10__logConfigAggregationInterval__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__logConfigAggregationInterval__c\"\
      \n  - name: \"CA10__flowLogs__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__flowLogs__c\"\n  - name: \"CA10__purpose__c\"\n    value: \n     \
      \ FIELD:\n        path: \"CA10__purpose__c\"\n  - name: \"CA10__privateGoogleAccess__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__privateGoogleAccess__c\"\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10G1__subnetwork__r.CA10__privateGoogleAccess__c') == 'Enabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10G1__CaGoogleGkeCluster__c()
  RETURNS ARRAY<STRUCT<
      CA10G1__disappearanceTime__c TIMESTAMP,
      CA10G1__subnetwork__c STRING,
      CA10G1__subnetworkUniqueId__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-09-08T10:28:58Z")
    },
    "CA10G1__subnetwork__c" : "01-1",
    "CA10G1__subnetworkUniqueId__c" : "projects/subnetworks/default",
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-08T10:28:58Z")
    },
    "CA10G1__subnetwork__c" : "02-1",
    "CA10G1__subnetworkUniqueId__c" : "projects/subnetworks/ids-cluster-subnet",
    "Id" : "002"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleGceSubnetwork__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__privateGoogleAccess__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-09-08T10:28:58Z")
    },
    "Id" : "01-1",
    "CA10__privateGoogleAccess__c" : "Enabled"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-08T10:28:58Z")
    },
    "Id" : "02-1",
    "CA10__privateGoogleAccess__c" : "Disabled"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10G1__CaGoogleGkeCluster__c(
      obj STRUCT<
          CA10G1__disappearanceTime__c TIMESTAMP,
          CA10G1__subnetwork__c STRING,
          CA10G1__subnetworkUniqueId__c STRING,
          Id STRING,
          CA10G1__subnetwork__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__privateGoogleAccess__c STRING
          >
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
  var TextLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Google [CA10G1__disappearanceTime__c]: ' + obj.CA10G1__disappearanceTime__c);
      if (obj.CA10G1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10G1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      if (TextLib.isEmpty(obj.CA10G1__subnetworkUniqueId__c) || TextLib.isEmpty(obj.CA10G1__subnetwork__c) || obj.CA10G1__subnetwork__r.CA10__disappearanceTime__c != null) {
          return {status: 'UNDETERMINED', conditionIndex: 199, conditionText: "isEmptyLookup('CA10G1__subnetwork__r')", currentStateMessage: "The subnetwork for this GKE cluster could not be found in the CMDB.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extractChecked2() {
          if (TextLib.isEmpty(obj.CA10G1__subnetworkUniqueId__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extractCheck(obj.CA10G1__subnetworkUniqueId__c)", currentStateMessage: "Related object via CA10G1__subnetworkUniqueId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10G1__subnetwork__c)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extractCheck(obj.CA10G1__subnetwork__c)", currentStateMessage: "Related object via CA10G1__subnetwork__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10G1__subnetwork__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extractCheck(obj.CA10G1__subnetwork__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10G1__subnetwork__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract3.call(extract3);
      }
      function extract3() { if (!this.out) { this.out = obj.CA10G1__subnetwork__r.CA10__privateGoogleAccess__c; } return this.out; };
      references1.push('Private Google Access [obj.CA10G1__subnetwork__r.CA10__privateGoogleAccess__c]: ' + obj.CA10G1__subnetwork__r.CA10__privateGoogleAccess__c);
      try {
          if (TextLib.equal(extractChecked2(), 'Enabled')) {
              return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10G1__subnetwork__r.CA10__privateGoogleAccess__c') == 'Enabled'", currentStateMessage: "Private Google Access is enabled for the cluster's subnetwork.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'INCOMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Private Google Access is not enabled for the cluster's subnetwork.", currentStateReferences: references1.join('\n'), remediation: "Enable Private Google Access on the subnetwork used by the GKE cluster.", runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.CA10G1__disappearanceTime__c AS CA10G1__disappearanceTime__c,
          sObject.CA10G1__subnetwork__c AS CA10G1__subnetwork__c,
          sObject.CA10G1__subnetworkUniqueId__c AS CA10G1__subnetworkUniqueId__c,
          sObject.Id AS Id,
          STRUCT (
              `CA10G1__subnetwork__r`.Id AS Id,
              `CA10G1__subnetwork__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
              `CA10G1__subnetwork__r`.CA10__privateGoogleAccess__c AS CA10__privateGoogleAccess__c
          ) AS CA10G1__subnetwork__r,
          process_CA10G1__CaGoogleGkeCluster__c(
              STRUCT(
                  sObject.CA10G1__disappearanceTime__c AS CA10G1__disappearanceTime__c,
                  sObject.CA10G1__subnetwork__c AS CA10G1__subnetwork__c,
                  sObject.CA10G1__subnetworkUniqueId__c AS CA10G1__subnetworkUniqueId__c,
                  sObject.Id AS Id,
                  STRUCT (
                      `CA10G1__subnetwork__r`.Id AS Id,
                      `CA10G1__subnetwork__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      `CA10G1__subnetwork__r`.CA10__privateGoogleAccess__c AS CA10__privateGoogleAccess__c
                  ) AS CA10G1__subnetwork__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10G1__CaGoogleGkeCluster__c()) AS sObject
      LEFT JOIN UNNEST(mock_CA10__CaGoogleGceSubnetwork__c()) AS `CA10G1__subnetwork__r`
          ON sObject.CA10G1__subnetwork__c = `CA10G1__subnetwork__r`.Id
  ) sObject ON sObject.Id = expectedResult.Id;
