---
policy: /ce/ca/aws/network-firewall/policy-rule-group-association
logic: /ce/ca/aws/network-firewall/policy-rule-group-association/prod.logic.yaml
executionTime: 2026-01-17T12:02:55.521024107Z
generationMs: 67
executionMs: 1010
rows:
  - id: test1
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10A2__disappearanceTime__c)
      actual: isDisappeared(CA10A2__disappearanceTime__c)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 101
      actual: 101
    conditionText:
      expected: CA10A2__firewallPolicyStatus__c.delegatedTo(CA10A2__firewallPolicyStatus__c).isEmpty()
      actual: CA10A2__firewallPolicyStatus__c.delegatedTo(CA10A2__firewallPolicyStatus__c).isEmpty()
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10A2__firewallPolicyStatus__c') != 'ACTIVE'
      actual: extract('CA10A2__firewallPolicyStatus__c') != 'ACTIVE'
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.hasNo(COMPLIANT)
      actual: CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.hasNo(COMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.has(COMPLIANT)
      actual: CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.has(COMPLIANT)
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/network-firewall/policy-rule-group-association/policy.yaml
    md5Hash: 68CBA2A130F1C8E3794C09403DC151A5
    content: "---\nnames:\n  full: \"AWS Network Firewall Policy is not associated\
      \ with a rule group\"\n  contextual: \"Policy is not associated with a rule\
      \ group\"\ndescription: >\n  Ensure that each AWS Network Firewall policy has\
      \ at least one rule group associated \n  with it. A firewall policy defines\
      \ the stateful and stateless rule groups that \n  provide the network traffic\
      \ filtering logic for your firewall. Policies without \n  rule groups may allow\
      \ or drop traffic based only on default actions without \n  specific inspection\
      \ logic.\ntype: \"COMPLIANCE_POLICY\"\ncategories:\n  - \"RELIABILITY\"\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\n\
      \  - \"/frameworks/aws-fsbp-v1.0.0/network-firewall/03\"\nsimilarPolicies:\n\
      \  awsSecurityHub:\n    - name: \"[NetworkFirewall.3] Network Firewall policies\
      \ should have at least one rule group associated\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/networkfirewall-controls.html#networkfirewall-3\""
  - path: /ce/ca/aws/network-firewall/policy-rule-group-association/prod.logic.yaml
    md5Hash: CEA5E247A94792372F33EEEFF8214C8A
    content: "---\ninputType: \"CA10A2__CaAwsNetworkFirewallFirewallPolicy__c\"\n\
      importExtracts:\n  - file: \"/types/CA10A2__CaAwsNetworkFirewallFirewallPolicy__c/object.extracts.yaml\"\
      \ntestData:\n  - file: \"test-data.json\"\nconditions:\n  - status: \"INAPPLICABLE\"\
      \n    currentStateMessage: \"The Network Firewall Policy is not active.\"\n\
      \    check:\n      NOT_EQUAL:\n        left:\n          EXTRACT: \"CA10A2__firewallPolicyStatus__c\"\
      \n        right:\n          TEXT: \"ACTIVE\"\n  - status: \"INCOMPLIANT\"\n\
      \    currentStateMessage: \"The Network Firewall Policy has no stateful or stateless\
      \ rule groups associated.\"\n    remediationMessage: \"Associate at least one\
      \ rule group with the firewall policy to define traffic filtering rules.\"\n\
      \    check:\n      RELATED_LIST_HAS_NO:\n        status: \"COMPLIANT\"\n   \
      \     relationshipName: \"CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r\"\
      \n  - status: \"COMPLIANT\"\n    currentStateMessage: \"The Network Firewall\
      \ Policy is associated with at least one rule group.\"\n    check:\n      RELATED_LIST_HAS:\n\
      \        status: \"COMPLIANT\"\n        relationshipName: \"CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r\"\
      \notherwise:\n  status: \"UNDETERMINED\"\n  currentStateMessage: \"Unexpected\
      \ values in the fields.\"\nrelatedLists:\n  - relationshipName: \"CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r\"\
      \n    conditions: \n      - status: \"COMPLIANT\" \n        currentStateMessage:\
      \ \"Rule group association exists.\"\n        check:\n          NOT_EMPTY_LOOKUP:\
      \ \"CA10A2__ruleGroup__r\" \n    otherwise:\n      status: \"INCOMPLIANT\"\n\
      \      currentStateMessage: \"Rule group association does not exist.\""
  - path: /ce/ca/aws/network-firewall/policy-rule-group-association/test-data.json
    md5Hash: 568BBA852ED7E377541EDCCC312E0D8D
    content: |-
      [
          {
              "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r": [],
              "CA10A2__disappearanceTime__c": "2026-01-15T10:42:39Z",
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "isDisappeared(CA10A2__disappearanceTime__c)",
                  "conditionIndex": 99,
                  "status": "DISAPPEARED"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "Id": "test1",
              "CA10A2__firewallPolicyStatus__c": ""
          },
          {
              "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r": [],
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "CA10A2__firewallPolicyStatus__c.delegatedTo(CA10A2__firewallPolicyStatus__c).isEmpty()",
                  "conditionIndex": 101,
                  "status": "UNDETERMINED"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "Id": "test2",
              "CA10A2__firewallPolicyStatus__c": ""
          },
          {
              "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r": [],
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10A2__firewallPolicyStatus__c') != 'ACTIVE'",
                  "conditionIndex": 199,
                  "status": "INAPPLICABLE"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "Id": "test3",
              "CA10A2__firewallPolicyStatus__c": "ERROR"
          },
          {
              "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r": [],
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.hasNo(COMPLIANT)",
                  "conditionIndex": 299,
                  "status": "INCOMPLIANT"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "Id": "test4",
              "CA10A2__firewallPolicyStatus__c": "ACTIVE"
          },
          {
              "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r": [
                  {
                      "CA10A2__disappearanceTime__c": null,
                      "CA10A2__ruleGroup__c": "test5_1",
                      "CA10A2__ruleGroup__r": {
                          "CA10A2__disappearanceTime__c": null,
                          "Id": "test5_1"
                      },
                      "CA10A2__ruleGroupArn__c": "ruleGroupArn",
                      "Id": "test5_2",
                      "CA10A2__firewallPolicy__c": "test5"
                  }
              ],
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.has(COMPLIANT)",
                  "conditionIndex": 399,
                  "status": "COMPLIANT"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "Id": "test5",
              "CA10A2__firewallPolicyStatus__c": "ACTIVE"
          }
      ]
  - path: /types/CA10A2__CaAwsNetworkFirewallFirewallPolicy__c/object.extracts.yaml
    md5Hash: 7D78149FCF8A2F3ABE66E6CFC4C9C395
    content: "---\nextracts:\n# Values: ACTIVE | DELETING | ERROR. Not nullable. \n\
      \  - name: CA10A2__firewallPolicyStatus__c\n    value:\n      FIELD: \n    \
      \    path: CA10A2__firewallPolicyStatus__c\n        undeterminedIf:\n      \
      \    noAccessDelegate:\n            path: \"CA10A2__firewallPolicyStatus__c\"\
      \n            currentStateMessage: \"Firewall Policy Status cannot be empty.\
      \ Possible permissions issue with networkfirewall:DescribeFirewallPolicy.\"\n\
      # Values: must be one of the defaults aws:pass | aws:drop | aws:forward_to_sfe\
      \ and custom actions\n# Not nullable\n  - name: CA10A2__statelessDefaultActions__c\n\
      \    value:\n      FIELD: \n        path: CA10A2__statelessDefaultActions__c\n\
      \        undeterminedIf:\n          noAccessDelegate:\n            path: \"\
      CA10A2__statelessDefaultActions__c\"\n            currentStateMessage: \"Firewall\
      \ Policy Stateless Default Actions cannot be empty. Possible permissions issue\
      \ with networkfirewall:DescribeFirewallPolicy.\"\n# Values: must be one of the\
      \ defaults aws:pass | aws:drop | aws:forward_to_sfe and custom actions\n# Not\
      \ nullable\n  - name: CA10A2__statelessFragmentDefaultActions__c\n    value:\n\
      \      FIELD: \n        path: CA10A2__statelessFragmentDefaultActions__c\n \
      \       undeterminedIf:\n          noAccessDelegate:\n            path: \"CA10A2__statelessFragmentDefaultActions__c\"\
      \n            currentStateMessage: \"Firewall Policy Stateless Default Actions\
      \ cannot be empty. Possible permissions issue with networkfirewall:DescribeFirewallPolicy.\"\
      \n"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "test1",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "isDisappeared(CA10A2__disappearanceTime__c)",
      "conditionIndex" : 99,
      "status" : "DISAPPEARED"
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "CA10A2__firewallPolicyStatus__c.delegatedTo(CA10A2__firewallPolicyStatus__c).isEmpty()",
      "conditionIndex" : 101,
      "status" : "UNDETERMINED"
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('CA10A2__firewallPolicyStatus__c') != 'ACTIVE'",
      "conditionIndex" : 199,
      "status" : "INAPPLICABLE"
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.hasNo(COMPLIANT)",
      "conditionIndex" : 299,
      "status" : "INCOMPLIANT"
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.has(COMPLIANT)",
      "conditionIndex" : 399,
      "status" : "COMPLIANT"
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A2__CaAwsNetworkFirewallFirewallPolicy__c()
  RETURNS ARRAY<STRUCT<
      CA10A2__disappearanceTime__c TIMESTAMP,
      CA10A2__firewallPolicyStatus__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__disappearanceTime__c" : new Date("2026-01-15T10:42:39Z"),
    "CA10A2__firewallPolicyStatus__c" : "",
    "Id" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__firewallPolicyStatus__c" : "",
    "Id" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__firewallPolicyStatus__c" : "ERROR",
    "Id" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__firewallPolicyStatus__c" : "ACTIVE",
    "Id" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__firewallPolicyStatus__c" : "ACTIVE",
    "Id" : "test5"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A2__CaAwsNetworkFirewallPolicyRuleGroupLink__c()
  RETURNS ARRAY<STRUCT<
      CA10A2__disappearanceTime__c TIMESTAMP,
      CA10A2__ruleGroup__c STRING,
      CA10A2__ruleGroupArn__c STRING,
      CA10A2__firewallPolicy__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__ruleGroup__c" : "test5_1",
    "CA10A2__ruleGroupArn__c" : "ruleGroupArn",
    "CA10A2__firewallPolicy__c" : "test5",
    "Id" : "test5_2"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A2__CaAwsNetworkFirewallRuleGroup__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10A2__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "Id" : "test5_1"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10A2__CaAwsNetworkFirewallFirewallPolicy__c(
      obj STRUCT<
          CA10A2__disappearanceTime__c TIMESTAMP,
          CA10A2__firewallPolicyStatus__c STRING,
          Id STRING,
          CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r ARRAY<STRUCT<
              CA10A2__disappearanceTime__c TIMESTAMP,
              CA10A2__ruleGroup__c STRING,
              CA10A2__ruleGroupArn__c STRING,
              CA10A2__firewallPolicy__c STRING,
              Id STRING,
              CA10A2__ruleGroup__r STRUCT<
                  Id STRING,
                  CA10A2__disappearanceTime__c TIMESTAMP
              >,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
          >>
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
  var 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 [CA10A2__disappearanceTime__c]: ' + obj.CA10A2__disappearanceTime__c);
      if (obj.CA10A2__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A2__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.CA10A2__firewallPolicyStatus__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A2__firewallPolicyStatus__c.delegatedTo(CA10A2__firewallPolicyStatus__c).isEmpty()", currentStateMessage: "Firewall Policy Status cannot be empty. Possible permissions issue with networkfirewall:DescribeFirewallPolicy.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A2__firewallPolicyStatus__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Firewall Policy Status [obj.CA10A2__firewallPolicyStatus__c]: ' + obj.CA10A2__firewallPolicyStatus__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'ACTIVE')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10A2__firewallPolicyStatus__c') != 'ACTIVE'", currentStateMessage: "The Network Firewall Policy is not active.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      var count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 = 0;
      if (obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r != null) {
          for (var i6 = 0; i6 < obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.length; i6++) {
              if (typeof(obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i6].status) !== 'undefined') {
                  if (obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i6].status == 'COMPLIANT') {
                      count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 += obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i6].count;
                  }
              } else  {
                  if (obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i6].result.status == 'COMPLIANT') {
                      count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 += 1;
                  }
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      references1.push('Related list [CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r] ' + (count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 == 0 ? 'does not have' : 'has') + ' objects in COMPLIANT status');
      if (count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 == 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.hasNo(COMPLIANT)", currentStateMessage: "The Network Firewall Policy has no stateful or stateless rule groups associated.", currentStateReferences: references1.join('\n'), remediation: "Associate at least one rule group with the firewall policy to define traffic filtering rules.", runtimeError: null};
      }
      var count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 = 0;
      if (obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r != null) {
          for (var i7 = 0; i7 < obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.length; i7++) {
              if (typeof(obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i7].status) !== 'undefined') {
                  if (obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i7].status == 'COMPLIANT') {
                      count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 += obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i7].count;
                  }
              } else  {
                  if (obj.CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r[i7].result.status == 'COMPLIANT') {
                      count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 += 1;
                  }
              }
          }
      }
      // condition[3], conditionIndex:[300..399]
      if (count_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r_COMPLIANT5 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r.has(COMPLIANT)", currentStateMessage: "The Network Firewall Policy is associated with at least one rule group.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Unexpected values in the fields.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r(
      obj STRUCT<
          CA10A2__disappearanceTime__c TIMESTAMP,
          CA10A2__ruleGroup__c STRING,
          CA10A2__ruleGroupArn__c STRING,
          CA10A2__firewallPolicy__c STRING,
          Id STRING,
          CA10A2__ruleGroup__r STRUCT<
              Id STRING,
              CA10A2__disappearanceTime__c TIMESTAMP
          >
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
  var TextLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10A2__disappearanceTime__c]: ' + obj.CA10A2__disappearanceTime__c);
      if (obj.CA10A2__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A2__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      if (TextLib.isNotEmpty(obj.CA10A2__ruleGroupArn__c) && TextLib.isNotEmpty(obj.CA10A2__ruleGroup__c) && obj.CA10A2__ruleGroup__r.CA10A2__disappearanceTime__c == null) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "notEmptyLookup('CA10A2__ruleGroup__r')", currentStateMessage: "Rule group association exists.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Rule group association does not exist.", 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.CA10A2__disappearanceTime__c AS CA10A2__disappearanceTime__c,
          sObject.CA10A2__firewallPolicyStatus__c AS CA10A2__firewallPolicyStatus__c,
          sObject.Id AS Id,
          `CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r`.arr AS CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r,
          process_CA10A2__CaAwsNetworkFirewallFirewallPolicy__c(
              STRUCT(
                  sObject.CA10A2__disappearanceTime__c AS CA10A2__disappearanceTime__c,
                  sObject.CA10A2__firewallPolicyStatus__c AS CA10A2__firewallPolicyStatus__c,
                  sObject.Id AS Id,
                  `CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r`.arr AS CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10A2__CaAwsNetworkFirewallFirewallPolicy__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10A2__firewallPolicy__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10A2__disappearanceTime__c AS CA10A2__disappearanceTime__c,
                      sObject.CA10A2__ruleGroup__c AS CA10A2__ruleGroup__c,
                      sObject.CA10A2__ruleGroupArn__c AS CA10A2__ruleGroupArn__c,
                      sObject.CA10A2__firewallPolicy__c AS CA10A2__firewallPolicy__c,
                      sObject.Id AS Id,
                      STRUCT (
                          `CA10A2__ruleGroup__r`.Id AS Id,
                          `CA10A2__ruleGroup__r`.CA10A2__disappearanceTime__c AS CA10A2__disappearanceTime__c
                      ) AS CA10A2__ruleGroup__r,
                      process_CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r(
                          STRUCT(
                              sObject.CA10A2__disappearanceTime__c AS CA10A2__disappearanceTime__c,
                              sObject.CA10A2__ruleGroup__c AS CA10A2__ruleGroup__c,
                              sObject.CA10A2__ruleGroupArn__c AS CA10A2__ruleGroupArn__c,
                              sObject.CA10A2__firewallPolicy__c AS CA10A2__firewallPolicy__c,
                              sObject.Id AS Id,
                              STRUCT (
                                  `CA10A2__ruleGroup__r`.Id AS Id,
                                  `CA10A2__ruleGroup__r`.CA10A2__disappearanceTime__c AS CA10A2__disappearanceTime__c
                              ) AS CA10A2__ruleGroup__r
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10A2__CaAwsNetworkFirewallPolicyRuleGroupLink__c()) AS sObject
          LEFT JOIN UNNEST(mock_CA10A2__CaAwsNetworkFirewallRuleGroup__c()) AS `CA10A2__ruleGroup__r`
              ON sObject.CA10A2__ruleGroup__c = `CA10A2__ruleGroup__r`.Id
          GROUP BY sObject.CA10A2__firewallPolicy__c
      ) AS `CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r`
          ON sObject.Id = `CA10A2__AWS_NetworkFirewall_PolicyRuleGroupLinks__r`.CA10A2__firewallPolicy__c
  ) sObject ON sObject.Id = expectedResult.Id;
