--- policy: /ce/ca/aws/elb/load-balancer-redirects-http-to-https logic: /ce/ca/aws/elb/load-balancer-redirects-http-to-https/prod.logic.yaml executionTime: 2026-06-06T12:02:57.158571392Z generationMs: 134 executionMs: 1385 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: 199 actual: 199 conditionText: expected: "not(setOfText(['caAwsLoadBalancerApplication']).contains(RecordType.DeveloperName))" actual: "not(setOfText(['caAwsLoadBalancerApplication']).contains(RecordType.DeveloperName))" runtimeError: {} - id: test3 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__type__c') != 'application' actual: extract('CA10__type__c') != 'application' runtimeError: {} - id: test4 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 399 actual: 399 conditionText: expected: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT) actual: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT) runtimeError: {} - id: test5 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT) actual: CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT) runtimeError: {} - id: test6 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 500 actual: 500 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test7 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 499 actual: 499 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-redirects-http-to-https/policy.yaml md5Hash: 8221BADCB32049ABBF15717ED226D5EE content: "---\nnames:\n full: \"AWS ELB Application Load Balancer is not configured\ \ to redirect HTTP to HTTPS\"\n contextual: \"Application Load Balancer is\ \ not configured to redirect HTTP to HTTPS\"\ndescription: >\n Ensure that\ \ Application Load Balancers are configured to automatically redirect \n all\ \ incoming HTTP traffic (port 80) to HTTPS (port 443). This ensures that data\ \ \n in transit is always encrypted.\"\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n\ \ - \"SECURITY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/resource-security/data-encryption\"\ \n - \"/frameworks/aws-fsbp-v1.0.0/elb/01\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[ELB.1] Application Load Balancer should be configured to redirect\ \ all HTTP requests to HTTPS\"\n url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/elb-controls.html#elb-1\"" - path: /ce/ca/aws/elb/load-balancer-redirects-http-to-https/prod.logic.yaml md5Hash: 089BB5A1C370067FB181F3095E6A3675 content: "---\ninputType: \"CA10__CaAwsLoadBalancer__c\"\nimportExtracts:\n -\ \ file: \"/types/CA10__CaAwsLoadBalancer__c/object.extracts.yaml\"\n - file:\ \ \"/types/CA10__CaAwsLoadBalancerListener__c/object.extracts.yaml\"\n - file:\ \ \"/types/CA10__CaAwsLoadBalancerListenerRule__c/object.extracts.yaml\"\nrecordTypes:\n\ \ - \"caAwsLoadBalancerApplication\"\ntestData:\n - file: \"test-data.json\"\ \nconditions:\n - status: \"INAPPLICABLE\"\n currentStateMessage: \"This\ \ is not an application load balancer.\"\n check:\n NOT_EQUAL:\n \ \ left:\n EXTRACT: \"CA10__type__c\"\n right:\n \ \ TEXT: \"application\"\n - status: \"INCOMPLIANT\"\n currentStateMessage:\ \ \"The ALB has an HTTP listener that is not configured to redirect to HTTPS.\"\ \n remediationMessage: \"Modify the HTTP listener to use a default action\ \ that redirects to port 443.\"\n check:\n RELATED_LIST_HAS:\n \ \ status: \"INCOMPLIANT\"\n relationshipName: \"CA10__AWS_EC2_Load_Balancer_Listeners__r\"\ \n - status: \"COMPLIANT\"\n currentStateMessage: \"The ALB correctly redirects\ \ HTTP traffic to HTTPS.\"\n check:\n RELATED_LIST_HAS:\n status:\ \ \"COMPLIANT\"\n relationshipName: \"CA10__AWS_EC2_Load_Balancer_Listeners__r\"\ \notherwise:\n status: \"COMPLIANT\"\n currentStateMessage: \"The ALB does\ \ not have an HTTP listener enabled.\"\nrelatedLists:\n - relationshipName:\ \ \"CA10__AWS_EC2_Load_Balancer_Listeners__r\"\n conditions:\n - status:\ \ \"INAPPLICABLE\"\n currentStateMessage: \"This is not an HTTP listener.\"\ \n check:\n NOT_EQUAL:\n left:\n EXTRACT:\ \ \"CA10__protocol__c\"\n right:\n TEXT: \"HTTP\"\n\ \ - status: \"COMPLIANT\"\n currentStateMessage: \"The load balancer\ \ listener's default action redirects HTTP to HTTPS.\"\n check:\n \ \ NOT_EQUAL:\n left:\n JSON_QUERY_NUMBER:\n \ \ expression: \"length([?type=='redirect' && redirectConfig.protocol=='HTTPS'\ \ && redirectConfig.port=='443'])\"\n arg:\n \ \ EXTRACT: \"caJsonFrom_defaultActionsJson__c\"\n undeterminedIf:\n\ \ evaluationError: \"The JSON query has failed.\"\n \ \ resultTypeMismatch: \"The JSON query did not return Number type.\"\ \ \n right:\n NUMBER: 0.0\n - status: \"COMPLIANT\"\ \n currentStateMessage: \"The load balancer listener's rule action redirects\ \ HTTP to HTTPS.\"\n check:\n RELATED_LIST_HAS:\n \ \ status: \"COMPLIANT\"\n relationshipName: \"CA10__AWS_EC2_Load_Balancer_Listener_Rules__r\"\ \n otherwise:\n status: \"INCOMPLIANT\"\n currentStateMessage:\ \ \"This HTTP listener does not have a redirect action configured.\"\n relatedLists:\n\ \ - relationshipName: \"CA10__AWS_EC2_Load_Balancer_Listener_Rules__r\"\ \n conditions:\n - status: \"COMPLIANT\"\n currentStateMessage:\ \ \"The load balancer listener rule action redirects HTTP to HTTPS.\"\n \ \ check:\n NOT_EQUAL:\n left:\n \ \ JSON_QUERY_NUMBER:\n expression: \"length([?type=='redirect'\ \ && redirectConfig.protocol=='HTTPS' && redirectConfig.port=='443'])\"\n \ \ arg:\n EXTRACT: \"caJsonFrom_actionsJson__c\"\ \n undeterminedIf:\n evaluationError:\ \ \"The JSON query has failed.\"\n resultTypeMismatch:\ \ \"The JSON query did not return Number type.\" \n right:\n\ \ NUMBER: 0.0\n otherwise:\n status: \"INCOMPLIANT\"\ \n currentStateMessage: \"This HTTP listener rule does not have the\ \ required redirect action.\"\n" - path: /ce/ca/aws/elb/load-balancer-redirects-http-to-https/test-data.json md5Hash: B18730B58C5394F24802342E2263F88B content: |- [ { "CA10__type__c": "network", "RecordType": { "Id": "RecordTypeId1", "DeveloperName": "caAwsLoadBalancerApplication" }, "expectedResult": { "runtimeError": null, "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "conditionIndex": 99, "status": "DISAPPEARED" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [], "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "RecordTypeId": "RecordTypeId1", "Id": "test1", "CA10__disappearanceTime__c": "2025-12-10T09:11:05Z" }, { "CA10__type__c": "classic", "RecordType": { "Id": "RecordTypeId2", "DeveloperName": "caAwsLoadBalancerClassic" }, "expectedResult": { "runtimeError": null, "conditionText": "not(setOfText(['caAwsLoadBalancerApplication']).contains(RecordType.DeveloperName))", "conditionIndex": 199, "status": "INAPPLICABLE" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [], "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "RecordTypeId": "RecordTypeId2", "Id": "test2", "CA10__disappearanceTime__c": null }, { "CA10__type__c": "gateway", "RecordType": { "Id": "RecordTypeId1", "DeveloperName": "caAwsLoadBalancerApplication" }, "expectedResult": { "runtimeError": null, "conditionText": "extract('CA10__type__c') != 'application'", "conditionIndex": 299, "status": "INAPPLICABLE" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [], "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "RecordTypeId": "RecordTypeId1", "Id": "test3", "CA10__disappearanceTime__c": null }, { "CA10__type__c": "application", "RecordType": { "Id": "RecordTypeId1", "DeveloperName": "caAwsLoadBalancerApplication" }, "expectedResult": { "runtimeError": null, "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)", "conditionIndex": 399, "status": "INCOMPLIANT" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [ { "RecordType": { "Id": "RecordTypeId1_1" }, "CA10__protocol__c": "HTTP", "RecordTypeId": "RecordTypeId1_1", "CA10__defaultActionsJson__c": "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "CA10__loadBalancer__c": "test4", "Id": "test4_1", "CA10__disappearanceTime__c": null, "CA10__AWS_EC2_Load_Balancer_Listener_Rules__r": [ { "CA10__actionsJson__c": "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "Id": "test4_2", "CA10__disappearanceTime__c": null, "CA10__listener__c": "test4_1" } ] } ], "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "RecordTypeId": "RecordTypeId1", "Id": "test4", "CA10__disappearanceTime__c": null }, { "CA10__type__c": "application", "RecordType": { "Id": "RecordTypeId1", "DeveloperName": "caAwsLoadBalancerApplication" }, "expectedResult": { "runtimeError": null, "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", "conditionIndex": 499, "status": "COMPLIANT" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [ { "RecordType": { "Id": "RecordTypeId1_1" }, "CA10__protocol__c": "HTTP", "RecordTypeId": "RecordTypeId1_1", "CA10__defaultActionsJson__c": "[{\"type\":\"redirect\",\"order\":1,\"redirectConfig\":{\"protocol\":\"HTTPS\",\"port\":\"443\",\"host\":\"#{host}\",\"path\":\"/#{path}\",\"query\":\"#{query}\",\"statusCode\":\"HTTP_301\"}}]", "CA10__loadBalancer__c": "test5", "Id": "test5_1", "CA10__disappearanceTime__c": null, "CA10__AWS_EC2_Load_Balancer_Listener_Rules__r": [ { "CA10__actionsJson__c": "[{\"type\":\"redirect\",\"order\":1,\"redirectConfig\":{\"protocol\":\"HTTPS\",\"port\":\"443\",\"host\":\"#{host}\",\"path\":\"/#{path}\",\"query\":\"#{query}\",\"statusCode\":\"HTTP_301\"}}]", "Id": "test5_2", "CA10__disappearanceTime__c": null, "CA10__listener__c": "test5_1" } ] }, { "RecordType": { "Id": "RecordTypeId1_1" }, "CA10__protocol__c": "HTTPS", "RecordTypeId": "RecordTypeId1_1", "CA10__defaultActionsJson__c": "[{\"type\":\"fixed-response\",\"order\":1,\"fixedResponseConfig\":{\"messageBody\":\"HEALTHY\",\"statusCode\":\"200\",\"contentType\":\"text/plain\"}}]", "CA10__loadBalancer__c": "test5", "Id": "test5_3", "CA10__disappearanceTime__c": null, "CA10__AWS_EC2_Load_Balancer_Listener_Rules__r": [ { "CA10__actionsJson__c": "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"order\":1,\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "Id": "test5_4", "CA10__disappearanceTime__c": null, "CA10__listener__c": "test5_3" } ] } ], "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "RecordTypeId": "RecordTypeId1", "Id": "test5", "CA10__disappearanceTime__c": null }, { "CA10__type__c": "application", "RecordType": { "Id": "RecordTypeId1", "DeveloperName": "caAwsLoadBalancerApplication" }, "expectedResult": { "runtimeError": null, "conditionText": "otherwise", "conditionIndex": 500, "status": "COMPLIANT" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [], "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "RecordTypeId": "RecordTypeId1", "Id": "test6", "CA10__disappearanceTime__c": null }, { "CA10__type__c": "application", "RecordType": { "Id": "RecordTypeId1", "DeveloperName": "caAwsLoadBalancerApplication" }, "expectedResult": { "runtimeError": null, "conditionText": "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", "conditionIndex": 499, "status": "COMPLIANT" }, "CA10__AWS_EC2_Load_Balancer_Listeners__r": [ { "RecordType": { "Id": "RecordTypeId1_1" }, "CA10__protocol__c": "HTTP", "RecordTypeId": "RecordTypeId1_1", "CA10__defaultActionsJson__c": "[{\"type\":\"fixed-response\",\"order\":1,\"fixedResponseConfig\":{\"messageBody\":\"HEALTHY\",\"statusCode\":\"200\",\"contentType\":\"text/plain\"}}]", "CA10__loadBalancer__c": "test7", "Id": "test7_1", "CA10__disappearanceTime__c": null, "CA10__AWS_EC2_Load_Balancer_Listener_Rules__r": [ { "CA10__actionsJson__c": "[{\"type\":\"redirect\",\"order\":1,\"redirectConfig\":{\"protocol\":\"HTTPS\",\"port\":\"443\",\"host\":\"#{host}\",\"path\":\"/#{path}\",\"query\":\"#{query}\",\"statusCode\":\"HTTP_301\"}}]", "Id": "test7_2", "CA10__disappearanceTime__c": null, "CA10__listener__c": "test7_1" } ] }, { "RecordType": { "Id": "RecordTypeId1_1" }, "CA10__protocol__c": "HTTPS", "RecordTypeId": "RecordTypeId1_1", "CA10__defaultActionsJson__c": "[{\"type\":\"fixed-response\",\"order\":1,\"fixedResponseConfig\":{\"messageBody\":\"HEALTHY\",\"statusCode\":\"200\",\"contentType\":\"text/plain\"}}]", "CA10__loadBalancer__c": "test7", "Id": "test7_3", "CA10__disappearanceTime__c": null, "CA10__AWS_EC2_Load_Balancer_Listener_Rules__r": [ { "CA10__actionsJson__c": "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"order\":1,\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "Id": "test7_4", "CA10__disappearanceTime__c": null, "CA10__listener__c": "test7_3" } ] } ], "context": { "snapshotTime": "2025-12-19T02:21:26Z" }, "RecordTypeId": "RecordTypeId1", "Id": "test7", "CA10__disappearanceTime__c": null } ] - path: /types/CA10__CaAwsLoadBalancerListenerRule__c/object.extracts.yaml md5Hash: 8620B9052184EA9DCB295F50762E2F27 content: "---\nextracts:\n# Not nullable. Can't have no access, retrieved via\ \ elasticloadbalancing:DescribeRules\n - name: CA10__actionsJson__c\n value:\ \ \n FIELD:\n returnType: \"BYTES\"\n path: CA10__actionsJson__c\n\ \ undeterminedIf:\n isEmpty: \"Load Balancer Listener Rule Actions\ \ cannot be empty. Corrupted data.\"\n - name: caJsonFrom_actionsJson__c\n\ \ value: \n JSON_FROM:\n arg:\n EXTRACT: \"CA10__actionsJson__c\"\ \n undeterminedIf:\n isInvalid: \"The Actions JSON is invalid\"\ \n" - 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" : "test1", "expectedResult" : { "runtimeError" : null, "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "conditionIndex" : 99, "status" : "DISAPPEARED" } }, { "Id" : "test2", "expectedResult" : { "runtimeError" : null, "conditionText" : "not(setOfText(['caAwsLoadBalancerApplication']).contains(RecordType.DeveloperName))", "conditionIndex" : 199, "status" : "INAPPLICABLE" } }, { "Id" : "test3", "expectedResult" : { "runtimeError" : null, "conditionText" : "extract('CA10__type__c') != 'application'", "conditionIndex" : 299, "status" : "INAPPLICABLE" } }, { "Id" : "test4", "expectedResult" : { "runtimeError" : null, "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)", "conditionIndex" : 399, "status" : "INCOMPLIANT" } }, { "Id" : "test5", "expectedResult" : { "runtimeError" : null, "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", "conditionIndex" : 499, "status" : "COMPLIANT" } }, { "Id" : "test6", "expectedResult" : { "runtimeError" : null, "conditionText" : "otherwise", "conditionIndex" : 500, "status" : "COMPLIANT" } }, { "Id" : "test7", "expectedResult" : { "runtimeError" : null, "conditionText" : "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", "conditionIndex" : 499, "status" : "COMPLIANT" } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancer__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__disappearanceTime__c" : new Date("2025-12-10T09:11:05Z"), "CA10__type__c" : "network", "Id" : "test1", "RecordTypeId" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__type__c" : "classic", "Id" : "test2", "RecordTypeId" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__type__c" : "gateway", "Id" : "test3", "RecordTypeId" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__type__c" : "application", "Id" : "test4", "RecordTypeId" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__type__c" : "application", "Id" : "test5", "RecordTypeId" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__type__c" : "application", "Id" : "test6", "RecordTypeId" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__type__c" : "application", "Id" : "test7", "RecordTypeId" : "RecordTypeId1" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "DeveloperName" : "caAwsLoadBalancerApplication", "Id" : "RecordTypeId1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "DeveloperName" : "caAwsLoadBalancerClassic", "Id" : "RecordTypeId2" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "Id" : "RecordTypeId1_1" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancerListener__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__protocol__c" : "HTTP", "CA10__defaultActionsJson__c" : "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "CA10__loadBalancer__c" : "test4", "Id" : "test4_1", "RecordTypeId" : "RecordTypeId1_1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__protocol__c" : "HTTP", "CA10__defaultActionsJson__c" : "[{\"type\":\"redirect\",\"order\":1,\"redirectConfig\":{\"protocol\":\"HTTPS\",\"port\":\"443\",\"host\":\"#{host}\",\"path\":\"/#{path}\",\"query\":\"#{query}\",\"statusCode\":\"HTTP_301\"}}]", "CA10__loadBalancer__c" : "test5", "Id" : "test5_1", "RecordTypeId" : "RecordTypeId1_1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__protocol__c" : "HTTPS", "CA10__defaultActionsJson__c" : "[{\"type\":\"fixed-response\",\"order\":1,\"fixedResponseConfig\":{\"messageBody\":\"HEALTHY\",\"statusCode\":\"200\",\"contentType\":\"text/plain\"}}]", "CA10__loadBalancer__c" : "test5", "Id" : "test5_3", "RecordTypeId" : "RecordTypeId1_1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__protocol__c" : "HTTP", "CA10__defaultActionsJson__c" : "[{\"type\":\"fixed-response\",\"order\":1,\"fixedResponseConfig\":{\"messageBody\":\"HEALTHY\",\"statusCode\":\"200\",\"contentType\":\"text/plain\"}}]", "CA10__loadBalancer__c" : "test7", "Id" : "test7_1", "RecordTypeId" : "RecordTypeId1_1" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__protocol__c" : "HTTPS", "CA10__defaultActionsJson__c" : "[{\"type\":\"fixed-response\",\"order\":1,\"fixedResponseConfig\":{\"messageBody\":\"HEALTHY\",\"statusCode\":\"200\",\"contentType\":\"text/plain\"}}]", "CA10__loadBalancer__c" : "test7", "Id" : "test7_3", "RecordTypeId" : "RecordTypeId1_1" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsLoadBalancerListenerRule__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__actionsJson__c" : "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "CA10__listener__c" : "test4_1", "Id" : "test4_2" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__actionsJson__c" : "[{\"type\":\"redirect\",\"order\":1,\"redirectConfig\":{\"protocol\":\"HTTPS\",\"port\":\"443\",\"host\":\"#{host}\",\"path\":\"/#{path}\",\"query\":\"#{query}\",\"statusCode\":\"HTTP_301\"}}]", "CA10__listener__c" : "test5_1", "Id" : "test5_2" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__actionsJson__c" : "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"order\":1,\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "CA10__listener__c" : "test5_3", "Id" : "test5_4" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__actionsJson__c" : "[{\"type\":\"redirect\",\"order\":1,\"redirectConfig\":{\"protocol\":\"HTTPS\",\"port\":\"443\",\"host\":\"#{host}\",\"path\":\"/#{path}\",\"query\":\"#{query}\",\"statusCode\":\"HTTP_301\"}}]", "CA10__listener__c" : "test7_1", "Id" : "test7_2" }, { "context" : { "snapshotTime" : new Date("2025-12-19T02:21:26Z") }, "CA10__actionsJson__c" : "[{\"type\":\"forward\",\"targetGroupArn\":\"targetGroupArn\",\"order\":1,\"forwardConfig\":{\"targetGroups\":[{\"targetGroupArn\":\"targetGroupArn\",\"weight\":1}]}}]", "CA10__listener__c" : "test7_3", "Id" : "test7_4" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsLoadBalancer__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, RecordType STRUCT< DeveloperName STRING, Id STRING >, CA10__type__c STRING, CA10__AWS_EC2_Load_Balancer_Listeners__r ARRAY >>, CA10__loadBalancer__c STRING, Id STRING, RecordTypeId STRING, RecordType STRUCT< Id STRING >, result STRUCT >>, Id STRING, RecordTypeId 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] references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName); if (!CollectionLib.contains(CollectionLib.fromArray(['caAwsLoadBalancerApplication'], true, true, true, true), obj.RecordType.DeveloperName, true)) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['caAwsLoadBalancerApplication']).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')) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__type__c') != 'application'", currentStateMessage: "This is not an application load balancer.", 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[3], conditionIndex:[300..399] 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: 399, conditionText: "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(INCOMPLIANT)", currentStateMessage: "The ALB has an HTTP listener that is not configured to redirect to HTTPS.", currentStateReferences: references1.join('\n'), remediation: "Modify the HTTP listener to use a default action that redirects to port 443.", 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[4], conditionIndex:[400..499] if (count_CA10__AWS_EC2_Load_Balancer_Listeners__r_COMPLIANT8 > 0) { return {status: 'COMPLIANT', conditionIndex: 499, conditionText: "CA10__AWS_EC2_Load_Balancer_Listeners__r.has(COMPLIANT)", currentStateMessage: "The ALB correctly redirects HTTP traffic to HTTPS.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The ALB does not have an HTTP listener enabled.", 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__protocol__c STRING, CA10__defaultActionsJson__c STRING, CA10__AWS_EC2_Load_Balancer_Listener_Rules__r ARRAY >>, CA10__loadBalancer__c STRING, Id STRING, RecordTypeId STRING, RecordType STRUCT< Id STRING > >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js OPTIONS (library=['gs://compliance-platform-public/jmespath.min.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 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__protocol__c; } return this.out; }; references1.push('Protocol [obj.CA10__protocol__c]: ' + obj.CA10__protocol__c); if (TextLib.notEqual(extract3.call(extract3), 'HTTP')) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__protocol__c') != 'HTTP'", currentStateMessage: "This is not an HTTP listener.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function jsonQueryChecked5() { var input = extract7.call(extract7); var out; try { out = jmespath.search(input, 'length([?type==\'redirect\' && redirectConfig.protocol==\'HTTPS\' && redirectConfig.port==\'443\'])'); if (out != null && typeof out != 'number') { throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extract('caJsonFrom_defaultActionsJson__c').jsonQueryText('length([?type==\\'redirect\\' && redirectConfig.protocol==\\'HTTPS\\' && redirectConfig.port==\\'443\\'])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return Number type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } } catch (e) { throw new Error("UNDETERMINED condition:204", {cause: {status: 'UNDETERMINED', conditionIndex: 204, conditionText: "extract('caJsonFrom_defaultActionsJson__c').jsonQueryText('length([?type==\\'redirect\\' && redirectConfig.protocol==\\'HTTPS\\' && redirectConfig.port==\\'443\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked8() { var input = extract10.call(extract10); input = TextLib.isEmpty(input) ? null : input; var out; try { out = JSON.parse(input); } catch (e) { throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extract('CA10__defaultActionsJson__c').asJson().isInvalid()", currentStateMessage: "The Actions JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function fieldChecked11() { if (BytesLib.isEmpty(obj.CA10__defaultActionsJson__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__defaultActionsJson__c.isEmpty()", currentStateMessage: "Load Balancer Listener Default Action cannot be empty. Corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__defaultActionsJson__c; } function extract10() { if (!this.out) { this.out = fieldChecked11(); } return this.out; }; function extract7() { if (!this.out) { this.out = jsonChecked8(); } return this.out; }; references1.push('Default Actions JSON [obj.CA10__defaultActionsJson__c]: ' + obj.CA10__defaultActionsJson__c); try { if (jsonQueryChecked5() != 0.0) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('caJsonFrom_defaultActionsJson__c').jsonQueryText('length([?type==\\'redirect\\' && redirectConfig.protocol==\\'HTTPS\\' && redirectConfig.port==\\'443\\'])') != number(0.0)", currentStateMessage: "The load balancer listener's default action redirects HTTP to HTTPS.", 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_Listener_Rules__r_COMPLIANT12 = 0; if (obj.CA10__AWS_EC2_Load_Balancer_Listener_Rules__r != null) { for (var i13 = 0; i13 < obj.CA10__AWS_EC2_Load_Balancer_Listener_Rules__r.length; i13++) { if (typeof(obj.CA10__AWS_EC2_Load_Balancer_Listener_Rules__r[i13].status) !== 'undefined') { if (obj.CA10__AWS_EC2_Load_Balancer_Listener_Rules__r[i13].status == 'COMPLIANT') { count_CA10__AWS_EC2_Load_Balancer_Listener_Rules__r_COMPLIANT12 += obj.CA10__AWS_EC2_Load_Balancer_Listener_Rules__r[i13].count; } } else { if (obj.CA10__AWS_EC2_Load_Balancer_Listener_Rules__r[i13].result.status == 'COMPLIANT') { count_CA10__AWS_EC2_Load_Balancer_Listener_Rules__r_COMPLIANT12 += 1; } } } } // condition[3], conditionIndex:[300..399] references1.push('Related list [CA10__AWS_EC2_Load_Balancer_Listener_Rules__r] ' + (count_CA10__AWS_EC2_Load_Balancer_Listener_Rules__r_COMPLIANT12 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status'); if (count_CA10__AWS_EC2_Load_Balancer_Listener_Rules__r_COMPLIANT12 > 0) { return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "CA10__AWS_EC2_Load_Balancer_Listener_Rules__r.has(COMPLIANT)", currentStateMessage: "The load balancer listener's rule action redirects HTTP to HTTPS.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'INCOMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "This HTTP listener does not have a redirect action configured.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__AWS_EC2_Load_Balancer_Listeners__r_CA10__AWS_EC2_Load_Balancer_Listener_Rules__r( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__actionsJson__c STRING, CA10__listener__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js OPTIONS (library=['gs://compliance-platform-public/jmespath.min.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 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 jsonQueryChecked2() { var input = extract4.call(extract4); var out; try { out = jmespath.search(input, 'length([?type==\'redirect\' && redirectConfig.protocol==\'HTTPS\' && redirectConfig.port==\'443\'])'); if (out != null && typeof out != 'number') { throw new Error("UNDETERMINED condition:103", {cause: {status: 'UNDETERMINED', conditionIndex: 103, conditionText: "extract('caJsonFrom_actionsJson__c').jsonQueryText('length([?type==\\'redirect\\' && redirectConfig.protocol==\\'HTTPS\\' && redirectConfig.port==\\'443\\'])').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return Number type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } } catch (e) { throw new Error("UNDETERMINED condition:104", {cause: {status: 'UNDETERMINED', conditionIndex: 104, conditionText: "extract('caJsonFrom_actionsJson__c').jsonQueryText('length([?type==\\'redirect\\' && redirectConfig.protocol==\\'HTTPS\\' && redirectConfig.port==\\'443\\'])').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function jsonChecked5() { var input = extract7.call(extract7); input = TextLib.isEmpty(input) ? null : input; var out; try { out = JSON.parse(input); } catch (e) { throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "extract('CA10__actionsJson__c').asJson().isInvalid()", currentStateMessage: "The Actions JSON is invalid", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}}); } return out; } function fieldChecked8() { if (BytesLib.isEmpty(obj.CA10__actionsJson__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__actionsJson__c.isEmpty()", currentStateMessage: "Load Balancer Listener Rule Actions cannot be empty. Corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__actionsJson__c; } function extract7() { if (!this.out) { this.out = fieldChecked8(); } return this.out; }; function extract4() { if (!this.out) { this.out = jsonChecked5(); } return this.out; }; references1.push('Actions JSON [obj.CA10__actionsJson__c]: ' + obj.CA10__actionsJson__c); try { if (jsonQueryChecked2() != 0.0) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('caJsonFrom_actionsJson__c').jsonQueryText('length([?type==\\'redirect\\' && redirectConfig.protocol==\\'HTTPS\\' && redirectConfig.port==\\'443\\'])') != number(0.0)", currentStateMessage: "The load balancer listener rule action redirects HTTP to HTTPS.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This HTTP listener rule does not have the required redirect action.", 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, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, 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, process_CA10__CaAwsLoadBalancer__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, 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 ), 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__protocol__c AS CA10__protocol__c, sObject.CA10__defaultActionsJson__c AS CA10__defaultActionsJson__c, `CA10__AWS_EC2_Load_Balancer_Listener_Rules__r`.arr AS CA10__AWS_EC2_Load_Balancer_Listener_Rules__r, 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__protocol__c AS CA10__protocol__c, sObject.CA10__defaultActionsJson__c AS CA10__defaultActionsJson__c, `CA10__AWS_EC2_Load_Balancer_Listener_Rules__r`.arr AS CA10__AWS_EC2_Load_Balancer_Listener_Rules__r, 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 LEFT JOIN ( SELECT sObject.CA10__listener__c, ARRAY_AGG( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__actionsJson__c AS CA10__actionsJson__c, sObject.CA10__listener__c AS CA10__listener__c, sObject.Id AS Id, process_CA10__AWS_EC2_Load_Balancer_Listeners__r_CA10__AWS_EC2_Load_Balancer_Listener_Rules__r( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__actionsJson__c AS CA10__actionsJson__c, sObject.CA10__listener__c AS CA10__listener__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10__CaAwsLoadBalancerListenerRule__c()) AS sObject GROUP BY sObject.CA10__listener__c ) AS `CA10__AWS_EC2_Load_Balancer_Listener_Rules__r` ON sObject.Id = `CA10__AWS_EC2_Load_Balancer_Listener_Rules__r`.CA10__listener__c 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;