Skip to main content

🧠 Azure Subscription Custom Subscription Administrator Roles exist - prod.logic.yaml 🟒

Flags​

Input Type​

TypeAPI NameExtractsExtract FilesLogic Files
πŸ”’πŸ“• Azure SubscriptionCA10__CaAzureAccount__c13131

Uses​

Test Results πŸŸ’β€‹

Generated at: 2025-04-24T23:46:14.722850431Z Open

ResultIdCondition IndexCondition TextRuntime Error
🟒test1βœ”οΈ 199βœ”οΈ CA10__Azure_Authorization_Role_Definitions__r.has(INCOMPLIANT)βœ”οΈ null
🟒test2βœ”οΈ 200βœ”οΈ otherwiseβœ”οΈ null
🟒test3βœ”οΈ 200βœ”οΈ otherwiseβœ”οΈ null
🟒test4βœ”οΈ 200βœ”οΈ otherwiseβœ”οΈ null
🟒test5βœ”οΈ 200βœ”οΈ otherwiseβœ”οΈ null

Generation​

FileMD5
Open/ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/policy.yaml513C8C5836BF33FDFCBA20DB5FD40742
Open/ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/prod.logic.yaml73DFCC88B98DBCD02F77722E23EC9D31
Open/ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/test-data.json765AF2CAA1D3B3A38E0FC73D056B3314
Open/types/CA10__CaAzureAuthorizationRole__c/object.extracts.yaml4CDB79E4A44CCA84E7046E7B9C7C8873

Generate FULL script​

java -jar repo-manager.jar policies generate FULL /ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/prod.logic.yaml

Generate DEBUG script​

java -jar repo-manager.jar policies generate DEBUG /ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/prod.logic.yaml

Generate CAPTURE_TEST_DATA script​

java -jar repo-manager.jar policies generate CAPTURE_TEST_DATA /ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/prod.logic.yaml

Generate TESTS script​

java -jar repo-manager.jar policies generate TESTS /ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/prod.logic.yaml

Execute tests​

java -jar repo-manager.jar policies test /ce/ca/azure/subscription/custom-subscription-administrator-roles-exist/prod.logic.yaml

Content​

Open File

---
inputType: "CA10__CaAzureAccount__c"
testData:
- file: "test-data.json"
conditions:
- status: "INCOMPLIANT"
currentStateMessage: "This subscription has a custom role with owner permissions\
\ and assignable scope is set to subscription."
remediationMessage: "Consider removing the custom role."
check:
RELATED_LIST_HAS:
relationshipName: "CA10__Azure_Authorization_Role_Definitions__r"
status: "INCOMPLIANT"
otherwise:
status: "COMPLIANT"
currentStateMessage: "This subscription doesn't have a custom role with owner permissions."
relatedLists:
- relationshipName: "CA10__Azure_Authorization_Role_Definitions__r"
importExtracts:
- file: "/types/CA10__CaAzureAuthorizationRole__c/object.extracts.yaml"
conditions:
- status: "INAPPLICABLE"
currentStateMessage: "This is not a Custom role."
check:
NOT_EQUAL:
left:
EXTRACT: "CA10__roleType__c"
right:
TEXT: "CustomRole"
- status: "INAPPLICABLE"
currentStateMessage: "Permissions do not have * actions."
check:
# Returns true if permissions' actions have "*" action
IS_EQUAL:
left:
JSON_QUERY_BOOLEAN:
arg:
JSON_FROM:
arg:
EXTRACT: "CA10__permissionsJson__c"
undeterminedIf:
isInvalid: "The provided Permissions JSON is invalid."
expression: "contains([*].actions[], '*')"
undeterminedIf:
evaluationError: "JSON query boolean has failed."
resultTypeMismatch: "JSON query did not return boolean type."
right:
BOOLEAN: false
- status: "INCOMPLIANT"
currentStateMessage: "This custom role has owner permissions and subscription scopes."
remediationMessage: "Consider removing this role."
check:
# JSON_QUERY_NUMBER returns the number of scopes that fall into the filter:
# the scope start with '/subscriptions/' and does not contain 'resourceGroups'
GREATER_THAN:
left:
JSON_QUERY_NUMBER:
arg:
JSON_FROM:
arg:
EXTRACT: "CA10__assignableScopesJson__c"
undeterminedIf:
isInvalid: "The provided Assignable Scopes JSON is invalid."
expression: "length([?starts_with(@, '/subscriptions/') && !contains(@, 'resourceGroups')])"
undeterminedIf:
evaluationError: "JSON query number has failed."
resultTypeMismatch: "JSON query did not return number type."
right:
NUMBER: 0.0
otherwise:
status: "INAPPLICABLE"
currentStateMessage: "A role has owner permissions without subscription scopes."