---
policy: /ce/ca/azure/virtual-machine/virtual-machine-managed-disks
logic: /ce/ca/azure/virtual-machine/virtual-machine-managed-disks/prod.logic.yaml
executionTime: 2025-04-24T23:46:32.050266655Z
rows:
  - id: test1
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__Azure_Virtual_Machine_Disks__r.has(COMPLIANT)
      actual: CA10__Azure_Virtual_Machine_Disks__r.has(COMPLIANT)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Virtual_Machine_Disks__r.has(INCOMPLIANT)
      actual: CA10__Azure_Virtual_Machine_Disks__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: CA10__Azure_Virtual_Machine_Disks__r.has(UNDETERMINED)
      actual: CA10__Azure_Virtual_Machine_Disks__r.has(UNDETERMINED)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/virtual-machine/virtual-machine-managed-disks/policy.yaml
    md5Hash: D3BD41D999497E2FA16A1C81EEEDF897
    content: |
      ---
      names:
        full: Azure Virtual Machine is not utilizing Managed Disks
        contextual: Virtual Machine is not utilizing Managed Disks
      description: "Migrate blob-based VHDs to Managed Disks on Virtual Machines toexploit\
        \ the default features of this configuration. The features include: 1. Default Disk\
        \ Encryption 2. Resilience, as Microsoft will managed the disk storage and move\
        \ around if underlying hardware goes faulty 3. Reduction of costs over storage accounts"
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
        - RELIABILITY
        - PERFORMANCE
        - COST
      frameworkMappings:
        - "/frameworks/cis-azure-v2.1.0/07/02"
        - "/frameworks/cis-azure-v3.0.0/08/02"
        - "/frameworks/cloudaware/resource-reliability/system-configuration"
        - "/frameworks/cloudaware/resource-performance/performance-tuning"
        - "/frameworks/cloudaware/cost-efficiency-and-optimization/resource-optimization"
      similarPolicies:
        internal:
          - dec-x-588af79c
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/VirtualMachines/managed-disks-in-use.html
            name: Use Managed Disk Volumes for Virtual Machines
  - path: /ce/ca/azure/virtual-machine/virtual-machine-managed-disks/prod.logic.yaml
    md5Hash: 2EF451BDAE53E0B394781B5E9C0F62CC
    content: |-
      ---
      inputType: "CA10__CaAzureVirtualMachine__c"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "This Virtual Machine utilizes VHD Disks."
          remediationMessage: "Consider migrating to Managed Disks."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__Azure_Virtual_Machine_Disks__r"
              status: "INCOMPLIANT"
        - status: "COMPLIANT"
          currentStateMessage: "This Virtual Machine utilizes Managed Disks."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__Azure_Virtual_Machine_Disks__r"
              status: "COMPLIANT"
        - status: "UNDETERMINED"
          currentStateMessage: "Unable to determine the disk type."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__Azure_Virtual_Machine_Disks__r"
              status: "UNDETERMINED"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "This Virtual Machine doesn't have disks."
      relatedLists:
        - relationshipName: "CA10__Azure_Virtual_Machine_Disks__r"
          importExtracts:
            - file: "/types/CA10__CaAzureVirtualMachineDisk__c/object.extracts.yaml"
          conditions:
            - status: "COMPLIANT"
              currentStateMessage: "This is a Managed Disk."
              check:
                NOT_EMPTY:
                  arg:
                    EXTRACT: "CA10__managedDiskId__c"
            - status: "INCOMPLIANT"
              currentStateMessage: "This is a VHD Disk."
              check:
                NOT_EMPTY:
                  arg:
                    EXTRACT: "CA10__vhdUri__c"
          otherwise:
            status: "UNDETERMINED"
            currentStateMessage: "Unable to determine the Disk."
  - path: /types/CA10__CaAzureVirtualMachineDisk__c/object.extracts.yaml
    md5Hash: D3F8096AF4D7CD8C8BE9FD7F4FD0EF93
    content: "---\nextracts:\n# Checkbox. Can't have no access, retrieved via Microsoft.Compute/virtualMachines\n\
      \  - name: \"CA10__isOsDisk__c\"\n    value: \n      FIELD:\n        path: \"\
      CA10__isOsDisk__c\"\n# Nullable. Can't have no access, retrieved via Microsoft.Compute/virtualMachines\n\
      \  - name: \"CA10__managedDiskLookup__c\"\n    value: \n      FIELD:\n     \
      \   path: \"CA10__managedDiskLookup__c\"\n# Nullable. Can't have no access,\
      \ retrieved via Microsoft.Compute/virtualMachines\n  - name: \"CA10__vhdUri__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__vhdUri__c\"\n# Nullable.\
      \ Can't have no access, retrieved via Microsoft.Compute/virtualMachines\n  -\
      \ name: \"CA10__managedDiskId__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__managedDiskId__c\""
  - path: /ce/ca/azure/virtual-machine/virtual-machine-managed-disks/test-data.json
    md5Hash: 5D5C634FAA19B1BDDB367D27B6ED5D49
    content: |-
      [
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__Azure_Virtual_Machine_Disks__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test1",
              "RecordTypeId": "recordType1",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "recordType1",
                  "Id": "recordType1"
              },
              "CA10__Azure_Virtual_Machine_Disks__r": [
                  {
                      "Id": "test1_1",
                      "RecordTypeId": "recordType2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__managedDiskId__c": "managedDiskId",
                      "CA10__vhdUri__c": "",
                      "RecordType": {
                          "DeveloperName": "recordType2",
                          "Id": "recordType2"
                      },
                      "CA10__virtualMachine__c": "test1"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__Azure_Virtual_Machine_Disks__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test2",
              "RecordTypeId": "recordType1",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "recordType1",
                  "Id": "recordType1"
              },
              "CA10__Azure_Virtual_Machine_Disks__r": [
                  {
                      "Id": "test2_1",
                      "RecordTypeId": "recordType2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__managedDiskId__c": "",
                      "CA10__vhdUri__c": "vhdUri",
                      "RecordType": {
                          "DeveloperName": "recordType2",
                          "Id": "recordType2"
                      },
                      "CA10__virtualMachine__c": "test2"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "399",
                  "conditionText": "CA10__Azure_Virtual_Machine_Disks__r.has(UNDETERMINED)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test3",
              "RecordTypeId": "recordType1",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "recordType1",
                  "Id": "recordType1"
              },
              "CA10__Azure_Virtual_Machine_Disks__r": [
                  {
                      "Id": "test3_1",
                      "RecordTypeId": "recordType2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__managedDiskId__c": "",
                      "CA10__vhdUri__c": "",
                      "RecordType": {
                          "DeveloperName": "recordType2",
                          "Id": "recordType2"
                      },
                      "CA10__virtualMachine__c": "test3"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "400",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test4",
              "RecordTypeId": "recordType1",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "recordType1",
                  "Id": "recordType1"
              },
              "CA10__Azure_Virtual_Machine_Disks__r": [
                  {
                      "Id": "test4_1",
                      "RecordTypeId": "recordType2",
                      "CA10__disappearanceTime__c": "2024-06-27T20:33:04Z",
                      "CA10__managedDiskId__c": "managedDiskId",
                      "CA10__vhdUri__c": "",
                      "RecordType": {
                          "DeveloperName": "recordType2",
                          "Id": "recordType2"
                      },
                      "CA10__virtualMachine__c": "test4"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test5",
              "RecordTypeId": "recordType1",
              "CA10__disappearanceTime__c": "2024-06-27T20:33:04Z",
              "RecordType": {
                  "DeveloperName": "recordType1",
                  "Id": "recordType1"
              },
              "CA10__Azure_Virtual_Machine_Disks__r": [
                  {
                      "Id": "test5_1",
                      "RecordTypeId": "recordType2",
                      "CA10__disappearanceTime__c": null,
                      "CA10__managedDiskId__c": "managedDiskId",
                      "CA10__vhdUri__c": "",
                      "RecordType": {
                          "DeveloperName": "recordType2",
                          "Id": "recordType2"
                      },
                      "CA10__virtualMachine__c": "test5"
                  }
              ]
          }
      ]
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" : "test1",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__Azure_Virtual_Machine_Disks__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Virtual_Machine_Disks__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "399",
      "conditionText" : "CA10__Azure_Virtual_Machine_Disks__r.has(UNDETERMINED)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureVirtualMachine__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test1",
    "RecordTypeId" : "recordType1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test2",
    "RecordTypeId" : "recordType1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test3",
    "RecordTypeId" : "recordType1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test4",
    "RecordTypeId" : "recordType1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test5",
    "RecordTypeId" : "recordType1",
    "CA10__disappearanceTime__c" : new Date("2024-06-27T20:33:04Z")
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      DeveloperName STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "DeveloperName" : "recordType1",
    "Id" : "recordType1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "DeveloperName" : "recordType2",
    "Id" : "recordType2"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureVirtualMachineDisk__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__managedDiskId__c STRING,
      CA10__vhdUri__c STRING,
      CA10__virtualMachine__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test1_1",
    "RecordTypeId" : "recordType2",
    "CA10__managedDiskId__c" : "managedDiskId",
    "CA10__vhdUri__c" : "",
    "CA10__virtualMachine__c" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test2_1",
    "RecordTypeId" : "recordType2",
    "CA10__managedDiskId__c" : "",
    "CA10__vhdUri__c" : "vhdUri",
    "CA10__virtualMachine__c" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test3_1",
    "RecordTypeId" : "recordType2",
    "CA10__managedDiskId__c" : "",
    "CA10__vhdUri__c" : "",
    "CA10__virtualMachine__c" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test4_1",
    "RecordTypeId" : "recordType2",
    "CA10__disappearanceTime__c" : new Date("2024-06-27T20:33:04Z"),
    "CA10__managedDiskId__c" : "managedDiskId",
    "CA10__vhdUri__c" : "",
    "CA10__virtualMachine__c" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test5_1",
    "RecordTypeId" : "recordType2",
    "CA10__managedDiskId__c" : "managedDiskId",
    "CA10__vhdUri__c" : "",
    "CA10__virtualMachine__c" : "test5"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureVirtualMachine__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__Azure_Virtual_Machine_Disks__r ARRAY<STRUCT<
              Id STRING,
              RecordTypeId STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__managedDiskId__c STRING,
              CA10__vhdUri__c STRING,
              CA10__virtualMachine__c STRING,
              RecordType STRUCT<
                  DeveloperName STRING,
                  Id 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 references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Azure [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};
      }
      var count_CA10__Azure_Virtual_Machine_Disks__r_INCOMPLIANT2 = 0;
      if (obj.CA10__Azure_Virtual_Machine_Disks__r != null) {
          for (var i3 = 0; i3 < obj.CA10__Azure_Virtual_Machine_Disks__r.length; i3++) {
              if (obj.CA10__Azure_Virtual_Machine_Disks__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10__Azure_Virtual_Machine_Disks__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__Azure_Virtual_Machine_Disks__r] ' + (count_CA10__Azure_Virtual_Machine_Disks__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__Azure_Virtual_Machine_Disks__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__Azure_Virtual_Machine_Disks__r.has(INCOMPLIANT)", currentStateMessage: "This Virtual Machine utilizes VHD Disks.", currentStateReferences: references1.join('\n'), remediation: "Consider migrating to Managed Disks.", runtimeError: null};
      }
      var count_CA10__Azure_Virtual_Machine_Disks__r_COMPLIANT4 = 0;
      if (obj.CA10__Azure_Virtual_Machine_Disks__r != null) {
          for (var i5 = 0; i5 < obj.CA10__Azure_Virtual_Machine_Disks__r.length; i5++) {
              if (obj.CA10__Azure_Virtual_Machine_Disks__r[i5].result.status == 'COMPLIANT') {
                  count_CA10__Azure_Virtual_Machine_Disks__r_COMPLIANT4 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      if (count_CA10__Azure_Virtual_Machine_Disks__r_COMPLIANT4 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10__Azure_Virtual_Machine_Disks__r.has(COMPLIANT)", currentStateMessage: "This Virtual Machine utilizes Managed Disks.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__Azure_Virtual_Machine_Disks__r_UNDETERMINED6 = 0;
      if (obj.CA10__Azure_Virtual_Machine_Disks__r != null) {
          for (var i7 = 0; i7 < obj.CA10__Azure_Virtual_Machine_Disks__r.length; i7++) {
              if (obj.CA10__Azure_Virtual_Machine_Disks__r[i7].result.status == 'UNDETERMINED') {
                  count_CA10__Azure_Virtual_Machine_Disks__r_UNDETERMINED6 += 1;
              }
          }
      }
      // condition[3], conditionIndex:[300..399]
      if (count_CA10__Azure_Virtual_Machine_Disks__r_UNDETERMINED6 > 0) {
          return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "CA10__Azure_Virtual_Machine_Disks__r.has(UNDETERMINED)", currentStateMessage: "Unable to determine the disk type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "This Virtual Machine doesn't have disks.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__Azure_Virtual_Machine_Disks__r(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__managedDiskId__c STRING,
          CA10__vhdUri__c STRING,
          CA10__virtualMachine__c STRING,
          RecordType STRUCT<
              DeveloperName 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));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Azure [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 extract3() { if (!this.out) { this.out = obj.CA10__managedDiskId__c; } return this.out; };
      references1.push('Managed Disk ID [obj.CA10__managedDiskId__c]: ' + obj.CA10__managedDiskId__c);
      if (TextLib.isNotEmpty(extract3.call(extract3))) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__managedDiskId__c').isNotEmpty()", currentStateMessage: "This is a Managed Disk.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__vhdUri__c; } return this.out; };
      references1.push('VHD URI [obj.CA10__vhdUri__c]: ' + obj.CA10__vhdUri__c);
      if (TextLib.isNotEmpty(extract6.call(extract6))) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__vhdUri__c').isNotEmpty()", currentStateMessage: "This is a VHD Disk.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unable to determine the Disk.", 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.RecordTypeId AS RecordTypeId,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          `CA10__Azure_Virtual_Machine_Disks__r`.arr AS CA10__Azure_Virtual_Machine_Disks__r,
          process_CA10__CaAzureVirtualMachine__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  `CA10__Azure_Virtual_Machine_Disks__r`.arr AS CA10__Azure_Virtual_Machine_Disks__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureVirtualMachine__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
      LEFT JOIN (
          SELECT
              sObject.CA10__virtualMachine__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.RecordTypeId AS RecordTypeId,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__managedDiskId__c AS CA10__managedDiskId__c,
                      sObject.CA10__vhdUri__c AS CA10__vhdUri__c,
                      sObject.CA10__virtualMachine__c AS CA10__virtualMachine__c,
                      STRUCT (
                          `RecordType`.DeveloperName AS DeveloperName,
                          `RecordType`.Id AS Id
                      ) AS RecordType,
                      process_CA10__Azure_Virtual_Machine_Disks__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.RecordTypeId AS RecordTypeId,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__managedDiskId__c AS CA10__managedDiskId__c,
                              sObject.CA10__vhdUri__c AS CA10__vhdUri__c,
                              sObject.CA10__virtualMachine__c AS CA10__virtualMachine__c,
                              STRUCT (
                                  `RecordType`.DeveloperName AS DeveloperName,
                                  `RecordType`.Id AS Id
                              ) AS RecordType
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAzureVirtualMachineDisk__c()) AS sObject
          LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
              ON sObject.RecordTypeId = `RecordType`.Id
          GROUP BY sObject.CA10__virtualMachine__c
      ) AS `CA10__Azure_Virtual_Machine_Disks__r`
          ON sObject.Id = `CA10__Azure_Virtual_Machine_Disks__r`.CA10__virtualMachine__c
  ) sObject ON sObject.Id = expectedResult.Id;
