---
policy: /ce/ca/google/gke/cluster-network-policy
logic: /ce/ca/google/gke/cluster-network-policy/prod.logic.yaml
executionTime: 2025-10-25T12:02:45.481198592Z
generationMs: 51
executionMs: 754
rows:
  - id: '001'
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10G1__disappearanceTime__c)
      actual: isDisappeared(CA10G1__disappearanceTime__c)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10G1__networkPolicy__c').isEmpty() && extract('CA10G1__addonsNetworkPolicyConfig__c').isEmpty()
      actual: extract('CA10G1__networkPolicy__c').isEmpty() && extract('CA10G1__addonsNetworkPolicyConfig__c').isEmpty()
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10G1__networkPolicy__c') == 'Enabled' || extract('CA10G1__addonsNetworkPolicyConfig__c')
        == 'Enabled'
      actual: extract('CA10G1__networkPolicy__c') == 'Enabled' || extract('CA10G1__addonsNetworkPolicyConfig__c')
        == 'Enabled'
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10G1__networkPolicy__c') == 'Disabled' || extract('CA10G1__addonsNetworkPolicyConfig__c')
        == 'Disabled'
      actual: extract('CA10G1__networkPolicy__c') == 'Disabled' || extract('CA10G1__addonsNetworkPolicyConfig__c')
        == 'Disabled'
    runtimeError: {}
