---
policy: /ce/ca/azure/subscription/integration-with-microsoft-defender-for-endpoint
logic: /ce/ca/azure/subscription/integration-with-microsoft-defender-for-endpoint/prod.logic.yaml
executionTime: 2025-04-24T23:46:16.289899622Z
rows:
  - id: test1
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 101
      actual: 101
    conditionText:
      expected: CA10__defenderForCloudSettingsJson__c.delegatedTo(CA10__defenderForCloudSettingsJson__c).isEmpty()
      actual: CA10__defenderForCloudSettingsJson__c.delegatedTo(CA10__defenderForCloudSettingsJson__c).isEmpty()
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
      actual: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]')"
      actual: "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]')"
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
      actual: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
      actual: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
      actual: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name\
        \ == \\'WDATP\\'].enabled | [0]'))"
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/subscription/integration-with-microsoft-defender-for-endpoint/policy.yaml
    md5Hash: 314079FF538D4FD6EFE65F32B0107E4B
    content: |
      ---
      names:
        full: Microsoft Defender For Cloud Integration With Microsoft Defender For Endpoint
          is not enabled
        contextual: Integration With Microsoft Defender For Endpoint is not enabled
      description: This integration setting enables Microsoft Defender for Endpoint (formerly
        'Advanced Threat Protection' or 'ATP' or 'WDATP' - see additional info) to communicate
        with Microsoft Defender for Cloud.
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v2.1.0/02/01/21"
        - "/frameworks/cis-azure-v3.0.0/03/01/03/03"
        - "/frameworks/cloudaware/resource-security/microsoft-defender-configuration"
      similarPolicies:
        internal:
          - dec-x-cff561fd
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/SecurityCenter/defender-endpoint-integration.html
            name: Enable Defender for Endpoint Integration with Microsoft Defender for Cloud
  - path: /ce/ca/azure/subscription/integration-with-microsoft-defender-for-endpoint/prod.logic.yaml
    md5Hash: 267B5095BAA7709E3FD1E4E4751578E4
    content: "---\ninputType: \"CA10__CaAzureAccount__c\"\nimportExtracts:\n  - file:\
      \ \"/types/CA10__CaAzureAccount__c/object.extracts.yaml\"\ntestData:\n  - file:\
      \ \"test-data.json\"\nconditions:\n      - status: \"INCOMPLIANT\"\n       \
      \ currentStateMessage: \"Microsoft Defender for Endpoint is not enabled.\"\n\
      \        remediationMessage: \"Consider enabling Microsoft Defender for Endpoint.\"\
      \n        check:\n          NOT:\n            arg:\n              JSON_QUERY_BOOLEAN:\n\
      \                arg: \n                  EXTRACT: \"caJsonFrom__defenderForCloudSettings__c\"\
      \n                expression: \"settings[?name == 'WDATP'].enabled | [0]\"\n\
      \                undeterminedIf: \n                  evaluationError: \"The\
      \ JSON query has failed.\"\n                  resultTypeMismatch: \"The JSON\
      \ query did not return text type.\"\n      - status: \"COMPLIANT\"\n       \
      \ currentStateMessage: \"Microsoft Defender for Endpoint is enabled.\"\n   \
      \     check:\n          JSON_QUERY_BOOLEAN:\n            arg: \n           \
      \   EXTRACT: \"caJsonFrom__defenderForCloudSettings__c\"\n            expression:\
      \ \"settings[?name == 'WDATP'].enabled | [0]\"\n            undeterminedIf:\
      \ \n              evaluationError: \"The JSON query has failed.\"\n        \
      \      resultTypeMismatch: \"The JSON query did not return text type.\"\notherwise:\n\
      \  status: \"UNDETERMINED\"\n  currentStateMessage: \"Unexpected value in the\
      \ field.\""
  - path: /types/CA10__CaAzureAccount__c/object.extracts.yaml
    md5Hash: 9C78116D7D6EA5327842D3BC5DCF8980
    content: "---\nextracts:\n# Not Nullable.\n  - name: \"CA10__availableLocationNames__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__availableLocationNames__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__availableLocationNames__c\"\n            currentStateMessage: \"Unable\
      \ to determine Subscription Available Locations. Possible permission issue withMicrosoft.Resources/subscriptions/locations/read\"\
      \n  - name: \"caJsonFrom_availableLocationNames__c\"\n    value:\n      JSON_FROM:\n\
      \        arg:\n          EXTRACT: \"CA10__availableLocationNames__c\"\n    \
      \    undeterminedIf:\n          isInvalid: \"Subscription Available Locations\
      \ JSON is invalid.\"\n  - name: \"CA10__subscriptionId__c\"\n    value: \n \
      \     FIELD:\n        path: \"CA10__subscriptionId__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"Corrupted data. Subscription ID cannot be empty.\"\n#\
      \ Not Nullable\n  - name: \"CA10__securityCenterAutoProvisioning__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__securityCenterAutoProvisioning__c\"\n\
      \        returnType: BYTES\n        undeterminedIf:\n          noAccessDelegate:\n\
      \            path: \"CA10__securityCenterAutoProvisioning__c\"\n           \
      \ currentStateMessage: \"Unable to determine Auto Provisioning Settings. Possible\
      \ permission issue with Microsoft.Security/autoProvisioningSettings\" \n# Not\
      \ Nullable\n  - name: \"CA10__securityCenterContacts__c\"\n    value: \n   \
      \   FIELD:\n        path: \"CA10__securityCenterContacts__c\"\n        returnType:\
      \ BYTES\n        undeterminedIf:\n          noAccessDelegate:\n            path:\
      \ \"CA10__securityCenterContacts__c\"\n            currentStateMessage: \"Unable\
      \ to determine Security Contacts. Possible permission issue with Microsoft.Security/securityContacts\"\
      \ \n  - name: \"caJsonFrom__securityCenterContacts__c\"\n    value: \n     \
      \ JSON_FROM:\n        arg: \n          EXTRACT: \"CA10__securityCenterContacts__c\"\
      \n        undeterminedIf:\n          isInvalid: \"Security Center Contacts JSON\
      \ is invalid.\"\n          isEmpty: \"Unable to determine Security Contacts.\
      \ Possible permission issue with Microsoft.Security/securityContacts\"\n# Security\
      \ Center: Contacts properties.notificationsByRole roles for the default contact\n\
      # notificationsByRoleRoles is a string that contains roles separated by comma\n\
      # Values: AccountAdmin, Contributor, Owner, ServiceAdmin.\n  - name: \"caJsonQueryBoolean__securityCenterContacts_default_roles__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg: \n          EXTRACT: \"\
      caJsonFrom__securityCenterContacts__c\"\n        expression: \"to_string([?\
      \ name == 'default'].notificationsByRoleRoles | [0])\"\n        undeterminedIf:\
      \ \n          evaluationError: \"The JSON query has failed.\"\n          resultTypeMismatch:\
      \ \"The JSON query did not return text type.\"\n# Security Center: Contacts\
      \ properties.notificationsByRole state for the default contact\n# Values: On,\
      \ Off.\n  - name: \"caJsonQueryText__securityCenterContacts_default_state__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg: \n          EXTRACT: \"\
      caJsonFrom__securityCenterContacts__c\"\n        expression: \"[? name == 'default'].notificationsByRoleState\
      \ | [0]\"\n        undeterminedIf: \n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n# Security Center: Contacts email for the default contact\n\
      # email is a string that contains values separated by comma\n  - name: \"caJsonQueryText__securityCenterContacts_default_email__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg: \n          EXTRACT: \"\
      caJsonFrom__securityCenterContacts__c\"\n        expression: \"[? name == 'default'\
      \ && email != ''].email | [0]\"\n        undeterminedIf: \n          evaluationError:\
      \ \"The JSON query has failed.\"\n          resultTypeMismatch: \"The JSON query\
      \ did not return text type.\"\n# Values: On, Off.\n  - name: \"caJsonQueryText__securityCenterContacts_default_alert_notifications__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg: \n          EXTRACT: \"\
      caJsonFrom__securityCenterContacts__c\"\n        expression: \"[? name == 'default'].alertNotifications\
      \ | [0]\"\n        undeterminedIf: \n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n# Values: High, Medium, Low.\n  - name: \"caJsonQueryText__securityCenterContacts_default_alert_notifications_severity__c\"\
      \n    value: \n      JSON_QUERY_TEXT:\n        arg: \n          EXTRACT: \"\
      caJsonFrom__securityCenterContacts__c\"\n        expression: \"[? name == 'default'].alertNotificationsMinimalSeverity\
      \ | [0]\"\n        undeterminedIf: \n          evaluationError: \"The JSON query\
      \ has failed.\"\n          resultTypeMismatch: \"The JSON query did not return\
      \ text type.\"\n# Not Nullable\n  - name: \"CA10__defenderForCloudSettingsJson__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__defenderForCloudSettingsJson__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__defenderForCloudSettingsJson__c\"\n            currentStateMessage: \"\
      Unable to determine Microsoft Defender for Cloud Settings. Possible permission\
      \ issue with Microsoft.Security/settings\" \n  - name: \"caJsonFrom__defenderForCloudSettings__c\"\
      \n    value: \n      JSON_FROM:\n        arg: \n          EXTRACT: \"CA10__defenderForCloudSettingsJson__c\"\
      \n        undeterminedIf:\n          isInvalid: \"Security Center Contacts JSON\
      \ is invalid.\"\n          isEmpty: \"Unable to determine Security Contacts.\
      \ Possible permission issue with Microsoft.Security/settings\""
  - path: /ce/ca/azure/subscription/integration-with-microsoft-defender-for-endpoint/test-data.json
    md5Hash: 434472371BA494A55950ECDD146C784C
    content: |-
      [
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "101",
                  "conditionText": "CA10__defenderForCloudSettingsJson__c.delegatedTo(CA10__defenderForCloudSettingsJson__c).isEmpty()",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-12T08:07:11Z"
              },
              "Id": "test1",
              "CA10__defenderForCloudSettingsJson__c": ""
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-12T08:07:11Z"
              },
              "Id": "test2",
              "CA10__defenderForCloudSettingsJson__c": "{\"settings\":[{\"name\":\"MCAS\",\"enabled\":true},{\"name\":\"WDATP\",\"enabled\":false},{\"name\":\"Sentinel\",\"enabled\":false}]}"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-12T08:07:11Z"
              },
              "Id": "test3",
              "CA10__defenderForCloudSettingsJson__c": "{\"settings\":[{\"name\":\"MCAS\",\"enabled\":true},{\"name\":\"WDATP\",\"enabled\":true},{\"name\":\"Sentinel\",\"enabled\":false}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-12T08:07:11Z"
              },
              "Id": "test4",
              "CA10__defenderForCloudSettingsJson__c": "{\"settings\":[{\"name\":\"Sentinel\",\"enabled\":false}]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-12T08:07:11Z"
              },
              "Id": "test5",
              "CA10__defenderForCloudSettingsJson__c": "{\"settings\":[]}"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-12T08:07:11Z"
              },
              "Id": "test6",
              "CA10__defenderForCloudSettingsJson__c": "{}"
          }
      ]
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" : "UNDETERMINED",
      "conditionIndex" : "101",
      "conditionText" : "CA10__defenderForCloudSettingsJson__c.delegatedTo(CA10__defenderForCloudSettingsJson__c).isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureAccount__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__defenderForCloudSettingsJson__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-12T08:07:11Z")
    },
    "Id" : "test1",
    "CA10__defenderForCloudSettingsJson__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-12T08:07:11Z")
    },
    "Id" : "test2",
    "CA10__defenderForCloudSettingsJson__c" : "{\"settings\":[{\"name\":\"MCAS\",\"enabled\":true},{\"name\":\"WDATP\",\"enabled\":false},{\"name\":\"Sentinel\",\"enabled\":false}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-12T08:07:11Z")
    },
    "Id" : "test3",
    "CA10__defenderForCloudSettingsJson__c" : "{\"settings\":[{\"name\":\"MCAS\",\"enabled\":true},{\"name\":\"WDATP\",\"enabled\":true},{\"name\":\"Sentinel\",\"enabled\":false}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-12T08:07:11Z")
    },
    "Id" : "test4",
    "CA10__defenderForCloudSettingsJson__c" : "{\"settings\":[{\"name\":\"Sentinel\",\"enabled\":false}]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-12T08:07:11Z")
    },
    "Id" : "test5",
    "CA10__defenderForCloudSettingsJson__c" : "{\"settings\":[]}"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-12T08:07:11Z")
    },
    "Id" : "test6",
    "CA10__defenderForCloudSettingsJson__c" : "{}"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureAccount__c(
      obj STRUCT<
          Id STRING,
          CA10__defenderForCloudSettingsJson__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 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]
      if (false) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared()", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function jsonQueryChecked2() {
          var input = extract4.call(extract4);
          var out;
          try {
              out = jmespath.search(input, 'settings[?name == \'WDATP\'].enabled | [0]');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:104", {cause: {status: 'UNDETERMINED', conditionIndex: 104, conditionText: "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return text type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:105", {cause: {status: 'UNDETERMINED', conditionIndex: 105, conditionText: "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked5() {
          var input = extract7.call(extract7);
          if (TextLib.isEmpty(input)) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "extract('CA10__defenderForCloudSettingsJson__c').asJson().isEmpty()", currentStateMessage: "Unable to determine Security Contacts. Possible permission issue with Microsoft.Security/settings", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:103", {cause: {status: 'UNDETERMINED', conditionIndex: 103, conditionText: "extract('CA10__defenderForCloudSettingsJson__c').asJson().isInvalid()", currentStateMessage: "Security Center Contacts JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function fieldChecked8() {
          if ((obj.CA10__defenderForCloudSettingsJson__c == null || obj.CA10__defenderForCloudSettingsJson__c == '')) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__defenderForCloudSettingsJson__c.delegatedTo(CA10__defenderForCloudSettingsJson__c).isEmpty()", currentStateMessage: "Unable to determine Microsoft Defender for Cloud Settings. Possible permission issue with Microsoft.Security/settings", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__defenderForCloudSettingsJson__c;
      }
      function extract7() { if (!this.out) { this.out = fieldChecked8(); } return this.out; };
      function extract4() { if (!this.out) { this.out = jsonChecked5(); } return this.out; };
      references1.push('Defender For Cloud Settings JSON [obj.CA10__defenderForCloudSettingsJson__c]: ' + obj.CA10__defenderForCloudSettingsJson__c);
      try {
          if (!jsonQueryChecked2()) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "not(extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]'))", currentStateMessage: "Microsoft Defender for Endpoint is not enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling Microsoft Defender for Endpoint.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function jsonQueryChecked10() {
          var input = extract12.call(extract12);
          var out;
          try {
              out = jmespath.search(input, 'settings[?name == \'WDATP\'].enabled | [0]');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:204", {cause: {status: 'UNDETERMINED', conditionIndex: 204, conditionText: "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return text type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:205", {cause: {status: 'UNDETERMINED', conditionIndex: 205, conditionText: "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked13() {
          var input = extract15.call(extract15);
          if (TextLib.isEmpty(input)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('CA10__defenderForCloudSettingsJson__c').asJson().isEmpty()", currentStateMessage: "Unable to determine Security Contacts. Possible permission issue with Microsoft.Security/settings", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('CA10__defenderForCloudSettingsJson__c').asJson().isInvalid()", currentStateMessage: "Security Center Contacts JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function fieldChecked16() {
          if ((obj.CA10__defenderForCloudSettingsJson__c == null || obj.CA10__defenderForCloudSettingsJson__c == '')) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__defenderForCloudSettingsJson__c.delegatedTo(CA10__defenderForCloudSettingsJson__c).isEmpty()", currentStateMessage: "Unable to determine Microsoft Defender for Cloud Settings. Possible permission issue with Microsoft.Security/settings", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__defenderForCloudSettingsJson__c;
      }
      function extract15() { if (!this.out) { this.out = fieldChecked16(); } return this.out; };
      function extract12() { if (!this.out) { this.out = jsonChecked13(); } return this.out; };
      try {
          if (jsonQueryChecked10()) {
              return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('caJsonFrom__defenderForCloudSettings__c').jsonQueryText('settings[?name == \\'WDATP\\'].enabled | [0]')", currentStateMessage: "Microsoft Defender for Endpoint is enabled.", 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: 300, 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.CA10__defenderForCloudSettingsJson__c AS CA10__defenderForCloudSettingsJson__c,
          process_CA10__CaAzureAccount__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__defenderForCloudSettingsJson__c AS CA10__defenderForCloudSettingsJson__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureAccount__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
