---
policy: /ce/ca/azure/virtual-machine/allows-unrestricted-ftp-traffic
logic: /ce/ca/azure/virtual-machine/allows-unrestricted-ftp-traffic/prod.logic.yaml
executionTime: 2025-05-10T12:03:52.153198162Z
rows:
  - id: test-0
    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: test-1
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test-2
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test-3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test-4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test-5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test-5_2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test-6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)
      actual: CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test-7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/virtual-machine/allows-unrestricted-ftp-traffic/policy.yaml
    md5Hash: E8A1DE84C7C3F8C7A569691D42054A6F
    content: "---\nnames:\n  full: \"Azure Virtual Machine allows public access to\
      \ FTP ports\"\n  contextual: \"Virtual Machine allows public access to FTP ports\"\
      \ndescription: Ensure that Azure Virtual Machines do not allow unrestricted\
      \ public access to \n  the FTP traffic (ports 20 and 21), which can expose systems\
      \ to unauthorized \n  access and potential attacks.\ncategories:\n  - \"SECURITY\"\
      \ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/resource-security/public-and-anonymous-access\"\
      \n"
  - path: /ce/ca/azure/virtual-machine/allows-unrestricted-ftp-traffic/prod.logic.yaml
    md5Hash: EBDBD275E4F2A3D281D494D8F7AB2D01
    content: "---\ninputType: \"CA10__CaAzureVirtualMachine__c\"\ntestData:\n  - file:\
      \ test-data.json\nconditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage:\
      \ \"The Virtual Machine has a Network Interface with a NSG that allows FTP access\
      \ from the Internet.\"\n    remediationMessage: \"Restrict inbound FTP access\
      \ from the Internet.\"\n    check:\n      RELATED_LIST_HAS:\n        status:\
      \ \"INCOMPLIANT\"\n        relationshipName: \"CA10__Azure_Network_Interfaces__r\"\
      \notherwise:\n  status: \"COMPLIANT\"\n  currentStateMessage: \"The Virtual\
      \ Machine doesn't allow FTP access from the Internet.\" \nrelatedLists:\n  -\
      \ relationshipName: \"CA10__Azure_Network_Interfaces__r\"\n    importExtracts:\n\
      \      - file: \"/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml\"\
      \n    conditions:\n      - status: \"INCOMPLIANT\"\n        currentStateMessage:\
      \ \"Network Interface with publicly accessible Network Security Group\"\n  \
      \      check:\n          RELATED_LIST_HAS:\n            status: \"INCOMPLIANT\"\
      \n            relationshipName:  \"CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r\"\
      \n    otherwise:\n      status: \"COMPLIANT\"\n      currentStateMessage: \"\
      Network Interface is not publicly accessible\"\n    relatedLists:\n      - relationshipName:\
      \ \"CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r\"\
      \n        importExtracts:\n          - file: \"/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml\"\
      \n        conditions:\n# sort public group rules\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 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 Rule with the port other than TCP or\
      \ Any.\"\n            check:\n              NOT:\n                arg:\n   \
      \               OR:\n                    args:\n                      - IS_EQUAL:\n\
      \                          left:\n                            EXTRACT: \"CA10__protocol__c\"\
      \n                          right:\n                            TEXT: \"Tcp\"\
      \n                      - IS_EQUAL:\n                          left:\n     \
      \                       EXTRACT: \"CA10__protocol__c\"\n                   \
      \       right:\n                            TEXT: \"*\"\n                  \
      \    - IS_EQUAL:\n                          left:\n                        \
      \    EXTRACT: \"CA10__protocol__c\"\n                          right:\n    \
      \                        TEXT: \"null\"\n          - status: \"INAPPLICABLE\"\
      \n            currentStateMessage: \"NSG Rule source is not any address.\"\n\
      \            check:\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         \
      \             - IS_EQUAL:\n                          left:\n               \
      \             EXTRACT: \"CA10__sourceAddressPrefix__c\"\n                  \
      \        right:\n                            TEXT: \"Any\"\n               \
      \       - CONTAINS:\n                          arg:\n                      \
      \      EXTRACT: \"CA10__sourceAddressPrefix__c\"\n                         \
      \ substring:\n                            TEXT: \"/0\"\n          - status:\
      \ \"INCOMPLIANT\"\n            currentStateMessage: \"NSG Rule with FTP port\
      \ with public access from the Internet.\"\n            remediationMessage: \"\
      Restrict access to the FTP port\"\n            check:\n                # PORT\
      \ 20, 21\n              OR:\n                args:\n                  - IS_EQUAL:\n\
      \                      left:\n                        EXTRACT: \"CA10__destinationPortRange__c\"\
      \n                      right:\n                          TEXT: \"20\"\n   \
      \               - AND:\n                      args:\n                      \
      \  - LESS_THAN_EQUAL:\n                            left:\n                 \
      \             EXTRACT: \"CA10__destinationPortFrom__c\"\n                  \
      \          right:\n                              NUMBER: 20.0\n            \
      \            - GREATER_THAN_EQUAL:\n                              left:\n  \
      \                              EXTRACT: \"CA10__destinationPortTo__c\"\n   \
      \                           right:\n                                NUMBER:\
      \ 20.0\n                  - IS_EQUAL:\n                      left:\n       \
      \                 EXTRACT: \"CA10__destinationPortRange__c\"\n             \
      \         right:\n                          TEXT: \"21\"\n                 \
      \ - AND:\n                      args:\n                        - LESS_THAN_EQUAL:\n\
      \                            left:\n                              EXTRACT: \"\
      CA10__destinationPortFrom__c\"\n                            right:\n       \
      \                       NUMBER: 21.0\n                        - GREATER_THAN_EQUAL:\n\
      \                              left:\n                                EXTRACT:\
      \ \"CA10__destinationPortTo__c\"\n                              right:\n   \
      \                             NUMBER: 21.0\n        otherwise:\n          status:\
      \ \"COMPLIANT\"\n          currentStateMessage: \"NSG rule without public access\
      \ on FTP ports\"\n"
  - path: /ce/ca/azure/virtual-machine/allows-unrestricted-ftp-traffic/test-data.json
    md5Hash: A41C0F5A3431E83AC8757AF3C09BCDAC
    content: |-
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-0",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": "2023-05-22T10:08:05Z",
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": []
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-1",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-1",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-1",
              "CA10__networkSecurityGroup__c": "group-1",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-1",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-1",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Outbound",
                    "CA10__access__c": "Allow",
                    "CA10__protocol__c": "*",
                    "CA10__sourceAddressPrefix__c": "*",
                    "CA10__destinationPortRange__c": "77",
                    "CA10__destinationPortFrom__c": 1,
                    "CA10__destinationPortTo__c": 4000,
                    "CA10__networkSecurityGroup__c": "group-1"
                  }
                ]
              }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-2",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-2",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-2",
              "CA10__networkSecurityGroup__c": "group-2",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-2",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-2",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Inbound",
                    "CA10__access__c": "Deny",
                    "CA10__protocol__c": "*",
                    "CA10__sourceAddressPrefix__c": "*",
                    "CA10__destinationPortRange__c": "77",
                    "CA10__destinationPortFrom__c": 1,
                    "CA10__destinationPortTo__c": 4000,
                    "CA10__networkSecurityGroup__c": "group-2"
                  }
                ]
              }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-3",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-3",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-3",
              "CA10__networkSecurityGroup__c": "group-3",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-3",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-3",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Inbound",
                    "CA10__access__c": "Allow",
                    "CA10__protocol__c": "UDP",
                    "CA10__sourceAddressPrefix__c": "*",
                    "CA10__destinationPortRange__c": "77",
                    "CA10__destinationPortFrom__c": 1,
                    "CA10__destinationPortTo__c": 4000,
                    "CA10__networkSecurityGroup__c": "group-3"
                  }
                ]
              }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-4",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-4",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-4",
              "CA10__networkSecurityGroup__c": "group-4",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-4",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-4",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Inbound",
                    "CA10__access__c": "Allow",
                    "CA10__protocol__c": "*",
                    "CA10__sourceAddressPrefix__c": "1.1.1.1",
                    "CA10__destinationPortRange__c": "77",
                    "CA10__destinationPortFrom__c": 1,
                    "CA10__destinationPortTo__c": 4000,
                    "CA10__networkSecurityGroup__c": "group-4"
                  }
                ]
              }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-5",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-5",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-5",
              "CA10__networkSecurityGroup__c": "group-5",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-5",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-5",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Inbound",
                    "CA10__access__c": "Allow",
                    "CA10__protocol__c": "*",
                    "CA10__sourceAddressPrefix__c": "*",
                    "CA10__destinationPortRange__c": "20",
                    "CA10__destinationPortFrom__c": 20.0,
                    "CA10__destinationPortTo__c": 20.0,
                    "CA10__networkSecurityGroup__c": "group-5"
                  }
                ]
              }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-5_2",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-5_2",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-5_2",
              "CA10__networkSecurityGroup__c": "group-5_2",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-5_2",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-5_2",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Inbound",
                    "CA10__access__c": "Allow",
                    "CA10__protocol__c": "*",
                    "CA10__sourceAddressPrefix__c": "*",
                    "CA10__destinationPortRange__c": "21",
                    "CA10__destinationPortFrom__c": 21.0,
                    "CA10__destinationPortTo__c": 21.0,
                    "CA10__networkSecurityGroup__c": "group-5_2"
                  }
                ]
              }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "199",
            "conditionText": "CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-6",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-6",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-6",
              "CA10__networkSecurityGroup__c": "group-6",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-6",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-6",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Inbound",
                    "CA10__access__c": "Allow",
                    "CA10__protocol__c": "*",
                    "CA10__sourceAddressPrefix__c": "*",
                    "CA10__destinationPortRange__c": "77",
                    "CA10__destinationPortFrom__c": 1,
                    "CA10__destinationPortTo__c": 4000,
                    "CA10__networkSecurityGroup__c": "group-6"
                  }
                ]
              }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": {
            "snapshotTime": "2025-04-18T07:09:41Z"
          },
          "Id": "test-7",
          "RecordTypeId": "RecordTypeId",
          "CA10__disappearanceTime__c": null,
          "RecordType": {
            "DeveloperName": "caAzureRMVirtualMachine",
            "Id": "RecordTypeId"
          },
          "CA10__Azure_Network_Interfaces__r": [
            {
              "Id": "interface-7",
              "CA10__disappearanceTime__c": null,
              "CA10__virtualMachine__c": "test-7",
              "CA10__networkSecurityGroup__c": "group-7",
              "CA10__networkSecurityGroup__r": {
                "Id": "group-7",
                "CA10__Azure_Network_Security_Group_Rules__r": [
                  {
                    "Id": "rule-7",
                    "CA10__disappearanceTime__c": null,
                    "CA10__direction__c": "Inbound",
                    "CA10__access__c": "Allow",
                    "CA10__protocol__c": "*",
                    "CA10__sourceAddressPrefix__c": "*",
                    "CA10__destinationPortRange__c": "77",
                    "CA10__destinationPortFrom__c": 70,
                    "CA10__destinationPortTo__c": 700,
                    "CA10__networkSecurityGroup__c": "group-7"
                  }
                ]
              }
            }
          ]
        }
      ]
  - 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" : "test-0",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-1",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-2",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-5_2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureVirtualMachine__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-0",
    "RecordTypeId" : "RecordTypeId",
    "CA10__disappearanceTime__c" : new Date("2023-05-22T10:08:05Z")
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-1",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-2",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-3",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-4",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-5",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-5_2",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-6",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "test-7",
    "RecordTypeId" : "RecordTypeId"
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      DeveloperName STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "DeveloperName" : "caAzureRMVirtualMachine",
    "Id" : "RecordTypeId"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureNetworkInterface__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__virtualMachine__c STRING,
      CA10__networkSecurityGroup__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-1",
    "CA10__virtualMachine__c" : "test-1",
    "CA10__networkSecurityGroup__c" : "group-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-2",
    "CA10__virtualMachine__c" : "test-2",
    "CA10__networkSecurityGroup__c" : "group-2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-3",
    "CA10__virtualMachine__c" : "test-3",
    "CA10__networkSecurityGroup__c" : "group-3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-4",
    "CA10__virtualMachine__c" : "test-4",
    "CA10__networkSecurityGroup__c" : "group-4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-5",
    "CA10__virtualMachine__c" : "test-5",
    "CA10__networkSecurityGroup__c" : "group-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-5_2",
    "CA10__virtualMachine__c" : "test-5_2",
    "CA10__networkSecurityGroup__c" : "group-5_2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-6",
    "CA10__virtualMachine__c" : "test-6",
    "CA10__networkSecurityGroup__c" : "group-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "interface-7",
    "CA10__virtualMachine__c" : "test-7",
    "CA10__networkSecurityGroup__c" : "group-7"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureNetworkSecurityGroup__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-5_2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "group-7"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureNetworkSecurityGroupRule__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__direction__c STRING,
      CA10__access__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("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-1",
    "CA10__direction__c" : "Outbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "77",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 4000,
    "CA10__networkSecurityGroup__c" : "group-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-2",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Deny",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "77",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 4000,
    "CA10__networkSecurityGroup__c" : "group-2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-3",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "UDP",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "77",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 4000,
    "CA10__networkSecurityGroup__c" : "group-3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-4",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "1.1.1.1",
    "CA10__destinationPortRange__c" : "77",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 4000,
    "CA10__networkSecurityGroup__c" : "group-4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-5",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "20",
    "CA10__destinationPortFrom__c" : 20.0,
    "CA10__destinationPortTo__c" : 20.0,
    "CA10__networkSecurityGroup__c" : "group-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-5_2",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "21",
    "CA10__destinationPortFrom__c" : 21.0,
    "CA10__destinationPortTo__c" : 21.0,
    "CA10__networkSecurityGroup__c" : "group-5_2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-6",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "77",
    "CA10__destinationPortFrom__c" : 1,
    "CA10__destinationPortTo__c" : 4000,
    "CA10__networkSecurityGroup__c" : "group-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-18T07:09:41Z")
    },
    "Id" : "rule-7",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "77",
    "CA10__destinationPortFrom__c" : 70,
    "CA10__destinationPortTo__c" : 700,
    "CA10__networkSecurityGroup__c" : "group-7"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureVirtualMachine__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__Azure_Network_Interfaces__r ARRAY<STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__virtualMachine__c STRING,
              CA10__networkSecurityGroup__c STRING,
              CA10__networkSecurityGroup__r STRUCT<
                  Id STRING,
                  CA10__Azure_Network_Security_Group_Rules__r ARRAY<STRUCT<
                      Id STRING,
                      CA10__disappearanceTime__c TIMESTAMP,
                      CA10__direction__c STRING,
                      CA10__access__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>
                  >>
              >,
              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_Interfaces__r_INCOMPLIANT2 = 0;
      if (obj.CA10__Azure_Network_Interfaces__r != null) {
          for (var i3 = 0; i3 < obj.CA10__Azure_Network_Interfaces__r.length; i3++) {
              if (obj.CA10__Azure_Network_Interfaces__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10__Azure_Network_Interfaces__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__Azure_Network_Interfaces__r] ' + (count_CA10__Azure_Network_Interfaces__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__Azure_Network_Interfaces__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__Azure_Network_Interfaces__r.has(INCOMPLIANT)", currentStateMessage: "The Virtual Machine has a Network Interface with a NSG that allows FTP access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Restrict inbound FTP access from the Internet.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The Virtual Machine doesn't allow FTP access from the Internet.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__Azure_Network_Interfaces__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__virtualMachine__c STRING,
          CA10__networkSecurityGroup__c STRING,
          CA10__networkSecurityGroup__r STRUCT<
              Id STRING,
              CA10__Azure_Network_Security_Group_Rules__r ARRAY<STRUCT<
                  Id STRING,
                  CA10__disappearanceTime__c TIMESTAMP,
                  CA10__direction__c STRING,
                  CA10__access__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__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 = 0;
      if (obj.CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r != null) {
          for (var i3 = 0; i3 < obj.CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r.length; i3++) {
              if (obj.CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r] ' + (count_CA10__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)", currentStateMessage: "Network Interface with publicly accessible Network Security Group", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Network Interface is not publicly accessible", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__direction__c STRING,
          CA10__access__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__direction__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, 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 extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Direction [obj.CA10__direction__c]: ' + obj.CA10__direction__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'Inbound')) {
              return {status: 'INAPPLICABLE', conditionIndex: 199, 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[2], conditionIndex:[200..299]
      function fieldChecked7() {
          if (TextLib.isEmpty(obj.CA10__access__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, 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 extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; };
      references1.push('Access [obj.CA10__access__c]: ' + obj.CA10__access__c);
      try {
          if (TextLib.notEqual(extract6.call(extract6), 'Allow')) {
              return {status: 'INAPPLICABLE', conditionIndex: 299, 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[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.equal(extract9.call(extract9), 'Tcp') || TextLib.equal(extract9.call(extract9), '*') || TextLib.equal(extract9.call(extract9), 'null'))) {
              return {status: 'INAPPLICABLE', conditionIndex: 399, conditionText: "not(extract('CA10__protocol__c') == 'Tcp' || extract('CA10__protocol__c') == '*' || extract('CA10__protocol__c') == 'null')", currentStateMessage: "NSG Rule with the port other than TCP or Any.", 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 extract14() { 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(extract14.call(extract14), 'Internet') || TextLib.equal(extract14.call(extract14), '*') || TextLib.equal(extract14.call(extract14), '0.0.0.0') || TextLib.equal(extract14.call(extract14), 'Any') || TextLib.contains(extract14.call(extract14), '/0'))) {
          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') == 'Any' || extract('CA10__sourceAddressPrefix__c').contains('/0'))", currentStateMessage: "NSG Rule source is not any address.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      function fieldChecked22() {
          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 extract21() { if (!this.out) { this.out = fieldChecked22(); } 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(extract21.call(extract21), '20') || ((extract25.call(extract25) != null && 20.0 != null && extract25.call(extract25) <= 20.0) && (extract29.call(extract29) != null && 20.0 != null && extract29.call(extract29) >= 20.0)) || TextLib.equal(extract21.call(extract21), '21') || ((extract25.call(extract25) != null && 21.0 != null && extract25.call(extract25) <= 21.0) && (extract29.call(extract29) != null && 21.0 != null && extract29.call(extract29) >= 21.0))) {
              return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "extract('CA10__destinationPortRange__c') == '20' || (extract('CA10__destinationPortFrom__c') <= number(20.0) && extract('CA10__destinationPortTo__c') >= number(20.0)) || extract('CA10__destinationPortRange__c') == '21' || (extract('CA10__destinationPortFrom__c') <= number(21.0) && extract('CA10__destinationPortTo__c') >= number(21.0))", currentStateMessage: "NSG Rule with FTP port with public access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Restrict access to the FTP port", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "NSG rule without public access on FTP ports", 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.RecordTypeId AS RecordTypeId,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          `CA10__Azure_Network_Interfaces__r`.arr AS CA10__Azure_Network_Interfaces__r,
          process_CA10__CaAzureVirtualMachine__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  `CA10__Azure_Network_Interfaces__r`.arr AS CA10__Azure_Network_Interfaces__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureVirtualMachine__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
      LEFT JOIN (
          SELECT
              sObject.CA10__virtualMachine__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__virtualMachine__c AS CA10__virtualMachine__c,
                      sObject.CA10__networkSecurityGroup__c AS CA10__networkSecurityGroup__c,
                      STRUCT (
                          `CA10__networkSecurityGroup__r`.Id AS Id,
                          `CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`.arr AS CA10__Azure_Network_Security_Group_Rules__r
                      ) AS CA10__networkSecurityGroup__r,
                      process_CA10__Azure_Network_Interfaces__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__virtualMachine__c AS CA10__virtualMachine__c,
                              sObject.CA10__networkSecurityGroup__c AS CA10__networkSecurityGroup__c,
                              STRUCT (
                                  `CA10__networkSecurityGroup__r`.Id AS Id,
                                  `CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`.arr AS CA10__Azure_Network_Security_Group_Rules__r
                              ) AS CA10__networkSecurityGroup__r
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAzureNetworkInterface__c()) AS sObject
          LEFT JOIN UNNEST(mock_CA10__CaAzureNetworkSecurityGroup__c()) AS `CA10__networkSecurityGroup__r`
              ON sObject.CA10__networkSecurityGroup__c = `CA10__networkSecurityGroup__r`.Id
          LEFT JOIN (
              SELECT
                  sObject.CA10__networkSecurityGroup__c,
                  ARRAY_AGG(
                      STRUCT(
                          sObject.Id AS Id,
                          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                          sObject.CA10__direction__c AS CA10__direction__c,
                          sObject.CA10__access__c AS CA10__access__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__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r(
                              STRUCT(
                                  sObject.Id AS Id,
                                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                                  sObject.CA10__direction__c AS CA10__direction__c,
                                  sObject.CA10__access__c AS CA10__access__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__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`
              ON `CA10__networkSecurityGroup__r`.Id = `CA10__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`.CA10__networkSecurityGroup__c
          GROUP BY sObject.CA10__virtualMachine__c
      ) AS `CA10__Azure_Network_Interfaces__r`
          ON sObject.Id = `CA10__Azure_Network_Interfaces__r`.CA10__virtualMachine__c
  ) sObject ON sObject.Id = expectedResult.Id;
