Skip to main content

🧠 Azure PostgreSQL Flexible Server Firewall Rules allow access to Azure services - prod.logic.yaml 🟒

Flags​

Input Type​

TypeAPI NameExtractsExtract FilesLogic Files
πŸ”’πŸ“• Azure PostgreSQL ServerCA10Z1__CaAzurePostgreSqlServer__c719

Uses​

Test Results πŸŸ’β€‹

Generated at: 2025-04-24T23:45:37.391925180Z Open

ResultIdCondition IndexCondition TextRuntime Error
🟒test1βœ”οΈ 99βœ”οΈ isDisappeared(CA10Z1__disappearanceTime__c)βœ”οΈ null
🟒test2βœ”οΈ 399βœ”οΈ extract('caJsonFrom__firewallRules__c').jsonQueryText('length([? properties.startIpAddress == \'0.0.0.0\' && (properties.endIpAddress == \'0.0.0.0\' || properties.endIpAddress == \'255.255.255.255\')])') > number(0.0)βœ”οΈ null
🟒test3βœ”οΈ 299βœ”οΈ extract('caJsonFrom__firewallRules__c').jsonQueryText('length([? starts_with(name, \'AllowAllAzureServicesAndResourcesWithinAzureIps\')])') > number(0.0)βœ”οΈ null
🟒test4βœ”οΈ 399βœ”οΈ extract('caJsonFrom__firewallRules__c').jsonQueryText('length([? properties.startIpAddress == \'0.0.0.0\' && (properties.endIpAddress == \'0.0.0.0\' || properties.endIpAddress == \'255.255.255.255\')])') > number(0.0)βœ”οΈ null
🟒test5βœ”οΈ 500βœ”οΈ otherwiseβœ”οΈ null
🟒test6βœ”οΈ 500βœ”οΈ otherwiseβœ”οΈ null
🟒test7βœ”οΈ 204βœ”οΈ extract('caJsonFrom__firewallRules__c').jsonQueryText('length([? starts_with(name, \'AllowAllAzureServicesAndResourcesWithinAzureIps\')])').isEvaluationFailed()βœ”οΈ TypeError: starts_with() expected argument 1 to be type 2 but received type 7 instead.
🟒test8βœ”οΈ 500βœ”οΈ otherwiseβœ”οΈ null
🟒test9βœ”οΈ 201βœ”οΈ CA10Z1__firewallRules__c.delegatedTo(CA10Z1__firewallRules__c).isEmpty()βœ”οΈ null
🟒test10βœ”οΈ 199βœ”οΈ extract('CA10Z1__deploymentMode__c') != 'Flexible'βœ”οΈ null

Generation​

FileMD5
Open/ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/policy.yaml36E75FE441963552505613F88F297027
Open/ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/prod.logic.yaml115EA6A75B7D2B51C3505AD3291E8168
Open/types/CA10Z1__CaAzurePostgreSqlServer__c/object.extracts.yaml08BBA6DB6D72395AA7E05F67B74F9223
Open/ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/test-data.jsonD368F0DE994691DB4F945A6D5306C790

Generate FULL script​

java -jar repo-manager.jar policies generate FULL /ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/prod.logic.yaml

Generate DEBUG script​

java -jar repo-manager.jar policies generate DEBUG /ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/prod.logic.yaml

Generate CAPTURE_TEST_DATA script​

java -jar repo-manager.jar policies generate CAPTURE_TEST_DATA /ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/prod.logic.yaml

Generate TESTS script​

java -jar repo-manager.jar policies generate TESTS /ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/prod.logic.yaml

Execute tests​

java -jar repo-manager.jar policies test /ce/ca/azure/postgresql-database/disable-flexible-server-allows-access-to-azure-services/prod.logic.yaml

Content​

Open File

---
inputType: "CA10Z1__CaAzurePostgreSqlServer__c"
testData:
- file: "test-data.json"
importExtracts:
- file: "/types/CA10Z1__CaAzurePostgreSqlServer__c/object.extracts.yaml"
conditions:
- status: "INAPPLICABLE"
currentStateMessage: "This is not the Flexible Server deployment mode."
check:
NOT_EQUAL:
left:
EXTRACT: "CA10Z1__deploymentMode__c"
right:
TEXT: "Flexible"
- status: "INCOMPLIANT"
currentStateMessage: "PostgreSQL Database Server Firewall Rules contain AllowAllWindowsAzureIps rule allowing ingress from 0.0.0.0/0 (ANY IP)."
remediationMessage: "Consider removing or disabling the overly permissive rule."
check:
# returns the number of rules which names start with AllowAllAzureServicesAndResourcesWithinAzureIps
GREATER_THAN:
left:
JSON_QUERY_NUMBER:
arg:
EXTRACT: "caJsonFrom__firewallRules__c"
expression: "length([? starts_with(name, 'AllowAllAzureServicesAndResourcesWithinAzureIps')])"
undeterminedIf:
evaluationError: "The JSON query has failed."
resultTypeMismatch: "The JSON query did not return number type."
right:
NUMBER: 0.0
- status: "INCOMPLIANT"
currentStateMessage: "PostgreSQL Database Server Firewall Rules contain a rule allowing ingress from 0.0.0.0/0 (ANY IP)."
remediationMessage: "Consider removing or disabling the overly permissive rule."
check:
# number of rules with start and end IPs as 0.0.0.0
GREATER_THAN:
left:
JSON_QUERY_NUMBER:
arg:
EXTRACT: "caJsonFrom__firewallRules__c"
expression: "length([? properties.startIpAddress == '0.0.0.0' && (properties.endIpAddress == '0.0.0.0' || properties.endIpAddress == '255.255.255.255')])"
undeterminedIf:
evaluationError: "The JSON query has failed."
resultTypeMismatch: "The JSON query did not return number type."
right:
NUMBER: 0.0
- status: "COMPLIANT"
currentStateMessage: "PostgreSQL Database Server doesn't have any Firewall Rules."
check:
IS_EMPTY:
arg:
EXTRACT: "CA10Z1__firewallRules__c"
otherwise:
status: "COMPLIANT"
currentStateMessage: "PostgreSQL Database Server Firewall Rules do not have a rule allowing ingress from 0.0.0.0/0 (ANY IP)."