---
policy: /ce/ca/azure/storage/locally-redundant-storage
logic: /ce/ca/azure/storage/locally-redundant-storage/prod.logic.yaml
executionTime: 2025-05-10T12:03:15.391184472Z
rows:
  - id: 111
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__skuName__c').endsWith('LRS')
      actual: extract('CA10__skuName__c').endsWith('LRS')
    runtimeError: {}
  - id: 222
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/storage/locally-redundant-storage/policy.yaml
    md5Hash: EB5F93241FF96BDED4C70CD8D8B6EF09
    content: "---\nnames:\n  full: \"Azure Storage Account uses Locally Redundant\
      \ Storage replication option\"\n  contextual: \"Storage Account uses Locally\
      \ Redundant Storage replication option\"\ndescription: >\n  Consider switching\
      \ Storage Account SKU to the recommended zone-redundant storage (ZRS), \n  geo-redundant\
      \ storage (GRS), or geo-zone-redundant storage (GZRS).\n  LRS is the lowest-cost\
      \ redundancy option and offers the least durability \n  compared to other options.\n\
      categories:\n  - \"RELIABILITY\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\n"
  - path: /ce/ca/azure/storage/locally-redundant-storage/prod.logic.yaml
    md5Hash: A5DB5B03F0C90513AF08113DEE60BBE3
    content: "---\ninputType: \"CA10__CaAzureStorageAccount__c\"\ntestData:\n  - file:\
      \ test-data.json\nimportExtracts:\n  - file: /types/CA10__CaAzureStorageAccount__c/object.extracts.yaml\n\
      conditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"The Storage\
      \ Account is configured to use Locally Redundant Storage.\"\n    remediationMessage:\
      \ \"Consider changing redundancy configuration to one of \n      \\ the recommended\
      \ options (ZRS, GRS, or GZRS).\"\n    check:\n      ENDS_WITH:\n        arg:\n\
      \          EXTRACT: \"CA10__skuName__c\"\n        suffix:\n          TEXT: \"\
      LRS\"\notherwise:\n  status: \"COMPLIANT\"\n  currentStateMessage: \"The Storage\
      \ Account is not configured to use LRS.\""
  - path: /types/CA10__CaAzureStorageAccount__c/object.extracts.yaml
    md5Hash: 2E0979CA85C35CDB555F32B262F6942F
    content: "---\nextracts:\n# This is a checkbox. Not nullable. Can't have no access,\
      \ retrieved via Microsoft.Storage/storageAccounts\n  - name: \"CA10__secureTransferRequired__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__secureTransferRequired__c\"\
      \n# Values: Enabled, Disabled. Not Nullable. Can't have no access, retrieved\
      \ via Microsoft.Storage/storageAccounts\n  - name: \"CA10__requireInfrastructureEncryptionState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__requireInfrastructureEncryptionState__c\"\
      \n        undeterminedIf:\n          isEmpty: \"Corrupted data. Require Infrastructure\
      \ Encryption setting cannot be empty.\"\n# Values: Enabled, Disabled. Not Nullable.\
      \ Can't have no access, retrieved via Microsoft.Storage/storageAccounts\n  -\
      \ name: \"CA10__publicNetworkAccessState__c\"\n    value: \n      FIELD:\n \
      \       path: \"CA10__publicNetworkAccessState__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"Corrupted data. Public Network Access cannot be empty.\"\
      \n# Values: Allow, Deny. Not nullable. Can't have no access, retrieved via Microsoft.Storage/storageAccounts.\n\
      \  - name: \"CA10__networkAclsDefaultAction__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__networkAclsDefaultAction__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"Corrupted data. Default Network Action cannot be empty.\"\
      \n# Values: any combination of Logging|Metrics|AzureServices or None. Not nullable.\
      \ \n# Can't have no access, retrieved via Microsoft.Storage/storageAccounts.\n\
      \  - name: \"CA10__networkAclsBypass__c\"\n    value: \n      FIELD:\n     \
      \   path: \"CA10__networkAclsBypass__c\"\n        undeterminedIf:\n        \
      \  isEmpty: \"Corrupted data. Network Bypass cannot be empty.\"\n# Values TLS1_0,\
      \ TLS1_1, TLS1_2. Not nullable. Can't have no access, retrieved via Microsoft.Storage/storageAccounts.\n\
      \  - name: \"CA10__minimumTlsVersion__c\"\n    value: \n      FIELD:\n     \
      \   path: \"CA10__minimumTlsVersion__c\"\n        undeterminedIf:\n        \
      \  isEmpty: \"Corrupted data. TLS Version cannot be empty.\"\n# Values: Allow,\
      \ Deny, null (Old storage accounts can have null, which means that the account\
      \ can still have replication). \n# Nullable. Can't have no access, retrieved\
      \ via Microsoft.Storage/storageAccounts.\n  - name: \"CA10__crossTenantReplication__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__crossTenantReplication__c\"\
      \n# Values: Allow, Deny. Not nullable. Can't have no access, retrieved via Microsoft.Storage/storageAccounts.\n\
      \  - name: \"CA10__blobPublicAccess__c\"\n    value: \n      FIELD:\n      \
      \  path: \"CA10__blobPublicAccess__c\"\n        undeterminedIf:\n          isEmpty:\
      \ \"Corrupted data. Allow Blob Anonymous Access cannot be empty.\"\n# Values\
      \ Enabled, Disabled. Not Nullable\n  - name: \"CA10__blobLoggingReadState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__blobLoggingReadState__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__blobLoggingReadState__c\"\n            currentStateMessage: \"Unable to\
      \ determine Blob Container Logging Read property. Possible permission issue\
      \ with Microsoft.Storage/storageAccounts/blobServices/containers/read\"\n  \
      \        isEmpty: \"Storage Blob Logging is not populated yet.\"\n# Values Enabled,\
      \ Disabled. Not Nullable\n  - name: \"CA10__blobLoggingWriteState__c\"\n   \
      \ value: \n      FIELD:\n        path: \"CA10__blobLoggingWriteState__c\"\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__blobLoggingWriteState__c\"\n            currentStateMessage: \"Unable\
      \ to determine Blob Container Logging Write property. Possible permission issue\
      \ with Microsoft.Storage/storageAccounts/blobServices/containers/read\"\n  \
      \        isEmpty: \"Storage Blob Logging is not populated yet.\"\n # Values\
      \ Enabled, Disabled. Not Nullable\n  - name: \"CA10__blobLoggingDeleteState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__blobLoggingDeleteState__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__blobLoggingDeleteState__c\"\n            currentStateMessage: \"Unable\
      \ to determine Blob Container Logging Delete property. Possible permission issue\
      \ with Microsoft.Storage/storageAccounts/blobServices/containers/read\"\n  \
      \        isEmpty: \"Storage Blob Logging is not populated yet.\"\n# Values Enabled,\
      \ Disabled. Not Nullable\n  - name: \"CA10__queueLoggingReadState__c\"\n   \
      \ value: \n      FIELD:\n        path: \"CA10__queueLoggingReadState__c\"\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__queueLoggingReadState__c\"\n            currentStateMessage: \"Unable\
      \ to determine Queue Logging Read property. Possible permission issue with Microsoft.Storage/storageAccounts/queueServices/queues/read\"\
      \n          isEmpty: \"Storage Queue Logging is not populated yet.\"\n# Values\
      \ Enabled, Disabled. Not Nullable\n  - name: \"CA10__queueLoggingWriteState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__queueLoggingWriteState__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__queueLoggingWriteState__c\"\n            currentStateMessage: \"Unable\
      \ to determine Queue Logging Write property. Possible permission issue with\
      \ Microsoft.Storage/storageAccounts/queueServices/queues/read\"\n          isEmpty:\
      \ \"Storage Queue Logging is not populated yet.\"\n# Values Enabled, Disabled.\
      \ Not Nullable\n  - name: \"CA10__queueLoggingDeleteState__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__queueLoggingDeleteState__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__queueLoggingDeleteState__c\"\
      \n            currentStateMessage: \"Unable to determine Queue Logging Delete\
      \ property. Possible permission issue with Microsoft.Storage/storageAccounts/queueServices/queues/read\"\
      \n          isEmpty: \"Storage Queue Logging is not populated yet.\"\n# Values\
      \ Enabled, Disabled. Not Nullable\n  - name: \"CA10__tableLoggingReadState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__tableLoggingReadState__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__tableLoggingReadState__c\"\n            currentStateMessage: \"Unable\
      \ to determine Table Logging Read property. Possible permission issue with Microsoft.Storage/storageAccounts/tableServices/tables/read\"\
      \n          isEmpty: \"Storage Table Logging is not populated yet.\"\n# Values\
      \ Enabled, Disabled. Not Nullable\n  - name: \"CA10__tableLoggingWriteState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__tableLoggingWriteState__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__tableLoggingWriteState__c\"\n            currentStateMessage: \"Unable\
      \ to determine Table Logging Write property. Possible permission issue with\
      \ Microsoft.Storage/storageAccounts/tableServices/tables/read\"\n          isEmpty:\
      \ \"Storage Table Logging is not populated yet.\"\n# Values Enabled, Disabled.\
      \ Not Nullable\n  - name: \"CA10__tableLoggingDeleteState__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__tableLoggingDeleteState__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__tableLoggingDeleteState__c\"\
      \n            currentStateMessage: \"Unable to determine Table Logging Delete\
      \ property. Possible permission issue with Microsoft.Storage/storageAccounts/tableServices/tables/read\"\
      \n          isEmpty: \"Storage Table Logging is not populated yet.\"\n# Values\
      \ Microsoft.Storage, Microsoft.Keyvault. Not Nullable. Can't have no access,\
      \ retrieved via Microsoft.Storage/storageAccounts\n  - name: \"CA10__encryptionKeySource__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__encryptionKeySource__c\"\n\
      \        undeterminedIf:\n          isEmpty: \"Corrupted data. Encryption Key\
      \ Source cannot be empty.\"\n# Nullable. Can't have no access, retrieved via\
      \ Microsoft.Storage/storageAccounts\n  - name: \"CA10__encryptionKeyVaultUri__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__encryptionKeyVaultUri__c\"\
      \n# Nullable. \n  - name: \"CA10__blobRetentionPolicyDays__c\"\n    value: \n\
      \      FIELD:\n        path: \"CA10__blobRetentionPolicyDays__c\"\n# Values:\
      \ Enabled, Disabled. Nullable. \n  - name: \"CA10__blobRetentionPolicyState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__blobRetentionPolicyState__c\"\
      \n# Nullable. \n  - name: \"CA10__containerRetentionPolicyDays__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__containerRetentionPolicyDays__c\"\n\
      # Values: Enabled, Disabled. Nullable. \n  - name: \"CA10__containerRetentionPolicyState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__containerRetentionPolicyState__c\"\
      \n# Nullable. Text field.\n  - name: \"CA10__skuName__c\"\n    value:\n    \
      \  FIELD:\n        path: \"CA10__skuName__c\"\n"
  - path: /ce/ca/azure/storage/locally-redundant-storage/test-data.json
    md5Hash: 10C8BD197387AC183C7A12A488884AE1
    content: |-
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__skuName__c').endsWith('LRS')",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-03-26T11:02:25Z"
          },
          "Id": "111",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "CA10__skuName__c": "Premium_LRS",
          "RecordType": {
            "DeveloperName": "caAzureRMStorageAccount",
            "Id": "RecordTypeId"
          }
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-03-26T11:02:25Z"
          },
          "Id": "222",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "CA10__skuName__c": "Standard_RAGRS",
          "RecordType": {
            "DeveloperName": "caAzureRMStorageAccount",
            "Id": "RecordTypeId"
          }
        }
      ]
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" : "111",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__skuName__c').endsWith('LRS')",
      "runtimeError" : null
    }
  }, {
    "Id" : "222",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureStorageAccount__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__skuName__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-03-26T11:02:25Z")
    },
    "Id" : "111",
    "RecordTypeId" : "RecordTypeId",
    "CA10__skuName__c" : "Premium_LRS"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-03-26T11:02:25Z")
    },
    "Id" : "222",
    "RecordTypeId" : "RecordTypeId",
    "CA10__skuName__c" : "Standard_RAGRS"
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      DeveloperName STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-03-26T11:02:25Z")
    },
    "DeveloperName" : "caAzureRMStorageAccount",
    "Id" : "RecordTypeId"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureStorageAccount__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__skuName__c STRING,
          RecordType STRUCT<
              DeveloperName 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));
          };
      }();
      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__skuName__c; } return this.out; };
      references1.push('SKU Name [obj.CA10__skuName__c]: ' + obj.CA10__skuName__c);
      if (TextLib.endsWith(extract3.call(extract3), 'LRS')) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__skuName__c').endsWith('LRS')", currentStateMessage: "The Storage Account is configured to use Locally Redundant Storage.", currentStateReferences: references1.join('\n'), remediation: "Consider changing redundancy configuration to one of  the recommended options (ZRS, GRS, or GZRS).", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The Storage Account is not configured to use LRS.", 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.RecordTypeId AS RecordTypeId,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__skuName__c AS CA10__skuName__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          process_CA10__CaAzureStorageAccount__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__skuName__c AS CA10__skuName__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureStorageAccount__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
  ) sObject ON sObject.Id = expectedResult.Id;
