Enforcement Action Dynamic Value Statement Syntax Table
  • 16 Dec 2024
  • 12 Minutes to read
  • Dark
    Light
  • PDF

Enforcement Action Dynamic Value Statement Syntax Table

  • Dark
    Light
  • PDF

Article summary

The following table describes the syntax of all Dynamic Value statement (also referred to as "statement") types and the available functions and operators. 

The syntax in the table includes:

  • [asset type] - The asset type on which to apply the statement.
  • form.field - A field in the selected Enforcement Action Configuration dialog.
  • adapter.field - A field from the selected adapter.
  • itemN - A value or single value field (number or string type).

In a Dynamic Value statement, form.field and adapter.field must be of the same field type (e.g., both number or both string).

Learn some useful tips and tricks for working with dynamic value statements.  

See Dynamic Value Statement Examples and Use Cases for some detailed examples.


ElementTypeSyntaxNotes
allStatement[asset type] all then form.field set_valueExamples:
device all then form.field set_value
user all then form.field set_value
vulnerability all then form.field set_value
software all then form.field set_value

See set_value below for options.
switch/caseStatement

switch [adapter.field]
case operator then form.field set_value

Operators support functions. A value can be used instead of an operator.
addFunctionadd (item1, item2,…, itemN)Supports a list of number arguments (values and/or single value number type fields).
Adds the number arguments in the list. 
arrayFunctionarray ([adapter.field1],[adapter.field2],..., [adapter.fieldN])Creates an array of multiple fields. Each field input to the function can be an adapter field or text string. The array resulting from this function can be written into a single multi-value custom field (of type array (list)).
averageFunctionaverage ([adapter.field])Returns the average of the number values in the list. The field type of adapter.field is a list (array) of numbers.
by_keyFunctionby_key ([adapter_complex_field_path], field_to_compare, by_value, field_to_pick)
  • adapter_complex_field_path - The path to the complex field.
  • field_to_compare - The field in the object to compare with by_value.
  • by_value - The string value to match against the field_to_compare.
  • field_to_pick - The field value from the first matched object.
The function checks each object of the complex field ([adapter_complex_field_path]), checks each object until it finds a match between the specified field (field_to_compare) and the specified value (by_value). The function returns the value in another specified field (field_to_pick) from that first object with a match.
Notes:
  • This function supports only an exact comparison. It does not support a comparison between one value from a list field (field_to_compare) and a by_value.
  • This function does not support aggregated complex fields (which are in fact arrays of complex fields).
    For example, device all then form.tag_name set_value by_key ([device.specific_data.data.plugin_and_severities], "plugin_id", " 10395", "severity") does not work, as Plugins Information  (device.specific_data.data.plugin_and_severities) is not supported as it is an aggregated complex field, which combines several similar adapter fields into an aggregated one. In order for this function to work, use an adapter specific field, such as Tenable IO Plugins Information (device.adapters_data.tenable_io_adapter.plugin_and_severities).
concatFunctionconcat (item1, item2,…, itemN)Supports a list of string arguments (values and/or single value string type fields).
Concatenates the string arguments in the list.
concat_arrayFunctionconcat_array ([adapter.field], [adapter.field],...,[adapter.field])Joins one or more arrays into a single array.
For example: concat_array (list1 {a, b, c}, list2 [d, e, f, g]) --> [a, b, c, d, e, f, g]
concat_prefixFunctionconcat_prefix ("prefix", [adapter.field])Appends a prefix to each field value in a list (array). The field type of adapter.field is a list (array) of values.
For example: concat_prefix ("prefix", [adapter.field]) --> [prefixfield1, prefixfield2]
countFunctioncount ([adapter.field])Counts and returns the number of values in a list. The field type of adapter.field is a list (array) of numbers.
date_formatFunctiondate_format ([adapter.field], "format")Formats a date field using any of the following formats for the date and time:
  • %Y - Year (four digits)
  • %m - Month (01-12)
  • %d - Day of the month (01-31) 
  • %H - Hour (00-23) 
  • %M - Minute (00-59) 
  • %S - Second (00-60) 
  • %L - Millisecond (000-999) 
  • %j - Day of the year (001-366) 
  • %w - Day of the week (0-6, Sunday is 0) 
  • %a - Abbreviated weekday name (Sun, Mon, Tue, etc.) 
  • %A - Full weekday name (Sunday, Monday, Tuesday, etc.) 
  • %Z - Timezone (e.g., EST, PST, UTC)
