---
policy: /ce/ca/google/compute-engine/instance-use-default-service-account
logic: /ce/ca/google/compute-engine/instance-use-default-service-account/prod.logic.yaml
executionTime: 2025-04-24T23:46:56.095814343Z
rows:
  - id: a41
    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: a42
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('Name').startsWith('gke-')
      actual: extract('Name').startsWith('gke-')
    runtimeError: {}
  - id: a43
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__Google_Instance_Service_Account_Links__r.has(INCOMPLIANT)
      actual: CA10__Google_Instance_Service_Account_Links__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: a44
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/google/compute-engine/instance-use-default-service-account/policy.yaml
    md5Hash: DB8712704661B281D2EFC9C73A53BDC2
    content: "---\nnames: \n  full: \"Google GCE Instance is configured to use the\
      \ Default Service Account\"\n  contextual: \"Instance is configured to use the\
      \ Default Service Account\"\ndescription: \"It is recommended to configure your\
      \ instance to not use the default Compute Engine \\ \n service account because\
      \ it has the Editor role on the project.\"\ntype: COMPLIANCE_POLICY\ncategories:\n\
      \  - \"SECURITY\"\nframeworkMappings:\n  - /frameworks/cis-gcp-v3.0.0/04/01\n\
      \  - /frameworks/cloudaware/resource-security/secure-access\nsimilarPolicies:\n\
      \  cloudConformity:\n    - url: \"https://www.trendmicro.com/cloudoneconformity-staging/knowledge-base/gcp/ComputeEngine/default-service-accounts-in-use.html\"\
      \n      name: \"Check for Instances Associated with Default Service Accounts\""
  - path: /ce/ca/google/compute-engine/instance-use-default-service-account/prod.logic.yaml
    md5Hash: F542D59B237D2DD16B10F67D0BED6914
    content: |
      ---
      inputType: "CA10__CaGoogleGceInstance__c"
      testData:
        - file: test-data.json
      importExtracts:
        - file: /types/CA10__CaGoogleGceInstance__c/object.extracts.yaml
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The instance is created by GKE."
          check:
            STARTS_WITH:
              arg:
                EXTRACT: "Name"
              prefix:
                TEXT: 'gke-'
        - status: "INCOMPLIANT"
          currentStateMessage: "The instance is configured to use the default service account."
          remediationMessage: "Update the instance to use a user-managed service account."
          check:
            RELATED_LIST_HAS:
              status: "INCOMPLIANT"
              relationshipName: "CA10__Google_Instance_Service_Account_Links__r"
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "Instance is not configured to use the default service account."
      relatedLists:
        - relationshipName: "CA10__Google_Instance_Service_Account_Links__r"
          importExtracts:
            - file: /types/CA10__CaGoogleGceInstanceServiceAccountLink__c/object.extracts.yaml
          conditions:
          - status: "INCOMPLIANT"
            currentStateMessage: "Default Compute Engine service account."
            check:
              ENDS_WITH:
                arg:
                  EXTRACT: "CA10__iamServiceAccountEmail__c"
                suffix:
                  TEXT: 'compute@developer.gserviceaccount.com'
          otherwise:
            status: "COMPLIANT"
            currentStateMessage: "There is no default Compute Engine service account."
  - path: /ce/ca/google/compute-engine/instance-use-default-service-account/test-data.json
    md5Hash: CA6320B06FFA6B71A84FC07889B21E92
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-08-27T19:17:54Z" },
          "Id": "a41",
          "CA10__disappearanceTime__c": "2024-08-26T21:36:28Z",
          "Name": "gke-prod1",
          "CA10__labels__c": "",
          "CA10__Google_Instance_Service_Account_Links__r": [
          ]
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "199",
            "conditionText": "extract('Name').startsWith('gke-')",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-08-27T19:17:54Z" },
          "Id": "a42",
          "CA10__disappearanceTime__c": null,
          "Name": "gke-default-pool",
          "CA10__labels__c": "goog-gke-node:",
          "CA10__Google_Instance_Service_Account_Links__r": [
            {
              "Id": "aCR2",
              "CA10__disappearanceTime__c": null,
              "CA10__iamServiceAccountEmail__c": "7011111-compute@developer.gserviceaccount.com",
              "CA10__gceInstance__c": "a42"
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "299",
            "conditionText": "CA10__Google_Instance_Service_Account_Links__r.has(INCOMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-08-27T19:17:54Z" },
          "Id": "a43",
          "CA10__disappearanceTime__c": null,
          "Name": "stat-image",
          "CA10__labels__c": "",
          "CA10__Google_Instance_Service_Account_Links__r": [
            {
              "Id": "aCR0e000000k9nHGAQ",
              "CA10__disappearanceTime__c": null,
              "CA10__iamServiceAccountEmail__c": "94111111-compute@developer.gserviceaccount.com",
              "CA10__gceInstance__c": "a43"
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "300",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2024-08-27T19:17:54Z" },
          "Id": "a44",
          "CA10__disappearanceTime__c": null,
          "Name": "stat-image",
          "CA10__labels__c": "goog-gke-cost-management",
          "CA10__Google_Instance_Service_Account_Links__r": [
            {
              "Id": "aCRVU4",
              "CA10__disappearanceTime__c": null,
              "CA10__iamServiceAccountEmail__c": "tfc@ce.iam.gserviceaccount.com",
              "CA10__gceInstance__c": "a44"
            }
          ]
        }
      ]
  - path: /types/CA10__CaGoogleGceInstanceServiceAccountLink__c/object.extracts.yaml
    md5Hash: 0C66B01DC5A053558EA02D513AF8875C
    content: "---\nextracts:\n  - name: \"CA10__iamServiceAccountEmail__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__iamServiceAccountEmail__c\"\n      \
      \  undeterminedIf:\n          isEmpty:  \"Field should not be empty\"\n  - name:\
      \ \"CA10__scopes__c\"\n    value: \n      FIELD:\n        path: \"CA10__scopes__c\"\
      \n        undeterminedIf:\n          isEmpty:  \"Field should not be empty\""
  - path: /types/CA10__CaGoogleGceInstance__c/object.extracts.yaml
    md5Hash: 95F28CC49887E4035F2848BC20DC25D1
    content: "---\nextracts:\n  - name: \"Name\"\n    value: \n      FIELD:\n    \
      \    path: \"Name\"\n        undeterminedIf:\n          isEmpty:  \"Name should\
      \ not be empty\"\n  - name: \"CA10__labels__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__labels__c\"\n        undeterminedIf:\n          isEmpty:\
      \  \"Labels should not be empty\"\n  - name: \"CA10__ipForwarding__c\"\n   \
      \ value: \n      FIELD:\n        path: \"CA10__ipForwarding__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"IP forwarding can't be empty\"\n  - name: \"CA10__shieldedIntegrityMonitoringState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__shieldedIntegrityMonitoringState__c\"\
      \n  - name: \"CA10__shieldedVtpmState__c\"\n    value: \n      FIELD:\n    \
      \    path: \"CA10__shieldedVtpmState__c\"\n  - name: \"CA10__confidentialComputeStatus__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__confidentialComputeStatus__c\"\
      \n  - name: \"CA10__machineTypeName__c\"\n    value: \n      FIELD:\n      \
      \  path: \"CA10__machineTypeName__c\"\n  - name: \"CA10__metadataJson__c\"\n\
      \    value: \n      FIELD:\n        path: \"CA10__metadataJson__c\"\n      \
      \  returnType: BYTES\n  - name: \"caJsonFrom__metadataJson__c\"\n    value:\
      \ \n      JSON_FROM:\n        arg: \n          EXTRACT: \"CA10__metadataJson__c\"\
      \n        undeterminedIf:\n          isInvalid: \"Metadata JSON is invalid.\"\
      \n          isEmpty: \"Metadata JSON is empty.\"\n  - name: \"caJsonFrom__metadataJson__block_project_ssh_keys_value\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caJsonFrom__metadataJson__c\"\
      \n        expression: \"to_string(items[?key=='block-project-ssh-keys'].value)\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return a text.\"\n\
      \          resultIsEmpty: \"The JSON query did not return a value.\"\n  - name:\
      \ \"caJsonFrom__metadataJson__enable_oslogin_value\"\n    value: \n      JSON_QUERY_TEXT:\n\
      \        arg:\n          EXTRACT: \"caJsonFrom__metadataJson__c\"\n        expression:\
      \ \"to_string(items[?key=='enable-oslogin'].value)\"\n        undeterminedIf:\n\
      \          evaluationError: \"The JSON query has failed.\"\n          resultTypeMismatch:\
      \ \"The JSON query did not return a text.\"\n          resultIsEmpty: \"The\
      \ JSON query did not return a value.\"\n  - name: \"caJsonFrom__metadataJson__serial_port_enable_value\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg:\n          EXTRACT: \"caJsonFrom__metadataJson__c\"\
      \n        expression: \"to_string(items[?key=='serial-port-enable'].value)\"\
      \n        undeterminedIf:\n          evaluationError: \"The JSON query has failed.\"\
      \n          resultTypeMismatch: \"The JSON query did not return a text.\"\n\
      \          resultIsEmpty: \"The JSON query did not return a value.\"\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" : "a41",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "a42",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('Name').startsWith('gke-')",
      "runtimeError" : null
    }
  }, {
    "Id" : "a43",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__Google_Instance_Service_Account_Links__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "a44",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleGceInstance__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      Name STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-08-27T19:17:54Z")
    },
    "Id" : "a41",
    "CA10__disappearanceTime__c" : new Date("2024-08-26T21:36:28Z"),
    "Name" : "gke-prod1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-08-27T19:17:54Z")
    },
    "Id" : "a42",
    "Name" : "gke-default-pool"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-08-27T19:17:54Z")
    },
    "Id" : "a43",
    "Name" : "stat-image"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-08-27T19:17:54Z")
    },
    "Id" : "a44",
    "Name" : "stat-image"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleGceInstanceServiceAccountLink__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__iamServiceAccountEmail__c STRING,
      CA10__gceInstance__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-08-27T19:17:54Z")
    },
    "Id" : "aCR2",
    "CA10__iamServiceAccountEmail__c" : "7011111-compute@developer.gserviceaccount.com",
    "CA10__gceInstance__c" : "a42"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-08-27T19:17:54Z")
    },
    "Id" : "aCR0e000000k9nHGAQ",
    "CA10__iamServiceAccountEmail__c" : "94111111-compute@developer.gserviceaccount.com",
    "CA10__gceInstance__c" : "a43"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-08-27T19:17:54Z")
    },
    "Id" : "aCRVU4",
    "CA10__iamServiceAccountEmail__c" : "tfc@ce.iam.gserviceaccount.com",
    "CA10__gceInstance__c" : "a44"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaGoogleGceInstance__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          Name STRING,
          CA10__Google_Instance_Service_Account_Links__r ARRAY<STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__iamServiceAccountEmail__c STRING,
              CA10__gceInstance__c STRING,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError 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));
          };
      }();
      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 (TextLib.isEmpty(obj.Name)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "Name.isEmpty()", currentStateMessage: "Name should not be empty", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.Name;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Name [obj.Name]: ' + obj.Name);
      try {
          if (TextLib.startsWith(extract3.call(extract3), 'gke-')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('Name').startsWith('gke-')", currentStateMessage: "The instance is created by GKE.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      var count_CA10__Google_Instance_Service_Account_Links__r_INCOMPLIANT5 = 0;
      if (obj.CA10__Google_Instance_Service_Account_Links__r != null) {
          for (var i6 = 0; i6 < obj.CA10__Google_Instance_Service_Account_Links__r.length; i6++) {
              if (obj.CA10__Google_Instance_Service_Account_Links__r[i6].result.status == 'INCOMPLIANT') {
                  count_CA10__Google_Instance_Service_Account_Links__r_INCOMPLIANT5 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      references1.push('Related list [CA10__Google_Instance_Service_Account_Links__r] ' + (count_CA10__Google_Instance_Service_Account_Links__r_INCOMPLIANT5 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__Google_Instance_Service_Account_Links__r_INCOMPLIANT5 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10__Google_Instance_Service_Account_Links__r.has(INCOMPLIANT)", currentStateMessage: "The instance is configured to use the default service account.", currentStateReferences: references1.join('\n'), remediation: "Update the instance to use a user-managed service account.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Instance is not configured to use the default service account.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__Google_Instance_Service_Account_Links__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__iamServiceAccountEmail__c STRING,
          CA10__gceInstance__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));
          };
      }();
      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 (TextLib.isEmpty(obj.CA10__iamServiceAccountEmail__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__iamServiceAccountEmail__c.isEmpty()", currentStateMessage: "Field should not be empty", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__iamServiceAccountEmail__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('IAM Service Account Email [obj.CA10__iamServiceAccountEmail__c]: ' + obj.CA10__iamServiceAccountEmail__c);
      try {
          if (TextLib.endsWith(extract3.call(extract3), 'compute@developer.gserviceaccount.com')) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__iamServiceAccountEmail__c').endsWith('compute@developer.gserviceaccount.com')", currentStateMessage: "Default Compute Engine service account.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "There is no default Compute Engine service account.", 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.Name AS Name,
          `CA10__Google_Instance_Service_Account_Links__r`.arr AS CA10__Google_Instance_Service_Account_Links__r,
          process_CA10__CaGoogleGceInstance__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.Name AS Name,
                  `CA10__Google_Instance_Service_Account_Links__r`.arr AS CA10__Google_Instance_Service_Account_Links__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaGoogleGceInstance__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10__gceInstance__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__iamServiceAccountEmail__c AS CA10__iamServiceAccountEmail__c,
                      sObject.CA10__gceInstance__c AS CA10__gceInstance__c,
                      process_CA10__Google_Instance_Service_Account_Links__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__iamServiceAccountEmail__c AS CA10__iamServiceAccountEmail__c,
                              sObject.CA10__gceInstance__c AS CA10__gceInstance__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaGoogleGceInstanceServiceAccountLink__c()) AS sObject
          GROUP BY sObject.CA10__gceInstance__c
      ) AS `CA10__Google_Instance_Service_Account_Links__r`
          ON sObject.Id = `CA10__Google_Instance_Service_Account_Links__r`.CA10__gceInstance__c
  ) sObject ON sObject.Id = expectedResult.Id;