usedFiles:
  - path: /ce/ca/google/gke/cluster-network-policy/policy.yaml
    md5Hash: 219C60D9877A8F12E485DB73C2189BEC
    content: "---\nnames: \n  full: \"Google GKE Cluster Network policy is disabled.\"\
      \n  contextual: \"Cluster Network policy is disabled\"\ndescription: \"A network\
      \ policy is a specification of how groups of pods are allowed to \\\n  \\ communicate\
      \ with each other and other network endpoints. NetworkPolicy resources use \\\
      \n  \\ labels to select pods and define rules which specify what traffic is\
      \ allowed to the \\\n  \\ selected pods. The Kubernetes Network Policy API allows\
      \ the cluster administrator to \\\n  \\ specify what pods are allowed to communicate\
      \ with each other.\"\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n  - \"SECURITY\"\
      \n  - \"RELIABILITY\"\nframeworkMappings:\n  - \"/frameworks/nist-sp-800-53-r4/sc/07\"\
      \n  - \"/frameworks/pci-dss-v3.2.1/01/03\"\n  - \"/frameworks/iso-iec-27001-2013/13/01/01\"\
      \n"
  - path: /ce/ca/google/gke/cluster-network-policy/prod.logic.yaml
    md5Hash: 9AB52307E07FB6684A022E85DE2CD66C
    content: |
      ---

      inputType: "CA10G1__CaGoogleGkeCluster__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10G1__CaGoogleGkeCluster__c/object.extracts.yaml"
      conditions:
        - status: "UNDETERMINED"
          currentStateMessage: "The Cluster Network policy state is indeterminate."
          check:
            AND:
              args:
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10G1__networkPolicy__c"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10G1__addonsNetworkPolicyConfig__c"
        - status: "INCOMPLIANT"
          currentStateMessage: "The Cluster Network policy is disabled."
          remediationMessage: "Enable the Cluster Network policy"
          check:
            OR:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10G1__networkPolicy__c"
                    right:
                      TEXT: "Disabled"
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10G1__addonsNetworkPolicyConfig__c"
                    right:
                      TEXT: "Disabled"
        - status: "COMPLIANT"
          currentStateMessage: "The Cluster Network policy is enabled."
          check:
            OR:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10G1__networkPolicy__c"
                    right:
                      TEXT: "Enabled"
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10G1__addonsNetworkPolicyConfig__c"
                    right:
                      TEXT: "Enabled"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected values in the fields."
  - path: /ce/ca/google/gke/cluster-network-policy/test-data.json
    md5Hash: B5A12E61AE237B64CDB064C115F13330
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10G1__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-12T22:03:58Z" },
          "CA10G1__disappearanceTime__c": "2022-02-25T17:19:05Z",
          "CA10G1__networkPolicy__c": "Enabled",
          "CA10G1__addonsNetworkPolicyConfig__c": "",
          "Id": "001"
        },
        {
          "expectedResult": {
            "status": "UNDETERMINED",
            "conditionIndex": "199",
            "conditionText": "extract('CA10G1__networkPolicy__c').isEmpty() && extract('CA10G1__addonsNetworkPolicyConfig__c').isEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-12T22:03:58Z" },
          "CA10G1__disappearanceTime__c": null,
          "CA10G1__networkPolicy__c": "",
          "CA10G1__addonsNetworkPolicyConfig__c": "",
          "Id": "002"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10G1__networkPolicy__c') == 'Enabled' || extract('CA10G1__addonsNetworkPolicyConfig__c') == 'Enabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-12T22:03:58Z" },
          "CA10G1__disappearanceTime__c": null,
          "CA10G1__networkPolicy__c": "Enabled",
          "CA10G1__addonsNetworkPolicyConfig__c": "",
          "Id": "003"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10G1__networkPolicy__c') == 'Disabled' || extract('CA10G1__addonsNetworkPolicyConfig__c') == 'Disabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-12T22:03:58Z" },
          "CA10G1__disappearanceTime__c": null,
          "CA10G1__networkPolicy__c": "",
          "CA10G1__addonsNetworkPolicyConfig__c": "Disabled",
          "Id": "004"
        }
      ]
  - 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"
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" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10G1__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10G1__networkPolicy__c').isEmpty() && extract('CA10G1__addonsNetworkPolicyConfig__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10G1__networkPolicy__c') == 'Enabled' || extract('CA10G1__addonsNetworkPolicyConfig__c') == 'Enabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10G1__networkPolicy__c') == 'Disabled' || extract('CA10G1__addonsNetworkPolicyConfig__c') == 'Disabled'",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10G1__CaGoogleGkeCluster__c()
  RETURNS ARRAY<STRUCT<
      CA10G1__disappearanceTime__c TIMESTAMP,
      CA10G1__networkPolicy__c STRING,
      CA10G1__addonsNetworkPolicyConfig__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-12T22:03:58Z")
    },
    "CA10G1__disappearanceTime__c" : new Date("2022-02-25T17:19:05Z"),
    "CA10G1__networkPolicy__c" : "Enabled",
    "CA10G1__addonsNetworkPolicyConfig__c" : "",
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-12T22:03:58Z")
    },
    "CA10G1__networkPolicy__c" : "",
    "CA10G1__addonsNetworkPolicyConfig__c" : "",
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-12T22:03:58Z")
    },
    "CA10G1__networkPolicy__c" : "Enabled",
    "CA10G1__addonsNetworkPolicyConfig__c" : "",
    "Id" : "003"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-12T22:03:58Z")
    },
    "CA10G1__networkPolicy__c" : "",
    "CA10G1__addonsNetworkPolicyConfig__c" : "Disabled",
    "Id" : "004"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10G1__CaGoogleGkeCluster__c(
      obj STRUCT<
          CA10G1__disappearanceTime__c TIMESTAMP,
          CA10G1__networkPolicy__c STRING,
          CA10G1__addonsNetworkPolicyConfig__c STRING,
          Id 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]
      function extract3() { if (!this.out) { this.out = obj.CA10G1__networkPolicy__c; } return this.out; };
      function extract6() { if (!this.out) { this.out = obj.CA10G1__addonsNetworkPolicyConfig__c; } return this.out; };
      references1.push('Network Policy [obj.CA10G1__networkPolicy__c]: ' + obj.CA10G1__networkPolicy__c);
      references1.push('Add-ons: Network Policy Config [obj.CA10G1__addonsNetworkPolicyConfig__c]: ' + obj.CA10G1__addonsNetworkPolicyConfig__c);
      if (TextLib.isEmpty(extract3.call(extract3)) && TextLib.isEmpty(extract6.call(extract6))) {
          return {status: 'UNDETERMINED', conditionIndex: 199, conditionText: "extract('CA10G1__networkPolicy__c').isEmpty() && extract('CA10G1__addonsNetworkPolicyConfig__c').isEmpty()", currentStateMessage: "The Cluster Network policy state is indeterminate.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract9() { if (!this.out) { this.out = obj.CA10G1__networkPolicy__c; } return this.out; };
      function extract12() { if (!this.out) { this.out = obj.CA10G1__addonsNetworkPolicyConfig__c; } return this.out; };
      if (TextLib.equal(extract9.call(extract9), 'Disabled') || TextLib.equal(extract12.call(extract12), 'Disabled')) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10G1__networkPolicy__c') == 'Disabled' || extract('CA10G1__addonsNetworkPolicyConfig__c') == 'Disabled'", currentStateMessage: "The Cluster Network policy is disabled.", currentStateReferences: references1.join('\n'), remediation: "Enable the Cluster Network policy", runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract15() { if (!this.out) { this.out = obj.CA10G1__networkPolicy__c; } return this.out; };
      function extract18() { if (!this.out) { this.out = obj.CA10G1__addonsNetworkPolicyConfig__c; } return this.out; };
      if (TextLib.equal(extract15.call(extract15), 'Enabled') || TextLib.equal(extract18.call(extract18), 'Enabled')) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10G1__networkPolicy__c') == 'Enabled' || extract('CA10G1__addonsNetworkPolicyConfig__c') == 'Enabled'", currentStateMessage: "The Cluster Network policy is enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected values in the fields.", currentStateReferences: references1.join('\n'), remediation: null, 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__networkPolicy__c AS CA10G1__networkPolicy__c,
          sObject.CA10G1__addonsNetworkPolicyConfig__c AS CA10G1__addonsNetworkPolicyConfig__c,
          sObject.Id AS Id,
          process_CA10G1__CaGoogleGkeCluster__c(
              STRUCT(
                  sObject.CA10G1__disappearanceTime__c AS CA10G1__disappearanceTime__c,
                  sObject.CA10G1__networkPolicy__c AS CA10G1__networkPolicy__c,
                  sObject.CA10G1__addonsNetworkPolicyConfig__c AS CA10G1__addonsNetworkPolicyConfig__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10G1__CaGoogleGkeCluster__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