Note:
  • M = minute; m = month
  • The date_format function does not work with lists (arrays). In order for this function to work when used on list fields, add a function that selects one value from the list, for example, date_format ((max([adapter.field]), "format")
divideFunctiondivide (item1, item2,…, itemN)Supports a list of number arguments (values and/or single value number type fields). Divides the number values in the list from left to right.
filter_by_keyFunctionfilter_by_key ([adapter_complex_field_path], field_to_compare, by_value, field_to_pick)The filter_by_key function filters data within complex fields and extracts a specific field value based on matching conditions.
  • adapter_complex_field_path - The path to the complex field being filtered.
  • field_to_compare - The field in the object to compare with by_value.
  • by_value - The string value to match against the field_to_compare.
  • field_to_pick - The field whose values are added to the resulting list for all matched objects.
The function checks each object of the complex field ([adapter_complex_field_path]) to see if the specified field (field_to_compare) is equivalent to the specified value (by_value). From each object with a match, places the value from another specified field (field_to_pick) into a comma-separated list. This list is returned by this function.
Notes:
  • This function fetches a field from each object in the complex field with a matching field value, as opposed to the by_key function that only fetches a field from the first object with a match.
  • This function supports only an exact comparison. It does not support a comparison between one value from a list field (field_to_compare) and a by_value.
  • This function does not support aggregated complex fields (which are in fact arrays of complex fields). See the example in the by_key function above.
joinFunctionjoin ([adapter.field], delimiter)Converts/flattens a list (array) into a single string of values separated by a delimiter.
maxFunctionmax ([adapter.field])
max (item1, item2,…, itemN)
Returns the highest number value in the list. The field type of adapter.field is a list (array) of numbers.
minFunctionmin ([adapter.field])
min (item1, item2,…, itemN)
Returns the lowest number value in the list. The field type of adapter.field is a list (array) of numbers.
multiplyFunctionmultiply (item1, item2,…, itemN)Supports a list of number arguments (values and/or single value number type fields). Multiplies the number values in the list.
nowFunctionnow ()Returns today's date and time formatted YYYY-mm-dd HH:MM:SS. For example: 2023-08-22 10:03:04
regex_extractFunctionregex_extract([adapter.field], "regex_expression", index)The Regular Expression function regex_extract extracts from adapter.field the string that matches regex_expression so that it can be used to populate Custom Fields or Tags. If index is not specified, it captures the first occurrence of the string in adapter.field. If index is specified (optional), it extracts the occurrence of the string specified by the index (is first occurrence, 1 is second, and so on).
Example: device all then form.field_value set_value  regex_extract([device.specific_data.data.name],"([a-zA-Z]{2}\d{3})",1)
regex_replaceFunctionregex_replace([adapter.field], regex_expression, replace_value)The regex_replace function returns the string value in adapter.field, and replaces the part of the string that matches regex_expression with the value in replace_value. Note that replace_value can also be a function that returns a string.
Example: device all then form.tag_name set_value regex_replace ([device.specific_data.data.name], "(.*?)-", "banana")
relationFunction[relation.[asset type]("[relationship name] ").[adapter.field]] The relation function fetches data from a field in a related asset (i.e., an asset that is related to the Enforcement Center action asset via a Relationship). For example, when running an action on a ticket, it is possible to retrieve data from an associated user based on a defined ticket-user Relationship.
[asset type] - The related asset type to pull data from.
[relationship name] - The name of the Relationship defined in the system. Learn more about Relationships.
[adapter.field] - The name of the field in the related asset.
You can retrieve the entire Relationship field name in the format relation.asset_type("relationship_name").adapter_field via the Relationship Fields tab in the Syntax Helper and then enclose it in [] .
For example, relation.disk("Has").specific_data.data.asset_type
This function is supported by the Dynamic Value Statement Wizard.
splitFunctionsplit([adapter.field], delimiter)Splits the string (in adapter.field) at the delimiter character and creates a list of the separate strings separated by commas.
substringFunction (string manipulation)substring([adapter.field], start_index, length)Returns a substring of the field value, beginning from the specified start position in the string for the length specified.
For example: substring('firstmiddlelast', 6, 3) = mid
subtractFunctionsubtract(item1, item2)Returns the result of subtracting item2 from item1. Supports two numbers (typed or values from fields) or two date-time fields. When subtracting two date-time fields, the result is the number of days with one decimal point. For example: 2.3
Note: This function expects exactly two numbers or dates. When using list (array) fields in the subtraction, it is recommended to add min or max functions so that the subtract is done on single value fields. Otherwise, if a list (array) field is used in the function instead of a single value field, although the syntax validates successfully, the function fails and the action field in all assets is set to the fallback static value.
sumFunctionsum ([adapter.field])Returns the sum of all the number values in the list. The field type of adapter.field is a list (array) of numbers.
to_dateFunctionto_date (number of milliseconds)Converts the results of a date calculation (epoch date in milliseconds) to a date in human-readable Date format.
For example: device all then form.field_date.now set_value to_date (add(now(),2592000000)) sets the date to 30 days (=2592000000 microseconds) from the current date.
to_intFunctionto_int ([adapter.field])Converts a string or float value in an array (list field) or single value field to an integer value. The value type of adapter.field is String or Float.
For example: device all then form.field_value set_value to_int ([device.specific_data.data.cpus.cores]) converts a field value of 7.0 (float) to 7 (integer)
to_lowerFunction (string manipulation)to_lower ([adapter.field])Converts the string in adapter.field to lowercase. 
to_upperFunction (string manipulation)to_upper ([adapter.field])Converts the string in adapter.field to uppercase. 
uniqueFunctionunique ([adapter.field])
unique (nested function)

unique ([adapter.field]) returns the unique values in the list. The field type of adapter.field is a list (array) of values.
unique (nested function) returns the unique results of a function.
alsoOperatorform.field1 set_value "string1" also form.field2 set_value "string2"

Applies dynamic content to two or more fields in an action.
For example: form.field1 set_value "aaa" also form.field2 set_value "XXX"

containsOperatorcase contains (“string”)

For lists - True if at least one item="string".
For string fields - True if part of the string value in the field ="string".
For example: case contains (“aaa”)

not_containsOperatorcase not_contains (“string”)

For lists - True if at least one item not ="string".
For string fields - True if "string" does not appear in all or part of the string value in the field.
For example: case not_contains (“aaa”)

countOperatorcase count (number value)Counts and matches the number of items in a list.
For example: case count (10)
starts_withOperatorcase starts_with (“string”)

For lists - True if at least one item starts with "string".
For string fields - True if the string value starts with "string".
See also not_starts_with.
For example: case starts_with (“aaa”)

ends_withOperatorcase ends_with (“string”)

For lists - True if at least one item ends with "string".
For string fields - True if the string value in the field ends with "string". See also not_ends_with.
For example: case ends_with (“aaa”) 

inOperatorcase in ([“string1”, "string2", ..., "stringN"])

For lists - True if at least one item is equivalent to one of the strings in the square brackets [string1, string2,..., stringN].
See also not_in.
For example: case in ([“aaa”, "bbb", "ccc"]) 

not_inOperatorcase not_in ([“string1”, "string2", ..., "stringN"])

For lists - True if at least one item is not equivalent to one of the strings in the square brackets [string1, string2,..., stringN].
For example: case not_in ([“aaa”, "bbb", "ccc"]) 

not_starts_withOperatorcase not_starts_with (“string”)For lists - True if at least one item does not start with "string".
For string fields - True if the string value in the field does not start with "string".
For example: case not_starts_with (“aaa”)
not_ends_withOperatorcase not_ends_with (“string”)For lists - True if at least one item does not end with "string".
For string fields - True if the string value in the field does not end with "string".
For example: case not_ends_with (“aaa”)
field_equalOperatorcase field_equal (“string”)True if the exact given string is identical to the string value in the field.
Examples:
case field_equal (“google”) for string fields
case field_equal (“8.3”) for number fields
case field_equal (true) for boolean fields
field_not_equalOperatorcase field_not_equal (“string”)True if the exact given string is not identical to the string value in the field.
Examples:
case field_not_equal (“google”)
case field_not_equal (“8.3”)
case field_not_equal (true)
field_existsOperatorswitch adapter.field
case field_exists then form.field set_value “value”
Tests whether adapter.field exists. If true, sets the value of form.field to "value".
field_not_existsOperatorswitch adapter.field
case field_not_exists then form.field set_value “value”
Tests whether adapter.field exists. If false, sets the value of form.field to "value".
in_netOperatorswitch [adapter.field]
case in_net (IP address range) then form.field set_value “value”
Tests whether the IP addresses in adapter.field (list field) or IP address in adapter.field (string field) are in the specified IP address range.  
If true, sets the value of form.field to "value".
IP address range can be in the format "10.10.0.4/3.6" or "10.10.0.4-10.10.3.6"
Can compare to multiple comma-separated subnets.
Valid for IPv4 and IPv6 addresses.
not_in_netOperatorswitch [adapter.field]
case not_in_net (IP address range) then form.field set_value “value”
Tests whether the IP addresses in adapter.field (list field) or IP address in adapter.field (string field) are in the specified IP address range.  
If false, sets the value of form.field to "value".
IP address range can be in the format "10.10.0.4/3.6" or "10.10.0.4-10.10.3.6"
Can compare to multiple comma-separated subnets.
Valid for IPv4 and IPv6 addresses.
gtOperatorswitch [adapter.field] case gt(number value)
switch [adapter.field1] case gt([adapter.field2])
Tests whether the number value in adapter.field is greater than the specified number value (for example, 10).
OR
Tests whether the number value in adapter.field1 is greater than the number value in adapter.field2.
ltOperatorswitch [adapter.field] case lt(number value)
switch [adapter.field1] case lt([adapter.field2])
Tests whether the number value in adapter.field is less than the specified number value (for example, 20).
OR
Tests whether the number value in adapter.field1 is less than the number value in adapter.field2.
set_valueOperatorset_value “string”
set_value [adapter.field]
set_value [adapter.field_path]
set_value true; set_value false for Boolean fields
set_value function ()
set_value item1 or item2 ... or itemN
Multiple (nested) functions can be used. The field type of adapter.field and adapter.field_path must match the field type of form.field. For example, both fields must be string type or both number type.
Note that "or" is supported with set_value inside a Case statement to set the value of the action field to the first field value in the "or" list that exists on the asset. item1 or item2 ... or itemN



Was this article helpful?