---
policy: /ce/ca/google/sql/sql-instance-public-ip-whitelist
logic: /ce/ca/google/sql/sql-instance-public-ip-whitelist/prod.logic.yaml
executionTime: 2025-05-10T12:05:51.729821579Z
rows:
  - id: 111
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: 112
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__ipv4Enabled__c') != true
      actual: extract('CA10__ipv4Enabled__c') != true
    runtimeError: {}
  - id: 113
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: 114
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('caJsonFrom_authorizedNetworksJson_value__c').contains('0.0.0.0/0')
      actual: extract('caJsonFrom_authorizedNetworksJson_value__c').contains('0.0.0.0/0')
    runtimeError: {}
usedFiles:
  - path: /ce/ca/google/sql/sql-instance-public-ip-whitelist/policy.yaml
    md5Hash: 1A370A86A2765933D712FDDFB7C3307A
    content: "---\nnames: \n  full: \"Google Cloud SQL Instance External Authorized\
      \ Networks do not whitelist all public IP addresses\"\n  contextual: \"SQL Instance\
      \ External Authorized Networks do not whitelist all public IP addresses\"\n\
      description: \"Database Server should accept connections only from trusted Network(s)/IP(s)\
      \ and restrict access from public IP addresses.\"\ntype: COMPLIANCE_POLICY\n\
      categories:\n  - \"SECURITY\"\nframeworkMappings:\n  - /frameworks/cis-gcp-v3.0.0/06/05\n\
      \  - /frameworks/cloudaware/resource-security/public-and-anonymous-access\n\
      similarPolicies:\n  cloudConformity:\n    - url: \"https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/gcp/CloudSQL/publicly-accessible-cloud-sql-instances.html\"\
      \n      name: \"Check for Publicly Accessible Cloud SQL Database Instances\"\
      \n"
  - path: /ce/ca/google/sql/sql-instance-public-ip-whitelist/prod.logic.yaml
    md5Hash: 7A41CDC73AA00343071D1F3E3921AB93
    content: |-
      ---

      inputType: "CA10__CaGoogleSqlInstance__c"
      testData:
        - file: test-data.json
      importExtracts:
        - file: /types/CA10__CaGoogleSqlInstance__c/object.extracts.yaml
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "Authorized networks apply only to instances with public IPs"
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10__ipv4Enabled__c"
              right:
                BOOLEAN: true
        - status: "INCOMPLIANT"
          currentStateMessage: "Cloud SQL Database Instance do not implicitly Whitelist all public IP addresses."
          remediationMessage: "Update the authorized network list."
          check:
                CONTAINS:
                  arg:
                    EXTRACT: "caJsonFrom_authorizedNetworksJson_value__c"
                  substring:
                    TEXT: "0.0.0.0/0"
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "Cloud SQL database instances are not open to the world."
  - path: /types/CA10__CaGoogleSqlInstance__c/object.extracts.yaml
    md5Hash: CF5DA82560FA69E6A48E44B5BF123F0B
    content: "---\nextracts:\n  - name: \"CA10__databaseVersion__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__databaseVersion__c\"\n        undeterminedIf:\n\
      \          isEmpty:  \"Database version should not be empty\"\n  - name: \"\
      CA10__ipv4Enabled__c\"\n    value: \n      FIELD:\n        path: \"CA10__ipv4Enabled__c\"\
      \n        undeterminedIf:\n          isEmpty:  \"Ipv4Enabled should not be empty\"\
      \n  - name: \"caExtract__databaseFlagsJson__c\"\n    value: \n      JSON_FROM:\n\
      \        arg:\n          FIELD:\n            path: CA10__databaseFlagsJson__c\n\
      \            returnType: BYTES\n        undeterminedIf:\n          isInvalid:\
      \ \"Database Flags JSON is invalid.\"\n          isEmpty: \"Database Flags JSON\
      \ is empty.\"\n\n  - name: \"caExtract_databaseFlags_skip_show_database_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'skip_show_database'].value[] |\
      \ [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"caExtract_databaseFlags_local_infile_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'local_infile'].value[] | [0])\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_log_error_verbosity_flagValue__c\"\n\
      \    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression:  \"to_string([?name == 'log_error_verbosity'].value[]\
      \ | [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"caExtract_databaseFlags_log_connections_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'log_connections'].value[] | [0])\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_log_disconnections_flagValue__c\"\n\
      \    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression:  \"to_string([?name == 'log_disconnections'].value[] |\
      \ [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"caExtract_databaseFlags_log_statement_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'log_statement'].value[] | [0])\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_log_min_messages_flagValue__c\"\n  \
      \  value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'log_min_messages'].value[] | [0])\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_log_min_error_statement_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'log_min_error_statement'].value[]\
      \ | [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"caExtract_databaseFlags_log_min_duration_statement_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'log_min_duration_statement'].value[]\
      \ | [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n\n  - name: \"caExtract_databaseFlags_cloudsql_enable_pgaudit_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'cloudsql.enable_pgaudit'].value[]\
      \ | [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"caExtract_databaseFlags_external_scripts_enabled_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'external scripts enabled'].value[]\
      \ | [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"caExtract_databaseFlags_cross_db_ownership_chaining_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'cross db ownership chaining'].value[]\
      \ | [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"caExtract_databaseFlags_user_connections_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'user connections'].value[] | [0])\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_user_options_flagValue__c\"\n    value:\
      \ \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'user options'].value[] | [0])\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_remote_access_flagValue__c\"\n    value:\
      \ \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'remote access'].value[] | [0])\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_3625_flagValue__c\"\n    value: \n \
      \     JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == '3625'].value[] | [0])\"\n     \
      \   undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return text type.\"\
      \n\n  - name: \"caExtract_databaseFlags_contained_database_authentication_flagValue__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caExtract__databaseFlagsJson__c\"\
      \n        expression: \"to_string([?name == 'contained database authentication'].value[]\
      \ | [0])\"\n        undeterminedIf:\n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n\n  - name: \"CA10__authorizedNetworksJson__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__authorizedNetworksJson__c\"\n      \
      \  returnType: BYTES\n  - name: \"caJsonFrom_authorizedNetworksJson__c\"\n \
      \   value: \n      JSON_FROM:\n        arg: \n          EXTRACT: \"CA10__authorizedNetworksJson__c\"\
      \n        undeterminedIf:\n          isInvalid: \"Authorized Networks JSON is\
      \ invalid.\"  \n  - name: \"caJsonFrom_authorizedNetworksJson_value__c\"\n \
      \   value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caJsonFrom_authorizedNetworksJson__c\"\
      \n        expression: \"to_string([].value)\"\n        undeterminedIf:\n   \
      \       evaluationError: \"The JSON query was failed.\"\n          resultTypeMismatch:\
      \ \"The JSON query did not return a text.\"\n\n  - name: \"CA10__instanceType__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__instanceType__c\"\n     \
      \   undeterminedIf:\n          isEmpty: \"Instance type should not be empty\"\
      \n  - name: \"CA10__backendType__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__backendType__c\"\n        undeterminedIf:\n          isEmpty: \"Backend\
      \ type should not be empty\"\n  - name: \"CA10__backupEnabled__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__backupEnabled__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"Backup enabled should not be empty\"\n  - name: \"CA10__backupStartTime__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__backupStartTime__c\"\n  -\
      \ name: \"CA10__sslMode__c\"\n    value: \n      FIELD:\n        path: \"CA10__sslMode__c\"\
      \n"
  - path: /ce/ca/google/sql/sql-instance-public-ip-whitelist/test-data.json
    md5Hash: 83B5644053D2FF19DEA8A93B72648A72
    content: |-
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-01-19T19:03:22Z" },
          "Id": "111",
          "CA10__disappearanceTime__c": "2023-12-06T13:34:16Z",
          "CA10__ipv4Enabled__c": false,
          "CA10__authorizedNetworksJson__c": "[]"
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__ipv4Enabled__c') != true",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-01-19T19:03:22Z" },
          "Id": "112",
          "CA10__disappearanceTime__c": null,
          "CA10__ipv4Enabled__c": false,
          "CA10__authorizedNetworksJson__c": "[]"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "300",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-01-19T19:03:22Z" },
          "Id": "113",
          "CA10__disappearanceTime__c": null,
          "CA10__ipv4Enabled__c": true,
          "CA10__authorizedNetworksJson__c": "[{\"kind\":\"sql#aclEntry\",\"name\":\"VPN\",\"value\":\"100.150.200.250\"}]"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('caJsonFrom_authorizedNetworksJson_value__c').contains('0.0.0.0/0')",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-01-19T19:03:22Z" },
          "Id": "114",
          "CA10__disappearanceTime__c": null,
          "CA10__ipv4Enabled__c": true,
          "CA10__authorizedNetworksJson__c": "[{\"kind\":\"sql#aclEntry\",\"name\":\"VPN\",\"value\":\"0.0.0.0/0\"}]"
        }
      ]
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" : "111",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "112",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__ipv4Enabled__c') != true",
      "runtimeError" : null
    }
  }, {
    "Id" : "113",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "114",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom_authorizedNetworksJson_value__c').contains('0.0.0.0/0')",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleSqlInstance__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__ipv4Enabled__c BOOLEAN,
      CA10__authorizedNetworksJson__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-01-19T19:03:22Z")
    },
    "Id" : "111",
    "CA10__disappearanceTime__c" : new Date("2023-12-06T13:34:16Z"),
    "CA10__ipv4Enabled__c" : false,
    "CA10__authorizedNetworksJson__c" : "[]"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-01-19T19:03:22Z")
    },
    "Id" : "112",
    "CA10__ipv4Enabled__c" : false,
    "CA10__authorizedNetworksJson__c" : "[]"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-01-19T19:03:22Z")
    },
    "Id" : "113",
    "CA10__ipv4Enabled__c" : true,
    "CA10__authorizedNetworksJson__c" : "[{\"kind\":\"sql#aclEntry\",\"name\":\"VPN\",\"value\":\"100.150.200.250\"}]"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-01-19T19:03:22Z")
    },
    "Id" : "114",
    "CA10__ipv4Enabled__c" : true,
    "CA10__authorizedNetworksJson__c" : "[{\"kind\":\"sql#aclEntry\",\"name\":\"VPN\",\"value\":\"0.0.0.0/0\"}]"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaGoogleSqlInstance__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__ipv4Enabled__c BOOLEAN,
          CA10__authorizedNetworksJson__c STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  OPTIONS (library=['gs://compliance-platform-public/jmespath.min.js'])
  AS r"""
      var IsEmptyLib = new function () {
          this.simpleIsEmpty = function(arg) {
              return arg == null;
          };
          this.simpleIsNotEmpty = function(arg) {
              return arg != null;
          };
      }();
      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));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Google [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (IsEmptyLib.simpleIsEmpty(obj.CA10__ipv4Enabled__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__ipv4Enabled__c.isEmpty()", currentStateMessage: "Ipv4Enabled should not be empty", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__ipv4Enabled__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('IPv4 Enabled [obj.CA10__ipv4Enabled__c]: ' + obj.CA10__ipv4Enabled__c);
      try {
          if (extract3.call(extract3) != true) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__ipv4Enabled__c') != true", currentStateMessage: "Authorized networks apply only to instances with public IPs", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function jsonQueryChecked7() {
          var input = extract9.call(extract9);
          var out;
          try {
              out = jmespath.search(input, 'to_string([].value)');
          if (out != null && typeof out != 'string') {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('caJsonFrom_authorizedNetworksJson__c').jsonQueryText('to_string([].value)').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return a text.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom_authorizedNetworksJson__c').jsonQueryText('to_string([].value)').isEvaluationFailed()", currentStateMessage: "The JSON query was failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked10() {
          var input = extract12.call(extract12);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extract('CA10__authorizedNetworksJson__c').asJson().isInvalid()", currentStateMessage: "Authorized Networks JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract12() { if (!this.out) { this.out = obj.CA10__authorizedNetworksJson__c; } return this.out; };
      function extract9() { if (!this.out) { this.out = jsonChecked10(); } return this.out; };
      function extract6() { if (!this.out) { this.out = jsonQueryChecked7(); } return this.out; };
      references1.push('Authorized Networks JSON [obj.CA10__authorizedNetworksJson__c]: ' + obj.CA10__authorizedNetworksJson__c);
      try {
          if (TextLib.contains(extract6.call(extract6), '0.0.0.0/0')) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('caJsonFrom_authorizedNetworksJson_value__c').contains('0.0.0.0/0')", currentStateMessage: "Cloud SQL Database Instance do not implicitly Whitelist all public IP addresses.", currentStateReferences: references1.join('\n'), remediation: "Update the authorized network list.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Cloud SQL database instances are not open to the world.", 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.Id AS Id,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__ipv4Enabled__c AS CA10__ipv4Enabled__c,
          sObject.CA10__authorizedNetworksJson__c AS CA10__authorizedNetworksJson__c,
          process_CA10__CaGoogleSqlInstance__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__ipv4Enabled__c AS CA10__ipv4Enabled__c,
                  sObject.CA10__authorizedNetworksJson__c AS CA10__authorizedNetworksJson__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaGoogleSqlInstance__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
