---
policy: /ce/ca/azure/app-service/minimum-tls-version
logic: /ce/ca/azure/app-service/minimum-tls-version/prod.logic.yaml
executionTime: 2025-04-24T23:45:19.428857992Z
rows:
  - id: test1
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__configMinTlsVersion__c') == '1.0'
      actual: extract('CA10__configMinTlsVersion__c') == '1.0'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__configMinTlsVersion__c') == '1.1'
      actual: extract('CA10__configMinTlsVersion__c') == '1.1'
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__configMinTlsVersion__c') == '1.2'
      actual: extract('CA10__configMinTlsVersion__c') == '1.2'
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/app-service/minimum-tls-version/policy.yaml
    md5Hash: 27E45140F0B0826181934291F5655636
    content: |
      ---
      names:
        full: Azure App Service Minimum TLS Version is not set to TLS 1.2 or higher
        contextual: Minimum TLS Version is not set to TLS 1.2 or higher
      description: "The TLS (Transport Layer Security) protocol secures transmission of\
        \ data over the internet using standard encryption technology. Encryption should\
        \ be set with the latest version of TLS. App service allows TLS 1.2 by default,\
        \ which is the recommended TLS level by industry standards such as PCI DSS."
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v2.1.0/09/03"
        - "/frameworks/cis-azure-v3.0.0/09/04"
        - "/frameworks/cloudaware/resource-security/data-encryption"
      similarPolicies:
        internal:
          - dec-x-2ace1952
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/AppService/latest-version-of-tls-encryption-in-use.html
            name: Check for TLS Protocol Latest Version
  - path: /ce/ca/azure/app-service/minimum-tls-version/prod.logic.yaml
    md5Hash: BBEFC9807D82F926FA2232B59E2DBE70
    content: |
      ---
      inputType: "CA10__CaAzureAppService__c"
      importExtracts:
        - file: "/types/CA10__CaAzureAppService__c/object.extracts.yaml"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "App Service Minimum TLS Version is 1.0."
          remediationMessage: "Consider setting Minimum TLS Version to 1.2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__configMinTlsVersion__c"
              right:
                TEXT: "1.0"
        - status: "INCOMPLIANT"
          currentStateMessage: "App Service Minimum TLS Version is 1.1."
          remediationMessage: "Consider setting Minimum TLS Version to 1.2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__configMinTlsVersion__c"
              right:
                TEXT: "1.1"
        - status: "COMPLIANT"
          currentStateMessage: "App Service Minimum TLS Version is 1.2."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__configMinTlsVersion__c"
              right:
                TEXT: "1.2"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected value in the field."
  - path: /types/CA10__CaAzureAppService__c/object.extracts.yaml
    md5Hash: BA4130C0EACD0EA4C609D6BD75139054
    content: "---\nextracts:\n# Values: Enabled, Disabled. Not Nullable.\n  - name:\
      \ \"CA10__authStatus__c\"\n    value: \n      FIELD:\n        path: \"CA10__authStatus__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__authStatus__c\"\n            currentStateMessage: \"Unable to determine\
      \ Auth Settings. Possible permission issue with Microsoft.Web/sites/config/authsettings/list\"\
      \n# Values: Enabled, Disabled. Not Nullable.\n  - name: \"CA10__basicPublishingCredentialsFtpState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__basicPublishingCredentialsFtpState__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__basicPublishingCredentialsFtpState__c\"\n            currentStateMessage:\
      \ \"Unable to determine Basic Auth Settings. Possible permission issue with\
      \ Microsoft.Web/sites/basicPublishingCredentialsPolicies\"\n# Values: Enabled,\
      \ Disabled. Not Nullable.\n  - name: \"CA10__basicPublishingCredentialsScmState__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__basicPublishingCredentialsScmState__c\"\
      \n        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__basicPublishingCredentialsScmState__c\"\n            currentStateMessage:\
      \ \"Unable to determine Basic Auth Settings. Possible permission issue with\
      \ Microsoft.Web/sites/basicPublishingCredentialsPolicies\"\n# Values: Enabled,\
      \ Disabled. Not Nullable. Can't have no access, retrieved via Microsoft.Web/sites\n\
      \  - name: \"CA10__httpsOnly__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__httpsOnly__c\"\n        undeterminedIf:\n          isEmpty: \"Corrupted\
      \ data. HTTPS Only configuration cannot be empty.\"\n# Values: 1.0, 1.1, 1.2.\
      \ Not Nullable.\n  - name: \"CA10__configMinTlsVersion__c\"\n    value: \n \
      \     FIELD:\n        path: \"CA10__configMinTlsVersion__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__configMinTlsVersion__c\"\
      \n            currentStateMessage: \"Unable to determine minimum version of\
      \ TLS. Possible permission issue with Microsoft.Web/sites/config/web/read\"\n\
      # Nullable. Can't have no access, retrieved via Microsoft.Web/sites\n  - name:\
      \ \"CA10__identityPrincipalId__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__identityPrincipalId__c\"\n# Values: Enabled, Disabled. Not Nullable.\n\
      \  - name: \"CA10__configHttp20__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__configHttp20__c\"\n        undeterminedIf:\n          noAccessDelegate:\n\
      \            path: \"CA10__configHttp20__c\"\n            currentStateMessage:\
      \ \"Unable to determine HTTP2.0 configuration. Possible permission issue with\
      \ Microsoft.Web/sites/config/web/read\"\n# Values: AllAllowed, Disabled, FtpsOnly.\
      \ Not Nullable.\n  - name: \"CA10__configFtpsState__c\"\n    value: \n     \
      \ FIELD:\n        path: \"CA10__configFtpsState__c\"\n        undeterminedIf:\n\
      \          noAccessDelegate:\n            path: \"CA10__configFtpsState__c\"\
      \n            currentStateMessage: \"Unable to determine FTPS State. Possible\
      \ permission issue with Microsoft.Web/sites/config/web/read\"\n# Values: Enabled,\
      \ Disabled. Not Nullable.\n  - name: \"CA10__configRemoteDebugging__c\"\n  \
      \  value: \n      FIELD:\n        path: \"CA10__configRemoteDebugging__c\"\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10__configRemoteDebugging__c\"\n            currentStateMessage: \"Unable\
      \ to determine FTPS State. Possible permission issue with Microsoft.Web/sites/config/web/read\"\
      \n"
  - path: /ce/ca/azure/app-service/minimum-tls-version/test-data.json
    md5Hash: 2A9B5C296A54CB4134C6828C36FE08E7
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2024-06-20T20:56:36Z",
              "CA10__configMinTlsVersion__c": "1.2"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__configMinTlsVersion__c') == '1.0'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__configMinTlsVersion__c": "1.0"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10__configMinTlsVersion__c') == '1.1'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__configMinTlsVersion__c": "1.1"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('CA10__configMinTlsVersion__c') == '1.2'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__configMinTlsVersion__c": "1.2"
          }
      ]
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" : "test1",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__configMinTlsVersion__c') == '1.0'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__configMinTlsVersion__c') == '1.1'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__configMinTlsVersion__c') == '1.2'",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureAppService__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__configMinTlsVersion__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2024-06-20T20:56:36Z"),
    "CA10__configMinTlsVersion__c" : "1.2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test2",
    "CA10__configMinTlsVersion__c" : "1.0"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test3",
    "CA10__configMinTlsVersion__c" : "1.1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test4",
    "CA10__configMinTlsVersion__c" : "1.2"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureAppService__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__configMinTlsVersion__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));
          };
      }();
      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 fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__configMinTlsVersion__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__configMinTlsVersion__c.delegatedTo(CA10__configMinTlsVersion__c).isEmpty()", currentStateMessage: "Unable to determine minimum version of TLS. Possible permission issue with Microsoft.Web/sites/config/web/read", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__configMinTlsVersion__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Config: Min TLS Version [obj.CA10__configMinTlsVersion__c]: ' + obj.CA10__configMinTlsVersion__c);
      try {
          if (TextLib.equal(extract3.call(extract3), '1.0')) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__configMinTlsVersion__c') == '1.0'", currentStateMessage: "App Service Minimum TLS Version is 1.0.", currentStateReferences: references1.join('\n'), remediation: "Consider setting Minimum TLS Version to 1.2.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__configMinTlsVersion__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__configMinTlsVersion__c.delegatedTo(CA10__configMinTlsVersion__c).isEmpty()", currentStateMessage: "Unable to determine minimum version of TLS. Possible permission issue with Microsoft.Web/sites/config/web/read", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__configMinTlsVersion__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      try {
          if (TextLib.equal(extract6.call(extract6), '1.1')) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__configMinTlsVersion__c') == '1.1'", currentStateMessage: "App Service Minimum TLS Version is 1.1.", currentStateReferences: references1.join('\n'), remediation: "Consider setting Minimum TLS Version to 1.2.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10__configMinTlsVersion__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__configMinTlsVersion__c.delegatedTo(CA10__configMinTlsVersion__c).isEmpty()", currentStateMessage: "Unable to determine minimum version of TLS. Possible permission issue with Microsoft.Web/sites/config/web/read", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__configMinTlsVersion__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      try {
          if (TextLib.equal(extract9.call(extract9), '1.2')) {
              return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__configMinTlsVersion__c') == '1.2'", currentStateMessage: "App Service Minimum TLS Version is 1.2.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected value in the field.", 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__configMinTlsVersion__c AS CA10__configMinTlsVersion__c,
          process_CA10__CaAzureAppService__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__configMinTlsVersion__c AS CA10__configMinTlsVersion__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureAppService__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
