π§ Azure Network Security Group allows public access to DNS port - prod.logic.yaml π’
- Contextual name: π§ prod.logic.yaml π’
- ID:
/ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-traffic/prod.logic.yaml
- Located in: π Azure Network Security Group allows public access to DNS port π’
Flagsβ
- π’ Logic test success
- π’ Logic with extracts
- π’ Logic with test data
Input Typeβ
Type | API Name | Extracts | Extract Files | Logic Files | |
---|---|---|---|---|---|
π | π Azure Network Security Group | CA10__CaAzureNetworkSecurityGroup__c | 3 | 1 | 17 |
Usesβ
Test Results π’β
Generated at: 2025-05-10T12:04:18.487039472Z Open
Result | Id | Condition Index | Condition Text | Runtime 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β
File | MD5 | |
---|---|---|
Open | /ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-traffic/policy.yaml | 7F62A818DF1B2B804DB068113D5F7E00 |
Open | /ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-traffic/prod.logic.yaml | 9CEC8041ABB47B87EB99741A93245946 |
Open | /types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml | A60C817EFBC8F066D6D082898E8597BC |
Open | /ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-traffic/test-data.json | 0E679173B3D498C5A03E82E2946357CA |
Generate FULL scriptβ
java -jar repo-manager.jar policies generate FULL /ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-traffic/prod.logic.yaml
Generate DEBUG scriptβ
java -jar repo-manager.jar policies generate DEBUG /ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-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-dns-traffic/prod.logic.yaml
Generate TESTS scriptβ
java -jar repo-manager.jar policies generate TESTS /ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-traffic/prod.logic.yaml
Execute testsβ
java -jar repo-manager.jar policies test /ce/ca/azure/virtual-network/security-group-allows-unrestricted-dns-traffic/prod.logic.yaml
Contentβ
---
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-dns-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-dns-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 DNS access from the Internet."
remediationMessage: "Restrict inbound DNS 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 DNS 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, UDP or Any."
check:
NOT:
arg:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "Tcp"
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "Udp"
- 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 DNS 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: "53"
- AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortFrom__c"
right:
NUMBER: 53.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortTo__c"
right:
NUMBER: 53.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."