Functions

Functions

Use functions in rules to identify specific information about resource types. Functions use the following syntax:

<function>(<argument>)  

Following are the functions used in NGL:

len

age

text match

Common Errors

This section outlines errors that may occur with the functions.

Error ScenarioIncorrect NGL ExampleSample Error MessageSteps to fix the error
Undefined functionAzureAD oauth2permissiongrant should-not-have text-match(scope, "AppRoleAssignment.ReadWrite.All") = trueError: undefined function text-matchUse correct function name.
For example: AzureAD oauth2permissiongrant should-not-have textmatch(scope, "AppRoleAssignment.ReadWrite.All") = true
Wrong type for len functionAzureAD User should-have len(employeeHireDate) = 5Error: len() only supports string and list type, got numberUse a property that satisfies the required data type. See DOM files to learn more.
For example: AzureAD User should-have len(mobilePhone) < 11
First parameter for textmatch is not a propertyAzureAD User should-have textmatch("5", "5") = trueError: textmatch() only accepts property as the first parameter, got string.Use first parameter as property in textmatch. See textmatch function for more info.
For example: AzureAD User should-have textmatch(department, "eng") = true
Property used for textmatch is not a string nor a list of stringAzureAD User should-have textmatch(employeeHireDate, "department") = trueError: textmatch() only supports a property of data type 'string' or 'list', got 'employeeHireDate' of type 'number'Use a property that satisfies the required data type.
For example:AzureAD User should-have textmatch ( department, "Retail") = true
Second parameter for textmatch is not stringAzureAD User should-have textmatch (department, 5) = trueError: textmatch() pattern should be a string, got numberUse string pattern to match.
For example: AzureAD User should-have textmatch ( department, "Retail") = true
First parameter for age is not a propertyAzureAD User should-have age("createdDateTime", "days") > 1Error: age() only accepts property as the first parameter, got stringUse property as first parameter.
For example: AzureAD User should-have age(createdDateTime, "days") > 1
Wrong conversion unitAzureAD User should-have age(createdDateTime, "years") > 1Error: date-time conversion parameter should be days or hours, got yearsUse the correct time unit.
For example: AzureAD User should-have age(createdDateTime, "days") > 1
Identifier is not a numberAzureAD User should-have age(department, "days") > 1Error: age() only supports a property of data type number, got 'department' of type 'string'Use numeric data type properties with age.
For example: AzureAD User should-have age(createdDateTime, "days") > 1
Share this Doc

Functions

Or copy link

In this topic ...