---
policy: /ce/ca/azure/subscription/microsoft-defender-for-cspm
logic: /ce/ca/azure/subscription/microsoft-defender-for-cspm/prod.logic.yaml
executionTime: 2025-12-17T01:31:20.240103942Z
generationMs: 52
executionMs: 607
rows:
  - id: test1
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(INCOMPLIANT)
      actual: CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(COMPLIANT)
      actual: CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(COMPLIANT)
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/subscription/microsoft-defender-for-cspm/policy.yaml
    md5Hash: F0F84101DEA1051A3AE13EB3C1DA59ED
    content: |
      ---
      names:
        full: Azure Subscription Microsoft Defender CSPM is not set to On
        contextual: Microsoft Defender CSPM is not set to On
      description: "Turning on Microsoft Defender CSPM enables threat detection\
        \ CSPM, providing threat intelligence, anomaly detection, and behavior\
        \ analytics in the Microsoft Defender for Cloud."
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v5.0.0/08/01/01/01"
        - "/frameworks/cloudaware/resource-security/microsoft-defender-configuration"
  - path: /ce/ca/azure/subscription/microsoft-defender-for-cspm/prod.logic.yaml
    md5Hash: DE08F6581E8F935599A1CA5D44005145
    content: "---\ninputType: \"CA10__CaAzureAccount__c\"\ntestData:\n  - file: \"\
      test-data.json\"\nconditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage:\
      \ \"Microsoft Defender CSPM is in Free tier.\"\n    remediationMessage: \"Consider\
      \ enabling Defender CSPM Standard plan.\"\n    check:\n      RELATED_LIST_HAS:\n\
      \        relationshipName: \"CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r\"\
      \n        status: \"INCOMPLIANT\"\n  - status: \"COMPLIANT\"\n    currentStateMessage:\
      \ \"Microsoft Defender CSPM Standard tier is enabled.\"\n    check:\n      RELATED_LIST_HAS:\n\
      \        relationshipName: \"CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r\"\
      \n        status: \"COMPLIANT\"\notherwise:\n  status: \"INCOMPLIANT\"\n  currentStateMessage:\
      \ \"Microsoft Defender CSPM is not enabled.\"\n  remediationMessage: \"Consider\
      \ enabling Microsoft Defender CSPM Standard plan.\"\nrelatedLists:\n  - relationshipName:\
      \ \"CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r\"\n    importExtracts:\n\
      \      - file: \"/types/CA10Z1__CaAzureDefenderPlan__c/object.extracts.yaml\"\
      \n    conditions:\n      - status: \"INAPPLICABLE\"\n        currentStateMessage:\
      \ \"Other pricing configurations.\"\n        check:\n          NOT_EQUAL:\n\
      \            left: \n              EXTRACT: \"CA10Z1__name__c\"\n          \
      \  right: \n              TEXT: \"CloudPosture\"\n      - status: \"COMPLIANT\"\
      \n        currentStateMessage: \"This is a Standard tier.\"\n        check:\n\
      \          IS_EQUAL:\n            left: \n              EXTRACT: \"CA10Z1__pricingTier__c\"\
      \n            right: \n              TEXT: \"Standard\"\n      - status: \"\
      INCOMPLIANT\"\n        currentStateMessage: \"This is a Free tier.\"\n     \
      \   remediationMessage: \"Enable Defender CSPM Standard plan.\"\n        check:\n\
      \          IS_EQUAL:\n            left: \n              EXTRACT: \"CA10Z1__pricingTier__c\"\
      \n            right: \n              TEXT: \"Free\"\n    otherwise: \n     \
      \ status: \"UNDETERMINED\"\n      currentStateMessage: \"Unexpected values in\
      \ the fields.\"\n"
  - path: /ce/ca/azure/subscription/microsoft-defender-for-cspm/test-data.json
    md5Hash: CD3FF3A8F9DEC222938B357ABD0CE8AD
    content: |-
      [
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-10T19:35:50Z"
              },
              "Id": "test1",
              "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r": [
                  {
                      "Id": "test1_1",
                      "CA10Z1__disappearanceTime__c": null,
                      "CA10Z1__pricingTier__c": "Free",
                      "CA10Z1__name__c": "CloudPosture",
                      "CA10Z1__subscription__c": "test1"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-10T19:35:50Z"
              },
              "Id": "test2",
              "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r": [
                  {
                      "Id": "test2_1",
                      "CA10Z1__disappearanceTime__c": null,
                      "CA10Z1__pricingTier__c": "Standard",
                      "CA10Z1__name__c": "CloudPosture",
                      "CA10Z1__subscription__c": "test2"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "300",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-10T19:35:50Z"
              },
              "Id": "test3",
              "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "300",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-10T19:35:50Z"
              },
              "Id": "test4",
              "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r": [
                  {
                      "Id": "test4_1",
                      "CA10Z1__disappearanceTime__c": null,
                      "CA10Z1__pricingTier__c": "Standard",
                      "CA10Z1__name__c": "VirtualMachines",
                      "CA10Z1__subscription__c": "test4"
                  }
              ]
          }
      ]
  - path: /types/CA10Z1__CaAzureDefenderPlan__c/object.extracts.yaml
    md5Hash: 633467A2022A23296CE19EBA90D307C4
    content: "---\n# Not Nullable. Can't have no access, retrieved via Microsoft.Security/pricings\n\
      extracts:\n  - name: \"CA10Z1__name__c\"\n    value: \n      FIELD:\n      \
      \  path: \"CA10Z1__name__c\"\n        undeterminedIf:\n          isEmpty: \"\
      Corrupted data. Name cannot be empty.\"\n# Values: Free, Standard. Not Nullable.\
      \ Can't have no access, retrieved via Microsoft.Security/pricings\n  - name:\
      \ \"CA10Z1__pricingTier__c\"\n    value: \n      FIELD:\n        path: \"CA10Z1__pricingTier__c\"\
      \n        undeterminedIf:\n          isEmpty: \"Corrupted data. Pricing Tier\
      \ cannot be empty.\"\n# Nullable. Text.\n  - name: \"CA10Z1__extensions__c\"\
      \n    value:\n      FIELD:\n        path: \"CA10Z1__extensions__c\"\n      \
      \  returnType: BYTES\n# Nullable.\n  - name: \"caJsonFrom__extensions__c\"\n\
      \    value:\n      JSON_FROM:\n        arg:\n          EXTRACT: \"CA10Z1__extensions__c\"\
      \n        undeterminedIf:\n          isInvalid: \"Extensions JSON is invalid\"\
      \n# Number. ContainerRegistriesVulnerabilityAssessments extension status.\n\
      \  - name: \"caJsonNumber__extensionsContainerRegistriesVulnerabilityAssessmentsIsEnabled__c\"\
      \n    value: \n      JSON_QUERY_NUMBER:\n        arg: \n          EXTRACT: \"\
      caJsonFrom__extensions__c\"\n        expression: \"length([?name=='ContainerRegistriesVulnerabilityAssessments'\
      \ && isEnabled=='True'])\"\n        undeterminedIf: \n          evaluationError:\
      \ \"The JSON query has failed.\"\n          resultTypeMismatch: \"The JSON query\
      \ did not return a number type.\"\n\n\n# Number. AgentlessDiscoveryForKubernetes\
      \ extension status.\n  - name: \"caJsonNumber__extensionsAgentlessDiscoveryForKubernetesIsEnabled__c\"\
      \n    value: \n      JSON_QUERY_NUMBER:\n        arg: \n          EXTRACT: \"\
      caJsonFrom__extensions__c\"\n        expression: \"length([?name=='AgentlessDiscoveryForKubernetes'\
      \ && isEnabled=='True'])\"\n        undeterminedIf: \n          evaluationError:\
      \ \"The JSON query has failed.\"\n          resultTypeMismatch: \"The JSON query\
      \ did not return a number type.\"\n# Number. AgentlessVmScanning extension status.\n\
      \  - name: \"caJsonNumber__extensionsAgentlessVmScanningIsEnabled__c\"\n   \
      \ value: \n      JSON_QUERY_NUMBER:\n        arg: \n          EXTRACT: \"caJsonFrom__extensions__c\"\
      \n        expression: \"length([?name=='AgentlessVmScanning' && isEnabled=='True'])\"\
      \n        undeterminedIf: \n          evaluationError: \"The JSON query has\
      \ failed.\"\n          resultTypeMismatch: \"The JSON query did not return a\
      \ number type.\"\n# Number. ContainerSensor extension status.\n  - name: \"\
      caJsonNumber__extensionsContainerSensorIsEnabled__c\"\n    value: \n      JSON_QUERY_NUMBER:\n\
      \        arg: \n          EXTRACT: \"caJsonFrom__extensions__c\"\n        expression:\
      \ \"length([?name=='ContainerSensor' && isEnabled=='True'])\"\n        undeterminedIf:\
      \ \n          evaluationError: \"The JSON query has failed.\"\n          resultTypeMismatch:\
      \ \"The JSON query did not return a number type.\""
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" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureAccount__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-10T19:35:50Z")
    },
    "Id" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-10T19:35:50Z")
    },
    "Id" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-10T19:35:50Z")
    },
    "Id" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-10T19:35:50Z")
    },
    "Id" : "test4"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureDefenderPlan__c()
  RETURNS ARRAY<STRUCT<
      CA10Z1__disappearanceTime__c TIMESTAMP,
      CA10Z1__name__c STRING,
      CA10Z1__pricingTier__c STRING,
      CA10Z1__subscription__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-10T19:35:50Z")
    },
    "CA10Z1__name__c" : "CloudPosture",
    "CA10Z1__pricingTier__c" : "Free",
    "CA10Z1__subscription__c" : "test1",
    "Id" : "test1_1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-10T19:35:50Z")
    },
    "CA10Z1__name__c" : "CloudPosture",
    "CA10Z1__pricingTier__c" : "Standard",
    "CA10Z1__subscription__c" : "test2",
    "Id" : "test2_1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-10T19:35:50Z")
    },
    "CA10Z1__name__c" : "VirtualMachines",
    "CA10Z1__pricingTier__c" : "Standard",
    "CA10Z1__subscription__c" : "test4",
    "Id" : "test4_1"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureAccount__c(
      obj STRUCT<
          Id STRING,
          CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r ARRAY<STRUCT<
              CA10Z1__disappearanceTime__c TIMESTAMP,
              CA10Z1__name__c STRING,
              CA10Z1__pricingTier__c STRING,
              CA10Z1__subscription__c 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]
      if (false) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared()", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_INCOMPLIANT2 = 0;
      if (obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r != null) {
          for (var i3 = 0; i3 < obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.length; i3++) {
              if (typeof(obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i3].status) !== 'undefined') {
                  if (obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i3].status == 'INCOMPLIANT') {
                      count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_INCOMPLIANT2 += obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i3].count;
                  }
              } else  {
                  if (obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i3].result.status == 'INCOMPLIANT') {
                      count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_INCOMPLIANT2 += 1;
                  }
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r] ' + (count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(INCOMPLIANT)", currentStateMessage: "Microsoft Defender CSPM is in Free tier.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling Defender CSPM Standard plan.", runtimeError: null};
      }
      var count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_COMPLIANT4 = 0;
      if (obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r != null) {
          for (var i5 = 0; i5 < obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.length; i5++) {
              if (typeof(obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i5].status) !== 'undefined') {
                  if (obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i5].status == 'COMPLIANT') {
                      count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_COMPLIANT4 += obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i5].count;
                  }
              } else  {
                  if (obj.CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r[i5].result.status == 'COMPLIANT') {
                      count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_COMPLIANT4 += 1;
                  }
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      if (count_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r_COMPLIANT4 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r.has(COMPLIANT)", currentStateMessage: "Microsoft Defender CSPM Standard tier is enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Microsoft Defender CSPM is not enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling Microsoft Defender CSPM Standard plan.", runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r(
      obj STRUCT<
          CA10Z1__disappearanceTime__c TIMESTAMP,
          CA10Z1__name__c STRING,
          CA10Z1__pricingTier__c STRING,
          CA10Z1__subscription__c 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));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Azure [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c);
      if (obj.CA10Z1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10Z1__name__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10Z1__name__c.isEmpty()", currentStateMessage: "Corrupted data. Name cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10Z1__name__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Name [obj.CA10Z1__name__c]: ' + obj.CA10Z1__name__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'CloudPosture')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10Z1__name__c') != 'CloudPosture'", currentStateMessage: "Other pricing configurations.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10Z1__pricingTier__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10Z1__pricingTier__c.isEmpty()", currentStateMessage: "Corrupted data. Pricing Tier cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10Z1__pricingTier__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      references1.push('Pricing Tier [obj.CA10Z1__pricingTier__c]: ' + obj.CA10Z1__pricingTier__c);
      try {
          if (TextLib.equal(extract6.call(extract6), 'Standard')) {
              return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10Z1__pricingTier__c') == 'Standard'", currentStateMessage: "This is a Standard tier.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10Z1__pricingTier__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10Z1__pricingTier__c.isEmpty()", currentStateMessage: "Corrupted data. Pricing Tier cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10Z1__pricingTier__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      try {
          if (TextLib.equal(extract9.call(extract9), 'Free')) {
              return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10Z1__pricingTier__c') == 'Free'", currentStateMessage: "This is a Free tier.", currentStateReferences: references1.join('\n'), remediation: "Enable Defender CSPM Standard plan.", 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 values in the fields.", 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,
          `CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r`.arr AS CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r,
          process_CA10__CaAzureAccount__c(
              STRUCT(
                  sObject.Id AS Id,
                  `CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r`.arr AS CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureAccount__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10Z1__subscription__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                      sObject.CA10Z1__name__c AS CA10Z1__name__c,
                      sObject.CA10Z1__pricingTier__c AS CA10Z1__pricingTier__c,
                      sObject.CA10Z1__subscription__c AS CA10Z1__subscription__c,
                      sObject.Id AS Id,
                      process_CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r(
                          STRUCT(
                              sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                              sObject.CA10Z1__name__c AS CA10Z1__name__c,
                              sObject.CA10Z1__pricingTier__c AS CA10Z1__pricingTier__c,
                              sObject.CA10Z1__subscription__c AS CA10Z1__subscription__c,
                              sObject.Id AS Id
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10Z1__CaAzureDefenderPlan__c()) AS sObject
          GROUP BY sObject.CA10Z1__subscription__c
      ) AS `CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r`
          ON sObject.Id = `CA10Z1__Azure_SQL_Server_Vulnerability_Assessmnt__r`.CA10Z1__subscription__c
  ) sObject ON sObject.Id = expectedResult.Id;
