---
policy: /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-oracle-dbms
logic: /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-oracle-dbms/prod.logic.yaml
executionTime: 2025-05-03T12:05:27.6198191Z
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: CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)
      actual: CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test-6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)
      actual: CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__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/vm-scale-set/instance-allows-unrestricted-traffic-to-oracle-dbms/policy.yaml
    md5Hash: E5AFE0464C34B88F5B2B444C3F0E0DF4
    content: "---\nnames:\n  full: \"Azure VM Scale Set Instance allows public access\
      \ to Oracle DBMS ports\"\n  contextual: \"Instance allows public access to Oracle\
      \ DBMS ports\"\ndescription: >\n  Ensure that Azure VM Scale Set Instances do\
      \ not allow unrestricted public access to \n  the Oracle DBMS (ports 1521, 1830,\
      \ 2483 and 2484) by limiting access to trusted \n  IP addresses or internal\
      \ networks. \ncategories:\n  - \"SECURITY\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/resource-security/public-and-anonymous-access\"\
      \n"
  - path: /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-oracle-dbms/prod.logic.yaml
    md5Hash: 4A62FA14084E1B6B85C725F9748F099B
    content: "---\ninputType: \"CA10__CaAzureVmScaleSetInstance__c\"\ntestData:\n\
      \  - file: test-data.json\nconditions:\n  - status: \"INCOMPLIANT\"\n    currentStateMessage:\
      \ \"The Instance has a Network Interface with a NSG with a rule that allows\
      \ Oracle DBMS access from the Internet.\"\n    remediationMessage: \"Restrict\
      \ inbound Oracle DBMS access from the Internet.\"\n    check:\n      RELATED_LIST_HAS:\n\
      \        status: \"INCOMPLIANT\"\n        relationshipName: \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\"\
      \notherwise:\n  status: \"COMPLIANT\"\n  currentStateMessage: \"The Instance\
      \ doesn't allow Oracle DBMS access from the Internet.\" \nrelatedLists:\n  -\
      \ relationshipName: \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\"\n\
      \    importExtracts:\n      - file: \"/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml\"\
      \n    conditions:\n      - status: \"INCOMPLIANT\"\n        currentStateMessage:\
      \ \"Interface with publicly accessible Network Security Group\"\n        check:\n\
      \          RELATED_LIST_HAS:\n            status: \"INCOMPLIANT\"\n        \
      \    relationshipName:  \"CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r\"\
      \n    otherwise:\n      status: \"COMPLIANT\"\n      currentStateMessage: \"\
      Interface is not publicly accessible\"\n    relatedLists:\n      - relationshipName:\
      \ \"CA10Z1__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          # ports 1521,\
      \ 1830, 2483 and 2484\n          - status: \"INCOMPLIANT\"\n            currentStateMessage:\
      \ \"NSG Rule with Oracle DBMS port 1521 with public access from the Internet.\"\
      \n            remediationMessage: \"Restrict access to the Oracle DBMS port\"\
      \n            check:\n              OR:\n                args:\n           \
      \       - IS_EQUAL:\n                      left:\n                        EXTRACT:\
      \ \"CA10__destinationPortRange__c\"\n                      right:\n        \
      \                  TEXT: \"1521\"\n                  - AND:\n              \
      \        args:\n                        - LESS_THAN_EQUAL:\n               \
      \             left:\n                              EXTRACT: \"CA10__destinationPortFrom__c\"\
      \n                            right:\n                              NUMBER:\
      \ 1521.0\n                        - GREATER_THAN_EQUAL:\n                  \
      \            left:\n                                EXTRACT: \"CA10__destinationPortTo__c\"\
      \n                              right:\n                                NUMBER:\
      \ 1521.0\n          - status: \"INCOMPLIANT\"\n            currentStateMessage:\
      \ \"NSG Rule with Oracle DBMS port 1830 with public access from the Internet.\"\
      \n            remediationMessage: \"Restrict access to the Oracle DBMS port\"\
      \n            check:\n              OR:\n                args:\n           \
      \       - IS_EQUAL:\n                      left:\n                        EXTRACT:\
      \ \"CA10__destinationPortRange__c\"\n                      right:\n        \
      \                  TEXT: \"1830\"\n                  - AND:\n              \
      \        args:\n                        - LESS_THAN_EQUAL:\n               \
      \             left:\n                              EXTRACT: \"CA10__destinationPortFrom__c\"\
      \n                            right:\n                              NUMBER:\
      \ 1830.0\n                        - GREATER_THAN_EQUAL:\n                  \
      \            left:\n                                EXTRACT: \"CA10__destinationPortTo__c\"\
      \n                              right:\n                                NUMBER:\
      \ 1830.0\n          - status: \"INCOMPLIANT\"\n            currentStateMessage:\
      \ \"NSG Rule with Oracle DBMS port 2483 with public access from the Internet.\"\
      \n            remediationMessage: \"Restrict access to the Oracle DBMS port\"\
      \n            check:\n              OR:\n                args:\n           \
      \       - IS_EQUAL:\n                      left:\n                        EXTRACT:\
      \ \"CA10__destinationPortRange__c\"\n                      right:\n        \
      \                  TEXT: \"2483\"\n                  - AND:\n              \
      \        args:\n                        - LESS_THAN_EQUAL:\n               \
      \             left:\n                              EXTRACT: \"CA10__destinationPortFrom__c\"\
      \n                            right:\n                              NUMBER:\
      \ 2483.0\n                        - GREATER_THAN_EQUAL:\n                  \
      \            left:\n                                EXTRACT: \"CA10__destinationPortTo__c\"\
      \n                              right:\n                                NUMBER:\
      \ 2483.0\n          - status: \"INCOMPLIANT\"\n            currentStateMessage:\
      \ \"NSG Rule with Oracle DBMS port 2484 with public access from the Internet.\"\
      \n            remediationMessage: \"Restrict access to the Oracle DBMS port\"\
      \n            check:\n              OR:\n                args:\n           \
      \       - IS_EQUAL:\n                      left:\n                        EXTRACT:\
      \ \"CA10__destinationPortRange__c\"\n                      right:\n        \
      \                  TEXT: \"2484\"\n                  - AND:\n              \
      \        args:\n                        - LESS_THAN_EQUAL:\n               \
      \             left:\n                              EXTRACT: \"CA10__destinationPortFrom__c\"\
      \n                            right:\n                              NUMBER:\
      \ 2484.0\n                        - GREATER_THAN_EQUAL:\n                  \
      \            left:\n                                EXTRACT: \"CA10__destinationPortTo__c\"\
      \n                              right:\n                                NUMBER:\
      \ 2484.0\n        otherwise:\n          status: \"COMPLIANT\"\n          currentStateMessage:\
      \ \"NSG rule without public access on Oracle DBMS port\"\n"
  - path: /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-oracle-dbms/test-data.json
    md5Hash: 42C26C4B55E2E667F01CD0265EABE733
    content: "[\n  {\n    \"expectedResult\": {\n      \"status\": \"DISAPPEARED\"\
      ,\n      \"conditionIndex\": \"99\",\n      \"conditionText\": \"isDisappeared(CA10__disappearanceTime__c)\"\
      ,\n      \"runtimeError\": null\n    },\n    \"context\": { \"snapshotTime\"\
      : \"2025-04-20T17:08:07Z\" },\n    \"Id\": \"test-0\",\n    \"CA10__disappearanceTime__c\"\
      : \"2025-04-10T23:15:10Z\",\n    \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\"\
      : []\n  },\n  {\n    \"expectedResult\": {\n      \"status\": \"COMPLIANT\"\
      ,\n      \"conditionIndex\": \"200\",\n      \"conditionText\": \"otherwise\"\
      ,\n      \"runtimeError\": null\n    },\n    \"context\": { \"snapshotTime\"\
      : \"2025-04-20T17:08:07Z\" },\n    \"Id\": \"test-1\",\n    \"CA10__disappearanceTime__c\"\
      : null,\n    \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\": [\n  \
      \    {\n        \"Id\": \"interface-1\",\n        \"CA10Z1__disappearanceTime__c\"\
      : null,\n        \"CA10Z1__vmScaleSetInstance__c\": \"test-1\",\n        \"\
      CA10Z1__networkSecurityGroup__c\": \"group-1\",\n        \"CA10Z1__networkSecurityGroup__r\"\
      : {\n          \"Id\": \"group-1\",\n          \"CA10__Azure_Network_Security_Group_Rules__r\"\
      : [\n            {\n                \"Id\": \"rule-1\",\n                \"\
      CA10__disappearanceTime__c\": null,\n                \"CA10__direction__c\"\
      : \"Outbound\",\n                \"CA10__access__c\": \"Allow\",\n         \
      \       \"CA10__protocol__c\": \"*\",\n                \"CA10__sourceAddressPrefix__c\"\
      : \"*\",\n                \"CA10__destinationPortRange__c\": \"77\",\n     \
      \           \"CA10__destinationPortFrom__c\": 1,\n                \"CA10__destinationPortTo__c\"\
      : 4000,\n                \"CA10__networkSecurityGroup__c\": \"group-1\"    \
      \       \n            }\n          ]\n        }\n      }\n    ]\n  },\n  {\n\
      \    \"expectedResult\": {\n      \"status\": \"COMPLIANT\",\n      \"conditionIndex\"\
      : \"200\",\n      \"conditionText\": \"otherwise\",\n      \"runtimeError\"\
      : null\n    },\n    \"context\": { \"snapshotTime\": \"2025-04-20T17:08:07Z\"\
      \ },\n    \"Id\": \"test-2\",\n    \"CA10__disappearanceTime__c\": null,\n \
      \   \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\": [\n      {\n  \
      \      \"Id\": \"interface-2\",\n        \"CA10Z1__disappearanceTime__c\": null,\n\
      \        \"CA10Z1__vmScaleSetInstance__c\": \"test-2\",\n        \"CA10Z1__networkSecurityGroup__c\"\
      : \"group-2\",\n        \"CA10Z1__networkSecurityGroup__r\": {\n          \"\
      Id\": \"group-2\",\n          \"CA10__Azure_Network_Security_Group_Rules__r\"\
      : [\n            {\n                \"Id\": \"rule-2\",\n                \"\
      CA10__disappearanceTime__c\": null,\n                \"CA10__direction__c\"\
      : \"Inbound\",\n                \"CA10__access__c\": \"Deny\",\n           \
      \     \"CA10__protocol__c\": \"*\",\n                \"CA10__sourceAddressPrefix__c\"\
      : \"*\",\n                \"CA10__destinationPortRange__c\": \"77\",\n     \
      \           \"CA10__destinationPortFrom__c\": 1,\n                \"CA10__destinationPortTo__c\"\
      : 4000,\n                \"CA10__networkSecurityGroup__c\": \"group-2\"    \
      \    \n            }\n          ]\n        }\n      }\n    ]\n  },\n  {\n  \
      \  \"expectedResult\": {\n      \"status\": \"COMPLIANT\",\n      \"conditionIndex\"\
      : \"200\",\n      \"conditionText\": \"otherwise\",\n      \"runtimeError\"\
      : null\n    },\n    \"context\": { \"snapshotTime\": \"2025-04-20T17:08:07Z\"\
      \ },\n    \"Id\": \"test-3\",\n    \"CA10__disappearanceTime__c\": null,\n \
      \   \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\": [\n      {\n  \
      \      \"Id\": \"interface-3\",\n        \"CA10Z1__disappearanceTime__c\": null,\n\
      \        \"CA10Z1__vmScaleSetInstance__c\": \"test-3\",\n        \"CA10Z1__networkSecurityGroup__c\"\
      : \"group-3\",\n        \"CA10Z1__networkSecurityGroup__r\": {\n          \"\
      Id\": \"group-3\",\n          \"CA10__Azure_Network_Security_Group_Rules__r\"\
      : [\n            {\n                \"Id\": \"rule-3\",\n                \"\
      CA10__disappearanceTime__c\": null,\n                \"CA10__direction__c\"\
      : \"Inbound\",\n                \"CA10__access__c\": \"Allow\",\n          \
      \      \"CA10__protocol__c\": \"UDP\",\n                \"CA10__sourceAddressPrefix__c\"\
      : \"*\",\n                \"CA10__destinationPortRange__c\": \"77\",\n     \
      \           \"CA10__destinationPortFrom__c\": 1,\n                \"CA10__destinationPortTo__c\"\
      : 4000,\n                \"CA10__networkSecurityGroup__c\": \"group-3\"    \
      \       \n            }\n          ]\n        }\n      }\n    ]\n  },\n  {\n\
      \    \"expectedResult\": {\n      \"status\": \"COMPLIANT\",\n      \"conditionIndex\"\
      : \"200\",\n      \"conditionText\": \"otherwise\",\n      \"runtimeError\"\
      : null\n    },\n    \"context\": { \"snapshotTime\": \"2025-04-20T17:08:07Z\"\
      \ },\n    \"Id\": \"test-4\",\n    \"CA10__disappearanceTime__c\": null,\n \
      \   \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\": [\n      {\n  \
      \      \"Id\": \"interface-4\",\n        \"CA10Z1__disappearanceTime__c\": null,\n\
      \        \"CA10Z1__vmScaleSetInstance__c\": \"test-4\",\n        \"CA10Z1__networkSecurityGroup__c\"\
      : \"group-4\",\n        \"CA10Z1__networkSecurityGroup__r\": {\n          \"\
      Id\": \"group-4\",\n          \"CA10__Azure_Network_Security_Group_Rules__r\"\
      : [\n            {\n                \"Id\": \"rule-4\",\n                \"\
      CA10__disappearanceTime__c\": null,\n                \"CA10__direction__c\"\
      : \"Inbound\",\n                \"CA10__access__c\": \"Allow\",\n          \
      \      \"CA10__protocol__c\": \"*\",\n                \"CA10__sourceAddressPrefix__c\"\
      : \"1.1.1.1\",\n                \"CA10__destinationPortRange__c\": \"77\",\n\
      \                \"CA10__destinationPortFrom__c\": 1,\n                \"CA10__destinationPortTo__c\"\
      : 4000,\n                \"CA10__networkSecurityGroup__c\": \"group-4\"    \
      \      \n            }\n          ]\n        }\n      }\n    ]\n  },\n  {\n\
      \    \"expectedResult\": {\n      \"status\": \"INCOMPLIANT\",\n      \"conditionIndex\"\
      : \"199\",\n      \"conditionText\": \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)\"\
      ,\n      \"runtimeError\": null\n    },\n    \"context\": { \"snapshotTime\"\
      : \"2025-04-20T17:08:07Z\" },\n    \"Id\": \"test-5\",\n    \"CA10__disappearanceTime__c\"\
      : null,\n    \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\": [\n  \
      \    {\n        \"Id\": \"interface-5\",\n        \"CA10Z1__disappearanceTime__c\"\
      : null,\n        \"CA10Z1__vmScaleSetInstance__c\": \"test-5\",\n        \"\
      CA10Z1__networkSecurityGroup__c\": \"group-5\",\n        \"CA10Z1__networkSecurityGroup__r\"\
      : {\n          \"Id\": \"group-5\",\n          \"CA10__Azure_Network_Security_Group_Rules__r\"\
      : [\n            {\n                \"Id\": \"rule-5\",\n                \"\
      CA10__disappearanceTime__c\": null,\n                \"CA10__direction__c\"\
      : \"Inbound\",\n                \"CA10__access__c\": \"Allow\",\n          \
      \      \"CA10__protocol__c\": \"*\",\n                \"CA10__sourceAddressPrefix__c\"\
      : \"*\",\n                \"CA10__destinationPortRange__c\": \"1521\",\n   \
      \             \"CA10__destinationPortFrom__c\": 1521.0,\n                \"\
      CA10__destinationPortTo__c\": 1521.0,\n                \"CA10__networkSecurityGroup__c\"\
      : \"group-5\"        \n            }\n          ]\n        }\n      }\n    ]\n\
      \  },\n  {\n    \"expectedResult\": {\n      \"status\": \"INCOMPLIANT\",\n\
      \      \"conditionIndex\": \"199\",\n      \"conditionText\": \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)\"\
      ,\n      \"runtimeError\": null\n    },\n    \"context\": { \"snapshotTime\"\
      : \"2025-04-20T17:08:07Z\" },\n    \"Id\": \"test-6\",\n    \"CA10__disappearanceTime__c\"\
      : null,\n    \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\": [\n  \
      \    {\n        \"Id\": \"interface-6\",\n        \"CA10Z1__disappearanceTime__c\"\
      : null,\n        \"CA10Z1__vmScaleSetInstance__c\": \"test-6\",\n        \"\
      CA10Z1__networkSecurityGroup__c\": \"group-6\",\n        \"CA10Z1__networkSecurityGroup__r\"\
      : {\n          \"Id\": \"group-6\",\n          \"CA10__Azure_Network_Security_Group_Rules__r\"\
      : [\n            {\n                \"Id\": \"rule-6\",\n                \"\
      CA10__disappearanceTime__c\": null,\n                \"CA10__direction__c\"\
      : \"Inbound\",\n                \"CA10__access__c\": \"Allow\",\n          \
      \      \"CA10__protocol__c\": \"*\",\n                \"CA10__sourceAddressPrefix__c\"\
      : \"*\",\n                \"CA10__destinationPortRange__c\": \"77\",\n     \
      \           \"CA10__destinationPortFrom__c\": 1500,\n                \"CA10__destinationPortTo__c\"\
      : 4000,\n                \"CA10__networkSecurityGroup__c\": \"group-6\"    \
      \ \n            }\n          ]\n        }\n      }\n    ]\n  },\n  {\n    \"\
      expectedResult\": {\n      \"status\": \"COMPLIANT\",\n      \"conditionIndex\"\
      : \"200\",\n      \"conditionText\": \"otherwise\",\n      \"runtimeError\"\
      : null\n    },\n    \"context\": { \"snapshotTime\": \"2025-04-20T17:08:07Z\"\
      \ },\n    \"Id\": \"test-7\",\n    \"CA10__disappearanceTime__c\": null,\n \
      \   \"CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r\": [\n      {\n  \
      \      \"Id\": \"interface-7\",\n        \"CA10Z1__disappearanceTime__c\": null,\n\
      \        \"CA10Z1__vmScaleSetInstance__c\": \"test-7\",\n        \"CA10Z1__networkSecurityGroup__c\"\
      : \"group-7\",\n        \"CA10Z1__networkSecurityGroup__r\": {\n          \"\
      Id\": \"group-7\",\n          \"CA10__Azure_Network_Security_Group_Rules__r\"\
      : [\n            {\n                \"Id\": \"rule-7\",\n                \"\
      CA10__disappearanceTime__c\": null,\n                \"CA10__direction__c\"\
      : \"Inbound\",\n                \"CA10__access__c\": \"Allow\",\n          \
      \      \"CA10__protocol__c\": \"*\",\n                \"CA10__sourceAddressPrefix__c\"\
      : \"*\",\n                \"CA10__destinationPortRange__c\": \"700\",\n    \
      \            \"CA10__destinationPortFrom__c\": 1700,\n                \"CA10__destinationPortTo__c\"\
      : 1800,\n                \"CA10__networkSecurityGroup__c\": \"group-7\"    \
      \  \n            }\n          ]\n        }\n      }\n    ]\n  }\n]\n"
  - 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" : "CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test-7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureVmScaleSetInstance__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-0",
    "CA10__disappearanceTime__c" : new Date("2025-04-10T23:15:10Z")
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "test-7"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureVmScaleSetInstanceNetworkInt__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10Z1__disappearanceTime__c TIMESTAMP,
      CA10Z1__vmScaleSetInstance__c STRING,
      CA10Z1__networkSecurityGroup__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "interface-1",
    "CA10Z1__vmScaleSetInstance__c" : "test-1",
    "CA10Z1__networkSecurityGroup__c" : "group-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "interface-2",
    "CA10Z1__vmScaleSetInstance__c" : "test-2",
    "CA10Z1__networkSecurityGroup__c" : "group-2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "interface-3",
    "CA10Z1__vmScaleSetInstance__c" : "test-3",
    "CA10Z1__networkSecurityGroup__c" : "group-3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "interface-4",
    "CA10Z1__vmScaleSetInstance__c" : "test-4",
    "CA10Z1__networkSecurityGroup__c" : "group-4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "interface-5",
    "CA10Z1__vmScaleSetInstance__c" : "test-5",
    "CA10Z1__networkSecurityGroup__c" : "group-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "interface-6",
    "CA10Z1__vmScaleSetInstance__c" : "test-6",
    "CA10Z1__networkSecurityGroup__c" : "group-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "interface-7",
    "CA10Z1__vmScaleSetInstance__c" : "test-7",
    "CA10Z1__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-20T17:08:07Z")
    },
    "Id" : "group-1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "group-2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "group-3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "group-4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "group-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "group-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "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-20T17:08:07Z")
    },
    "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-20T17:08:07Z")
    },
    "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-20T17:08:07Z")
    },
    "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-20T17:08:07Z")
    },
    "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-20T17:08:07Z")
    },
    "Id" : "rule-5",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "1521",
    "CA10__destinationPortFrom__c" : 1521.0,
    "CA10__destinationPortTo__c" : 1521.0,
    "CA10__networkSecurityGroup__c" : "group-5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "rule-6",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "77",
    "CA10__destinationPortFrom__c" : 1500,
    "CA10__destinationPortTo__c" : 4000,
    "CA10__networkSecurityGroup__c" : "group-6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-04-20T17:08:07Z")
    },
    "Id" : "rule-7",
    "CA10__direction__c" : "Inbound",
    "CA10__access__c" : "Allow",
    "CA10__protocol__c" : "*",
    "CA10__sourceAddressPrefix__c" : "*",
    "CA10__destinationPortRange__c" : "700",
    "CA10__destinationPortFrom__c" : 1700,
    "CA10__destinationPortTo__c" : 1800,
    "CA10__networkSecurityGroup__c" : "group-7"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureVmScaleSetInstance__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r ARRAY<STRUCT<
              Id STRING,
              CA10Z1__disappearanceTime__c TIMESTAMP,
              CA10Z1__vmScaleSetInstance__c STRING,
              CA10Z1__networkSecurityGroup__c STRING,
              CA10Z1__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_CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r_INCOMPLIANT2 = 0;
      if (obj.CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r != null) {
          for (var i3 = 0; i3 < obj.CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.length; i3++) {
              if (obj.CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r] ' + (count_CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT)", currentStateMessage: "The Instance has a Network Interface with a NSG with a rule that allows Oracle DBMS access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Restrict inbound Oracle DBMS access from the Internet.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "The Instance doesn't allow Oracle DBMS access from the Internet.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r(
      obj STRUCT<
          Id STRING,
          CA10Z1__disappearanceTime__c TIMESTAMP,
          CA10Z1__vmScaleSetInstance__c STRING,
          CA10Z1__networkSecurityGroup__c STRING,
          CA10Z1__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 [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c);
      if (obj.CA10Z1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10Z1__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 = 0;
      if (obj.CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r != null) {
          for (var i3 = 0; i3 < obj.CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r.length; i3++) {
              if (obj.CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10Z1__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r] ' + (count_CA10Z1__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10Z1__networkSecurityGroup__r_CA10__Azure_Network_Security_Group_Rules__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)", currentStateMessage: "Interface with publicly accessible Network Security Group", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Interface is not publicly accessible", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10Z1__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), '1521') || ((extract25.call(extract25) != null && 1521.0 != null && extract25.call(extract25) <= 1521.0) && (extract29.call(extract29) != null && 1521.0 != null && extract29.call(extract29) >= 1521.0))) {
              return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "extract('CA10__destinationPortRange__c') == '1521' || (extract('CA10__destinationPortFrom__c') <= number(1521.0) && extract('CA10__destinationPortTo__c') >= number(1521.0))", currentStateMessage: "NSG Rule with Oracle DBMS port 1521 with public access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Restrict access to the Oracle DBMS port", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[6], conditionIndex:[600..699]
      function fieldChecked33() {
          if (TextLib.isEmpty(obj.CA10__destinationPortRange__c)) {
              throw new Error("UNDETERMINED condition:601", {cause: {status: 'UNDETERMINED', conditionIndex: 601, 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 extract32() { if (!this.out) { this.out = fieldChecked33(); } return this.out; };
      function extract36() { if (!this.out) { this.out = obj.CA10__destinationPortFrom__c; } return this.out; };
      function extract40() { if (!this.out) { this.out = obj.CA10__destinationPortTo__c; } return this.out; };
      try {
          if (TextLib.equal(extract32.call(extract32), '1830') || ((extract36.call(extract36) != null && 1830.0 != null && extract36.call(extract36) <= 1830.0) && (extract40.call(extract40) != null && 1830.0 != null && extract40.call(extract40) >= 1830.0))) {
              return {status: 'INCOMPLIANT', conditionIndex: 699, conditionText: "extract('CA10__destinationPortRange__c') == '1830' || (extract('CA10__destinationPortFrom__c') <= number(1830.0) && extract('CA10__destinationPortTo__c') >= number(1830.0))", currentStateMessage: "NSG Rule with Oracle DBMS port 1830 with public access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Restrict access to the Oracle DBMS port", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[7], conditionIndex:[700..799]
      function fieldChecked44() {
          if (TextLib.isEmpty(obj.CA10__destinationPortRange__c)) {
              throw new Error("UNDETERMINED condition:701", {cause: {status: 'UNDETERMINED', conditionIndex: 701, 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 extract43() { if (!this.out) { this.out = fieldChecked44(); } return this.out; };
      function extract47() { if (!this.out) { this.out = obj.CA10__destinationPortFrom__c; } return this.out; };
      function extract51() { if (!this.out) { this.out = obj.CA10__destinationPortTo__c; } return this.out; };
      try {
          if (TextLib.equal(extract43.call(extract43), '2483') || ((extract47.call(extract47) != null && 2483.0 != null && extract47.call(extract47) <= 2483.0) && (extract51.call(extract51) != null && 2483.0 != null && extract51.call(extract51) >= 2483.0))) {
              return {status: 'INCOMPLIANT', conditionIndex: 799, conditionText: "extract('CA10__destinationPortRange__c') == '2483' || (extract('CA10__destinationPortFrom__c') <= number(2483.0) && extract('CA10__destinationPortTo__c') >= number(2483.0))", currentStateMessage: "NSG Rule with Oracle DBMS port 2483 with public access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Restrict access to the Oracle DBMS port", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[8], conditionIndex:[800..899]
      function fieldChecked55() {
          if (TextLib.isEmpty(obj.CA10__destinationPortRange__c)) {
              throw new Error("UNDETERMINED condition:801", {cause: {status: 'UNDETERMINED', conditionIndex: 801, 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 extract54() { if (!this.out) { this.out = fieldChecked55(); } return this.out; };
      function extract58() { if (!this.out) { this.out = obj.CA10__destinationPortFrom__c; } return this.out; };
      function extract62() { if (!this.out) { this.out = obj.CA10__destinationPortTo__c; } return this.out; };
      try {
          if (TextLib.equal(extract54.call(extract54), '2484') || ((extract58.call(extract58) != null && 2484.0 != null && extract58.call(extract58) <= 2484.0) && (extract62.call(extract62) != null && 2484.0 != null && extract62.call(extract62) >= 2484.0))) {
              return {status: 'INCOMPLIANT', conditionIndex: 899, conditionText: "extract('CA10__destinationPortRange__c') == '2484' || (extract('CA10__destinationPortFrom__c') <= number(2484.0) && extract('CA10__destinationPortTo__c') >= number(2484.0))", currentStateMessage: "NSG Rule with Oracle DBMS port 2484 with public access from the Internet.", currentStateReferences: references1.join('\n'), remediation: "Restrict access to the Oracle DBMS port", runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'COMPLIANT', conditionIndex: 900, conditionText: "otherwise", currentStateMessage: "NSG rule without public access on Oracle DBMS port", 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,
          `CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r`.arr AS CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r,
          process_CA10__CaAzureVmScaleSetInstance__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  `CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r`.arr AS CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureVmScaleSetInstance__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10Z1__vmScaleSetInstance__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                      sObject.CA10Z1__vmScaleSetInstance__c AS CA10Z1__vmScaleSetInstance__c,
                      sObject.CA10Z1__networkSecurityGroup__c AS CA10Z1__networkSecurityGroup__c,
                      STRUCT (
                          `CA10Z1__networkSecurityGroup__r`.Id AS Id,
                          `CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`.arr AS CA10__Azure_Network_Security_Group_Rules__r
                      ) AS CA10Z1__networkSecurityGroup__r,
                      process_CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                              sObject.CA10Z1__vmScaleSetInstance__c AS CA10Z1__vmScaleSetInstance__c,
                              sObject.CA10Z1__networkSecurityGroup__c AS CA10Z1__networkSecurityGroup__c,
                              STRUCT (
                                  `CA10Z1__networkSecurityGroup__r`.Id AS Id,
                                  `CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`.arr AS CA10__Azure_Network_Security_Group_Rules__r
                              ) AS CA10Z1__networkSecurityGroup__r
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10Z1__CaAzureVmScaleSetInstanceNetworkInt__c()) AS sObject
          LEFT JOIN UNNEST(mock_CA10__CaAzureNetworkSecurityGroup__c()) AS `CA10Z1__networkSecurityGroup__r`
              ON sObject.CA10Z1__networkSecurityGroup__c = `CA10Z1__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_CA10Z1__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 `CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`
              ON `CA10Z1__networkSecurityGroup__r`.Id = `CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r`.CA10__networkSecurityGroup__c
          GROUP BY sObject.CA10Z1__vmScaleSetInstance__c
      ) AS `CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r`
          ON sObject.Id = `CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r`.CA10Z1__vmScaleSetInstance__c
  ) sObject ON sObject.Id = expectedResult.Id;
