---
policy: /ce/ca/aws/network-firewall/rule-group-stateless-rules
logic: /ce/ca/aws/network-firewall/rule-group-stateless-rules/prod.logic.yaml
executionTime: 2026-01-17T12:02:55.57052484Z
generationMs: 97
executionMs: 723
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: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10A2__ruleGroupStatus__c') != 'ACTIVE'
      actual: extract('CA10A2__ruleGroupStatus__c') != 'ACTIVE'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10A2__type__c') != 'STATELESS'
      actual: extract('CA10A2__type__c') != 'STATELESS'
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 500
      actual: 500
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10A2__statelessRulesJson__c').asJson().jsonQueryText('length(@)')
        == number(0.0)
      actual: extract('CA10A2__statelessRulesJson__c').asJson().jsonQueryText('length(@)')
        == number(0.0)
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10A2__statelessRulesJson__c').isEmpty()
      actual: extract('CA10A2__statelessRulesJson__c').isEmpty()
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10A2__statelessRulesJson__c').isEmpty()
      actual: extract('CA10A2__statelessRulesJson__c').isEmpty()
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/network-firewall/rule-group-stateless-rules/policy.yaml
    md5Hash: B0D7089F2BA8D2EEF1BB10A3BECA377F
    content: "---\nnames:\n  full: \"AWS Network Firewall Rule Group Stateless Rules\
      \ are empty\"\n  contextual: \"Rule Group Stateless Rules are empty\"\ndescription:\
      \ >\n  Ensure that each AWS Network Firewall stateless rule group contains at\
      \ least one \n  rule. Empty rule groups do not provide any traffic filtering\
      \ or inspection and \n  may represent incomplete security configurations.\n\
      type: \"COMPLIANCE_POLICY\"\ncategories:\n  - \"RELIABILITY\"\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\n\
      \  - \"/frameworks/aws-fsbp-v1.0.0/network-firewall/06\"\nsimilarPolicies:\n\
      \  awsSecurityHub:\n    - name: \"[NetworkFirewall.6] Stateless Network Firewall\
      \ rule group should not be empty\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/networkfirewall-controls.html#networkfirewall-6\""
  - path: /ce/ca/aws/network-firewall/rule-group-stateless-rules/prod.logic.yaml
    md5Hash: D3BC04DCB363E675248FF28F89FBFBEC
    content: |-
      ---
      inputType: "CA10A2__CaAwsNetworkFirewallRuleGroup__c"
      importExtracts:
        - file: "/types/CA10A2__CaAwsNetworkFirewallRuleGroup__c/object.extracts.yaml"
      testData:
        - file: "test-data.json"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The Network Firewall Rule Group is not active."
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10A2__ruleGroupStatus__c"
              right:
                TEXT: "ACTIVE"
        - status: "INAPPLICABLE"
          currentStateMessage: "This policy only applies to stateless rule groups."
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10A2__type__c"
              right:
                TEXT: "STATELESS"
        - status: "INCOMPLIANT"
          currentStateMessage: "The stateless rule group contains no rules."
          remediationMessage: "Add rules to the stateless rule group or delete the rule group
            \ if it is no longer required and is not associated with a firewall policy."
          check:
            IS_EMPTY:
              arg:
                EXTRACT: "CA10A2__statelessRulesJson__c"
        - status: "INCOMPLIANT"
          currentStateMessage: "The stateless rule group contains no rules."
          remediationMessage: "Add rules to the stateless rule group or delete the rule group if it is no longer required."
          check:
            IS_EQUAL:
              left:
                JSON_QUERY_NUMBER:
                  arg:
                    JSON_FROM:
                      arg:
                        EXTRACT: "CA10A2__statelessRulesJson__c"
                      undeterminedIf:
                        isInvalid: "The rule group rules contain invalid JSON."
                  expression: "length(@)"
                  undeterminedIf:
                    evaluationError: "Failed to evaluate the number of rules."
                    resultTypeMismatch: "The rule group rules structure is unexpected."
              right:
                NUMBER: 0
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The stateless rule group contains at least one rule."
  - path: /ce/ca/aws/network-firewall/rule-group-stateless-rules/test-data.json
    md5Hash: 59798ECCE1C9AF0EAE045F4D4A368CA2
    content: |-
      [
          {
              "CA10A2__statelessRulesJson__c": "",
              "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"
              },
              "CA10A2__ruleGroupStatus__c": "ACTIVE",
              "Id": "test1",
              "CA10A2__type__c": "STATEFUL"
          },
          {
              "CA10A2__statelessRulesJson__c": "",
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10A2__ruleGroupStatus__c') != 'ACTIVE'",
                  "conditionIndex": 199,
                  "status": "INAPPLICABLE"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "CA10A2__ruleGroupStatus__c": "ERROR",
              "Id": "test2",
              "CA10A2__type__c": "STATEFUL"
          },
          {
              "CA10A2__statelessRulesJson__c": "",
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10A2__type__c') != 'STATELESS'",
                  "conditionIndex": 299,
                  "status": "INAPPLICABLE"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "CA10A2__ruleGroupStatus__c": "ACTIVE",
              "Id": "test3",
              "CA10A2__type__c": "STATEFUL"
          },
          {
              "CA10A2__statelessRulesJson__c": "[{\"ruleDefinition\":{\"matchAttributes\":{\"sources\":[{\"addressDefinition\":\"0.0.0.0/0\"}],\"destinations\":[{\"addressDefinition\":\"0.0.0.0/0\"}]},\"actions\":[\"aws:forward_to_sfe\"]},\"priority\":100}]",
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "otherwise",
                  "conditionIndex": 500,
                  "status": "COMPLIANT"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "CA10A2__ruleGroupStatus__c": "ACTIVE",
              "Id": "test4",
              "CA10A2__type__c": "STATELESS"
          },
          {
              "CA10A2__statelessRulesJson__c": "[]",
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10A2__statelessRulesJson__c').asJson().jsonQueryText('length(@)') == number(0.0)",
                  "conditionIndex": 499,
                  "status": "INCOMPLIANT"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "CA10A2__ruleGroupStatus__c": "ACTIVE",
              "Id": "test5",
              "CA10A2__type__c": "STATELESS"
          },
          {
              "CA10A2__statelessRulesJson__c": "",
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10A2__statelessRulesJson__c').isEmpty()",
                  "conditionIndex": 399,
                  "status": "INCOMPLIANT"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "CA10A2__ruleGroupStatus__c": "ACTIVE",
              "Id": "test6",
              "CA10A2__type__c": "STATELESS"
          },
          {
              "CA10A2__statelessRulesJson__c": null,
              "CA10A2__disappearanceTime__c": null,
              "expectedResult": {
                  "runtimeError": null,
                  "conditionText": "extract('CA10A2__statelessRulesJson__c').isEmpty()",
                  "conditionIndex": 399,
                  "status": "INCOMPLIANT"
              },
              "context": {
                  "snapshotTime": "2026-01-15T10:42:39Z"
              },
              "CA10A2__ruleGroupStatus__c": "ACTIVE",
              "Id": "test7",
              "CA10A2__type__c": "STATELESS"
          }
      ]
  - path: /types/CA10A2__CaAwsNetworkFirewallRuleGroup__c/object.extracts.yaml
    md5Hash: 83B447F7D2F96FE20ABB020DF9B1A9BC
    content: "---\nextracts:\n# Values: ACTIVE | DELETING | ERROR. Not nullable. \n\
      \  - name: CA10A2__ruleGroupStatus__c\n    value:\n      FIELD: \n        path:\
      \ CA10A2__ruleGroupStatus__c\n        undeterminedIf:\n          noAccessDelegate:\n\
      \            path: \"CA10A2__ruleGroupStatus__c\"\n            currentStateMessage:\
      \ \"Firewall Rule Group Status cannot be empty. Possible permissions issue with\
      \ networkfirewall:DescribeRuleGroup.\"\n# Not nullable\n  - name: CA10A2__statelessRulesJson__c\n\
      \    value:\n      FIELD: \n        path: CA10A2__statelessRulesJson__c\n  \
      \      # undeterminedIf:\n        #   noAccessDelegate:\n        #     path:\
      \ \"CA10A2__statelessRulesJson__c\"\n        #     currentStateMessage: \"Firewall\
      \ Policy Stateless Default Actions cannot be empty. Possible permissions issue\
      \ with networkfirewall:DescribeRuleGroup.\"\n# Values: STATELESS | STATEFUL\n\
      # Not nullable\n  - name: CA10A2__type__c\n    value:\n      FIELD: \n     \
      \   path: CA10A2__type__c\n        undeterminedIf:\n          noAccessDelegate:\n\
      \            path: \"CA10A2__type__c\"\n            currentStateMessage: \"\
      Firewall Rule Group Type cannot be empty. Possible permissions issue with networkfirewall:DescribeRuleGroup.\"\
      \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" : "extract('CA10A2__ruleGroupStatus__c') != 'ACTIVE'",
      "conditionIndex" : 199,
      "status" : "INAPPLICABLE"
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('CA10A2__type__c') != 'STATELESS'",
      "conditionIndex" : 299,
      "status" : "INAPPLICABLE"
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "otherwise",
      "conditionIndex" : 500,
      "status" : "COMPLIANT"
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('CA10A2__statelessRulesJson__c').asJson().jsonQueryText('length(@)') == number(0.0)",
      "conditionIndex" : 499,
      "status" : "INCOMPLIANT"
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('CA10A2__statelessRulesJson__c').isEmpty()",
      "conditionIndex" : 399,
      "status" : "INCOMPLIANT"
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "runtimeError" : null,
      "conditionText" : "extract('CA10A2__statelessRulesJson__c').isEmpty()",
      "conditionIndex" : 399,
      "status" : "INCOMPLIANT"
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A2__CaAwsNetworkFirewallRuleGroup__c()
  RETURNS ARRAY<STRUCT<
      CA10A2__disappearanceTime__c TIMESTAMP,
      CA10A2__ruleGroupStatus__c STRING,
      CA10A2__type__c STRING,
      CA10A2__statelessRulesJson__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__ruleGroupStatus__c" : "ACTIVE",
    "CA10A2__type__c" : "STATEFUL",
    "CA10A2__statelessRulesJson__c" : "",
    "Id" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__ruleGroupStatus__c" : "ERROR",
    "CA10A2__type__c" : "STATEFUL",
    "CA10A2__statelessRulesJson__c" : "",
    "Id" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__ruleGroupStatus__c" : "ACTIVE",
    "CA10A2__type__c" : "STATEFUL",
    "CA10A2__statelessRulesJson__c" : "",
    "Id" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__ruleGroupStatus__c" : "ACTIVE",
    "CA10A2__type__c" : "STATELESS",
    "CA10A2__statelessRulesJson__c" : "[{\"ruleDefinition\":{\"matchAttributes\":{\"sources\":[{\"addressDefinition\":\"0.0.0.0/0\"}],\"destinations\":[{\"addressDefinition\":\"0.0.0.0/0\"}]},\"actions\":[\"aws:forward_to_sfe\"]},\"priority\":100}]",
    "Id" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__ruleGroupStatus__c" : "ACTIVE",
    "CA10A2__type__c" : "STATELESS",
    "CA10A2__statelessRulesJson__c" : "[]",
    "Id" : "test5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__ruleGroupStatus__c" : "ACTIVE",
    "CA10A2__type__c" : "STATELESS",
    "CA10A2__statelessRulesJson__c" : "",
    "Id" : "test6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2026-01-15T10:42:39Z")
    },
    "CA10A2__ruleGroupStatus__c" : "ACTIVE",
    "CA10A2__type__c" : "STATELESS",
    "CA10A2__statelessRulesJson__c" : null,
    "Id" : "test7"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10A2__CaAwsNetworkFirewallRuleGroup__c(
      obj STRUCT<
          CA10A2__disappearanceTime__c TIMESTAMP,
          CA10A2__ruleGroupStatus__c STRING,
          CA10A2__type__c STRING,
          CA10A2__statelessRulesJson__c STRING,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  OPTIONS (library=['gs://compliance-platform-public/jmespath.min.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 BytesLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg;
      };
      this.isEmpty = function(arg) {
          return this.normalize(arg) == '';
      };
      this.isNotEmpty = function(arg) {
          return this.normalize(arg) != '';
      };
      this.equal = function(left, right) {
          return this.normalize(left) == this.normalize(right);
      };
      this.notEqual = function(left, right) {
          return this.normalize(left) != this.normalize(right);
      };
      this.startsWith = function(arg, substring) {
          return this.normalize(arg).startsWith(this.normalize(substring));
      };
      this.endsWith = function(arg, substring) {
          return this.normalize(arg).endsWith(this.normalize(substring));
      };
      this.contains = function(arg, substring) {
          return this.normalize(arg).includes(this.normalize(substring));
      };
      this.containsAll = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.every(sub => normalizedArg.includes(this.normalize(sub)));
      };
      this.containsAny = function(arg, substrings) {
          if (substrings == null || substrings.length === 0) return false;
          let normalizedArg = this.normalize(arg);
          return substrings.some(sub => normalizedArg.includes(this.normalize(sub)));
      };
  }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [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__ruleGroupStatus__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A2__ruleGroupStatus__c.delegatedTo(CA10A2__ruleGroupStatus__c).isEmpty()", currentStateMessage: "Firewall Rule Group Status cannot be empty. Possible permissions issue with networkfirewall:DescribeRuleGroup.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A2__ruleGroupStatus__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Rule Group Status [obj.CA10A2__ruleGroupStatus__c]: ' + obj.CA10A2__ruleGroupStatus__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'ACTIVE')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10A2__ruleGroupStatus__c') != 'ACTIVE'", currentStateMessage: "The Network Firewall Rule Group 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; }
      }
      // condition[2], conditionIndex:[200..299]
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10A2__type__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10A2__type__c.delegatedTo(CA10A2__type__c).isEmpty()", currentStateMessage: "Firewall Rule Group Type cannot be empty. Possible permissions issue with networkfirewall:DescribeRuleGroup.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A2__type__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      references1.push('Type [obj.CA10A2__type__c]: ' + obj.CA10A2__type__c);
      try {
          if (TextLib.notEqual(extract6.call(extract6), 'STATELESS')) {
              return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10A2__type__c') != 'STATELESS'", currentStateMessage: "This policy only applies to stateless rule groups.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[3], conditionIndex:[300..399]
      function extract9() { if (!this.out) { this.out = obj.CA10A2__statelessRulesJson__c; } return this.out; };
      references1.push('Stateless Rules JSON [obj.CA10A2__statelessRulesJson__c]: ' + obj.CA10A2__statelessRulesJson__c);
      if (BytesLib.isEmpty(extract9.call(extract9))) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10A2__statelessRulesJson__c').isEmpty()", currentStateMessage: "The stateless rule group contains no rules.", currentStateReferences: references1.join('\n'), remediation: "Add rules to the stateless rule group or delete the rule group  if it is no longer required and is not associated with a firewall policy.", runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function jsonQueryChecked11() {
          var input = jsonChecked12();
          var out;
          try {
              out = jmespath.search(input, 'length(@)');
          if (out != null && typeof out != 'number') {
              throw new Error("UNDETERMINED condition:402", {cause: {status: 'UNDETERMINED', conditionIndex: 402, conditionText: "extract('CA10A2__statelessRulesJson__c').asJson().jsonQueryText('length(@)').isResultTypeMismatch()", currentStateMessage: "The rule group rules structure is unexpected.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:403", {cause: {status: 'UNDETERMINED', conditionIndex: 403, conditionText: "extract('CA10A2__statelessRulesJson__c').asJson().jsonQueryText('length(@)').isEvaluationFailed()", currentStateMessage: "Failed to evaluate the number of rules.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked12() {
          var input = extract14.call(extract14);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:401", {cause: {status: 'UNDETERMINED', conditionIndex: 401, conditionText: "extract('CA10A2__statelessRulesJson__c').asJson().isInvalid()", currentStateMessage: "The rule group rules contain invalid JSON.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function extract14() { if (!this.out) { this.out = obj.CA10A2__statelessRulesJson__c; } return this.out; };
      try {
          if (jsonQueryChecked11() == 0.0) {
              return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10A2__statelessRulesJson__c').asJson().jsonQueryText('length(@)') == number(0.0)", currentStateMessage: "The stateless rule group contains no rules.", currentStateReferences: references1.join('\n'), remediation: "Add rules to the stateless rule group or delete the rule group if it is no longer required.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 500, conditionText: "otherwise", currentStateMessage: "The stateless rule group contains at least one rule.", 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__ruleGroupStatus__c AS CA10A2__ruleGroupStatus__c,
          sObject.CA10A2__type__c AS CA10A2__type__c,
          sObject.CA10A2__statelessRulesJson__c AS CA10A2__statelessRulesJson__c,
          sObject.Id AS Id,
          process_CA10A2__CaAwsNetworkFirewallRuleGroup__c(
              STRUCT(
                  sObject.CA10A2__disappearanceTime__c AS CA10A2__disappearanceTime__c,
                  sObject.CA10A2__ruleGroupStatus__c AS CA10A2__ruleGroupStatus__c,
                  sObject.CA10A2__type__c AS CA10A2__type__c,
                  sObject.CA10A2__statelessRulesJson__c AS CA10A2__statelessRulesJson__c,
                  sObject.Id AS Id
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10A2__CaAwsNetworkFirewallRuleGroup__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
