---
policy: /ce/ca/aws/elb/load-balancer-listener-security
logic: /ce/ca/aws/elb/load-balancer-listener-security/prod.logic.yaml
executionTime: 2025-12-27T12:01:58.964185997Z
generationMs: 102
executionMs: 661
rows:
  - id: '001'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)
      actual: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)
      actual: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)
      actual: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/elb/load-balancer-listener-security/policy.yaml
    md5Hash: 6FD3DA858850F78425BD5DBB9EC1785C
    content: "---\nnames:\n  full: \"AWS ELB Load Balancer listeners are not using\
      \ a secure protocol\"\n  contextual: \"Load Balancer listeners are not using\
      \ a secure protocol\"\ndescription: >\n  Check your Elastic Load Balancers (ELBs)\
      \ listeners for insecure configurations. \n  CloudAware recommends only using\
      \ secure protocols, such as HTTPS, TLS or QUIC, to \n  encrypt the communication\
      \ between the client and your load balancers.\ntype: \"COMPLIANCE_POLICY\"\n\
      categories:\n  - \"SECURITY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/resource-security/data-encryption\"\
      \n  - \"/frameworks/aws-well-architected/sec/09/01\"\n  - \"/frameworks/aws-fsbp-v1.0.0/elb/18\"\
      \nsimilarPolicies:\n  awsSecurityHub:\n    - name: \"[ELB.18] Application and\
      \ Network Load Balancer listeners should use secure protocols to encrypt data\
      \ in transit\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/elb-controls.html#elb-18\"\
      \n    - name: \"[ELB.3] Classic Load Balancer listeners should be configured\
      \ with HTTPS or TLS termination\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/elb-controls.html#elb-3\"\
      \n  cloudConformity:\n    - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/aws/ELB/elb-listener-security.html\n\
      \      name: ELB Listener Security"
  - path: /ce/ca/aws/elb/load-balancer-listener-security/prod.logic.yaml
    md5Hash: FD16839481AA67F618B7BF2FF6018369
    content: "---\ninputType: \"CA10__CaAwsLoadBalancer__c\"\ntestData:\n  - file:\
      \ \"test-data.json\"\nconditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage:\
      \ \"The Load Balancer has at least one Listener with an insecure protocol.\"\
      \n    remediationMessage: \"Update the Listener to use HTTPS or TLS.\"\n   \
      \ check:\n      RELATED_LIST_HAS:\n        status: \"INCOMPLIANT\"\n       \
      \ relationshipName: \"CA10__AWS_EC2_Load_Balancer_Listeners__r\"\n  - status:\
      \ \"COMPLIANT\"\n    currentStateMessage: \"All active Listeners are using secure\
      \ protocols.\"\n    check:\n      RELATED_LIST_HAS:\n        status: \"COMPLIANT\"\
      \n        relationshipName: \"CA10__AWS_EC2_Load_Balancer_Listeners__r\"\notherwise:\n\
      \  status: \"INAPPLICABLE\"\n  currentStateMessage: \"The Load Balancer doesn't\
      \ have any Listeners.\"\nrelatedLists:\n  - relationshipName: \"CA10__AWS_EC2_Load_Balancer_Listeners__r\"\
      \n    importExtracts:\n    - file: \"/types/CA10__CaAwsLoadBalancerListener__c/object.extracts.yaml\"\
      \n    conditions:\n      - status: \"COMPLIANT\"\n        currentStateMessage:\
      \ \"The Listener is configured to pass encrypted traffic to\\\n          \\\
      \ the targets without the load balancer decrypting it.\"\n        check:\n \
      \         AND:\n            args:\n              - IS_EQUAL:\n             \
      \     left:\n                    EXTRACT: \"CA10__loadBalancerPort__c\"\n  \
      \                right:\n                    NUMBER: 443.0\n              -\
      \ IS_EQUAL:\n                  left:\n                    EXTRACT: \"CA10__protocol__c\"\
      \n                  right:\n                    TEXT: \"TCP\"\n      - status:\
      \ \"COMPLIANT\"\n        currentStateMessage: \"The Listener uses a secure protocol.\"\
      \n        check:\n          CONTAINS_ANY:\n            arg:\n              EXTRACT:\
      \ \"CA10__protocol__c\"\n            search:\n              SET:\n         \
      \       itemType: TEXT\n                items:\n                  - \"HTTPS\"\
      \n                  - \"SSL\"\n                  - \"TLS\"\n               \
      \   - \"QUIC\"\n                  - \"TCP_QUIC\"\n    otherwise:\n      status:\
      \ \"INCOMPLIANT\" \n      currentStateMessage: \"The Listener uses insecure\
      \ protocol.\"\n      remediationMessage: \"Update the Listener to use a secure\
      \ protocol.\"\n"
  - path: /ce/ca/aws/elb/load-balancer-listener-security/test-data.json
    md5Hash: E81EA1F5DA4345777232BAAA26DE6958
    content: |
      [
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-08T06:03:44Z" },
          "CA10__disappearanceTime__c": null,
          "Id": "001",
          "RecordTypeId": "rt00id",
          "RecordType": { "Id": "rt00id" },
          "CA10__AWS_EC2_Load_Balancer_Listeners__r": [
            {
              "CA10__disappearanceTime__c": null,
              "CA10__protocol__c": "HTTP",
              "CA10__loadBalancerPort__c": 80.0,
              "CA10__loadBalancer__c": "001",
              "Id": "lis001",
              "RecordTypeId": "rtlis00id",
              "RecordType": { "Id": "rtlis00id" }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-08T06:03:44Z" },
          "CA10__disappearanceTime__c": null,
          "Id": "002",
          "RecordTypeId": "rt00id",
          "RecordType": { "Id": "rt00id" },
          "CA10__AWS_EC2_Load_Balancer_Listeners__r": [
            {
              "CA10__disappearanceTime__c": null,
              "CA10__protocol__c": "HTTPS",
              "CA10__loadBalancerPort__c": 80.0,
              "CA10__loadBalancer__c": "002",
              "Id": "lis002",
              "RecordTypeId": "rtlis00id",
              "RecordType": { "Id": "rtlis00id" }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "300",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-08T06:03:44Z" },
          "CA10__disappearanceTime__c": null,
          "Id": "003",
          "RecordTypeId": "rt00id",
          "RecordType": { "Id": "rt00id" },
          "CA10__AWS_EC2_Load_Balancer_Listeners__r": []
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "299",
            "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-12-08T06:03:44Z" },
          "CA10__disappearanceTime__c": null,
          "Id": "004",
          "RecordTypeId": "rt00id",
          "RecordType": { "Id": "rt00id" },
          "CA10__AWS_EC2_Load_Balancer_Listeners__r": [
            {
              "CA10__disappearanceTime__c": null,
              "CA10__protocol__c": "TCP",
              "CA10__loadBalancerPort__c": 443.0,
              "CA10__loadBalancer__c": "004",
              "Id": "lis004",
              "RecordTypeId": "rtlis00id",
              "RecordType": { "Id": "rtlis00id" }
            }
          ]
        }
      ]
  - path: /types/CA10__CaAwsLoadBalancerListener__c/object.extracts.yaml
    md5Hash: 242B81357463C0BA88DD9D030D4E1CFD
    content: "---\nextracts:\n# Not applicable to Classic Load Balancers\n# Not nullable.\
      \ Can't have no access, retrieved via elasticloadbalancing:DescribeListeners\n\
      \  - name: CA10__defaultActionsJson__c\n    value: \n      FIELD:\n        returnType:\
      \ \"BYTES\"\n        path: CA10__defaultActionsJson__c\n        undeterminedIf:\n\
      \          isEmpty: \"Load Balancer Listener Default Action cannot be empty.\
      \ Corrupted data.\"\n  - name: caJsonFrom_defaultActionsJson__c\n    value:\
      \ \n      JSON_FROM:\n        arg:\n          EXTRACT: \"CA10__defaultActionsJson__c\"\
      \n        undeterminedIf:\n          isInvalid: \"The Actions JSON is invalid\"\
      \n# Nullable. Text.\n  - name: CA10__protocol__c\n    value: \n      FIELD:\n\
      \        path: CA10__protocol__c\n  - name: CA10__loadBalancerPort__c\n    value:\
      \ \n      FIELD:\n        path: CA10__loadBalancerPort__c\n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "001",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancer__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      Id STRING,
      RecordTypeId STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "Id" : "001",
    "RecordTypeId" : "rt00id"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "Id" : "002",
    "RecordTypeId" : "rt00id"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "Id" : "003",
    "RecordTypeId" : "rt00id"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "Id" : "004",
    "RecordTypeId" : "rt00id"
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "Id" : "rt00id"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "Id" : "rtlis00id"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancerListener__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__loadBalancerPort__c FLOAT64,
      CA10__protocol__c STRING,
      CA10__loadBalancer__c STRING,
      Id STRING,
      RecordTypeId STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "CA10__loadBalancerPort__c" : 80.0,
    "CA10__protocol__c" : "HTTP",
    "CA10__loadBalancer__c" : "001",
    "Id" : "lis001",
    "RecordTypeId" : "rtlis00id"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "CA10__loadBalancerPort__c" : 80.0,
    "CA10__protocol__c" : "HTTPS",
    "CA10__loadBalancer__c" : "002",
    "Id" : "lis002",
    "RecordTypeId" : "rtlis00id"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-12-08T06:03:44Z")
    },
    "CA10__loadBalancerPort__c" : 443.0,
    "CA10__protocol__c" : "TCP",
    "CA10__loadBalancer__c" : "004",
    "Id" : "lis004",
    "RecordTypeId" : "rtlis00id"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsLoadBalancer__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          Id STRING,
          RecordTypeId STRING,
          RecordType STRUCT<
              Id STRING
          >,
          CA10__AWS_EC2_Load_Balancer_Listeners__r ARRAY<STRUCT<
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__loadBalancerPort__c FLOAT64,
              CA10__protocol__c STRING,
              CA10__loadBalancer__c STRING,
              Id STRING,
              RecordTypeId STRING,
              RecordType STRUCT<
                  Id STRING
              >,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError 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 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};
      }
      var count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT2 = 0;
      if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r != null) {
          for (var i3 = 0; i3 < obj.CA10__AWS_EC2_Load_Balancer_Listeners__r.length; i3++) {
              if (typeof(obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i3].status) !== 'undefined') {
                  if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i3].status == 'INCOMPLIANT') {
                      count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT2 += obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i3].count;
                  }
              } else  {
                  if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i3].result.status == 'INCOMPLIANT') {
                      count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT2 += 1;
                  }
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__AWS_EC2_Load_Balancer_Listeners__r] ' + (count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)", currentStateMessage: "The Load Balancer has at least one Listener with an insecure protocol.", currentStateReferences: references1.join('\n'), remediation: "Update the Listener to use HTTPS or TLS.", runtimeError: null};
      }
      var count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT4 = 0;
      if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r != null) {
          for (var i5 = 0; i5 < obj.CA10__AWS_EC2_Load_Balancer_Listeners__r.length; i5++) {
              if (typeof(obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i5].status) !== 'undefined') {
                  if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i5].status == 'COMPLIANT') {
                      count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT4 += obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i5].count;
                  }
              } else  {
                  if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i5].result.status == 'COMPLIANT') {
                      count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT4 += 1;
                  }
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      if (count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT4 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", currentStateMessage: "All active Listeners are using secure protocols.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INAPPLICABLE', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The Load Balancer doesn't have any Listeners.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_EC2_Load_Balancer_Listeners__r(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__loadBalancerPort__c FLOAT64,
          CA10__protocol__c STRING,
          CA10__loadBalancer__c STRING,
          Id STRING,
          RecordTypeId STRING,
          RecordType STRUCT<
              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 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 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 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]
      function extract3() { if (!this.out) { this.out = obj.CA10__loadBalancerPort__c; } return this.out; };
      function extract6() { if (!this.out) { this.out = obj.CA10__protocol__c; } return this.out; };
      references1.push('Load Balancer Port [obj.CA10__loadBalancerPort__c]: ' + obj.CA10__loadBalancerPort__c);
      references1.push('Protocol [obj.CA10__protocol__c]: ' + obj.CA10__protocol__c);
      if (extract3.call(extract3) == 443.0 && TextLib.equal(extract6.call(extract6), 'TCP')) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__loadBalancerPort__c') == number(443.0) && extract('CA10__protocol__c') == 'TCP'", currentStateMessage: "The Listener is configured to pass encrypted traffic to the targets without the load balancer decrypting it.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract9() { if (!this.out) { this.out = obj.CA10__protocol__c; } return this.out; };
      if (TextLib.containsAny(extract9.call(extract9), CollectionLib.fromArray(['HTTPS', 'SSL', 'TLS', 'QUIC', 'TCP_QUIC'], true, true, true, true))) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__protocol__c').containsAny(setOfText(['HTTPS', 'SSL', 'TLS', 'QUIC', 'TCP_QUIC']))", currentStateMessage: "The Listener uses a secure protocol.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The Listener uses insecure protocol.", currentStateReferences: references1.join('\n'), remediation: "Update the Listener to use a secure protocol.", 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.Id AS Id,
          sObject.RecordTypeId AS RecordTypeId,
          STRUCT (
              `RecordType`.Id AS Id
          ) AS RecordType,
          `CA10__AWS_EC2_Load_Balancer_Listeners__r`.arr AS CA10__AWS_EC2_Load_Balancer_Listeners__r,
          process_CA10__CaAwsLoadBalancer__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  STRUCT (
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  `CA10__AWS_EC2_Load_Balancer_Listeners__r`.arr AS CA10__AWS_EC2_Load_Balancer_Listeners__r
              ),
              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
      LEFT JOIN (
          SELECT
              sObject.CA10__loadBalancer__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__loadBalancerPort__c AS CA10__loadBalancerPort__c,
                      sObject.CA10__protocol__c AS CA10__protocol__c,
                      sObject.CA10__loadBalancer__c AS CA10__loadBalancer__c,
                      sObject.Id AS Id,
                      sObject.RecordTypeId AS RecordTypeId,
                      STRUCT (
                          `RecordType`.Id AS Id
                      ) AS RecordType,
                      process_CA10__AWS_EC2_Load_Balancer_Listeners__r(
                          STRUCT(
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__loadBalancerPort__c AS CA10__loadBalancerPort__c,
                              sObject.CA10__protocol__c AS CA10__protocol__c,
                              sObject.CA10__loadBalancer__c AS CA10__loadBalancer__c,
                              sObject.Id AS Id,
                              sObject.RecordTypeId AS RecordTypeId,
                              STRUCT (
                                  `RecordType`.Id AS Id
                              ) AS RecordType
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsLoadBalancerListener__c()) AS sObject
          LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
              ON sObject.RecordTypeId = `RecordType`.Id
          GROUP BY sObject.CA10__loadBalancer__c
      ) AS `CA10__AWS_EC2_Load_Balancer_Listeners__r`
          ON sObject.Id = `CA10__AWS_EC2_Load_Balancer_Listeners__r`.CA10__loadBalancer__c
  ) sObject ON sObject.Id = expectedResult.Id;
