--- policy: /ce/ca/aws/autoscaling/group-config-public-ip-assignement logic: /ce/ca/aws/autoscaling/group-config-public-ip-assignement/prod.logic.yaml executionTime: 2026-06-06T12:02:30.766878391Z generationMs: 66 executionMs: 1272 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: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT) actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT) runtimeError: {} - id: test3 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT) actual: CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT) runtimeError: {} - id: test4 match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10__launchConfigurationName__c').isEmpty() actual: extract('CA10__launchConfigurationName__c').isEmpty() runtimeError: {} - id: test5 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 399 actual: 399 conditionText: expected: isEmptyLookup('CA10__launchConfiguration__r') actual: isEmptyLookup('CA10__launchConfiguration__r') runtimeError: {} - id: test6 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 399 actual: 399 conditionText: expected: isEmptyLookup('CA10__launchConfiguration__r') actual: isEmptyLookup('CA10__launchConfiguration__r') runtimeError: {} - id: test7 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 499 actual: 499 conditionText: expected: extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == true actual: extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == true runtimeError: {} - id: test8 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 599 actual: 599 conditionText: expected: extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == false actual: extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == false runtimeError: {} usedFiles: - path: /ce/ca/aws/autoscaling/group-config-public-ip-assignement/policy.yaml md5Hash: 903A682E062061B5C47536E2F1574794 content: "---\nnames:\n full: AWS EC2 Auto Scaling Group behind ELB assigns public\ \ IP to instances\n contextual: Auto Scaling Group behind ELB assigns public\ \ IP to instances\ndescription: >\n Ensure that EC2 instances launched by Auto\ \ Scaling Group launch configuration \n and accessible from behind a load balancer\ \ are not assigned public IP addresses.\ncategories:\n - \"RELIABILITY\"\n\ \ - \"SECURITY\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\ \n - \"/frameworks/cloudaware/resource-security/network-exposure\"\n - \"\ /frameworks/aws-fsbp-v1.0.0/auto-scaling/05\"\nsimilarPolicies:\n awsSecurityHub:\n\ \ - name: \"[Autoscaling.5] Amazon EC2 instances launched using Auto Scaling\ \ group launch configurations should not have Public IP addresses\"\n url:\ \ \"https://docs.aws.amazon.com/securityhub/latest/userguide/autoscaling-controls.html#autoscaling-5\"\ \n internal:\n - dec-x-84342650\n" - path: /ce/ca/aws/autoscaling/group-config-public-ip-assignement/prod.logic.yaml md5Hash: E740FF33B003A6FE7BC6263162599569 content: "---\ninputType: \"CA10__CaAwsAutoScalingGroup__c\"\nimportExtracts:\n\ \ - file: \"/types/CA10__CaAwsAutoScalingGroupTrafficSourceLink__c/object.extracts.yaml\"\ \n - file: \"/types/CA10__CaAwsAutoScalingGroup__c/object.extracts.yaml\"\n\ \ - file: \"/types/CA10__CaAwsLaunchConfiguration__c/object.extracts.yaml\"\ \ntestData:\n - file: \"test-data.json\" \nconditions:\n - status: \"INAPPLICABLE\"\ \n currentStateMessage: \"The ASG is not associated with a load balancer.\"\ \n check:\n RELATED_LIST_HAS_NO:\n relationshipName: \"CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r\"\ \n status: \"COMPLIANT\"\n - status: \"INAPPLICABLE\"\n currentStateMessage:\ \ \"The ASG does not use a launch configuration.\"\n check:\n IS_EMPTY:\n\ \ arg:\n EXTRACT: \"CA10__launchConfigurationName__c\"\n -\ \ status: \"UNDETERMINED\"\n currentStateMessage: \"The launch configuration\ \ does not exist in the CMDB.\"\n check:\n IS_EMPTY_LOOKUP: \"CA10__launchConfiguration__r\"\ \n - status: \"INCOMPLIANT\"\n currentStateMessage: \"The launch configuration\ \ assigns a public IPv4 address to the group's instances.\"\n remediationMessage:\ \ \"Disable public IP assignment for instances behind a load balancer.\"\n \ \ check:\n IS_EQUAL:\n left:\n EXTRACT: \"CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c\"\ \n right:\n BOOLEAN: true\n - status: \"COMPLIANT\"\n currentStateMessage:\ \ \"The Auto Scaling group does not assign public IP addresses to instances\ \ behind a load balancer.\"\n check:\n IS_EQUAL:\n left:\n \ \ EXTRACT: \"CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c\"\ \n right:\n BOOLEAN: false\notherwise:\n status: \"UNDETERMINED\"\ \n currentStateMessage: \"Unexpected values in the fields.\"\nrelatedLists:\n\ \ - relationshipName: \"CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r\"\ \n conditions:\n - status: \"COMPLIANT\"\n currentStateMessage:\ \ \"The ASG traffic source is a Classic Load Balancer.\"\n check:\n \ \ IS_EQUAL:\n left:\n EXTRACT: \"CA10__trafficSourceType__c\"\ \n right:\n TEXT: \"elb\"\n - status: \"COMPLIANT\"\ \n currentStateMessage: \"The ASG traffic source is an ELB target group.\"\ \n check:\n IS_EQUAL:\n left:\n EXTRACT:\ \ \"CA10__trafficSourceType__c\"\n right:\n TEXT: \"\ elbv2\"\n otherwise:\n status: \"INAPPLICABLE\"\n currentStateMessage:\ \ \"Unrelated ASG traffic source.\"\n" - path: /ce/ca/aws/autoscaling/group-config-public-ip-assignement/test-data.json md5Hash: 60A5EE6525C71707FFC07B21C34E8A5C content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test1", "CA10__disappearanceTime__c": "2025-04-21T05:57:57Z", "CA10__launchConfigurationName__c": "launchConfigurationName", "CA10__launchConfiguration__c": "test1_1", "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": "test1_1", "CA10__disappearanceTime__c": null, "CA10__associatePublicIpAddress__c": true }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [ { "Id": "test1_2", "CA10__disappearanceTime__c": null, "CA10__trafficSourceType__c": "elbv2", "CA10__autoScalingGroup__c": "test1" } ] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test2", "CA10__disappearanceTime__c": null, "CA10__launchConfigurationName__c": "launchConfigurationName", "CA10__launchConfiguration__c": "test2_1", "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": "test2_1", "CA10__disappearanceTime__c": null, "CA10__associatePublicIpAddress__c": true }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "199", "conditionText": "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test3", "CA10__disappearanceTime__c": null, "CA10__launchConfigurationName__c": "launchConfigurationName", "CA10__launchConfiguration__c": "test3_1", "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": "test3_1", "CA10__disappearanceTime__c": null, "CA10__associatePublicIpAddress__c": true }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [ { "Id": "test3_2", "CA10__disappearanceTime__c": "2025-04-21T08:46:39Z", "CA10__trafficSourceType__c": "elbv2", "CA10__autoScalingGroup__c": "test3" } ] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "299", "conditionText": "extract('CA10__launchConfigurationName__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test4", "CA10__disappearanceTime__c": null, "CA10__launchConfigurationName__c": null, "CA10__launchConfiguration__c": null, "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": null, "CA10__disappearanceTime__c": null, "CA10__associatePublicIpAddress__c": null }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [ { "Id": "test4_2", "CA10__disappearanceTime__c": null, "CA10__trafficSourceType__c": "elbv2", "CA10__autoScalingGroup__c": "test4" } ] }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "399", "conditionText": "isEmptyLookup('CA10__launchConfiguration__r')", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test5", "CA10__disappearanceTime__c": null, "CA10__launchConfigurationName__c": "launchConfigurationName", "CA10__launchConfiguration__c": null, "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": null, "CA10__disappearanceTime__c": null, "CA10__associatePublicIpAddress__c": null }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [ { "Id": "test5_2", "CA10__disappearanceTime__c": null, "CA10__trafficSourceType__c": "elbv2", "CA10__autoScalingGroup__c": "test5" } ] }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "399", "conditionText": "isEmptyLookup('CA10__launchConfiguration__r')", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test6", "CA10__disappearanceTime__c": null, "CA10__launchConfigurationName__c": "launchConfigurationName", "CA10__launchConfiguration__c": "test6_1", "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": "test6_1", "CA10__disappearanceTime__c": "2025-04-21T08:46:39Z", "CA10__associatePublicIpAddress__c": true }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [ { "Id": "test6_2", "CA10__disappearanceTime__c": null, "CA10__trafficSourceType__c": "elbv2", "CA10__autoScalingGroup__c": "test6" } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "499", "conditionText": "extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == true", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test7", "CA10__disappearanceTime__c": null, "CA10__launchConfigurationName__c": "launchConfigurationName", "CA10__launchConfiguration__c": "test7_1", "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": "test7_1", "CA10__disappearanceTime__c": null, "CA10__associatePublicIpAddress__c": true }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [ { "Id": "test7_2", "CA10__disappearanceTime__c": null, "CA10__trafficSourceType__c": "elbv2", "CA10__autoScalingGroup__c": "test7" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "599", "conditionText": "extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == false", "runtimeError": null }, "context": { "snapshotTime": "2025-04-21T08:46:39Z" }, "Id": "test8", "CA10__disappearanceTime__c": null, "CA10__launchConfigurationName__c": "launchConfigurationName", "CA10__launchConfiguration__c": "test8_1", "CA10__launchConfigurationUniqueId__c": "launchConfigurationUniqueId", "CA10__launchConfiguration__r": { "Id": "test8_1", "CA10__disappearanceTime__c": null, "CA10__associatePublicIpAddress__c": false }, "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r": [ { "Id": "test8_2", "CA10__disappearanceTime__c": null, "CA10__trafficSourceType__c": "elb", "CA10__autoScalingGroup__c": "test8" } ] } ] - path: /types/CA10__CaAwsLaunchConfiguration__c/object.extracts.yaml md5Hash: D241396D967C94BB1020E577F9ABD9D8 content: "---\nextracts:\n# Checkbox. Can't have no access, retrieved via autoscaling:DescribeLaunchConfigurations\ \ \n - name: CA10__associatePublicIpAddress__c\n value: \n FIELD:\n\ \ path: CA10__associatePublicIpAddress__c \n" - path: /types/CA10__CaAwsAutoScalingGroup__c/object.extracts.yaml md5Hash: DD26D73C0CF43F8CE9CBE35D8241D89C content: "---\nextracts:\n # AvailabilityZones.member.N\n # One or more Availability\ \ Zones for the group.\n # Type: Array of strings\n # Length Constraints:\ \ Minimum length of 1. Maximum length of 255.\n # Pattern: [\\u0020-\\uD7FF\\\ uE000-\\uFFFD\\uD800\\uDC00-\\uDBFF\\uDFFF\\r\\n\\t]*\n # Required: Yes\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# A comma-separated value string\ \ of one or more health check types.\n# Values: EC2, EBS, ELB, VPC_LATTICE.\ \ Not nullable. Can't have no access, retrieved via autoscaling:DescribeAutoScalingGroups\n\ \ - name: CA10__healthCheckType__c\n value: \n FIELD:\n path:\ \ CA10__healthCheckType__c \n# Nullable. Can't have no access, retrieved\ \ via autoscaling:DescribeAutoScalingGroups \n - name: CA10__launchConfigurationName__c\n\ \ value: \n FIELD:\n path: CA10__launchConfigurationName__c \ \ \n# Nullable. Can't have no access, retrieved via autoscaling:DescribeAutoScalingGroups\ \ \n - name: CA10A1__launchTemplateId__c\n value: \n FIELD:\n \ \ path: CA10A1__launchTemplateId__c \n# Nullable. Can't have\ \ no access, retrieved via autoscaling:DescribeAutoScalingGroups \n - name:\ \ CA10A1__mixedInstancesLaunchTemplateId__c\n value: \n FIELD:\n \ \ path: CA10A1__mixedInstancesLaunchTemplateId__c \n# Values: Enable\ \ | Disable. Nullable, null == Disable. Can't have no access, retrieved via\ \ autoscaling:DescribeAutoScalingGroups \n - name: CA10__capacityRebalancing__c\n\ \ value: \n FIELD:\n path: CA10__capacityRebalancing__c \ \ \n" - path: /types/CA10__CaAwsAutoScalingGroupTrafficSourceLink__c/object.extracts.yaml md5Hash: 5D75919837EC6FE643E714B0EB120E9F content: "---\nextracts:\n# Values: elb, elbv2, vpc-lattice. Not Nullable. Can't\ \ have no access, retrieved via autoscaling:DescribeAutoScalingGroups\n - name:\ \ CA10__trafficSourceType__c\n value: \n FIELD:\n path: CA10__trafficSourceType__c\n\ \ undeterminedIf:\n isEmpty: \"Possibly corrupted data. Traffic\ \ source type cannot be empty.\"" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT)", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "199", "conditionText" : "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT)", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "299", "conditionText" : "extract('CA10__launchConfigurationName__c').isEmpty()", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "399", "conditionText" : "isEmptyLookup('CA10__launchConfiguration__r')", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "399", "conditionText" : "isEmptyLookup('CA10__launchConfiguration__r')", "runtimeError" : null } }, { "Id" : "test7", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "499", "conditionText" : "extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == true", "runtimeError" : null } }, { "Id" : "test8", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "599", "conditionText" : "extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == false", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsAutoScalingGroup__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__disappearanceTime__c" : new Date("2025-04-21T05:57:57Z"), "CA10__launchConfigurationName__c" : "launchConfigurationName", "CA10__launchConfiguration__c" : "test1_1", "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__launchConfigurationName__c" : "launchConfigurationName", "CA10__launchConfiguration__c" : "test2_1", "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__launchConfigurationName__c" : "launchConfigurationName", "CA10__launchConfiguration__c" : "test3_1", "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__launchConfigurationName__c" : null, "CA10__launchConfiguration__c" : null, "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__launchConfigurationName__c" : "launchConfigurationName", "CA10__launchConfiguration__c" : null, "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test5" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__launchConfigurationName__c" : "launchConfigurationName", "CA10__launchConfiguration__c" : "test6_1", "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test6" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__launchConfigurationName__c" : "launchConfigurationName", "CA10__launchConfiguration__c" : "test7_1", "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test7" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__launchConfigurationName__c" : "launchConfigurationName", "CA10__launchConfiguration__c" : "test8_1", "CA10__launchConfigurationUniqueId__c" : "launchConfigurationUniqueId", "Id" : "test8" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsLaunchConfiguration__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "Id" : "test1_1", "CA10__associatePublicIpAddress__c" : true }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "Id" : "test2_1", "CA10__associatePublicIpAddress__c" : true }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "Id" : "test3_1", "CA10__associatePublicIpAddress__c" : true }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "Id" : null, "CA10__associatePublicIpAddress__c" : null }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "Id" : "test6_1", "CA10__disappearanceTime__c" : new Date("2025-04-21T08:46:39Z"), "CA10__associatePublicIpAddress__c" : true }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "Id" : "test7_1", "CA10__associatePublicIpAddress__c" : true }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "Id" : "test8_1", "CA10__associatePublicIpAddress__c" : false } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAwsAutoScalingGroupTrafficSourceLink__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__trafficSourceType__c" : "elbv2", "CA10__autoScalingGroup__c" : "test1", "Id" : "test1_2" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__disappearanceTime__c" : new Date("2025-04-21T08:46:39Z"), "CA10__trafficSourceType__c" : "elbv2", "CA10__autoScalingGroup__c" : "test3", "Id" : "test3_2" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__trafficSourceType__c" : "elbv2", "CA10__autoScalingGroup__c" : "test4", "Id" : "test4_2" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__trafficSourceType__c" : "elbv2", "CA10__autoScalingGroup__c" : "test5", "Id" : "test5_2" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__trafficSourceType__c" : "elbv2", "CA10__autoScalingGroup__c" : "test6", "Id" : "test6_2" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__trafficSourceType__c" : "elbv2", "CA10__autoScalingGroup__c" : "test7", "Id" : "test7_2" }, { "context" : { "snapshotTime" : new Date("2025-04-21T08:46:39Z") }, "CA10__trafficSourceType__c" : "elb", "CA10__autoScalingGroup__c" : "test8", "Id" : "test8_2" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAwsAutoScalingGroup__c( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__launchConfigurationName__c STRING, CA10__launchConfiguration__r STRUCT< Id STRING, CA10__disappearanceTime__c TIMESTAMP, CA10__associatePublicIpAddress__c BOOLEAN >, CA10__launchConfiguration__c STRING, CA10__launchConfigurationUniqueId__c STRING, CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r ARRAY >>, 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}; } var count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT2 = 0; if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r != null) { for (var i3 = 0; i3 < obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.length; i3++) { if (typeof(obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i3].status) !== 'undefined') { if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i3].status == 'COMPLIANT') { count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT2 += obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i3].count; } } else { if (obj.CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r[i3].result.status == 'COMPLIANT') { count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r] ' + (count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT2 == 0 ? 'does not have' : 'has') + ' objects in COMPLIANT status'); if (count_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r_COMPLIANT2 == 0) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r.hasNo(COMPLIANT)", currentStateMessage: "The ASG is not associated with a load balancer.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract5() { if (!this.out) { this.out = obj.CA10__launchConfigurationName__c; } return this.out; }; references1.push('Launch Configuration Name [obj.CA10__launchConfigurationName__c]: ' + obj.CA10__launchConfigurationName__c); if (TextLib.isEmpty(extract5.call(extract5))) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__launchConfigurationName__c').isEmpty()", currentStateMessage: "The ASG does not use a launch configuration.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] if (TextLib.isEmpty(obj.CA10__launchConfigurationUniqueId__c) || TextLib.isEmpty(obj.CA10__launchConfiguration__c) || obj.CA10__launchConfiguration__r.CA10__disappearanceTime__c != null) { return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "isEmptyLookup('CA10__launchConfiguration__r')", currentStateMessage: "The launch configuration does not exist in the CMDB.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[4], conditionIndex:[400..499] function extractChecked7() { if (TextLib.isEmpty(obj.CA10__launchConfigurationUniqueId__c)) { throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "extractCheck(obj.CA10__launchConfigurationUniqueId__c)", currentStateMessage: "Related object via CA10__launchConfigurationUniqueId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } if (TextLib.isEmpty(obj.CA10__launchConfiguration__c)) { throw new Error("UNDETERMINED condition:402", {cause: {status: 'UNDETERMINED', conditionIndex: 402, conditionText: "extractCheck(obj.CA10__launchConfiguration__c)", currentStateMessage: "Related object via CA10__launchConfiguration__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } if (obj.CA10__launchConfiguration__r.CA10__disappearanceTime__c != null) { throw new Error("UNDETERMINED condition:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "extractCheck(obj.CA10__launchConfiguration__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__launchConfiguration__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return extract8.call(extract8); } function extract8() { if (!this.out) { this.out = obj.CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c; } return this.out; }; references1.push('Associate Public IP Address [obj.CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c]: ' + obj.CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c); try { if (extractChecked7() == true) { return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == true", currentStateMessage: "The launch configuration assigns a public IPv4 address to the group's instances.", currentStateReferences: references1.join('\n'), remediation: "Disable public IP assignment for instances behind a load balancer.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[5], conditionIndex:[500..599] function extractChecked10() { if (TextLib.isEmpty(obj.CA10__launchConfigurationUniqueId__c)) { throw new Error("UNDETERMINED condition:501", {cause: {status: 'UNDETERMINED', conditionIndex: 501, conditionText: "extractCheck(obj.CA10__launchConfigurationUniqueId__c)", currentStateMessage: "Related object via CA10__launchConfigurationUniqueId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } if (TextLib.isEmpty(obj.CA10__launchConfiguration__c)) { throw new Error("UNDETERMINED condition:502", {cause: {status: 'UNDETERMINED', conditionIndex: 502, conditionText: "extractCheck(obj.CA10__launchConfiguration__c)", currentStateMessage: "Related object via CA10__launchConfiguration__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } if (obj.CA10__launchConfiguration__r.CA10__disappearanceTime__c != null) { throw new Error("UNDETERMINED condition:503", {cause: {status: 'UNDETERMINED', conditionIndex: 503, conditionText: "extractCheck(obj.CA10__launchConfiguration__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__launchConfiguration__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return extract11.call(extract11); } function extract11() { if (!this.out) { this.out = obj.CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c; } return this.out; }; try { if (extractChecked10() == false) { return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "extract('CA10__launchConfiguration__r.CA10__associatePublicIpAddress__c') == false", currentStateMessage: "The Auto Scaling group does not assign public IP addresses to instances behind a load balancer.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'UNDETERMINED', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "Unexpected values in the fields.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__trafficSourceType__c STRING, CA10__autoScalingGroup__c STRING, 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__trafficSourceType__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__trafficSourceType__c.isEmpty()", currentStateMessage: "Possibly corrupted data. Traffic source type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__trafficSourceType__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Traffic Source Type [obj.CA10__trafficSourceType__c]: ' + obj.CA10__trafficSourceType__c); try { if (TextLib.equal(extract3.call(extract3), 'elb')) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__trafficSourceType__c') == 'elb'", currentStateMessage: "The ASG traffic source is a Classic Load Balancer.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[2], conditionIndex:[200..299] function fieldChecked7() { if (TextLib.isEmpty(obj.CA10__trafficSourceType__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__trafficSourceType__c.isEmpty()", currentStateMessage: "Possibly corrupted data. Traffic source type cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10__trafficSourceType__c; } function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; }; try { if (TextLib.equal(extract6.call(extract6), 'elbv2')) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__trafficSourceType__c') == 'elbv2'", currentStateMessage: "The ASG traffic source is an ELB target group.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'INAPPLICABLE', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unrelated ASG traffic source.", 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__launchConfigurationName__c AS CA10__launchConfigurationName__c, STRUCT ( `CA10__launchConfiguration__r`.Id AS Id, `CA10__launchConfiguration__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, `CA10__launchConfiguration__r`.CA10__associatePublicIpAddress__c AS CA10__associatePublicIpAddress__c ) AS CA10__launchConfiguration__r, sObject.CA10__launchConfiguration__c AS CA10__launchConfiguration__c, sObject.CA10__launchConfigurationUniqueId__c AS CA10__launchConfigurationUniqueId__c, `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r`.arr AS CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r, sObject.Id AS Id, process_CA10__CaAwsAutoScalingGroup__c( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__launchConfigurationName__c AS CA10__launchConfigurationName__c, STRUCT ( `CA10__launchConfiguration__r`.Id AS Id, `CA10__launchConfiguration__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, `CA10__launchConfiguration__r`.CA10__associatePublicIpAddress__c AS CA10__associatePublicIpAddress__c ) AS CA10__launchConfiguration__r, sObject.CA10__launchConfiguration__c AS CA10__launchConfiguration__c, sObject.CA10__launchConfigurationUniqueId__c AS CA10__launchConfigurationUniqueId__c, `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r`.arr AS CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAwsAutoScalingGroup__c()) AS sObject LEFT JOIN UNNEST(mock_CA10__CaAwsLaunchConfiguration__c()) AS `CA10__launchConfiguration__r` ON sObject.CA10__launchConfiguration__c = `CA10__launchConfiguration__r`.Id LEFT JOIN ( SELECT sObject.CA10__autoScalingGroup__c, ARRAY_AGG( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__trafficSourceType__c AS CA10__trafficSourceType__c, sObject.CA10__autoScalingGroup__c AS CA10__autoScalingGroup__c, sObject.Id AS Id, process_CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__trafficSourceType__c AS CA10__trafficSourceType__c, sObject.CA10__autoScalingGroup__c AS CA10__autoScalingGroup__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10__CaAwsAutoScalingGroupTrafficSourceLink__c()) AS sObject GROUP BY sObject.CA10__autoScalingGroup__c ) AS `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r` ON sObject.Id = `CA10__AWS_EC2_Auto_Scaling_Group_Tfc_Src_Links__r`.CA10__autoScalingGroup__c ) sObject ON sObject.Id = expectedResult.Id;