---
policy: /ce/ca/azure/app-service/enable-app-auth-and-disable-basic-auth
logic: /ce/ca/azure/app-service/enable-app-auth-and-disable-basic-auth/prod.logic.yaml
executionTime: 2025-04-24T23:45:17.293829935Z
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__authStatus__c') == 'Disabled' && (extract('CA10__basicPublishingCredentialsFtpState__c')
        == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') ==
        'Enabled')
      actual: extract('CA10__authStatus__c') == 'Disabled' && (extract('CA10__basicPublishingCredentialsFtpState__c')
        == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') ==
        'Enabled')
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__authStatus__c') == 'Disabled'
      actual: extract('CA10__authStatus__c') == 'Disabled'
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled'
        || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled'
      actual: extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled'
        || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled'
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10__authStatus__c') == 'Enabled' && (extract('CA10__basicPublishingCredentialsFtpState__c')
        == 'Disabled' || extract('CA10__basicPublishingCredentialsScmState__c') ==
        'Disabled')
      actual: extract('CA10__authStatus__c') == 'Enabled' && (extract('CA10__basicPublishingCredentialsFtpState__c')
        == 'Disabled' || extract('CA10__basicPublishingCredentialsScmState__c') ==
        'Disabled')
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/app-service/enable-app-auth-and-disable-basic-auth/policy.yaml
    md5Hash: 3B5EDE9190C98428E7023A17F3797B17
    content: |
      ---
      names:
        full: Azure App Service Authentication is disabled and Basic Authentication is enabled
        contextual: Authentication is disabled and Basic Authentication is enabled
      description: Azure App Service Authentication is a feature that can prevent anonymous
        HTTP requests from reaching a Web Application or authenticate those with tokens
        before they reach the app. Disabling HTTP Basic Authentication functionality further
        ensures legacy authentication methods are disabled within the application.
      type: COMPLIANCE_POLICY
      categories:
        - RELIABILITY
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v2.1.0/09/01"
        - "/frameworks/cis-azure-v3.0.0/09/02"
        - "/frameworks/cloudaware/resource-reliability/system-configuration"
        - "/frameworks/cloudaware/resource-security/secure-access"
      similarPolicies:
        internal:
          - dec-x-ca52f63a
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/AppService/enable-app-service-authentication.html
            name: Enable App Service Authentication
  - path: /ce/ca/azure/app-service/enable-app-auth-and-disable-basic-auth/prod.logic.yaml
    md5Hash: 047296CC2A1C0B916F1DE3AC0CE6268D
    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 Authentication is disabled and Basic Auth Publishing Credentials are enabled."
          remediationMessage: "Consider enabling App Service Authentication and disabling Basic Auth Publishing Credentials."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__authStatus__c"
                    right:
                      TEXT: "Disabled"
                - OR:
                    args:
                      - IS_EQUAL:
                          left:
                            EXTRACT: "CA10__basicPublishingCredentialsFtpState__c"
                          right:
                            TEXT: "Enabled"
                      - IS_EQUAL:
                          left:
                            EXTRACT: "CA10__basicPublishingCredentialsScmState__c"
                          right:
                            TEXT: "Enabled"
        - status: "INCOMPLIANT"
          currentStateMessage: "App Service Authentication is disabled."
          remediationMessage: "Consider enabling App Service Authentication."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__authStatus__c"
              right:
                TEXT: "Disabled"
        - status: "INCOMPLIANT"
          currentStateMessage: "Basic Auth Publishing Credentials are enabled."
          remediationMessage: "Consider disabling Basic Auth Publishing Credentials."
          check:
            OR:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__basicPublishingCredentialsFtpState__c"
                    right:
                      TEXT: "Enabled"
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__basicPublishingCredentialsScmState__c"
                    right:
                      TEXT: "Enabled"
        - status: "COMPLIANT"
          currentStateMessage: "App Service Authentication is enabled and Basic Auth Publishing Credentials are disabled."
          check:
            AND:
              args:
                - IS_EQUAL:
                    left:
                      EXTRACT: "CA10__authStatus__c"
                    right:
                      TEXT: "Enabled"
                - OR:
                    args:
                      - IS_EQUAL:
                          left:
                            EXTRACT: "CA10__basicPublishingCredentialsFtpState__c"
                          right:
                            TEXT: "Disabled"
                      - IS_EQUAL:
                          left:
                            EXTRACT: "CA10__basicPublishingCredentialsScmState__c"
                          right:
                            TEXT: "Disabled"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected values in the fields."
  - 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/enable-app-auth-and-disable-basic-auth/test-data.json
    md5Hash: 9E4B5DE9F35F9978FE02B484D055D260
    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__authStatus__c": "Disabled",
              "CA10__basicPublishingCredentialsFtpState__c": "Enabled",
              "CA10__basicPublishingCredentialsScmState__c": "Enabled"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__authStatus__c') == 'Disabled' && (extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__authStatus__c": "Disabled",
              "CA10__basicPublishingCredentialsFtpState__c": "Enabled",
              "CA10__basicPublishingCredentialsScmState__c": "Enabled"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10__authStatus__c') == 'Disabled'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__authStatus__c": "Disabled",
              "CA10__basicPublishingCredentialsFtpState__c": "Disabled",
              "CA10__basicPublishingCredentialsScmState__c": "Disabled"
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__authStatus__c": "Enabled",
              "CA10__basicPublishingCredentialsFtpState__c": "Enabled",
              "CA10__basicPublishingCredentialsScmState__c": "Enabled"
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "extract('CA10__authStatus__c') == 'Enabled' && (extract('CA10__basicPublishingCredentialsFtpState__c') == 'Disabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Disabled')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-28T08:24:16Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__authStatus__c": "Enabled",
              "CA10__basicPublishingCredentialsFtpState__c": "Disabled",
              "CA10__basicPublishingCredentialsScmState__c": "Disabled"
          }
      ]
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__authStatus__c') == 'Disabled' && (extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__authStatus__c') == 'Disabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('CA10__authStatus__c') == 'Enabled' && (extract('CA10__basicPublishingCredentialsFtpState__c') == 'Disabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Disabled')",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureAppService__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__authStatus__c STRING,
      CA10__basicPublishingCredentialsFtpState__c STRING,
      CA10__basicPublishingCredentialsScmState__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__authStatus__c" : "Disabled",
    "CA10__basicPublishingCredentialsFtpState__c" : "Enabled",
    "CA10__basicPublishingCredentialsScmState__c" : "Enabled"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test2",
    "CA10__authStatus__c" : "Disabled",
    "CA10__basicPublishingCredentialsFtpState__c" : "Enabled",
    "CA10__basicPublishingCredentialsScmState__c" : "Enabled"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test3",
    "CA10__authStatus__c" : "Disabled",
    "CA10__basicPublishingCredentialsFtpState__c" : "Disabled",
    "CA10__basicPublishingCredentialsScmState__c" : "Disabled"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test4",
    "CA10__authStatus__c" : "Enabled",
    "CA10__basicPublishingCredentialsFtpState__c" : "Enabled",
    "CA10__basicPublishingCredentialsScmState__c" : "Enabled"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-28T08:24:16Z")
    },
    "Id" : "test5",
    "CA10__authStatus__c" : "Enabled",
    "CA10__basicPublishingCredentialsFtpState__c" : "Disabled",
    "CA10__basicPublishingCredentialsScmState__c" : "Disabled"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureAppService__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__authStatus__c STRING,
          CA10__basicPublishingCredentialsFtpState__c STRING,
          CA10__basicPublishingCredentialsScmState__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__authStatus__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__authStatus__c.delegatedTo(CA10__authStatus__c).isEmpty()", currentStateMessage: "Unable to determine Auth Settings. Possible permission issue with Microsoft.Web/sites/config/authsettings/list", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__authStatus__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__basicPublishingCredentialsFtpState__c)) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "CA10__basicPublishingCredentialsFtpState__c.delegatedTo(CA10__basicPublishingCredentialsFtpState__c).isEmpty()", currentStateMessage: "Unable to determine Basic Auth Settings. Possible permission issue with Microsoft.Web/sites/basicPublishingCredentialsPolicies", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__basicPublishingCredentialsFtpState__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      function fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10__basicPublishingCredentialsScmState__c)) {
              throw new Error("UNDETERMINED condition:103", {cause: {status: 'UNDETERMINED', conditionIndex: 103, conditionText: "CA10__basicPublishingCredentialsScmState__c.delegatedTo(CA10__basicPublishingCredentialsScmState__c).isEmpty()", currentStateMessage: "Unable to determine Basic Auth Settings. Possible permission issue with Microsoft.Web/sites/basicPublishingCredentialsPolicies", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__basicPublishingCredentialsScmState__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      references1.push('Auth: Status [obj.CA10__authStatus__c]: ' + obj.CA10__authStatus__c);
      references1.push('Basic Publishing Credentials: FTP State [obj.CA10__basicPublishingCredentialsFtpState__c]: ' + obj.CA10__basicPublishingCredentialsFtpState__c);
      references1.push('Basic Publishing Credentials: SCM State [obj.CA10__basicPublishingCredentialsScmState__c]: ' + obj.CA10__basicPublishingCredentialsScmState__c);
      try {
          if (TextLib.equal(extract3.call(extract3), 'Disabled') && (TextLib.equal(extract6.call(extract6), 'Enabled') || TextLib.equal(extract9.call(extract9), 'Enabled'))) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__authStatus__c') == 'Disabled' && (extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled')", currentStateMessage: "App Service Authentication is disabled and Basic Auth Publishing Credentials are enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling App Service Authentication and disabling Basic Auth Publishing Credentials.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked13() {
          if (TextLib.isEmpty(obj.CA10__authStatus__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__authStatus__c.delegatedTo(CA10__authStatus__c).isEmpty()", currentStateMessage: "Unable to determine Auth Settings. Possible permission issue with Microsoft.Web/sites/config/authsettings/list", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__authStatus__c;
      }
      function extract12() { if (!this.out) { this.out = fieldChecked13(); } return this.out; };
      try {
          if (TextLib.equal(extract12.call(extract12), 'Disabled')) {
              return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__authStatus__c') == 'Disabled'", currentStateMessage: "App Service Authentication is disabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling App Service Authentication.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function fieldChecked16() {
          if (TextLib.isEmpty(obj.CA10__basicPublishingCredentialsFtpState__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__basicPublishingCredentialsFtpState__c.delegatedTo(CA10__basicPublishingCredentialsFtpState__c).isEmpty()", currentStateMessage: "Unable to determine Basic Auth Settings. Possible permission issue with Microsoft.Web/sites/basicPublishingCredentialsPolicies", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__basicPublishingCredentialsFtpState__c;
      }
      function extract15() { if (!this.out) { this.out = fieldChecked16(); } return this.out; };
      function fieldChecked19() {
          if (TextLib.isEmpty(obj.CA10__basicPublishingCredentialsScmState__c)) {
              throw new Error("UNDETERMINED condition:302", {cause: {status: 'UNDETERMINED', conditionIndex: 302, conditionText: "CA10__basicPublishingCredentialsScmState__c.delegatedTo(CA10__basicPublishingCredentialsScmState__c).isEmpty()", currentStateMessage: "Unable to determine Basic Auth Settings. Possible permission issue with Microsoft.Web/sites/basicPublishingCredentialsPolicies", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__basicPublishingCredentialsScmState__c;
      }
      function extract18() { if (!this.out) { this.out = fieldChecked19(); } return this.out; };
      try {
          if (TextLib.equal(extract15.call(extract15), 'Enabled') || TextLib.equal(extract18.call(extract18), 'Enabled')) {
              return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__basicPublishingCredentialsFtpState__c') == 'Enabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Enabled'", currentStateMessage: "Basic Auth Publishing Credentials are enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider disabling Basic Auth Publishing Credentials.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[4], conditionIndex:[400..499]
      function fieldChecked22() {
          if (TextLib.isEmpty(obj.CA10__authStatus__c)) {
              throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "CA10__authStatus__c.delegatedTo(CA10__authStatus__c).isEmpty()", currentStateMessage: "Unable to determine Auth Settings. Possible permission issue with Microsoft.Web/sites/config/authsettings/list", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__authStatus__c;
      }
      function extract21() { if (!this.out) { this.out = fieldChecked22(); } return this.out; };
      function fieldChecked25() {
          if (TextLib.isEmpty(obj.CA10__basicPublishingCredentialsFtpState__c)) {
              throw new Error("UNDETERMINED condition:402", {cause: {status: 'UNDETERMINED', conditionIndex: 402, conditionText: "CA10__basicPublishingCredentialsFtpState__c.delegatedTo(CA10__basicPublishingCredentialsFtpState__c).isEmpty()", currentStateMessage: "Unable to determine Basic Auth Settings. Possible permission issue with Microsoft.Web/sites/basicPublishingCredentialsPolicies", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__basicPublishingCredentialsFtpState__c;
      }
      function extract24() { if (!this.out) { this.out = fieldChecked25(); } return this.out; };
      function fieldChecked28() {
          if (TextLib.isEmpty(obj.CA10__basicPublishingCredentialsScmState__c)) {
              throw new Error("UNDETERMINED condition:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "CA10__basicPublishingCredentialsScmState__c.delegatedTo(CA10__basicPublishingCredentialsScmState__c).isEmpty()", currentStateMessage: "Unable to determine Basic Auth Settings. Possible permission issue with Microsoft.Web/sites/basicPublishingCredentialsPolicies", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__basicPublishingCredentialsScmState__c;
      }
      function extract27() { if (!this.out) { this.out = fieldChecked28(); } return this.out; };
      try {
          if (TextLib.equal(extract21.call(extract21), 'Enabled') && (TextLib.equal(extract24.call(extract24), 'Disabled') || TextLib.equal(extract27.call(extract27), 'Disabled'))) {
              return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__authStatus__c') == 'Enabled' && (extract('CA10__basicPublishingCredentialsFtpState__c') == 'Disabled' || extract('CA10__basicPublishingCredentialsScmState__c') == 'Disabled')", currentStateMessage: "App Service Authentication is enabled and Basic Auth Publishing Credentials are disabled.", 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: 500, 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__authStatus__c AS CA10__authStatus__c,
          sObject.CA10__basicPublishingCredentialsFtpState__c AS CA10__basicPublishingCredentialsFtpState__c,
          sObject.CA10__basicPublishingCredentialsScmState__c AS CA10__basicPublishingCredentialsScmState__c,
          process_CA10__CaAzureAppService__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__authStatus__c AS CA10__authStatus__c,
                  sObject.CA10__basicPublishingCredentialsFtpState__c AS CA10__basicPublishingCredentialsFtpState__c,
                  sObject.CA10__basicPublishingCredentialsScmState__c AS CA10__basicPublishingCredentialsScmState__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureAppService__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
