---
policy: /ce/ca/aws/elb/load-balancer-desync-mitigation-mode
logic: /ce/ca/aws/elb/load-balancer-desync-mitigation-mode/prod.logic.yaml
executionTime: 2025-12-27T12:01:58.349126958Z
generationMs: 111
executionMs: 594
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: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__type__c') != 'application' && extract('CA10__type__c')
        != 'classic'
      actual: extract('CA10__type__c') != 'application' && extract('CA10__type__c')
        != 'classic'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 799
      actual: 799
    conditionText:
      expected: "extract('caSetFrom_additionalAttributes__c').contains('routing.http.desync_mitigation_mode:\
        \ defensive')"
      actual: "extract('caSetFrom_additionalAttributes__c').contains('routing.http.desync_mitigation_mode:\
        \ defensive')"
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 899
      actual: 899
    conditionText:
      expected: "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode:\
        \ defensive')"
      actual: "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode:\
        \ defensive')"
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode:\
        \ monitor')"
      actual: "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode:\
        \ monitor')"
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/elb/load-balancer-desync-mitigation-mode/policy.yaml
    md5Hash: 7CCAAE9A2C2DDFDD7890FFA812380333
    content: "---\nnames:\n  full: \"AWS ELB Load Balancer is not configured with\
      \ defensive or strictest desync mitigation mode\"\n  contextual: \"Load Balancer\
      \ is not configured with defensive or strictest desync mitigation mode\"\ndescription:\
      \ >\n  Ensure that your Amazon Application Load Balancers and Classic Load Balancers\
      \ \n  are configured with defensive or strictest desync mitigation modes. \n\
      \  This prevents HTTP desynchronization vulnerabilities that can lead to request\
      \ \n  smuggling and unauthorized access to your backend applications.\ntype:\
      \ \"COMPLIANCE_POLICY\"\ncategories:\n  - \"RELIABILITY\"\n  - \"PERFORMANCE\"\
      \nframeworkMappings:\n  - \"/frameworks/cloudaware/resource-security/threat-protection\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/elb/12\"\n  - \"/frameworks/aws-fsbp-v1.0.0/elb/14\"\
      \nsimilarPolicies:\n  awsSecurityHub:\n    - name: \"[ELB.12] Application Load\
      \ Balancer should be configured with defensive or strictest desync mitigation\
      \ mode\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/elb-controls.html#elb-12\"\
      \n    - name: \"[ELB.14] Classic Load Balancer should be configured with defensive\
      \ or strictest desync mitigation mode\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/elb-controls.html#elb-14\""
  - path: /ce/ca/aws/elb/load-balancer-desync-mitigation-mode/prod.logic.yaml
    md5Hash: D1C227A2D0F1E8DF43793F8466625D90
    content: |-
      ---
      inputType: "CA10__CaAwsLoadBalancer__c"
      importExtracts:
        - file: "/types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml"
      recordTypes:
        - "caAwsLoadBalancerApplication"
        - "caAwsLoadBalancerClassic"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "Desync mitigation mode only applies to Application and Classic Load Balancers."
          check:
            AND:
              args:
                - NOT_EQUAL:
                    left:
                      EXTRACT: "CA10__type__c"
                    right:
                      TEXT: "application"
                - NOT_EQUAL:
                    left:
                      EXTRACT: "CA10__type__c"
                    right:
                      TEXT: "classic"
        - status: "INCOMPLIANT"
          currentStateMessage: "The Application Load Balancer is configured with the insecure 'monitor' desync mitigation mode."
          remediationMessage: "Change the 'routing.http.desync_mitigation_mode' attribute to 'defensive' or 'strictest'."
          check:
            CONTAINS:
              arg:
                EXTRACT: "caSetFrom_additionalAttributes__c"
              search:
                TEXT: "routing.http.desync_mitigation_mode: monitor"
        - status: "INCOMPLIANT"
          currentStateMessage: "The Classic Load Balancer is configured with the insecure 'monitor' desync mitigation mode."
          remediationMessage: "Change the 'routing.http.desync_mitigation_mode' attribute to 'defensive' or 'strictest'."
          check:
            CONTAINS:
              arg:
                EXTRACT: "caSetFrom_additionalAttributes__c"
              search:
                TEXT: "elb.http.desyncmitigationmode: monitor"
        - status: "COMPLIANT"
          currentStateMessage: "The Application Load Balancer is configured with 'strictest' desync mitigation mode."
          check:
            CONTAINS:
              arg:
                EXTRACT: "caSetFrom_additionalAttributes__c"
              search:
                TEXT: "routing.http.desync_mitigation_mode: strictest"
        - status: "COMPLIANT"
          currentStateMessage: "The Classic Load Balancer is configured with 'strictest' desync mitigation mode."
          check:
            CONTAINS:
              arg:
                EXTRACT: "caSetFrom_additionalAttributes__c"
              search:
                TEXT: "elb.http.desyncmitigationmode: strictest"
        - status: "COMPLIANT"
          currentStateMessage: "The Application Load Balancer is configured with 'defensive' desync mitigation mode."
          check:
            CONTAINS:
              arg:
                EXTRACT: "caSetFrom_additionalAttributes__c"
              search:
                TEXT: "routing.http.desync_mitigation_mode: defensive"
        - status: "COMPLIANT"
          currentStateMessage: "The Classic Load Balancer is configured with 'defensive' desync mitigation mode."
          check:
            CONTAINS:
              arg:
                EXTRACT: "caSetFrom_additionalAttributes__c"
              search:
                TEXT: "elb.http.desyncmitigationmode: defensive"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected values in the fields."
  - path: /ce/ca/aws/elb/load-balancer-desync-mitigation-mode/test-data.json
    md5Hash: D0E0C7C47A9279F08960F5614E6031E9
    content: |-
      [
          {
              "CA10__type__c": "gateway",
              "CA10__additionalAttributes__c": "",
              "RecordType": {
                  "Id": "RecordTypeId1",
                  "DeveloperName": "caAwsLoadBalancerApplication"
              },
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "conditionIndex": 99,
                  "status": "DISAPPEARED"
              },
              "context": {
                  "snapshotTime": "2025-12-22T05:18:15Z"
              },
              "RecordTypeId": "RecordTypeId1",
              "Id": "test1",
              "CA10__disappearanceTime__c": "2025-12-18T15:43:21Z"
          },
          {
              "CA10__type__c": "gateway",
              "CA10__additionalAttributes__c": "deletion_protection.enabled: false\nload_balancing.cross_zone.enabled: true",
              "RecordType": {
                  "Id": "RecordTypeId1",
                  "DeveloperName": "caAwsLoadBalancerApplication"
              },
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'classic'",
                  "conditionIndex": 299,
                  "status": "INAPPLICABLE"
              },
              "context": {
                  "snapshotTime": "2025-12-22T05:18:15Z"
              },
              "RecordTypeId": "RecordTypeId1",
              "Id": "test2",
              "CA10__disappearanceTime__c": null
          },
          {
              "CA10__type__c": "application",
              "CA10__additionalAttributes__c": "access_logs.s3.enabled: false\nrouting.http.drop_invalid_header_fields.enabled: false\nhealth_check_logs.s3.prefix: \nconnection_logs.s3.enabled: false\naccess_logs.s3.prefix: \nrouting.http2.enabled: true\nwaf.fail_open.enabled: false\nrouting.http.xff_client_port.enabled: false\nclient_keep_alive.seconds: 3600\nhealth_check_logs.s3.bucket: \nconnection_logs.s3.bucket: \ndeletion_protection.enabled: false\naccess_logs.s3.bucket: \nload_balancing.cross_zone.enabled: true\nzonal_shift.config.enabled: false\nrouting.http.preserve_host_header.enabled: false\nrouting.http.x_amzn_tls_version_and_cipher_suite.enabled: false\nconnection_logs.s3.prefix: \nidle_timeout.timeout_seconds: 60\nhealth_check_logs.s3.enabled: false\nrouting.http.xff_header_processing.mode: append\nrouting.http.desync_mitigation_mode: defensive",
              "RecordType": {
                  "Id": "RecordTypeId1",
                  "DeveloperName": "caAwsLoadBalancerApplication"
              },
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('caSetFrom_additionalAttributes__c').contains('routing.http.desync_mitigation_mode: defensive')",
                  "conditionIndex": 799,
                  "status": "COMPLIANT"
              },
              "context": {
                  "snapshotTime": "2025-12-22T05:18:15Z"
              },
              "RecordTypeId": "RecordTypeId1",
              "Id": "test3",
              "CA10__disappearanceTime__c": null
          },
          {
              "CA10__type__c": "classic",
              "CA10__additionalAttributes__c": "elb.http.desyncmitigationmode: defensive",
              "RecordType": {
                  "Id": "RecordTypeId2",
                  "DeveloperName": "caAwsLoadBalancerClassic"
              },
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode: defensive')",
                  "conditionIndex": 899,
                  "status": "COMPLIANT"
              },
              "context": {
                  "snapshotTime": "2025-12-22T05:18:15Z"
              },
              "RecordTypeId": "RecordTypeId2",
              "Id": "test4",
              "CA10__disappearanceTime__c": null
          },
          {
              "CA10__type__c": "classic",
              "CA10__additionalAttributes__c": "elb.http.desyncmitigationmode: monitor",
              "RecordType": {
                  "Id": "RecordTypeId2",
                  "DeveloperName": "caAwsLoadBalancerClassic"
              },
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode: monitor')",
                  "conditionIndex": 499,
                  "status": "INCOMPLIANT"
              },
              "context": {
                  "snapshotTime": "2025-12-22T05:18:15Z"
              },
              "RecordTypeId": "RecordTypeId2",
              "Id": "test5",
              "CA10__disappearanceTime__c": null
          }
      ]
  - path: /types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml
    md5Hash: 08ABDD2ADB04C6F391A6E9FE1F0ACBBE
    content: "---\nextracts:\n  # The subnets for the load balancer.\n  # Type: Array\
      \ of AvailabilityZone objects\n  # Required: No\n  # \n  # apparently it could\
      \ be empty according to documentation, but I don't believe so and can't find\
      \ any LB without AZs\n  - name: CA10__availabilityZones__c\n    value: \n  \
      \    FIELD:\n        path: CA10__availabilityZones__c\n        undeterminedIf:\n\
      \          isEmpty: Corrupted data. Availability zones should always present\n\
      \  - name: caSetFrom_availabilityZones__c\n    value: \n      SET_FROM:\n  \
      \      separator: \"\\n\"\n        arg:\n          EXTRACT: CA10__availabilityZones__c\n\
      # Checkbox for Classic load balancer record type.\n  - name: CA10__crossZoneLoadBalancing__c\n\
      \    value: \n      FIELD:\n        path: CA10__crossZoneLoadBalancing__c\n\
      # Values: classic | application | network | gateway. Not nullable\n  - name:\
      \ CA10__type__c\n    value: \n      FIELD:\n        path: CA10__type__c\n  \
      \      undeterminedIf:\n          isEmpty: \"Corrupted data. Load Balancer Type\
      \ cannot be empty.\"\n  - name: CA10__additionalAttributes__c\n    value: \n\
      \      FIELD:\n        path: CA10__additionalAttributes__c\n  - name: caSetFrom_additionalAttributes__c\n\
      \    value: \n      SET_FROM:\n        separator: \"\\n\"\n        arg:\n  \
      \        EXTRACT: CA10__additionalAttributes__c\n# Checkbox.\n  - name: CA10__accessLogsEnabled__c\n\
      \    value: \n      FIELD:\n        path: CA10__accessLogsEnabled__c\n# Number.\n\
      \  - name: CA10__requestCountOneMonth__c\n    value: \n      FIELD:\n      \
      \  path: CA10__requestCountOneMonth__c\n# Date/Time.\n  - name: CA10__createdTime__c\n\
      \    value: \n      FIELD:\n        path: CA10__createdTime__c"
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" : {
      "runtimeError" : null,
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "conditionIndex" : 99,
      "status" : "DISAPPEARED"
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'classic'",
      "conditionIndex" : 299,
      "status" : "INAPPLICABLE"
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('caSetFrom_additionalAttributes__c').contains('routing.http.desync_mitigation_mode: defensive')",
      "conditionIndex" : 799,
      "status" : "COMPLIANT"
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode: defensive')",
      "conditionIndex" : 899,
      "status" : "COMPLIANT"
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode: monitor')",
      "conditionIndex" : 499,
      "status" : "INCOMPLIANT"
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancer__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__type__c STRING,
      CA10__additionalAttributes__c STRING,
      Id STRING,
      RecordTypeId STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-22T05:18:15Z")
    },
    "CA10__disappearanceTime__c" : new Date("2025-12-18T15:43:21Z"),
    "CA10__type__c" : "gateway",
    "CA10__additionalAttributes__c" : "",
    "Id" : "test1",
    "RecordTypeId" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-22T05:18:15Z")
    },
    "CA10__type__c" : "gateway",
    "CA10__additionalAttributes__c" : "deletion_protection.enabled: false\nload_balancing.cross_zone.enabled: true",
    "Id" : "test2",
    "RecordTypeId" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-22T05:18:15Z")
    },
    "CA10__type__c" : "application",
    "CA10__additionalAttributes__c" : "access_logs.s3.enabled: false\nrouting.http.drop_invalid_header_fields.enabled: false\nhealth_check_logs.s3.prefix: \nconnection_logs.s3.enabled: false\naccess_logs.s3.prefix: \nrouting.http2.enabled: true\nwaf.fail_open.enabled: false\nrouting.http.xff_client_port.enabled: false\nclient_keep_alive.seconds: 3600\nhealth_check_logs.s3.bucket: \nconnection_logs.s3.bucket: \ndeletion_protection.enabled: false\naccess_logs.s3.bucket: \nload_balancing.cross_zone.enabled: true\nzonal_shift.config.enabled: false\nrouting.http.preserve_host_header.enabled: false\nrouting.http.x_amzn_tls_version_and_cipher_suite.enabled: false\nconnection_logs.s3.prefix: \nidle_timeout.timeout_seconds: 60\nhealth_check_logs.s3.enabled: false\nrouting.http.xff_header_processing.mode: append\nrouting.http.desync_mitigation_mode: defensive",
    "Id" : "test3",
    "RecordTypeId" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-22T05:18:15Z")
    },
    "CA10__type__c" : "classic",
    "CA10__additionalAttributes__c" : "elb.http.desyncmitigationmode: defensive",
    "Id" : "test4",
    "RecordTypeId" : "RecordTypeId2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-22T05:18:15Z")
    },
    "CA10__type__c" : "classic",
    "CA10__additionalAttributes__c" : "elb.http.desyncmitigationmode: monitor",
    "Id" : "test5",
    "RecordTypeId" : "RecordTypeId2"
  } ];
  """;

  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-12-22T05:18:15Z")
    },
    "DeveloperName" : "caAwsLoadBalancerApplication",
    "Id" : "RecordTypeId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-22T05:18:15Z")
    },
    "DeveloperName" : "caAwsLoadBalancerClassic",
    "Id" : "RecordTypeId2"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsLoadBalancer__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__type__c STRING,
          CA10__additionalAttributes__c STRING,
          Id STRING,
          RecordTypeId 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 BytesLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg;
      };
      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 CollectionLib = new function () {
      this.parse = function(arg, separator, skipEmpty, skipDuplicates, sort, normalize) {
          if (arg == null) return [];
          let parts = arg.split(separator);
          return this.fromArray(parts, skipEmpty, skipDuplicates, sort, normalize);
      };
      this.fromArray = function(arr, skipEmpty, skipDuplicates, sort, normalize) {
          if (arr == null) return [];
          let result = [];
          let seen = new Set();
          arr.forEach(el => {
              let normalized = normalize ? TextLib.normalize(el) : BytesLib.normalize(el);
              if (!skipEmpty || (normalize ? TextLib.isNotEmpty(el) : BytesLib.isNotEmpty(el))) {
                  if (!skipDuplicates || !seen.has(normalized)) {
                      if (skipDuplicates) seen.add(normalized);
                      result.push(normalized);
                  }
              }
          });
          if (sort) result.sort();
          return result;
      };
      this.equal = function(left, right) {
          left = left == null ? [] : left;
          right = right == null ? [] : right;
          if (left.length !== right.length) return false;
          for (let i = 0; i < left.length; i++) {
              if (left[i] !== right[i]) return false;
          }
          return true;
      };
      this.notEqual = function(left, right) {
          return !this.equal(left, right);
      };
      this.size = function(collection) {
          return collection == null ? 0 : collection.length;
      };
      this.startsWith = function(collection, search, normalize) {
          if (collection == null || collection.length === 0) return false;
          let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search);
          return collection[0] === normalizedSearch;
      };
      this.endsWith = function(collection, search, normalize) {
          if (collection == null || collection.length === 0) return false;
          let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search);
          return collection[collection.length - 1] === normalizedSearch;
      };
      this.contains = function(collection, search, normalize) {
          if (collection == null || collection.length === 0) return false;
          return collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search));
      };
      this.containsAll = function(collection, searchArray, normalize) {
          if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false;
          return searchArray.every(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search)));
      };
      this.containsAny = function(collection, searchArray, normalize) {
          if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false;
          return searchArray.some(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [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]
      references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName);
      if (!CollectionLib.contains(CollectionLib.fromArray(['caAwsLoadBalancerApplication', 'caAwsLoadBalancerClassic'], true, true, true, true), obj.RecordType.DeveloperName, true)) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['caAwsLoadBalancerApplication', 'caAwsLoadBalancerClassic']).contains(RecordType.DeveloperName))", currentStateMessage: "Object record type is not applicable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked5() {
          if (TextLib.isEmpty(obj.CA10__type__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__type__c.isEmpty()", currentStateMessage: "Corrupted data. Load Balancer Type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__type__c;
      }
      function extract4() { if (!this.out) { this.out = fieldChecked5(); } return this.out; };
      references1.push('Type [obj.CA10__type__c]: ' + obj.CA10__type__c);
      try {
          if (TextLib.notEqual(extract4.call(extract4), 'application') && TextLib.notEqual(extract4.call(extract4), 'classic')) {
              return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'classic'", currentStateMessage: "Desync mitigation mode only applies to Application and Classic Load Balancers.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function extract10() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract8() { if (!this.out) { this.out = CollectionLib.parse(extract10.call(extract10), '\n', true, true, true, true); } return this.out; };
      references1.push('Additional Attributes [obj.CA10__additionalAttributes__c]: ' + obj.CA10__additionalAttributes__c);
      if (CollectionLib.contains(extract8.call(extract8), 'routing.http.desync_mitigation_mode: monitor', true)) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('caSetFrom_additionalAttributes__c').contains('routing.http.desync_mitigation_mode: monitor')", currentStateMessage: "The Application Load Balancer is configured with the insecure 'monitor' desync mitigation mode.", currentStateReferences: references1.join('\n'), remediation: "Change the 'routing.http.desync_mitigation_mode' attribute to 'defensive' or 'strictest'.", runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function extract16() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract14() { if (!this.out) { this.out = CollectionLib.parse(extract16.call(extract16), '\n', true, true, true, true); } return this.out; };
      if (CollectionLib.contains(extract14.call(extract14), 'elb.http.desyncmitigationmode: monitor', true)) {
          return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode: monitor')", currentStateMessage: "The Classic Load Balancer is configured with the insecure 'monitor' desync mitigation mode.", currentStateReferences: references1.join('\n'), remediation: "Change the 'routing.http.desync_mitigation_mode' attribute to 'defensive' or 'strictest'.", runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      function extract22() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract20() { if (!this.out) { this.out = CollectionLib.parse(extract22.call(extract22), '\n', true, true, true, true); } return this.out; };
      if (CollectionLib.contains(extract20.call(extract20), 'routing.http.desync_mitigation_mode: strictest', true)) {
          return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "extract('caSetFrom_additionalAttributes__c').contains('routing.http.desync_mitigation_mode: strictest')", currentStateMessage: "The Application Load Balancer is configured with 'strictest' desync mitigation mode.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[6], conditionIndex:[600..699]
      function extract28() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract26() { if (!this.out) { this.out = CollectionLib.parse(extract28.call(extract28), '\n', true, true, true, true); } return this.out; };
      if (CollectionLib.contains(extract26.call(extract26), 'elb.http.desyncmitigationmode: strictest', true)) {
          return {status: 'COMPLIANT', conditionIndex: 699, conditionText: "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode: strictest')", currentStateMessage: "The Classic Load Balancer is configured with 'strictest' desync mitigation mode.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[7], conditionIndex:[700..799]
      function extract34() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract32() { if (!this.out) { this.out = CollectionLib.parse(extract34.call(extract34), '\n', true, true, true, true); } return this.out; };
      if (CollectionLib.contains(extract32.call(extract32), 'routing.http.desync_mitigation_mode: defensive', true)) {
          return {status: 'COMPLIANT', conditionIndex: 799, conditionText: "extract('caSetFrom_additionalAttributes__c').contains('routing.http.desync_mitigation_mode: defensive')", currentStateMessage: "The Application Load Balancer is configured with 'defensive' desync mitigation mode.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[8], conditionIndex:[800..899]
      function extract40() { if (!this.out) { this.out = obj.CA10__additionalAttributes__c; } return this.out; };
      function extract38() { if (!this.out) { this.out = CollectionLib.parse(extract40.call(extract40), '\n', true, true, true, true); } return this.out; };
      if (CollectionLib.contains(extract38.call(extract38), 'elb.http.desyncmitigationmode: defensive', true)) {
          return {status: 'COMPLIANT', conditionIndex: 899, conditionText: "extract('caSetFrom_additionalAttributes__c').contains('elb.http.desyncmitigationmode: defensive')", currentStateMessage: "The Classic Load Balancer is configured with 'defensive' desync mitigation mode.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 900, 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__type__c AS CA10__type__c,
          sObject.CA10__additionalAttributes__c AS CA10__additionalAttributes__c,
          sObject.Id AS Id,
          sObject.RecordTypeId AS RecordTypeId,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          process_CA10__CaAwsLoadBalancer__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__type__c AS CA10__type__c,
                  sObject.CA10__additionalAttributes__c AS CA10__additionalAttributes__c,
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsLoadBalancer__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
  ) sObject ON sObject.Id = expectedResult.Id;
