Skip to main content

🧠 Azure Network Security Group allows public access to FTP ports - prod.logic.yaml 🟒

Flags​

Input Type​

TypeAPI NameExtractsExtract FilesLogic Files
πŸ”’πŸ“• Azure Network Security GroupCA10__CaAzureNetworkSecurityGroup__c3117

Uses​

Test Results πŸŸ’β€‹

Generated at: 2025-05-10T12:04:19.477904599Z Open

ResultIdCondition IndexCondition TextRuntime Error
🟒test1βœ”οΈ 99βœ”οΈ isDisappeared(CA10__disappearanceTime__c)βœ”οΈ null
🟒test2βœ”οΈ 199βœ”οΈ CA10__Azure_Network_Interfaces__r.has(COMPLIANT)βœ”οΈ null
🟒test3βœ”οΈ 299βœ”οΈ CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(COMPLIANT)βœ”οΈ null
🟒test4βœ”οΈ 399βœ”οΈ CA10__Azure_Network_Security_Group_Rules__r.has(INCOMPLIANT)βœ”οΈ null
🟒test5βœ”οΈ 400βœ”οΈ otherwiseβœ”οΈ null

Generation​

FileMD5
Open/ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/policy.yaml9C975E9EA76F1B0206ED674CE505B29E
Open/ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/prod.logic.yaml903828A75EE1127E43B63476ABC12A2E
Open/ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/test-data.jsonB039036CCECF10727AAF70E10FE5201C
Open/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yamlA60C817EFBC8F066D6D082898E8597BC

Generate FULL script​

java -jar repo-manager.jar policies generate FULL /ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/prod.logic.yaml

Generate DEBUG script​

java -jar repo-manager.jar policies generate DEBUG /ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/prod.logic.yaml

Generate CAPTURE_TEST_DATA script​

java -jar repo-manager.jar policies generate CAPTURE_TEST_DATA /ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/prod.logic.yaml

Generate TESTS script​

java -jar repo-manager.jar policies generate TESTS /ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/prod.logic.yaml

Execute tests​

java -jar repo-manager.jar policies test /ce/ca/azure/virtual-network/security-group-allows-unrestricted-ftp-traffic/prod.logic.yaml

Content​

Open File

---
inputType: "CA10__CaAzureNetworkSecurityGroup__c"
testData:
- file: "test-data.json"
conditions:
# This check identifies if the NSG is attached to a VM
# if it is then the NSG should be evaluated by the policy on the VM level
- status: "INAPPLICABLE"
currentStateMessage: "The Network Security Group is evaluated by /ce/ca/azure/virtual-machine/allows-unrestricted-ftp-traffic."
check:
RELATED_LIST_HAS:
relationshipName: "CA10__Azure_Network_Interfaces__r"
status: "COMPLIANT"
# This check identifies if the NSG is attached to a VM Scale Set
# if it is then the NSG should be evaluated by the policy on the VM Scale Set level
- status: "INAPPLICABLE"
currentStateMessage: "The Network Security Group is evaluated by /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-ftp-traffic."
check:
RELATED_LIST_HAS:
relationshipName: "CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r"
status: "COMPLIANT"

- status: "INCOMPLIANT"
currentStateMessage: "The Network Security Group has a rule that allows FTP access from the Internet."
remediationMessage: "Restrict inbound FTP access from the Internet."
check:
RELATED_LIST_HAS:
relationshipName: "CA10__Azure_Network_Security_Group_Rules__r"
status: "INCOMPLIANT"
otherwise:
status: "COMPLIANT"
currentStateMessage: "The NSG doesn't allow FTP access from the Internet."
relatedLists:
- relationshipName: "CA10__Azure_Network_Security_Group_Rules__r"
importExtracts:
- file: "/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml"
conditions:
- status: "INAPPLICABLE"
currentStateMessage: "NSG Deny Rule."
check:
NOT_EQUAL:
left:
EXTRACT: "CA10__access__c"
right:
TEXT: "Allow"
- status: "INAPPLICABLE"
currentStateMessage: "NSG Outbound Rule."
check:
NOT_EQUAL:
left:
EXTRACT: "CA10__direction__c"
right:
TEXT: "Inbound"
- status: "INAPPLICABLE"
currentStateMessage: "NSG Rule with the port other than TCP or Any."
check:
# returns true when protocol is neither TCP nor *
NOT:
arg:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "TCP"
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "*"
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "null"
- status: "INAPPLICABLE"
currentStateMessage: "NSG Rule source is not any address."
check:
# returns true when source is neither Internet, *, 0.0.0.0, /0, or Any
NOT:
arg:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__sourceAddressPrefix__c"
right:
TEXT: "Internet"
- IS_EQUAL:
left:
EXTRACT: "CA10__sourceAddressPrefix__c"
right:
TEXT: "*"
- IS_EQUAL:
left:
EXTRACT: "CA10__sourceAddressPrefix__c"
right:
TEXT: "0.0.0.0"
- CONTAINS:
arg:
EXTRACT: "CA10__sourceAddressPrefix__c"
substring:
TEXT: "/0"
- IS_EQUAL:
left:
EXTRACT: "CA10__sourceAddressPrefix__c"
right:
TEXT: "Any"
- status: "INCOMPLIANT"
currentStateMessage: "NSG Rule with FTP access from the Internet."
remediationMessage: "Consider restricting internet-level access to your Azure resources."
check:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__destinationPortRange__c"
right:
TEXT: "20"
- AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortFrom__c"
right:
NUMBER: 20.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortTo__c"
right:
NUMBER: 20.0
- status: "INCOMPLIANT"
currentStateMessage: "NSG Rule with FTP access from the Internet."
remediationMessage: "Consider restricting internet-level access to your Azure resources."
check:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__destinationPortRange__c"
right:
TEXT: "21"
- AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortFrom__c"
right:
NUMBER: 21.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortTo__c"
right:
NUMBER: 21.0
otherwise:
status: "INAPPLICABLE"
currentStateMessage: "Unrelated rule."
- relationshipName: "CA10__Azure_Network_Interfaces__r"
conditions:
- status: "COMPLIANT"
currentStateMessage: "This is a Network Interface with a linked VM."
check:
NOT_EMPTY_LOOKUP: "CA10__virtualMachine__r"
otherwise:
status: "INAPPLICABLE"
currentStateMessage: "This is a Network Interface without a linked VM."
- relationshipName: "CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r"
conditions:
- status: "COMPLIANT"
currentStateMessage: "This is a Network Interface with a linked VM Scale Set Instance."
check:
NOT_EMPTY_LOOKUP: "CA10Z1__vmScaleSetInstance__r"
otherwise:
status: "INAPPLICABLE"
currentStateMessage: "This is a Network Interface without a linked VM Scale Set Instance."