---
policy: /ce/ca/azure/virtual-machine/os-and-data-disks-encryption-with-cmk
logic: /ce/ca/azure/virtual-machine/os-and-data-disks-encryption-with-cmk/prod.logic.yaml
executionTime: 2025-05-10T12:04:09.242159826Z
rows:
  - id: test1
    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: test2
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: isEmptyLookup('CA10__managedDiskLookup__r')
      actual: isEmptyLookup('CA10__managedDiskLookup__r')
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMKEY'
      actual: extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMKEY'
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS'
        || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'
      actual: extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS'
        || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS'
        || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'
      actual: extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS'
        || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/virtual-machine/os-and-data-disks-encryption-with-cmk/policy.yaml
    md5Hash: E172A5F7C73EE6F36B068CDC41A5C786
    content: |
      ---
      names:
        full: Azure Virtual Machine OS and Data disks are not encrypted with Customer-managed
          key
        contextual: OS and Data disks are not encrypted with Customer-managed key
      description: Ensure that OS disks (boot volumes) and data disks (non-boot volumes)
        are encrypted with CMK (Customer Managed Keys). Customer Managed keys can be either
        ADE or Server Side Encryption (SSE).
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v2.1.0/07/03"
        - "/frameworks/cis-azure-v3.0.0/08/03"
        - "/frameworks/cloudaware/resource-security/data-encryption"
      similarPolicies:
        internal:
          - dec-x-9cdb7407
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/VirtualMachines/sse-boot-disk-cmk.html
            name: Server Side Encryption for Boot Disk using CMK
  - path: /ce/ca/azure/virtual-machine/os-and-data-disks-encryption-with-cmk/prod.logic.yaml
    md5Hash: 05D5A4AC4CCDD235021B20F85F6B61D7
    content: |-
      ---
      inputType: "CA10__CaAzureVirtualMachineDisk__c"
      importExtracts:
        - file: "/types/CA10__CaAzureManagedDisk__c/object.extracts.yaml"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "This is a VHD."
          check:
            IS_EMPTY_LOOKUP: "CA10__managedDiskLookup__r"
        - status: "INCOMPLIANT"
          currentStateMessage: "The disk is encrypted at rest with the Platform Key."
          remediationMessage: "Consider encrypting the disk with a Customer Managed Key, if data stored in the disk is important.
           If data stored in the disk is no longer useful, consider deleting it."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__managedDiskLookup__r.CA10__encryptionType__c"
              right:
                TEXT: "ENCRYPTIONATRESTWITHPLATFORMKEY"
        - status: "COMPLIANT"
          currentStateMessage: "The disk is encrypted with a Customer Managed Key."
          check:
            OR:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__managedDiskLookup__r.CA10__encryptionType__c"
                    right:
                      TEXT: "ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS"
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__managedDiskLookup__r.CA10__encryptionType__c"
                    right:
                      TEXT: "ENCRYPTIONATRESTWITHCUSTOMERKEY"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected value in the field."
  - path: /types/CA10__CaAzureManagedDisk__c/object.extracts.yaml
    md5Hash: 324855F25B28A4A6B8613A3E228EEA01
    content: "---\nextracts:\n# Values: Succeeded, Deploying, Canceled, Failed. Not\
      \ Nullable. Can't have no access, retrieved via Microsoft.Compute/disks\n  -\
      \ name: \"CA10__provisioningState__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__provisioningState__c\"\n        undeterminedIf:\n          isEmpty:\
      \ \"Corrupted data. Provisioning State cannot be empty.\"\n# Values: ActiveSAS,\
      \ ActiveSASFrozen, ActiveUpload, Attached, Frozen, ReadyToUpload, Reserved,\
      \ Unattached. Not Nullable. Can't have no access, retrieved via Microsoft.Compute/disks\n\
      \  - name: \"CA10__diskState__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__diskState__c\"\n        undeterminedIf:\n          isEmpty: \"Corrupted\
      \ data. Disk State cannot be empty.\"\n# Values: ENCRYPTIONATRESTWITHPLATFORMKEY,\
      \ ENCRYPTIONATRESTWITHCUSTOMERKEY, ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS.\n\
      \  - name: \"CA10__encryptionType__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__encryptionType__c\"\n        undeterminedIf:\n          isEmpty: \"\
      Corrupted data. Encryption Type cannot be empty.\"\n# Values: Enabled, Disabled.\
      \ Not Nullable. Can't have no access, retrieved via Microsoft.Compute/disks\n\
      \  - name: \"CA10__publicNetworkAccess__c\"\n    value: \n      FIELD:\n   \
      \     path: \"CA10__publicNetworkAccess__c\"\n        undeterminedIf:\n    \
      \      isEmpty: \"Corrupted data. Public Network Access cannot be empty.\"\n\
      # Values: AllowAll, AllowPrivate, DenyAll. Not Nullable. Can't have no access,\
      \ retrieved via Microsoft.Compute/disks\n  - name: \"CA10__networkAccessPolicy__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__networkAccessPolicy__c\"\n\
      \        undeterminedIf:\n          isEmpty: \"Corrupted data. Public Network\
      \ Access cannot be empty.\"\n# Values: AzureActiveDirectory, None. Nullable\
      \ (which equals none). Can't have no access, retrieved via Microsoft.Compute/disks\n\
      \  - name: \"CA10__dataAccessAuthMode__c\"\n    value: \n      FIELD:\n    \
      \    path: \"CA10__dataAccessAuthMode__c\"\n        \n"
  - path: /ce/ca/azure/virtual-machine/os-and-data-disks-encryption-with-cmk/test-data.json
    md5Hash: A536C71FF3EF22388E35FD9485006966
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-17T01:40:36Z"
              },
              "Id": "test1",
              "RecordTypeId": "RecordTypeId1",
              "CA10__disappearanceTime__c": "2024-07-17T01:40:36Z",
              "CA10__managedDiskLookup__c": "managedDiskLookup1",
              "CA10__managedDiskId__c": "managedDiskId1",
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachineDisk1",
                  "Id": "RecordTypeId1"
              },
              "CA10__managedDiskLookup__r": {
                  "Id": "managedDiskLookup1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__encryptionType__c": "ENCRYPTIONATRESTWITHPLATFORMKEY"
              }
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "isEmptyLookup('CA10__managedDiskLookup__r')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-17T01:40:36Z"
              },
              "Id": "test2",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__managedDiskLookup__c": "managedDiskLookup2",
              "CA10__managedDiskId__c": "managedDiskId2",
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachineDisk2",
                  "Id": "RecordTypeId2"
              },
              "CA10__managedDiskLookup__r": {
                  "Id": "managedDiskLookup2",
                  "CA10__disappearanceTime__c": "2024-07-17T01:40:36Z",
                  "CA10__encryptionType__c": "ENCRYPTIONATRESTWITHPLATFORMKEY"
              }
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMKEY'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-17T01:40:36Z"
              },
              "Id": "test3",
              "RecordTypeId": "RecordTypeId3",
              "CA10__disappearanceTime__c": null,
              "CA10__managedDiskLookup__c": "managedDiskLookup3",
              "CA10__managedDiskId__c": "managedDiskId3",
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachineDisk3",
                  "Id": "RecordTypeId3"
              },
              "CA10__managedDiskLookup__r": {
                  "Id": "managedDiskLookup3",
                  "CA10__disappearanceTime__c": null,
                  "CA10__encryptionType__c": "ENCRYPTIONATRESTWITHPLATFORMKEY"
              }
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS' || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-17T01:40:36Z"
              },
              "Id": "test4",
              "RecordTypeId": "RecordTypeId4",
              "CA10__disappearanceTime__c": null,
              "CA10__managedDiskLookup__c": "managedDiskLookup4",
              "CA10__managedDiskId__c": "managedDiskId4",
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachineDisk4",
                  "Id": "RecordTypeId4"
              },
              "CA10__managedDiskLookup__r": {
                  "Id": "managedDiskLookup4",
                  "CA10__disappearanceTime__c": null,
                  "CA10__encryptionType__c": "ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS"
              }
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS' || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-07-17T01:40:36Z"
              },
              "Id": "test5",
              "RecordTypeId": "RecordTypeId5",
              "CA10__disappearanceTime__c": null,
              "CA10__managedDiskLookup__c": "managedDiskLookup5",
              "CA10__managedDiskId__c": "managedDiskId5",
              "RecordType": {
                  "DeveloperName": "caAzureRMVirtualMachineDisk5",
                  "Id": "RecordTypeId5"
              },
              "CA10__managedDiskLookup__r": {
                  "Id": "managedDiskLookup5",
                  "CA10__disappearanceTime__c": null,
                  "CA10__encryptionType__c": "ENCRYPTIONATRESTWITHCUSTOMERKEY"
              }
          }
      ]
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" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "isEmptyLookup('CA10__managedDiskLookup__r')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMKEY'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS' || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS' || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureVirtualMachineDisk__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__managedDiskLookup__c STRING,
      CA10__managedDiskId__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "test1",
    "RecordTypeId" : "RecordTypeId1",
    "CA10__disappearanceTime__c" : new Date("2024-07-17T01:40:36Z"),
    "CA10__managedDiskLookup__c" : "managedDiskLookup1",
    "CA10__managedDiskId__c" : "managedDiskId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "test2",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__managedDiskLookup__c" : "managedDiskLookup2",
    "CA10__managedDiskId__c" : "managedDiskId2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "test3",
    "RecordTypeId" : "RecordTypeId3",
    "CA10__managedDiskLookup__c" : "managedDiskLookup3",
    "CA10__managedDiskId__c" : "managedDiskId3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "test4",
    "RecordTypeId" : "RecordTypeId4",
    "CA10__managedDiskLookup__c" : "managedDiskLookup4",
    "CA10__managedDiskId__c" : "managedDiskId4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "test5",
    "RecordTypeId" : "RecordTypeId5",
    "CA10__managedDiskLookup__c" : "managedDiskLookup5",
    "CA10__managedDiskId__c" : "managedDiskId5"
  } ];
  """;

  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-07-17T01:40:36Z")
    },
    "DeveloperName" : "caAzureRMVirtualMachineDisk1",
    "Id" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "DeveloperName" : "caAzureRMVirtualMachineDisk2",
    "Id" : "RecordTypeId2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "DeveloperName" : "caAzureRMVirtualMachineDisk3",
    "Id" : "RecordTypeId3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "DeveloperName" : "caAzureRMVirtualMachineDisk4",
    "Id" : "RecordTypeId4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "DeveloperName" : "caAzureRMVirtualMachineDisk5",
    "Id" : "RecordTypeId5"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureManagedDisk__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__encryptionType__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "managedDiskLookup1",
    "CA10__encryptionType__c" : "ENCRYPTIONATRESTWITHPLATFORMKEY"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "managedDiskLookup2",
    "CA10__disappearanceTime__c" : new Date("2024-07-17T01:40:36Z"),
    "CA10__encryptionType__c" : "ENCRYPTIONATRESTWITHPLATFORMKEY"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "managedDiskLookup3",
    "CA10__encryptionType__c" : "ENCRYPTIONATRESTWITHPLATFORMKEY"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "managedDiskLookup4",
    "CA10__encryptionType__c" : "ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-07-17T01:40:36Z")
    },
    "Id" : "managedDiskLookup5",
    "CA10__encryptionType__c" : "ENCRYPTIONATRESTWITHCUSTOMERKEY"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureVirtualMachineDisk__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__managedDiskLookup__c STRING,
          CA10__managedDiskId__c STRING,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__managedDiskLookup__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__encryptionType__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 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]
      if (TextLib.isEmpty(obj.CA10__managedDiskId__c) || TextLib.isEmpty(obj.CA10__managedDiskLookup__c) || obj.CA10__managedDiskLookup__r.CA10__disappearanceTime__c != null) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "isEmptyLookup('CA10__managedDiskLookup__r')", currentStateMessage: "This is a VHD.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extractChecked2() {
          if (TextLib.isEmpty(obj.CA10__managedDiskId__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extractCheck(obj.CA10__managedDiskId__c)", currentStateMessage: "Related object via CA10__managedDiskId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__managedDiskLookup__c)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extractCheck(obj.CA10__managedDiskLookup__c)", currentStateMessage: "Related object via CA10__managedDiskLookup__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__managedDiskLookup__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extractCheck(obj.CA10__managedDiskLookup__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__managedDiskLookup__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract3.call(extract3);
      }
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__managedDiskLookup__r.CA10__encryptionType__c)) {
              throw new Error("UNDETERMINED condition:204", {cause: {status: 'UNDETERMINED', conditionIndex: 204, conditionText: "CA10__encryptionType__c.isEmpty()", currentStateMessage: "Corrupted data. Encryption Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__managedDiskLookup__r.CA10__encryptionType__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Encryption: Type [obj.CA10__managedDiskLookup__r.CA10__encryptionType__c]: ' + obj.CA10__managedDiskLookup__r.CA10__encryptionType__c);
      try {
          if (TextLib.equal(extractChecked2(), 'ENCRYPTIONATRESTWITHPLATFORMKEY')) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMKEY'", currentStateMessage: "The disk is encrypted at rest with the Platform Key.", currentStateReferences: references1.join('\n'), remediation: "Consider encrypting the disk with a Customer Managed Key, if data stored in the disk is important. If data stored in the disk is no longer useful, consider deleting it.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function extractChecked5() {
          if (TextLib.isEmpty(obj.CA10__managedDiskId__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "extractCheck(obj.CA10__managedDiskId__c)", currentStateMessage: "Related object via CA10__managedDiskId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__managedDiskLookup__c)) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "extractCheck(obj.CA10__managedDiskLookup__c)", currentStateMessage: "Related object via CA10__managedDiskLookup__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__managedDiskLookup__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:303", {cause: {status: 'UNDETERMINED', conditionIndex: 303, conditionText: "extractCheck(obj.CA10__managedDiskLookup__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__managedDiskLookup__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract6.call(extract6);
      }
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__managedDiskLookup__r.CA10__encryptionType__c)) {
              throw new Error("UNDETERMINED condition:304", {cause: {status: 'UNDETERMINED', conditionIndex: 304, conditionText: "CA10__encryptionType__c.isEmpty()", currentStateMessage: "Corrupted data. Encryption Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__managedDiskLookup__r.CA10__encryptionType__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      function extractChecked8() {
          if (TextLib.isEmpty(obj.CA10__managedDiskId__c)) {
              throw new Error("UNDETERMINED condition:305", {cause: {status: 'UNDETERMINED', conditionIndex: 305, conditionText: "extractCheck(obj.CA10__managedDiskId__c)", currentStateMessage: "Related object via CA10__managedDiskId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__managedDiskLookup__c)) {
              throw new Error("UNDETERMINED condition:306", {cause: {status: 'UNDETERMINED', conditionIndex: 306, conditionText: "extractCheck(obj.CA10__managedDiskLookup__c)", currentStateMessage: "Related object via CA10__managedDiskLookup__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__managedDiskLookup__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:307", {cause: {status: 'UNDETERMINED', conditionIndex: 307, conditionText: "extractCheck(obj.CA10__managedDiskLookup__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__managedDiskLookup__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract6.call(extract6);
      }
      try {
          if (TextLib.equal(extractChecked5(), 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS') || TextLib.equal(extractChecked8(), 'ENCRYPTIONATRESTWITHCUSTOMERKEY')) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHPLATFORMANDCUSTOMERKEYS' || extract('CA10__managedDiskLookup__r.CA10__encryptionType__c') == 'ENCRYPTIONATRESTWITHCUSTOMERKEY'", currentStateMessage: "The disk is encrypted with a Customer Managed Key.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected value in the field.", 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,
          sObject.CA10__managedDiskLookup__c AS CA10__managedDiskLookup__c,
          sObject.CA10__managedDiskId__c AS CA10__managedDiskId__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          STRUCT (
              `CA10__managedDiskLookup__r`.Id AS Id,
              `CA10__managedDiskLookup__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
              `CA10__managedDiskLookup__r`.CA10__encryptionType__c AS CA10__encryptionType__c
          ) AS CA10__managedDiskLookup__r,
          process_CA10__CaAzureVirtualMachineDisk__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__managedDiskLookup__c AS CA10__managedDiskLookup__c,
                  sObject.CA10__managedDiskId__c AS CA10__managedDiskId__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  STRUCT (
                      `CA10__managedDiskLookup__r`.Id AS Id,
                      `CA10__managedDiskLookup__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      `CA10__managedDiskLookup__r`.CA10__encryptionType__c AS CA10__encryptionType__c
                  ) AS CA10__managedDiskLookup__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureVirtualMachineDisk__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
      LEFT JOIN UNNEST(mock_CA10__CaAzureManagedDisk__c()) AS `CA10__managedDiskLookup__r`
          ON sObject.CA10__managedDiskLookup__c = `CA10__managedDiskLookup__r`.Id
  ) sObject ON sObject.Id = expectedResult.Id;
