---
policy: /ce/ca/azure/virtual-network/security-group-rule-disable-https-access-from-internet
logic: /ce/ca/azure/virtual-network/security-group-rule-disable-https-access-from-internet/prod.logic.yaml
executionTime: 2025-04-24T23:46:33.484548441Z
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: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test9
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test10
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test11
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/virtual-network/security-group-rule-disable-https-access-from-internet/policy.yaml
    md5Hash: 5AFFFB78EB9C51153544DE2DB568C00E
    content: |
      ---
      names:
        full: Azure Network Security Group allows unrestricted HTTP(S) access from the Internet
        contextual: Security Group allows unrestricted HTTP(S) access from the Internet
      description: "Network security groups should be periodically evaluated for port misconfigurations.\
        \ Where certain ports and protocols may be exposed to the Internet, they should\
        \ be evaluated for necessity and restricted wherever they are not explicitly required\
        \ and narrowly configured."
      type: COMPLIANCE_POLICY
      categories:
        - SECURITY
      frameworkMappings:
        - "/frameworks/cis-azure-v2.1.0/06/04"
        - "/frameworks/cis-azure-v3.0.0/07/04"
        - "/frameworks/cloudaware/resource-security/public-and-anonymous-access"
      similarPolicies:
        internal:
          - dec-x-f4cc003a
        cloudConformity:
          - url: https://www.trendmicro.com/cloudoneconformity/knowledge-base/azure/Network/unrestricted-http-access.html
            name: Check for Unrestricted HTTP Access
  - path: /ce/ca/azure/virtual-network/security-group-rule-disable-https-access-from-internet/prod.logic.yaml
    md5Hash: BCFD06C14210C7C8F53AB915184969D7
    content: "---\ninputType: \"CA10__CaAzureNetworkSecurityGroup__c\"\ntestData:\n\
      \  - file: \"test-data.json\"\nconditions:\n  - status: \"INCOMPLIANT\"\n  \
      \  currentStateMessage: \"Network Security Group has a rule that allows HTTP(S)\
      \ access from the Internet.\"\n    remediationMessage: \"Consider restricting\
      \ internet-level access to your Azure resources.\"\n    check:\n      RELATED_LIST_HAS:\n\
      \        relationshipName: \"CA10__Azure_Network_Security_Group_Rules__r\"\n\
      \        status: \"INCOMPLIANT\"\notherwise:\n  status: \"COMPLIANT\"\n  currentStateMessage:\
      \ \"Network Security Group does not allow unrestricted HTTP(S) access from the\
      \ internet.\"\nrelatedLists:\n  - relationshipName: \"CA10__Azure_Network_Security_Group_Rules__r\"\
      \n    importExtracts:\n      - file: \"/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml\"\
      \n    conditions:\n      - status: \"INAPPLICABLE\"\n        currentStateMessage:\
      \ \"NSG Deny Rule.\"\n        check:\n          NOT_EQUAL:\n            left:\n\
      \              EXTRACT: \"CA10__access__c\"\n            right:\n          \
      \    TEXT: \"Allow\"\n      - status: \"INAPPLICABLE\"\n        currentStateMessage:\
      \ \"NSG Outbound Rule.\"\n        check:\n          NOT_EQUAL:\n           \
      \ left:\n              EXTRACT: \"CA10__direction__c\"\n            right:\n\
      \              TEXT: \"Inbound\"\n      - status: \"INAPPLICABLE\"\n       \
      \ currentStateMessage: \"NSG Rule with the port other than UDP.\"\n        check:\n\
      \          NOT_EQUAL:\n            left:\n              EXTRACT: \"CA10__protocol__c\"\
      \n            right:\n              TEXT: \"TCP\"\n      - status: \"INAPPLICABLE\"\
      \n        currentStateMessage: \"NSG Rule source is not any address.\"\n   \
      \     check:\n        # returns true when source is neither Internet, *, 0.0.0.0,\
      \ /0, or Any\n          NOT:\n            arg:\n              OR:\n        \
      \        args:\n                  - IS_EQUAL:\n                      left:\n\
      \                        EXTRACT: \"CA10__sourceAddressPrefix__c\"\n       \
      \               right:\n                        TEXT: \"Internet\"\n       \
      \           - IS_EQUAL:\n                      left:\n                     \
      \   EXTRACT: \"CA10__sourceAddressPrefix__c\"\n                      right:\n\
      \                        TEXT: \"*\"\n                  - IS_EQUAL:\n      \
      \                left:\n                        EXTRACT: \"CA10__sourceAddressPrefix__c\"\
      \n                      right:\n                        TEXT: \"0.0.0.0\"\n\
      \                  - CONTAINS:\n                      arg:\n               \
      \         EXTRACT: \"CA10__sourceAddressPrefix__c\"\n                      substring:\n\
      \                        TEXT: \"/0\"\n                  - IS_EQUAL:\n     \
      \                 left:\n                        EXTRACT: \"CA10__sourceAddressPrefix__c\"\
      \n                      right:\n                        TEXT: \"Any\"\n    \
      \  - status: \"INCOMPLIANT\"\n        currentStateMessage: \"NSG Rule with HTTP(S)\
      \ access from the Internet.\"\n        remediationMessage: \"Consider restricting\
      \ internet-level access to your Azure resources.\"\n        check:\n       \
      \   OR:\n            args:\n              - IS_EQUAL:\n                  left:\n\
      \                    EXTRACT: \"CA10__destinationPortRange__c\"\n          \
      \        right:\n                    TEXT: \"80\"\n              - IS_EQUAL:\n\
      \                  left:\n                    EXTRACT: \"CA10__destinationPortRange__c\"\
      \n                  right:\n                    TEXT: \"443\"\n            \
      \  - IS_EQUAL:\n                  left:\n                    EXTRACT: \"CA10__destinationPortRange__c\"\
      \n                  right:\n                    TEXT: \"*\"\n              -\
      \ AND:\n                  args:\n                    - LESS_THAN_EQUAL:\n  \
      \                      left:\n                          EXTRACT: \"CA10__destinationPortFrom__c\"\
      \n                        right:\n                          NUMBER: 80.0\n \
      \                   - GREATER_THAN_EQUAL:\n                        left:\n \
      \                         EXTRACT: \"CA10__destinationPortTo__c\"\n        \
      \                right:\n                          NUMBER: 80.0\n          \
      \    - AND:\n                  args:\n                    - LESS_THAN_EQUAL:\n\
      \                        left:\n                          EXTRACT: \"CA10__destinationPortFrom__c\"\
      \n                        right:\n                          NUMBER: 443.0\n\
      \                    - GREATER_THAN_EQUAL:\n                        left:\n\
      \                          EXTRACT: \"CA10__destinationPortTo__c\"\n       \
      \                 right:\n                          NUMBER: 443.0\n    otherwise:\
      \ \n      status: \"INAPPLICABLE\"\n      currentStateMessage: \"Unrelated rule.\"\
      \n"
  - path: /ce/ca/azure/virtual-network/security-group-rule-disable-https-access-from-internet/test-data.json
    md5Hash: 722214B1DAF91C04C1EC42B30DFDB1CA
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2024-06-27T20:33:04Z",
              "CA10__Azure_Network_Security_Group_Rules__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test2_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "TCP",
                      "CA10__destinationPortRange__c": "*",
                      "CA10__destinationPortFrom__c": 1,
                      "CA10__destinationPortTo__c": 65535,
                      "CA10__sourceAddressPrefix__c": "0.0.0.0",
                      "CA10__networkSecurityGroup__c": "test2"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test3_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "TCP",
                      "CA10__destinationPortRange__c": "80",
                      "CA10__destinationPortFrom__c": 80,
                      "CA10__destinationPortTo__c": 80,
                      "CA10__sourceAddressPrefix__c": "*",
                      "CA10__networkSecurityGroup__c": "test3"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test4_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "TCP",
                      "CA10__destinationPortRange__c": "443",
                      "CA10__destinationPortFrom__c": 443,
                      "CA10__destinationPortTo__c": 443,
                      "CA10__sourceAddressPrefix__c": "Internet",
                      "CA10__networkSecurityGroup__c": "test4"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test5_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "TCP",
                      "CA10__destinationPortRange__c": "400-500",
                      "CA10__destinationPortFrom__c": 400,
                      "CA10__destinationPortTo__c": 500,
                      "CA10__sourceAddressPrefix__c": "1.1.1.1/0",
                      "CA10__networkSecurityGroup__c": "test5"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test6",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test6_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "TCP",
                      "CA10__destinationPortRange__c": "70-80",
                      "CA10__destinationPortFrom__c": 70,
                      "CA10__destinationPortTo__c": 80,
                      "CA10__sourceAddressPrefix__c": "0.0.0.0",
                      "CA10__networkSecurityGroup__c": "test6"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test7_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Deny",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "*",
                      "CA10__destinationPortRange__c": "*",
                      "CA10__destinationPortFrom__c": 1,
                      "CA10__destinationPortTo__c": 65535,
                      "CA10__sourceAddressPrefix__c": "*",
                      "CA10__networkSecurityGroup__c": "test7"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test8",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test8_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Outbound",
                      "CA10__protocol__c": "*",
                      "CA10__destinationPortRange__c": "*",
                      "CA10__destinationPortFrom__c": 1,
                      "CA10__destinationPortTo__c": 65535,
                      "CA10__sourceAddressPrefix__c": "*",
                      "CA10__networkSecurityGroup__c": "test8"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test9",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test9_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "icmp",
                      "CA10__destinationPortRange__c": "*",
                      "CA10__destinationPortFrom__c": 1,
                      "CA10__destinationPortTo__c": 65535,
                      "CA10__sourceAddressPrefix__c": "*",
                      "CA10__networkSecurityGroup__c": "test9"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test10",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test10_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "*",
                      "CA10__destinationPortRange__c": "1111",
                      "CA10__destinationPortFrom__c": 1111,
                      "CA10__destinationPortTo__c": 1111,
                      "CA10__sourceAddressPrefix__c": "*",
                      "CA10__networkSecurityGroup__c": "test10"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-06-27T20:33:04Z"
              },
              "Id": "test11",
              "CA10__disappearanceTime__c": null,
              "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                      "Id": "test11_1",
                      "CA10__disappearanceTime__c": null,
                      "CA10__access__c": "Allow",
                      "CA10__direction__c": "Inbound",
                      "CA10__protocol__c": "*",
                      "CA10__destinationPortRange__c": "*",
                      "CA10__destinationPortFrom__c": 1,
                      "CA10__destinationPortTo__c": 65535,
                      "CA10__sourceAddressPrefix__c": "1.1.1.1",
                      "CA10__networkSecurityGroup__c": "test11"
                  }
              ]
          }
      ]
  - path: /types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml
    md5Hash: A60C817EFBC8F066D6D082898E8597BC
    content: "---\nextracts:\n# Values: Allow, Deny. Not Nullable. Can't have no access,\
      \ retrieved via Microsoft.Network/networkSecurityGroups\n  - name: \"CA10__access__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__access__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"Corrupted data. NSG Rule Access cannot be empty.\"\n#\
      \ Number. Can't have no access, retrieved via Microsoft.Network/networkSecurityGroups\n\
      \  - name: \"CA10__destinationPortFrom__c\"\n    value: \n      FIELD:\n   \
      \     path: \"CA10__destinationPortFrom__c\"\n# Number. Can't have no access,\
      \ retrieved via Microsoft.Network/networkSecurityGroups\n  - name: \"CA10__destinationPortTo__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__destinationPortTo__c\"\n\
      # Not Nullable. Can't have no access, retrieved via Microsoft.Network/networkSecurityGroups\n\
      \  - name: \"CA10__destinationPortRange__c\"\n    value: \n      FIELD:\n  \
      \      path: \"CA10__destinationPortRange__c\"\n        undeterminedIf:\n  \
      \        isEmpty: \"Corrupted data. NSG Rule Destination Port Range cannot be\
      \ empty.\"\n# Values: Inbound, Outbound. Not Nullable. Can't have no access,\
      \ retrieved via Microsoft.Network/networkSecurityGroups\n  - name: \"CA10__direction__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__direction__c\"\n        undeterminedIf:\n\
      \          isEmpty: \"Corrupted data. NSG Rule Direction cannot be empty.\"\n\
      # Not Nullable. Can't have no access, retrieved via Microsoft.Network/networkSecurityGroups\n\
      \  - name: \"CA10__protocol__c\"\n    value: \n      FIELD:\n        path: \"\
      CA10__protocol__c\"\n        undeterminedIf:\n          isEmpty: \"Corrupted\
      \ data. NSG Rule Protocol cannot be empty.\"\n# Nullable. Can't have no access,\
      \ retrieved via Microsoft.Network/networkSecurityGroups\n  - name: \"CA10__sourceAddressPrefix__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__sourceAddressPrefix__c\"\n\
      # Nullable. Can't have no access, retrieved via Microsoft.Network/networkSecurityGroups\n\
      \  - name: \"CA10__sourceAddressPrefixes__c\"\n    value: \n      FIELD:\n \
      \       path: \"CA10__sourceAddressPrefixes__c\""
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" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test9",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test10",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test11",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureNetworkSecurityGroup__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2024-06-27T20:33:04Z")
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test8"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test9"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test10"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test11"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureNetworkSecurityGroupRule__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__access__c STRING,
      CA10__direction__c STRING,
      CA10__protocol__c STRING,
      CA10__sourceAddressPrefix__c STRING,
      CA10__destinationPortRange__c STRING,
      CA10__destinationPortFrom__c FLOAT64,
      CA10__destinationPortTo__c FLOAT64,
      CA10__networkSecurityGroup__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test2_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "TCP",
    "CA10__sourceAddressPrefix__c" : "0.0.0.0",
    "CA10__destinationPortRange__c" : "*",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 65535,
    "CA10__networkSecurityGroup__c" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test3_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "TCP",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "80",
    "CA10__destinationPortFrom__c" : 80,
    "CA10__destinationPortTo__c" : 80,
    "CA10__networkSecurityGroup__c" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test4_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "TCP",
    "CA10__sourceAddressPrefix__c" : "Internet",
    "CA10__destinationPortRange__c" : "443",
    "CA10__destinationPortFrom__c" : 443,
    "CA10__destinationPortTo__c" : 443,
    "CA10__networkSecurityGroup__c" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test5_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "TCP",
    "CA10__sourceAddressPrefix__c" : "1.1.1.1/0",
    "CA10__destinationPortRange__c" : "400-500",
    "CA10__destinationPortFrom__c" : 400,
    "CA10__destinationPortTo__c" : 500,
    "CA10__networkSecurityGroup__c" : "test5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test6_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "TCP",
    "CA10__sourceAddressPrefix__c" : "0.0.0.0",
    "CA10__destinationPortRange__c" : "70-80",
    "CA10__destinationPortFrom__c" : 70,
    "CA10__destinationPortTo__c" : 80,
    "CA10__networkSecurityGroup__c" : "test6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test7_1",
    "CA10__access__c" : "Deny",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "*",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 65535,
    "CA10__networkSecurityGroup__c" : "test7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test8_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Outbound",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "*",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 65535,
    "CA10__networkSecurityGroup__c" : "test8"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test9_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "icmp",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "*",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 65535,
    "CA10__networkSecurityGroup__c" : "test9"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test10_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "1111",
    "CA10__destinationPortFrom__c" : 1111,
    "CA10__destinationPortTo__c" : 1111,
    "CA10__networkSecurityGroup__c" : "test10"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-06-27T20:33:04Z")
    },
    "Id" : "test11_1",
    "CA10__access__c" : "Allow",
    "CA10__direction__c" : "Inbound",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "1.1.1.1",
    "CA10__destinationPortRange__c" : "*",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 65535,
    "CA10__networkSecurityGroup__c" : "test11"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureNetworkSecurityGroup__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__Azure_Network_Security_Group_Rules__r ARRAY<STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__access__c STRING,
              CA10__direction__c STRING,
              CA10__protocol__c STRING,
              CA10__sourceAddressPrefix__c STRING,
              CA10__destinationPortRange__c STRING,
              CA10__destinationPortFrom__c FLOAT64,
              CA10__destinationPortTo__c FLOAT64,
              CA10__networkSecurityGroup__c STRING,
              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 references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Azure [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__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 = 0;
      if (obj.CA10__Azure_Network_Security_Group_Rules__r != null) {
          for (var i3 = 0; i3 < obj.CA10__Azure_Network_Security_Group_Rules__r.length; i3++) {
              if (obj.CA10__Azure_Network_Security_Group_Rules__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__Azure_Network_Security_Group_Rules__r] ' + (count_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)", currentStateMessage: "Network Security Group has a rule that allows HTTP(S) access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Consider restricting internet-level access to your Azure resources.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Network Security Group does not allow unrestricted HTTP(S) access from the internet.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__Azure_Network_Security_Group_Rules__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__access__c STRING,
          CA10__direction__c STRING,
          CA10__protocol__c STRING,
          CA10__sourceAddressPrefix__c STRING,
          CA10__destinationPortRange__c STRING,
          CA10__destinationPortFrom__c FLOAT64,
          CA10__destinationPortTo__c FLOAT64,
          CA10__networkSecurityGroup__c 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));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Azure [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__access__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__access__c.isEmpty()", currentStateMessage: "Corrupted data. NSG Rule Access cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__access__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Access [obj.CA10__access__c]: ' + obj.CA10__access__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'Allow')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__access__c') != 'Allow'", currentStateMessage: "NSG Deny Rule.", 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__direction__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10__direction__c.isEmpty()", currentStateMessage: "Corrupted data. NSG Rule Direction cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__direction__c;
      }
      function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      references1.push('Direction [obj.CA10__direction__c]: ' + obj.CA10__direction__c);
      try {
          if (TextLib.notEqual(extract6.call(extract6), 'Inbound')) {
              return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__direction__c') != 'Inbound'", currentStateMessage: "NSG Outbound Rule.", 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 fieldChecked10() {
          if (TextLib.isEmpty(obj.CA10__protocol__c)) {
              throw new Error("UNDETERMINED condition:301", {cause: {status: 'UNDETERMINED', conditionIndex: 301, conditionText: "CA10__protocol__c.isEmpty()", currentStateMessage: "Corrupted data. NSG Rule Protocol cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__protocol__c;
      }
      function extract9() { if (!this.out) { this.out = fieldChecked10(); } return this.out; };
      references1.push('Protocol [obj.CA10__protocol__c]: ' + obj.CA10__protocol__c);
      try {
          if (TextLib.notEqual(extract9.call(extract9), 'TCP')) {
              return {status: 'INAPPLICABLE', conditionIndex: 399, conditionText: "extract('CA10__protocol__c') != 'TCP'", currentStateMessage: "NSG Rule with the port other than UDP.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[4], conditionIndex:[400..499]
      function extract12() { if (!this.out) { this.out = obj.CA10__sourceAddressPrefix__c; } return this.out; };
      references1.push('Source Address Prefix [obj.CA10__sourceAddressPrefix__c]: ' + obj.CA10__sourceAddressPrefix__c);
      if (!(TextLib.equal(extract12.call(extract12), 'Internet') || TextLib.equal(extract12.call(extract12), '*') || TextLib.equal(extract12.call(extract12), '0.0.0.0') || TextLib.contains(extract12.call(extract12), '/0') || TextLib.equal(extract12.call(extract12), 'Any'))) {
          return {status: 'INAPPLICABLE', conditionIndex: 499, conditionText: "not(extract('CA10__sourceAddressPrefix__c') == 'Internet' || extract('CA10__sourceAddressPrefix__c') == '*' || extract('CA10__sourceAddressPrefix__c') == '0.0.0.0' || extract('CA10__sourceAddressPrefix__c').contains('/0') || extract('CA10__sourceAddressPrefix__c') == 'Any')", currentStateMessage: "NSG Rule source is not any address.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      function fieldChecked20() {
          if (TextLib.isEmpty(obj.CA10__destinationPortRange__c)) {
              throw new Error("UNDETERMINED condition:501", {cause: {status: 'UNDETERMINED', conditionIndex: 501, conditionText: "CA10__destinationPortRange__c.isEmpty()", currentStateMessage: "Corrupted data. NSG Rule Destination Port Range cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__destinationPortRange__c;
      }
      function extract19() { if (!this.out) { this.out = fieldChecked20(); } return this.out; };
      function extract25() { if (!this.out) { this.out = obj.CA10__destinationPortFrom__c; } return this.out; };
      function extract29() { if (!this.out) { this.out = obj.CA10__destinationPortTo__c; } return this.out; };
      references1.push('Destination Port Range [obj.CA10__destinationPortRange__c]: ' + obj.CA10__destinationPortRange__c);
      references1.push('Destination Port From [obj.CA10__destinationPortFrom__c]: ' + obj.CA10__destinationPortFrom__c);
      references1.push('Destination Port To [obj.CA10__destinationPortTo__c]: ' + obj.CA10__destinationPortTo__c);
      try {
          if (TextLib.equal(extract19.call(extract19), '80') || TextLib.equal(extract19.call(extract19), '443') || TextLib.equal(extract19.call(extract19), '*') || ((extract25.call(extract25) != null && 80.0 != null && extract25.call(extract25) <= 80.0) && (extract29.call(extract29) != null && 80.0 != null && extract29.call(extract29) >= 80.0)) || ((extract25.call(extract25) != null && 443.0 != null && extract25.call(extract25) <= 443.0) && (extract29.call(extract29) != null && 443.0 != null && extract29.call(extract29) >= 443.0))) {
              return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "extract('CA10__destinationPortRange__c') == '80' || extract('CA10__destinationPortRange__c') == '443' || extract('CA10__destinationPortRange__c') == '*' || (extract('CA10__destinationPortFrom__c') <= number(80.0) && extract('CA10__destinationPortTo__c') >= number(80.0)) || (extract('CA10__destinationPortFrom__c') <= number(443.0) && extract('CA10__destinationPortTo__c') >= number(443.0))", currentStateMessage: "NSG Rule with HTTP(S) access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Consider restricting internet-level access to your Azure resources.", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'INAPPLICABLE', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "Unrelated 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.Id AS Id,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          `CA10__Azure_Network_Security_Group_Rules__r`.arr AS CA10__Azure_Network_Security_Group_Rules__r,
          process_CA10__CaAzureNetworkSecurityGroup__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  `CA10__Azure_Network_Security_Group_Rules__r`.arr AS CA10__Azure_Network_Security_Group_Rules__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureNetworkSecurityGroup__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10__networkSecurityGroup__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__access__c AS CA10__access__c,
                      sObject.CA10__direction__c AS CA10__direction__c,
                      sObject.CA10__protocol__c AS CA10__protocol__c,
                      sObject.CA10__sourceAddressPrefix__c AS CA10__sourceAddressPrefix__c,
                      sObject.CA10__destinationPortRange__c AS CA10__destinationPortRange__c,
                      sObject.CA10__destinationPortFrom__c AS CA10__destinationPortFrom__c,
                      sObject.CA10__destinationPortTo__c AS CA10__destinationPortTo__c,
                      sObject.CA10__networkSecurityGroup__c AS CA10__networkSecurityGroup__c,
                      process_CA10__Azure_Network_Security_Group_Rules__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__access__c AS CA10__access__c,
                              sObject.CA10__direction__c AS CA10__direction__c,
                              sObject.CA10__protocol__c AS CA10__protocol__c,
                              sObject.CA10__sourceAddressPrefix__c AS CA10__sourceAddressPrefix__c,
                              sObject.CA10__destinationPortRange__c AS CA10__destinationPortRange__c,
                              sObject.CA10__destinationPortFrom__c AS CA10__destinationPortFrom__c,
                              sObject.CA10__destinationPortTo__c AS CA10__destinationPortTo__c,
                              sObject.CA10__networkSecurityGroup__c AS CA10__networkSecurityGroup__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAzureNetworkSecurityGroupRule__c()) AS sObject
          GROUP BY sObject.CA10__networkSecurityGroup__c
      ) AS `CA10__Azure_Network_Security_Group_Rules__r`
          ON sObject.Id = `CA10__Azure_Network_Security_Group_Rules__r`.CA10__networkSecurityGroup__c
  ) sObject ON sObject.Id = expectedResult.Id;
