---
policy: /ce/ca/azure/microsoft-entra-id/multi-factor-auth-status
logic: /ce/ca/azure/microsoft-entra-id/multi-factor-auth-status/prod.logic.yaml
executionTime: 2025-12-17T01:31:06.707232389Z
generationMs: 60
executionMs: 658
rows:
  - id: '001'
    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: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__mfaState__c') == 'disabled'
      actual: extract('CA10__mfaState__c') == 'disabled'
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__mfaState__c') == 'enabled'
      actual: extract('CA10__mfaState__c') == 'enabled'
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/microsoft-entra-id/multi-factor-auth-status/policy.yaml
    md5Hash: BD15DCA2876201F5025845B5C8CFE151
    content: |
      ---
      names:
        full: Microsoft Entra ID User Multi-Factor Auth Status is not enabled
        contextual: Users Multi-Factor Auth Status is not enabled
      description: "Enable multi-factor authentication for all roles, groups, and users\
        \ that have write access or permissions to Azure resources. These include custom\
        \ created objects or built-in roles such as: Service Co-Administrators, Subscription\
        \ Owners Contributors"
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v5.0.0/05/01/02"
        - "/frameworks/cloudaware/identity-and-access-governance/mfa-implementation"
      similarPolicies:
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/ActiveDirectory/multi-factor-authentication-for-all-privileged-users.html
            name: Multi-factor Authentication For All Privileged Users
  - path: /ce/ca/azure/microsoft-entra-id/multi-factor-auth-status/prod.logic.yaml
    md5Hash: 932837A5092A962257EE577F6C5F9750
    content: |
      ---
      inputType: "CA10__CaAzureActiveDirectoryUser__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10__CaAzureActiveDirectoryUser__c/object.extracts.yaml"
      conditions:
            - status: "INCOMPLIANT"
              currentStateMessage: "MFA is not enabled for the Active Directory User."
              remediationMessage: "Enable MFA for the Active Directory User."
              check:
                IS_EMPTY:
                  arg:
                    EXTRACT: "CA10__mfaState__c"
            - status: "INCOMPLIANT"
              currentStateMessage: "MFA is disabled for the Active Directory User."
              remediationMessage: "Enable MFA for the Active Directory User."
              check:
                IS_EQUAL:
                  left:
                    EXTRACT: "CA10__mfaState__c"
                  right:
                    TEXT: "disabled"
            - status: "COMPLIANT"
              currentStateMessage: "MFA is enabled for the Active Directory User."
              check:
                IS_EQUAL:
                  left:
                    EXTRACT: "CA10__mfaState__c"
                  right:
                    TEXT: "enabled"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected MFA state value."
  - path: /ce/ca/azure/microsoft-entra-id/multi-factor-auth-status/test-data.json
    md5Hash: EA29BADDBE6CF36873F73039B3382B9B
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-14T05:59:27Z" },
          "CA10__disappearanceTime__c": "2025-11-07T18:56:04Z",
          "CA10__mfaState__c": "disabled",
          "Id": "001"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10__mfaState__c') == 'disabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-14T05:59:27Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__mfaState__c": "disabled",
          "Id": "002"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10__mfaState__c') == 'enabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-14T05:59:27Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__mfaState__c": "enabled",
          "Id": "003"
        }
      ]
  - path: /types/CA10__CaAzureActiveDirectoryUser__c/object.extracts.yaml
    md5Hash: EE0D37AA0DF91ABABC5EAAA073C15925
    content: "---\nextracts:\n# Text. Nullable\n  - name: \"CA10__mfaState__c\"\n\
      \    value: \n      FIELD:\n        path: \"CA10__mfaState__c\"\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__mfaState__c') == 'disabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__mfaState__c') == 'enabled'",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureActiveDirectoryUser__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__mfaState__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-11-14T05:59:27Z")
    },
    "CA10__disappearanceTime__c" : new Date("2025-11-07T18:56:04Z"),
    "CA10__mfaState__c" : "disabled",
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-14T05:59:27Z")
    },
    "CA10__mfaState__c" : "disabled",
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-14T05:59:27Z")
    },
    "CA10__mfaState__c" : "enabled",
    "Id" : "003"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureActiveDirectoryUser__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__mfaState__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 [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function extract3() { if (!this.out) { this.out = obj.CA10__mfaState__c; } return this.out; };
      references1.push('MFA State [obj.CA10__mfaState__c]: ' + obj.CA10__mfaState__c);
      if (TextLib.isEmpty(extract3.call(extract3))) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__mfaState__c').isEmpty()", currentStateMessage: "MFA is not enabled for the Active Directory User.", currentStateReferences: references1.join('\n'), remediation: "Enable MFA for the Active Directory User.", runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__mfaState__c; } return this.out; };
      if (TextLib.equal(extract6.call(extract6), 'disabled')) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__mfaState__c') == 'disabled'", currentStateMessage: "MFA is disabled for the Active Directory User.", currentStateReferences: references1.join('\n'), remediation: "Enable MFA for the Active Directory User.", runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract9() { if (!this.out) { this.out = obj.CA10__mfaState__c; } return this.out; };
      if (TextLib.equal(extract9.call(extract9), 'enabled')) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__mfaState__c') == 'enabled'", currentStateMessage: "MFA is enabled for the Active Directory User.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected MFA state value.", 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__mfaState__c AS CA10__mfaState__c,
          sObject.Id AS Id,
          process_CA10__CaAzureActiveDirectoryUser__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__mfaState__c AS CA10__mfaState__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureActiveDirectoryUser__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
