---
policy: /ce/ca/azure/storage/soft-delete-for-azure-file-shares
logic: /ce/ca/azure/storage/soft-delete-for-azure-file-shares/prod.logic.yaml
executionTime: 2025-07-21T17:38:58.246565544Z
rows:
  - id: '001'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled'
        || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()
      actual: extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled'
        || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled'
        || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()
      actual: extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled'
        || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Enabled'
        && extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isNotEmpty()
      actual: extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Enabled'
        && extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isNotEmpty()
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/storage/soft-delete-for-azure-file-shares/policy.yaml
    md5Hash: 9F7346CF2B1B17298556564498A96840
    content: |
      ---
      names:
        full: "Azure Storage File Shares Soft Delete is not enabled"
        contextual: "File Shares Soft Delete is not enabled"
      description: "Azure Files offers soft delete for file shares, allowing you to easily recover your data\
        \ when it is mistakenly deleted by an application or another storage account user."
      type: BEST_PRACTICE
      categories:
        - RELIABILITY
      frameworkMappings:
        - "/frameworks/cis-azure-v4.0.0/10/01/01"
        - "/frameworks/cloudaware/resource-security/data-protection-and-recovery"
  - path: /ce/ca/azure/storage/soft-delete-for-azure-file-shares/prod.logic.yaml
    md5Hash: B3E56CFD1314521D1F195B2DE77FE669
    content: |
      ---
      inputType: "CA10Z1__CaAzureStorageFile__c"
      testData:
        - file: test-data.json
      importExtracts:
        - file: /types/CA10Z1__CaAzureStorageFile__c/object.extracts.yaml
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "The soft delete configuration for Azure Files is not enabled."
          remediationMessage: "Consider enabling soft delete for Azure Files."
          check:
            OR:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10Z1__shareDeleteRetentionPolicyStatus__c"
                    right:
                      TEXT: "Disabled"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10Z1__shareDeleteRetentionPolicyStatus__c"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10Z1__shareDeleteRetentionPolicyDays__c"
        - status: "COMPLIANT"
          currentStateMessage: "The soft delete for Azure Files is enabled."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10Z1__shareDeleteRetentionPolicyStatus__c"
                    right:
                      TEXT: "Enabled"
                - NOT_EMPTY:
                    arg:
                      EXTRACT: "CA10Z1__shareDeleteRetentionPolicyDays__c"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected values in the fields."
  - path: /ce/ca/azure/storage/soft-delete-for-azure-file-shares/test-data.json
    md5Hash: 5C4E7644B11598E8E8ACD5017BCD4D8B
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled' || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "001",
          "CA10Z1__shareDeleteRetentionPolicyStatus__c": "",
          "CA10Z1__shareDeleteRetentionPolicyDays__c": null
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled' || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "002",
          "CA10Z1__shareDeleteRetentionPolicyStatus__c": "Disabled",
          "CA10Z1__shareDeleteRetentionPolicyDays__c": 0
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Enabled' && extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isNotEmpty()",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-03T06:52:36Z" },
          "Id": "003",
          "CA10Z1__shareDeleteRetentionPolicyStatus__c": "Enabled",
          "CA10Z1__shareDeleteRetentionPolicyDays__c": 7
        }
      ]
  - path: /types/CA10Z1__CaAzureStorageFile__c/object.extracts.yaml
    md5Hash: 710D57682B15A41C11105284C265F338
    content: "---\nextracts:\n# Nullable. Text field. Valid values are AES-128-CCM,\
      \ AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'\n\
      \  - name: \"CA10Z1__protocolSettingsSmbChannelEncrypt__c\"\n    value: \n \
      \     FIELD:\n        path: \"CA10Z1__protocolSettingsSmbChannelEncrypt__c\"\
      \n# Nullable, when Null, then the default maximum compatibility is set. \n#\
      \ Text field. Valid values are SMB2.1, SMB3.0, SMB3.1.1. Should be passed as\
      \ a string with delimiter ';'.\n  - name: \"CA10Z1__protocolSettingsSmbVersions__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10Z1__protocolSettingsSmbVersions__c\"\
      \n# Nullable. Text field.\n  - name: \"CA10Z1__shareDeleteRetentionPolicyStatus__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10Z1__shareDeleteRetentionPolicyStatus__c\"\
      \n# Nullable. Number field.\n  - name: \"CA10Z1__shareDeleteRetentionPolicyDays__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10Z1__shareDeleteRetentionPolicyDays__c\"\
      \        \n\n\n\n\n\n        \n\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('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled' || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled' || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Enabled' && extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isNotEmpty()",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureStorageFile__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10Z1__shareDeleteRetentionPolicyStatus__c STRING,
      CA10Z1__shareDeleteRetentionPolicyDays__c FLOAT64,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "001",
    "CA10Z1__shareDeleteRetentionPolicyStatus__c" : "",
    "CA10Z1__shareDeleteRetentionPolicyDays__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "002",
    "CA10Z1__shareDeleteRetentionPolicyStatus__c" : "Disabled",
    "CA10Z1__shareDeleteRetentionPolicyDays__c" : 0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-03T06:52:36Z")
    },
    "Id" : "003",
    "CA10Z1__shareDeleteRetentionPolicyStatus__c" : "Enabled",
    "CA10Z1__shareDeleteRetentionPolicyDays__c" : 7
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10Z1__CaAzureStorageFile__c(
      obj STRUCT<
          Id STRING,
          CA10Z1__shareDeleteRetentionPolicyStatus__c STRING,
          CA10Z1__shareDeleteRetentionPolicyDays__c FLOAT64
      >,
      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 IsEmptyLib = new function () {
          this.simpleIsEmpty = function(arg) {
              return arg == null;
          };
          this.simpleIsNotEmpty = function(arg) {
              return arg != null;
          };
      }();
      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.CA10Z1__shareDeleteRetentionPolicyStatus__c; } return this.out; };
      function extract7() { if (!this.out) { this.out = obj.CA10Z1__shareDeleteRetentionPolicyDays__c; } return this.out; };
      references1.push('Share Delete Retention Policy: Status [obj.CA10Z1__shareDeleteRetentionPolicyStatus__c]: ' + obj.CA10Z1__shareDeleteRetentionPolicyStatus__c);
      references1.push('Share Delete Retention Policy: Days [obj.CA10Z1__shareDeleteRetentionPolicyDays__c]: ' + obj.CA10Z1__shareDeleteRetentionPolicyDays__c);
      if (TextLib.equal(extract3.call(extract3), 'Disabled') || TextLib.isEmpty(extract3.call(extract3)) || IsEmptyLib.simpleIsEmpty(extract7.call(extract7))) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Disabled' || extract('CA10Z1__shareDeleteRetentionPolicyStatus__c').isEmpty() || extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isEmpty()", currentStateMessage: "The soft delete configuration for Azure Files is not enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling soft delete for Azure Files.", runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract10() { if (!this.out) { this.out = obj.CA10Z1__shareDeleteRetentionPolicyStatus__c; } return this.out; };
      function extract13() { if (!this.out) { this.out = obj.CA10Z1__shareDeleteRetentionPolicyDays__c; } return this.out; };
      if (TextLib.equal(extract10.call(extract10), 'Enabled') && IsEmptyLib.simpleIsNotEmpty(extract13.call(extract13))) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10Z1__shareDeleteRetentionPolicyStatus__c') == 'Enabled' && extract('CA10Z1__shareDeleteRetentionPolicyDays__c').isNotEmpty()", currentStateMessage: "The soft delete for Azure Files is enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 300, 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,
          sObject.CA10Z1__shareDeleteRetentionPolicyStatus__c AS CA10Z1__shareDeleteRetentionPolicyStatus__c,
          sObject.CA10Z1__shareDeleteRetentionPolicyDays__c AS CA10Z1__shareDeleteRetentionPolicyDays__c,
          process_CA10Z1__CaAzureStorageFile__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10Z1__shareDeleteRetentionPolicyStatus__c AS CA10Z1__shareDeleteRetentionPolicyStatus__c,
                  sObject.CA10Z1__shareDeleteRetentionPolicyDays__c AS CA10Z1__shareDeleteRetentionPolicyDays__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10Z1__CaAzureStorageFile__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
