---
policy: /ce/ca/azure/storage/smb-channel-encryption
logic: /ce/ca/azure/storage/smb-channel-encryption/prod.logic.yaml
executionTime: 2025-07-21T17:38:56.201149357Z
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: '004'
    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('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-256-GCM')
        && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-CCM'))
        && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-GCM'))
      actual: extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-256-GCM')
        && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-CCM'))
        && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-GCM'))
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/storage/smb-channel-encryption/policy.yaml
    md5Hash: E6C7CB9D227F71C68090189BFD4FC6B9
    content: "---\nnames:\n  full: \"Azure Storage File Shares SMB Channel Encryption\
      \ is not set to AES-256-GCM or higher\"\n  contextual: \"File Shares SMB Channel\
      \ Encryption is not set to AES-256-GCM or higher\"\ndescription: \"Implement\
      \ SMB channel encryption with AES-256-GCM for SMB file shares to ensure\\ \n\
      \  \\ data confidentiality and integrity in transit. This method offers strong\
      \ protection against\\\n  \\ eavesdropping and man-in-the-middle attacks, safeguarding\
      \ sensitive information.\"\ntype: BEST_PRACTICE\ncategories:\n  - SECURITY\n\
      frameworkMappings:\n  - \"/frameworks/cis-azure-v4.0.0/10/01/03\"\n  - \"/frameworks/cloudaware/resource-security/data-encryption\"\
      \n"
  - path: /ce/ca/azure/storage/smb-channel-encryption/prod.logic.yaml
    md5Hash: 30B80F85392139E72EE0D0381CEF4D28
    content: "---\ninputType: \"CA10Z1__CaAzureStorageFile__c\"\ntestData:\n  - file:\
      \ test-data.json\nimportExtracts:\n  - file: /types/CA10Z1__CaAzureStorageFile__c/object.extracts.yaml\n\
      conditions:\n  - status: \"COMPLIANT\"\n    currentStateMessage: \"SMB channel\
      \ encryption is set to AES-256-GCM.\"\n    check:\n      AND:\n        args:\n\
      \          - CONTAINS:\n              arg:\n                EXTRACT: \"CA10Z1__protocolSettingsSmbChannelEncrypt__c\"\
      \n              search:\n                TEXT: \"AES-256-GCM\"\n          -\
      \ NOT:\n              arg:\n                CONTAINS:\n                  arg:\n\
      \                    EXTRACT: \"CA10Z1__protocolSettingsSmbChannelEncrypt__c\"\
      \n                  search:\n                    TEXT: \"AES-128-CCM\"\n   \
      \       - NOT:\n              arg:\n                CONTAINS:\n            \
      \      arg:\n                    EXTRACT: \"CA10Z1__protocolSettingsSmbChannelEncrypt__c\"\
      \n                  search:\n                    TEXT: \"AES-128-GCM\"\n# if\
      \ CA10Z1__protocolSettingsSmbChannelEncrypt__c is empty, \n# then the default\
      \ maximum compatibility (that includes all values) is set\notherwise:\n  status:\
      \ \"INCOMPLIANT\"\n  currentStateMessage: \"SMB channel encryption is not set\
      \ to AES-256-GCM.\"\n  remediationMessage: \"Set SMB channel encryption to AES-256-GCM.\"\
      \n  "
  - path: /ce/ca/azure/storage/smb-channel-encryption/test-data.json
    md5Hash: 8DC4C17E7D827BE8F00FC115FDC4328E
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-07T09:01:03Z" },
          "Id": "001",
          "CA10Z1__protocolSettingsSmbChannelEncrypt__c": ""
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-07T09:01:03Z" },
          "Id": "002",
          "CA10Z1__protocolSettingsSmbChannelEncrypt__c": "AES-128-CCM; AES-128-GCM"
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-07T09:01:03Z" },
          "Id": "004",
          "CA10Z1__protocolSettingsSmbChannelEncrypt__c": "AES-128-GCM; AES-256-GCM"
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-256-GCM') && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-CCM')) && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-GCM'))",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-07-07T09:01:03Z" },
          "Id": "003",
          "CA10Z1__protocolSettingsSmbChannelEncrypt__c": "AES-256-GCM"
        }
      ]
  - 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" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-256-GCM') && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-CCM')) && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-GCM'))",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureStorageFile__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10Z1__protocolSettingsSmbChannelEncrypt__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-07T09:01:03Z")
    },
    "Id" : "001",
    "CA10Z1__protocolSettingsSmbChannelEncrypt__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-07T09:01:03Z")
    },
    "Id" : "002",
    "CA10Z1__protocolSettingsSmbChannelEncrypt__c" : "AES-128-CCM; AES-128-GCM"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-07T09:01:03Z")
    },
    "Id" : "004",
    "CA10Z1__protocolSettingsSmbChannelEncrypt__c" : "AES-128-GCM; AES-256-GCM"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-07T09:01:03Z")
    },
    "Id" : "003",
    "CA10Z1__protocolSettingsSmbChannelEncrypt__c" : "AES-256-GCM"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10Z1__CaAzureStorageFile__c(
      obj STRUCT<
          Id STRING,
          CA10Z1__protocolSettingsSmbChannelEncrypt__c 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.CA10Z1__protocolSettingsSmbChannelEncrypt__c; } return this.out; };
      references1.push('Protocol Settings: SMB Channel Encrypt [obj.CA10Z1__protocolSettingsSmbChannelEncrypt__c]: ' + obj.CA10Z1__protocolSettingsSmbChannelEncrypt__c);
      if (TextLib.contains(extract3.call(extract3), 'AES-256-GCM') && !TextLib.contains(extract3.call(extract3), 'AES-128-CCM') && !TextLib.contains(extract3.call(extract3), 'AES-128-GCM')) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-256-GCM') && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-CCM')) && not(extract('CA10Z1__protocolSettingsSmbChannelEncrypt__c').contains('AES-128-GCM'))", currentStateMessage: "SMB channel encryption is set to AES-256-GCM.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "SMB channel encryption is not set to AES-256-GCM.", currentStateReferences: references1.join('\n'), remediation: "Set SMB channel encryption to AES-256-GCM.", 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__protocolSettingsSmbChannelEncrypt__c AS CA10Z1__protocolSettingsSmbChannelEncrypt__c,
          process_CA10Z1__CaAzureStorageFile__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10Z1__protocolSettingsSmbChannelEncrypt__c AS CA10Z1__protocolSettingsSmbChannelEncrypt__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10Z1__CaAzureStorageFile__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
