---
policy: /ce/ca/azure/microsoft-entra-id/security-defaults
logic: /ce/ca/azure/microsoft-entra-id/security-defaults/prod.logic.yaml
executionTime: 2025-12-17T01:31:06.807035546Z
generationMs: 49
executionMs: 536
rows:
  - id: '001'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__securityDefaultsEnforcementPolicy__c').isEmpty()
      actual: extract('CA10__securityDefaultsEnforcementPolicy__c').isEmpty()
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Disabled'
      actual: extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Disabled'
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Enabled'
      actual: extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Enabled'
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/microsoft-entra-id/security-defaults/policy.yaml
    md5Hash: 03B879CAAA9056FECF5C567F65B63488
    content: |
      ---
      names:
        full: Microsoft Entra ID Security Defaults are not enabled
        contextual: Security Defaults are not enabled
      description: >
        Security defaults in Microsoft Entra ID make it easier to be secure and
        help protect your organization. Security defaults contain preconfigured security settings
        for common attacks.
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v5.0.0/05/01/01"
        - "/frameworks/cloudaware/identity-and-access-governance/general-access-controls"
      similarPolicies:
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/ActiveDirectory/security-defaults-enabled.html
            name: Enable Security Defaults
  - path: /ce/ca/azure/microsoft-entra-id/security-defaults/prod.logic.yaml
    md5Hash: 5548727ADC8B309B06A9956D83E21290
    content: |
      ---
      inputType: "CA10__CaAzureActiveDirectory__c"
      testData:
        - file: "test-data.json"
      importExtracts:
        - file: "/types/CA10__CaAzureActiveDirectory__c/object.extracts.yaml"
      conditions:
            - status: "INCOMPLIANT"
              currentStateMessage: "Security defaults are not enabled for the Active Directory."
              remediationMessage: "Enable Security defaults for Active Directory"
              check:
                IS_EMPTY:
                  arg:
                    EXTRACT: "CA10__securityDefaultsEnforcementPolicy__c"
            - status: "INCOMPLIANT"
              currentStateMessage: "Security defaults are disabled for the Active Directory."
              remediationMessage: "Enable Security defaults for Active Directory"
              check:
                IS_EQUAL:
                  left:
                    EXTRACT: "CA10__securityDefaultsEnforcementPolicy__c"
                  right:
                    TEXT: "Disabled"
            - status: "COMPLIANT"
              currentStateMessage: "Security defaults are enabled for the Active Directory."
              check:
                IS_EQUAL:
                  left:
                    EXTRACT: "CA10__securityDefaultsEnforcementPolicy__c"
                  right:
                    TEXT: "Enabled"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected Security Defaults state value."
  - path: /ce/ca/azure/microsoft-entra-id/security-defaults/test-data.json
    md5Hash: 6472B54D3DAA321D14DB02171EDDCD49
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__securityDefaultsEnforcementPolicy__c').isEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-14T05:59:27Z" },
          "CA10__securityDefaultsEnforcementPolicy__c": "",
          "Id": "001"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Disabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-14T05:59:27Z" },
          "CA10__securityDefaultsEnforcementPolicy__c": "Disabled",
          "Id": "002"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Enabled'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-14T05:59:27Z" },
          "CA10__securityDefaultsEnforcementPolicy__c": "Enabled",
          "Id": "003"
        }
      ]
  - path: /types/CA10__CaAzureActiveDirectory__c/object.extracts.yaml
    md5Hash: E7567F00A5ABA5CE30D1D71042DB9FF5
    content: "---\nextracts:\n# Text. Nullable\n  - name: \"CA10__securityDefaultsEnforcementPolicy__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__securityDefaultsEnforcementPolicy__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" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__securityDefaultsEnforcementPolicy__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Disabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Enabled'",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureActiveDirectory__c()
  RETURNS ARRAY<STRUCT<
      CA10__securityDefaultsEnforcementPolicy__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-11-14T05:59:27Z")
    },
    "CA10__securityDefaultsEnforcementPolicy__c" : "",
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-14T05:59:27Z")
    },
    "CA10__securityDefaultsEnforcementPolicy__c" : "Disabled",
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-14T05:59:27Z")
    },
    "CA10__securityDefaultsEnforcementPolicy__c" : "Enabled",
    "Id" : "003"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureActiveDirectory__c(
      obj STRUCT<
          CA10__securityDefaultsEnforcementPolicy__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]
      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 extract3() { if (!this.out) { this.out = obj.CA10__securityDefaultsEnforcementPolicy__c; } return this.out; };
      references1.push('Security Defaults Enforcement Policy [obj.CA10__securityDefaultsEnforcementPolicy__c]: ' + obj.CA10__securityDefaultsEnforcementPolicy__c);
      if (TextLib.isEmpty(extract3.call(extract3))) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__securityDefaultsEnforcementPolicy__c').isEmpty()", currentStateMessage: "Security defaults are not enabled for the Active Directory.", currentStateReferences: references1.join('\n'), remediation: "Enable Security defaults for Active Directory", runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__securityDefaultsEnforcementPolicy__c; } return this.out; };
      if (TextLib.equal(extract6.call(extract6), 'Disabled')) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Disabled'", currentStateMessage: "Security defaults are disabled for the Active Directory.", currentStateReferences: references1.join('\n'), remediation: "Enable Security defaults for Active Directory", runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract9() { if (!this.out) { this.out = obj.CA10__securityDefaultsEnforcementPolicy__c; } return this.out; };
      if (TextLib.equal(extract9.call(extract9), 'Enabled')) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__securityDefaultsEnforcementPolicy__c') == 'Enabled'", currentStateMessage: "Security defaults are enabled for the Active Directory.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected Security Defaults 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__securityDefaultsEnforcementPolicy__c AS CA10__securityDefaultsEnforcementPolicy__c,
          sObject.Id AS Id,
          process_CA10__CaAzureActiveDirectory__c(
              STRUCT(
                  sObject.CA10__securityDefaultsEnforcementPolicy__c AS CA10__securityDefaultsEnforcementPolicy__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureActiveDirectory__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
