--- policy: /ce/ca/aws/elb/load-balancer-listener-security-policy logic: /ce/ca/aws/elb/load-balancer-listener-security-policy/prod.logic.yaml executionTime: 2026-06-06T12:02:56.328433758Z generationMs: 53 executionMs: 927 rows: - id: '001' match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'network' actual: extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'network' runtimeError: {} - id: '002' match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: '003' match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT) actual: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT) runtimeError: {} - id: '004' match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT) actual: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT) runtimeError: {} - id: '005' match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 400 actual: 400 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/elb/load-balancer-listener-security-policy/policy.yaml md5Hash: 50D6B25656CCDE6A614B4FCA67C044F7 content: "---\nnames:\n full: \"AWS ELB Load Balancer listener is configured\ \ with an outdated security policy\"\n contextual: \"Load Balancer listener\ \ is configured with an outdated security policy\"\ndescription: >\n Ensure\ \ that your Application and Network Load Balancers use the latest recommended\ \ \n security policies for their HTTPS/SSL listeners. Outdated policies may\ \ support \n vulnerable protocols and weak ciphers, increasing the risk of\ \ man-in-the-middle attacks.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n -\ \ \"SECURITY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/secret-and-certificate-governance/cryptographic-configuration\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/elb/17\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[ELB.17] Application and Network Load Balancers with listeners\ \ should use recommended security policies\"\n url: https://docs.aws.amazon.com/securityhub/latest/userguide/elb-controls.html#elb-17\n" - path: /ce/ca/aws/elb/load-balancer-listener-security-policy/prod.logic.yaml md5Hash: 34D3DB62B24F71A31D1EDA2D4BA011CC content: | --- inputType: "CA10__CaAwsLoadBalancer__c" importExtracts: - file: "/types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml" testData: - file: "test-data.json" conditions: - status: "INAPPLICABLE" currentStateMessage: "This policy only applies to application and network load balancers." check: AND: args: - NOT_EQUAL: left: EXTRACT: "CA10__type__c" right: TEXT: "application" - NOT_EQUAL: left: EXTRACT: "CA10__type__c" right: TEXT: "network" - status: "INCOMPLIANT" currentStateMessage: "The load balancer has at least one listener using an outdated security policy." remediationMessage: "Update the listener to use a recommended security policy." check: RELATED_LIST_HAS: status: "INCOMPLIANT" relationshipName: "CA10__AWS_EC2_Load_Balancer_Listeners__r" - status: "COMPLIANT" currentStateMessage: "All listeners are using recommended security policies." check: RELATED_LIST_HAS: status: "COMPLIANT" relationshipName: "CA10__AWS_EC2_Load_Balancer_Listeners__r" otherwise: status: "COMPLIANT" currentStateMessage: "No HTTPS or TLS listeners are configured for this load balancer." relatedLists: - relationshipName: "CA10__AWS_EC2_Load_Balancer_Listeners__r" importExtracts: - file: "/types/CA10__CaAwsLoadBalancerListener__c/object.extracts.yaml" conditions: - status: "COMPLIANT" currentStateMessage: "The listener uses a recommended security policy." check: AND: args: - CONTAINS_ANY: arg: EXTRACT: "CA10__policyName__c" search: SET: itemType: "TEXT" items: - "ELBSecurityPolicy-TLS13-1-2-2021-06" - "ELBSecurityPolicy-TLS13-1-2-FIPS-2023-04" - "ELBSecurityPolicy-TLS13-1-3-2021-06" - "ELBSecurityPolicy-TLS13-1-3-FIPS-2023-04" - "ELBSecurityPolicy-TLS13-1-2-Res-2021-06 " - "ELBSecurityPolicy-TLS13-1-2-Res-FIPS-2023-04" - CONTAINS_ANY: arg: EXTRACT: "CA10__protocol__c" search: SET: itemType: "TEXT" items: - "HTTPS" - "TLS" - status: "INCOMPLIANT" currentStateMessage: "The listener uses an outdated security policy." remediationMessage: "Update the listener's security policy." check: CONTAINS_ANY: arg: EXTRACT: "CA10__protocol__c" search: SET: itemType: "TEXT" items: - "HTTPS" - "TLS" otherwise: status: "INAPPLICABLE" currentStateMessage: "This is not an HTTPS or TLS listener." - path: /ce/ca/aws/elb/load-balancer-listener-security-policy/test-data.json md5Hash: 5833598F4A9787390F13A0D9D2616B00 content: | [ { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'network'", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "CA10__type__c": "classic", "Id": "001", "RecordTypeId": "RecordTypeId1", "RecordType": { "Id": "RecordTypeId1" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [ { "CA10__disappearanceTime__c": null, "CA10__policyName__c": "", "CA10__loadBalancer__c": "001", "CA10__protocol__c": "HTTPS", "Id": "001-1", "RecordTypeId": "RecordTypeId3", "RecordType": { "Id": "RecordTypeId3" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "CA10__type__c": "network", "Id": "002", "RecordTypeId": "RecordTypeId2", "RecordType": { "Id": "RecordTypeId2" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "299", "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "CA10__type__c": "application", "Id": "003", "RecordTypeId": "RecordTypeId2", "RecordType": { "Id": "RecordTypeId2" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [ { "CA10__disappearanceTime__c": null, "CA10__policyName__c": "ELBSecurityPolicy-TLS13-1-3-2021-06", "CA10__loadBalancer__c": "003", "CA10__protocol__c": "HTTPS", "Id": "003-1", "RecordTypeId": "RecordTypeId4", "RecordType": { "Id": "RecordTypeId4" } }, { "CA10__disappearanceTime__c": null, "CA10__policyName__c": "ELBSecurityPolicy-TLS-1-2-2017-01", "CA10__loadBalancer__c": "003", "CA10__protocol__c": "HTTPS", "Id": "003-2", "RecordTypeId": "RecordTypeId4", "RecordType": { "Id": "RecordTypeId4" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "399", "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "CA10__type__c": "application", "Id": "004", "RecordTypeId": "RecordTypeId2", "RecordType": { "Id": "RecordTypeId2" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [ { "CA10__disappearanceTime__c": null, "CA10__policyName__c": "ELBSecurityPolicy-TLS13-1-2-2021-06", "CA10__loadBalancer__c": "004", "CA10__protocol__c": "HTTPS", "Id": "004-1", "RecordTypeId": "RecordTypeId4", "RecordType": { "Id": "RecordTypeId4" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "400", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2025-12-01T00:50:53Z" }, "CA10__disappearanceTime__c": null, "CA10__type__c": "network", "Id": "005", "RecordTypeId": "RecordTypeId2", "RecordType": { "Id": "RecordTypeId2" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [ { "CA10__disappearanceTime__c": null, "CA10__policyName__c": "ELBSecurityPolicy-TLS13-1-2-2021-06", "CA10__loadBalancer__c": "005", "CA10__protocol__c": "TCP", "Id": "005-1", "RecordTypeId": "RecordTypeId4", "RecordType": { "Id": "RecordTypeId4" } } ] } ] - path: /types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml md5Hash: 9895F1EB30DFD8DDB6D571F452C5A7DE 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\n# Checkbox.\n\ \ - name: CA10__connectionDrainingEnabled__c\n value: \n FIELD:\n \ \ path: CA10__connectionDrainingEnabled__c\n" - path: /types/CA10__CaAwsLoadBalancerListener__c/object.extracts.yaml md5Hash: B08DBF798158B3BBDAE5E17EB15C281B 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 - name: CA10__policyName__c\n\ \ value: \n FIELD:\n path: CA10__policyName__c\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "001", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'network'", "runtimeError" : null } }, { "Id" : "002", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "003", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "299", "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "004", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "399", "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "005", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "400", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancer__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__type__c" : "classic", "Id" : "001", "RecordTypeId" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__type__c" : "network", "Id" : "002", "RecordTypeId" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__type__c" : "application", "Id" : "003", "RecordTypeId" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__type__c" : "application", "Id" : "004", "RecordTypeId" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__type__c" : "network", "Id" : "005", "RecordTypeId" : "RecordTypeId2" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancerListener__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__policyName__c" : "", "CA10__protocol__c" : "HTTPS", "CA10__loadBalancer__c" : "001", "Id" : "001-1", "RecordTypeId" : "RecordTypeId3" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__policyName__c" : "ELBSecurityPolicy-TLS13-1-3-2021-06", "CA10__protocol__c" : "HTTPS", "CA10__loadBalancer__c" : "003", "Id" : "003-1", "RecordTypeId" : "RecordTypeId4" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__policyName__c" : "ELBSecurityPolicy-TLS-1-2-2017-01", "CA10__protocol__c" : "HTTPS", "CA10__loadBalancer__c" : "003", "Id" : "003-2", "RecordTypeId" : "RecordTypeId4" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__policyName__c" : "ELBSecurityPolicy-TLS13-1-2-2021-06", "CA10__protocol__c" : "HTTPS", "CA10__loadBalancer__c" : "004", "Id" : "004-1", "RecordTypeId" : "RecordTypeId4" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "CA10__policyName__c" : "ELBSecurityPolicy-TLS13-1-2-2021-06", "CA10__protocol__c" : "TCP", "CA10__loadBalancer__c" : "005", "Id" : "005-1", "RecordTypeId" : "RecordTypeId4" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "RecordTypeId3" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2025-12-01T00:50:53Z") }, "Id" : "RecordTypeId4" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsLoadBalancer__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__type__c STRING, CA10__AWS_EC2_Load_Balancer_Listeners__r ARRAY, result STRUCT >>, Id STRING, RecordTypeId STRING, RecordType STRUCT< Id STRING > >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] 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 fieldChecked4() { if (TextLib.isEmpty(obj.CA10__type__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, 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 extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Type [obj.CA10__type__c]: ' + obj.CA10__type__c); try { if (TextLib.notEqual(extract3.call(extract3), 'application') && TextLib.notEqual(extract3.call(extract3), 'network')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__type__c') != 'application' && extract('CA10__type__c') != 'network'", currentStateMessage: "This policy only applies to application and network load balancers.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } var count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT6 = 0; if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r != null) { for (var i7 = 0; i7 < obj.CA10__AWS_EC2_Load_Balancer_Listeners__r.length; i7++) { if (typeof(obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i7].status) !== 'undefined') { if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i7].status == 'INCOMPLIANT') { count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT6 += obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i7].count; } } else { if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i7].result.status == 'INCOMPLIANT') { count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT6 += 1; } } } } // condition[2], conditionIndex:[200..299] references1.push('Related list [CA10__AWS_EC2_Load_Balancer_Listeners__r] ' + (count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT6 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status'); if (count_CA10__AWS_EC2_Load_Balancer_Listeners__r_INCOMPLIANT6 > 0) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)", currentStateMessage: "The load balancer has at least one listener using an outdated security policy.", currentStateReferences: references1.join('\n'), remediation: "Update the listener to use a recommended security policy.", runtimeError: null}; } var count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT8 = 0; if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r != null) { for (var i9 = 0; i9 < obj.CA10__AWS_EC2_Load_Balancer_Listeners__r.length; i9++) { if (typeof(obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i9].status) !== 'undefined') { if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i9].status == 'COMPLIANT') { count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT8 += obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i9].count; } } else { if (obj.CA10__AWS_EC2_Load_Balancer_Listeners__r[i9].result.status == 'COMPLIANT') { count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT8 += 1; } } } } // condition[3], conditionIndex:[300..399] if (count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT8 > 0) { return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", currentStateMessage: "All listeners are using recommended security policies.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "No HTTPS or TLS listeners are configured for this load balancer.", 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__policyName__c STRING, CA10__protocol__c STRING, CA10__loadBalancer__c STRING, Id STRING, RecordTypeId STRING, RecordType STRUCT< Id STRING > >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" 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 TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] 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__policyName__c; } return this.out; }; function extract6() { if (!this.out) { this.out = obj.CA10__protocol__c; } return this.out; }; references1.push('Policy Name [obj.CA10__policyName__c]: ' + obj.CA10__policyName__c); references1.push('Protocol [obj.CA10__protocol__c]: ' + obj.CA10__protocol__c); if (TextLib.containsAny(extract3.call(extract3), CollectionLib.fromArray(['ELBSecurityPolicy-TLS13-1-2-2021-06', 'ELBSecurityPolicy-TLS13-1-2-FIPS-2023-04', 'ELBSecurityPolicy-TLS13-1-3-2021-06', 'ELBSecurityPolicy-TLS13-1-3-FIPS-2023-04', 'ELBSecurityPolicy-TLS13-1-2-Res-2021-06 ', 'ELBSecurityPolicy-TLS13-1-2-Res-FIPS-2023-04'], true, true, true, true)) && TextLib.containsAny(extract6.call(extract6), CollectionLib.fromArray(['HTTPS', 'TLS'], true, true, true, true))) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__policyName__c').containsAny(setOfText(['ELBSecurityPolicy-TLS13-1-2-2021-06', 'ELBSecurityPolicy-TLS13-1-2-FIPS-2023-04', 'ELBSecurityPolicy-TLS13-1-3-2021-06', 'ELBSecurityPolicy-TLS13-1-3-FIPS-2023-04', 'ELBSecurityPolicy-TLS13-1-2-Res-2021-06 ', 'ELBSecurityPolicy-TLS13-1-2-Res-FIPS-2023-04'])) && extract('CA10__protocol__c').containsAny(setOfText(['HTTPS', 'TLS']))", currentStateMessage: "The listener uses a recommended security policy.", 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', 'TLS'], true, true, true, true))) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__protocol__c').containsAny(setOfText(['HTTPS', 'TLS']))", currentStateMessage: "The listener uses an outdated security policy.", currentStateReferences: references1.join('\n'), remediation: "Update the listener's security policy.", runtimeError: null}; } return {status: 'INAPPLICABLE', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "This is not an HTTPS or TLS listener.", 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, `CA10__AWS_EC2_Load_Balancer_Listeners__r`.arr AS CA10__AWS_EC2_Load_Balancer_Listeners__r, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `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, `CA10__AWS_EC2_Load_Balancer_Listeners__r`.arr AS CA10__AWS_EC2_Load_Balancer_Listeners__r, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `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 LEFT JOIN ( SELECT sObject.CA10__loadBalancer__c, ARRAY_AGG( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__policyName__c AS CA10__policyName__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__policyName__c AS CA10__policyName__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;