---
policy: /ce/ca/azure/storage/disable-shared-key-access
logic: /ce/ca/azure/storage/disable-shared-key-access/prod.logic.yaml
executionTime: 2025-07-21T17:38:39.436664766Z
rows:
  - id: '001'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__sharedKeyAccess__c') == 'Deny'
      actual: extract('CA10__sharedKeyAccess__c') == 'Deny'
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/storage/disable-shared-key-access/policy.yaml
    md5Hash: F9249305DA7289308C9E89E9DA444A37
    content: |
      ---
      names:
        full: "Azure Storage Account Shared Key Access is not disabled"
        contextual: "Shared Key Access is not disabled"
      description: "Every secure request to an Azure Storage account must be authorized.\
        \ By default, requests can be authorized with either Microsoft Entra credentials\
        \ or by using the account access key for Shared Key authorization."
      type: BEST_PRACTICE
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v4.0.0/10/03/01/03"
        - "/frameworks/cloudaware/resource-security/secure-access"
  - path: /ce/ca/azure/storage/disable-shared-key-access/prod.logic.yaml
    md5Hash: F6356E670450B3FE58E89F09DEB36C86
    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: \"COMPLIANT\"\n    currentStateMessage: \"Shared key\
      \ access for Azure Storage Account is forbidden.\"\n    check:\n      IS_EQUAL:\n\
      \        left:\n          EXTRACT: \"CA10__sharedKeyAccess__c\"\n        right:\n\
      \          TEXT: \"Deny\"\notherwise:\n  status: \"INCOMPLIANT\"\n  currentStateMessage:\
      \ \"The storage account permits requests that are authorized with the Shared\
      \ Key.\"\n  remediationMessage: \"Disable shared key access for Azure Storage\
      \ Account.\"\n  "
  - path: /ce/ca/azure/storage/disable-shared-key-access/test-data.json
    md5Hash: 3AD9EB26F3E24D01C0AF43A704B00696
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-01T17:36:53Z" },
          "Id": "001",
          "RecordTypeId": "01236000000601XAAQ",
          "CA10__disappearanceTime__c": null,
          "CA10__sharedKeyAccess__c": "",
          "RecordType": {
            "DeveloperName": "caAzureRMStorageAccount",
            "Id": "01236000000601XAAQ"
          }
        },
          {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-01T17:36:53Z" },
          "Id": "002",
          "RecordTypeId": "01236000000601XAAQ",
          "CA10__disappearanceTime__c": null,
          "CA10__sharedKeyAccess__c": "Allow",
          "RecordType": {
            "DeveloperName": "caAzureRMStorageAccount",
            "Id": "01236000000601XAAQ"
          }
        },
            {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10__sharedKeyAccess__c') == 'Deny'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-01T17:36:53Z" },
          "Id": "003",
          "RecordTypeId": "01236000000601XAAQ",
          "CA10__disappearanceTime__c": null,
          "CA10__sharedKeyAccess__c": "Deny",
          "RecordType": {
            "DeveloperName": "caAzureRMStorageAccount",
            "Id": "01236000000601XAAQ"
          }
        }
      ]
  - path: /types/CA10__CaAzureStorageAccount__c/object.extracts.yaml
    md5Hash: B232DB23A5A5C67EC61EB2635C4A515D
    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# Nullable. Text field.\n  -\
      \ name: \"CA10__defaultToOAuthAuthentication__c\"\n    value:\n      FIELD:\n\
      \        path: \"CA10__defaultToOAuthAuthentication__c\"\n# Nullable. Text field.\n\
      \  - name: \"CA10__sharedKeyAccess__c\"\n    value:\n      FIELD:\n        path:\
      \ \"CA10__sharedKeyAccess__c\"\n# Nullable. Text field.\n  - name: \"CA10__blobVersioning__c\"\
      \n    value:\n      FIELD:\n        path: \"CA10__blobVersioning__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" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__sharedKeyAccess__c') == 'Deny'",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureStorageAccount__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__sharedKeyAccess__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-01T17:36:53Z")
    },
    "Id" : "001",
    "RecordTypeId" : "01236000000601XAAQ",
    "CA10__sharedKeyAccess__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-01T17:36:53Z")
    },
    "Id" : "002",
    "RecordTypeId" : "01236000000601XAAQ",
    "CA10__sharedKeyAccess__c" : "Allow"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-01T17:36:53Z")
    },
    "Id" : "003",
    "RecordTypeId" : "01236000000601XAAQ",
    "CA10__sharedKeyAccess__c" : "Deny"
  } ];
  """;

  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-07-01T17:36:53Z")
    },
    "DeveloperName" : "caAzureRMStorageAccount",
    "Id" : "01236000000601XAAQ"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureStorageAccount__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__sharedKeyAccess__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));
          };
          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__sharedKeyAccess__c; } return this.out; };
      references1.push('Shared Key Access [obj.CA10__sharedKeyAccess__c]: ' + obj.CA10__sharedKeyAccess__c);
      if (TextLib.equal(extract3.call(extract3), 'Deny')) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__sharedKeyAccess__c') == 'Deny'", currentStateMessage: "Shared key access for Azure Storage Account is forbidden.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The storage account permits requests that are authorized with the Shared Key.", currentStateReferences: references1.join('\n'), remediation: "Disable shared key access for Azure Storage Account.", 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__sharedKeyAccess__c AS CA10__sharedKeyAccess__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__sharedKeyAccess__c AS CA10__sharedKeyAccess__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;
