π§ Azure VM Scale Set Instance allows public access to MongoDB ports - prod.logic.yaml π’
- Contextual name: π§ prod.logic.yaml π’
- ID:
/ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/prod.logic.yaml
- Located in: π Azure VM Scale Set Instance allows public access to MongoDB ports π’
Flagsβ
- π’ Logic test success
- π’ Logic with extracts
- π’ Logic with test data
Input Typeβ
Type | API Name | Extracts | Extract Files | Logic Files | |
---|---|---|---|---|---|
π | π Azure VM Scale Set Instance | CA10__CaAzureVmScaleSetInstance__c | 1 | 1 | 17 |
Usesβ
Test Results π’β
Generated at: 2025-05-03T12:05:24.296297978Z Open
Result | Id | Condition Index | Condition Text | Runtime Error |
---|---|---|---|---|
π’ | test-0 | βοΈ 99 | βοΈ isDisappeared(CA10__disappearanceTime__c) | βοΈ null |
π’ | test-1 | βοΈ 200 | βοΈ otherwise | βοΈ null |
π’ | test-2 | βοΈ 200 | βοΈ otherwise | βοΈ null |
π’ | test-3 | βοΈ 200 | βοΈ otherwise | βοΈ null |
π’ | test-4 | βοΈ 200 | βοΈ otherwise | βοΈ null |
π’ | test-5 | βοΈ 199 | βοΈ CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT) | βοΈ null |
π’ | test-6 | βοΈ 199 | βοΈ CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r.has(INCOMPLIANT) | βοΈ null |
π’ | test-7 | βοΈ 200 | βοΈ otherwise | βοΈ null |
Generationβ
File | MD5 | |
---|---|---|
Open | /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/policy.yaml | 369B17153661FEDE5C032D2402746F6C |
Open | /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/prod.logic.yaml | 1C55D321B0FD0E40ADD5B77569E5E508 |
Open | /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/test-data.json | E0ADFFE954E88055D0C7655BA0CCD7C1 |
Open | /types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml | A60C817EFBC8F066D6D082898E8597BC |
Generate FULL scriptβ
java -jar repo-manager.jar policies generate FULL /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/prod.logic.yaml
Generate DEBUG scriptβ
java -jar repo-manager.jar policies generate DEBUG /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/prod.logic.yaml
Generate CAPTURE_TEST_DATA scriptβ
java -jar repo-manager.jar policies generate CAPTURE_TEST_DATA /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/prod.logic.yaml
Generate TESTS scriptβ
java -jar repo-manager.jar policies generate TESTS /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/prod.logic.yaml
Execute testsβ
java -jar repo-manager.jar policies test /ce/ca/azure/vm-scale-set/instance-allows-unrestricted-traffic-to-mongodb/prod.logic.yaml
Contentβ
---
inputType: "CA10__CaAzureVmScaleSetInstance__c"
testData:
- file: test-data.json
conditions:
- status: "INCOMPLIANT"
currentStateMessage: "The Instance has a Network Interface with a NSG with a rule that allows MongoDB access from the Internet."
remediationMessage: "Restrict inbound MongoDB access from the Internet."
check:
RELATED_LIST_HAS:
status: "INCOMPLIANT"
relationshipName: "CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r"
otherwise:
status: "COMPLIANT"
currentStateMessage: "The Instance doesn't allow MongoDB access from the Internet."
relatedLists:
- relationshipName: "CA10Z1__Azure_VM_Scale_Set_Instance_Network_Ints__r"
importExtracts:
- file: "/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml"
conditions:
- status: "INCOMPLIANT"
currentStateMessage: "Interface with publicly accessible Network Security Group"
check:
RELATED_LIST_HAS:
status: "INCOMPLIANT"
relationshipName: "CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r"
otherwise:
status: "COMPLIANT"
currentStateMessage: "Interface is not publicly accessible"
relatedLists:
- relationshipName: "CA10Z1__networkSecurityGroup__r.CA10__Azure_Network_Security_Group_Rules__r"
importExtracts:
- file: "/types/CA10__CaAzureNetworkSecurityGroupRule__c/object.extracts.yaml"
conditions:
# sort public group rules
- status: "INAPPLICABLE"
currentStateMessage: "NSG Outbound Rule."
check:
NOT_EQUAL:
left:
EXTRACT: "CA10__direction__c"
right:
TEXT: "Inbound"
- status: "INAPPLICABLE"
currentStateMessage: "NSG Deny Rule."
check:
NOT_EQUAL:
left:
EXTRACT: "CA10__access__c"
right:
TEXT: "Allow"
- status: "INAPPLICABLE"
currentStateMessage: "NSG Rule with the port other than TCP 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: "*"
- IS_EQUAL:
left:
EXTRACT: "CA10__protocol__c"
right:
TEXT: "null"
- status: "INAPPLICABLE"
currentStateMessage: "NSG Rule source is not any address."
check:
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"
- IS_EQUAL:
left:
EXTRACT: "CA10__sourceAddressPrefix__c"
right:
TEXT: "Any"
- CONTAINS:
arg:
EXTRACT: "CA10__sourceAddressPrefix__c"
substring:
TEXT: "/0"
# PORTS 27017-27020
- status: "INCOMPLIANT"
currentStateMessage: "NSG Rule with MongoDB port 27017 with public access from the Internet."
remediationMessage: "Restrict access to the MongoDB port"
check:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__destinationPortRange__c"
right:
TEXT: "27017"
- AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortFrom__c"
right:
NUMBER: 27017.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortTo__c"
right:
NUMBER: 27017.0
- status: "INCOMPLIANT"
currentStateMessage: "NSG Rule with MongoDB port 27018 with public access from the Internet."
remediationMessage: "Restrict access to the MongoDB port"
check:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__destinationPortRange__c"
right:
TEXT: "27018"
- AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortFrom__c"
right:
NUMBER: 27018.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortTo__c"
right:
NUMBER: 27018.0
- status: "INCOMPLIANT"
currentStateMessage: "NSG Rule with MongoDB port 27019 with public access from the Internet."
remediationMessage: "Restrict access to the MongoDB port"
check:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__destinationPortRange__c"
right:
TEXT: "27019"
- AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortFrom__c"
right:
NUMBER: 27019.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortTo__c"
right:
NUMBER: 27019.0
- status: "INCOMPLIANT"
currentStateMessage: "NSG Rule with MongoDB port 27020 with public access from the Internet."
remediationMessage: "Restrict access to the MongoDB port"
check:
OR:
args:
- IS_EQUAL:
left:
EXTRACT: "CA10__destinationPortRange__c"
right:
TEXT: "27020"
- AND:
args:
- LESS_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortFrom__c"
right:
NUMBER: 27020.0
- GREATER_THAN_EQUAL:
left:
EXTRACT: "CA10__destinationPortTo__c"
right:
NUMBER: 27020.0
otherwise:
status: "COMPLIANT"
currentStateMessage: "NSG rule without public access on MongoDB port"