Set Variable: operations

Operations let you modify variables in ways that were previously only available through the use of advanced metadata. See the table below of the transformations available in the Set Variable behavior.

Combining operations

To use more than one transformation on a variable, use multiple Set Variable behaviors in the rule. The order matters when setting the different transformations, and the transformations are applied in the order they appear in the rule. After the first transformation, any subsequent instance of the Set Variable behavior must have that variable selected as were the value is coming from. You can string as many transformations together as you want.

πŸ“˜

Set Variable only allows one transformation per instance of the behavior. If you require multiple transformations for a variable, use multiple Set Variable behaviors.

For example, if you want to retrieve the first two characters of a variable's value, then change those two characters to uppercase. To do this you would need two instances of the Set Variable behavior; one to change the case of the value, and the other to retrieve the first two characters from that same value.

This is how you would accomplish this task:

How to

  1. Add the first instance of Set Variable.

    1. Select the variable you want to transform.

    2. Select Extract as the source of the value.

    3. Select Request Header.

    4. Enter the name of the header to take the value from.

    5. Select Upper Case transform.

  2. Add a second Set Variable behavior.

    1. Select the same variable.

    2. Create value from expression.

    3. Add the variable as the expression value.

    4. Select sub-string as your transformation.

    5. Start index of 0.

    6. Max index of 1.

Available operations

OperationOperatorsDescription
AddOperand: IntegerAdd the value of an operand to the variable. The transformation could fail if either of the input values are not integers.
Base 64 EncodeApply base64 encoding to a variable.
Base 64 DecodeDecode a base64-encoded string.
Bitwise ANDOperandPerform a bitwise-and operation on the variable and an operand. This transformation could generate an error if either of the inputs is not an integer.
Bitwise NOT*Perform a bitwise-not operation on the variable. This transformation could generate an error if the input is not an integer
Bitwise OROperandPerform a bitwise-or operation on the variable and an operand. This transformation could generate an error if either of the inputs is not an integer.
Bitwise-XOROperandPerform a bitwise-xor operation on the variable and an operand. This transformation could generate an error if either of the inputs is not an integer.
Decimal To HexConvert a decimal integer to a hexadecimal string. This transformation could generate an error if the input is not an integer.
DecryptAlgorithm: Picklist Encryption Key: String Initialization Vector: String Encryption Mode: Picklist Nonce: String Prepend Bytes: On/Off"Decrypt an encrypted string.

πŸ“˜

The first 8 bytes of the decrypted value are automatically deleted, as the corresponding <encrypt> operation adds a random 8 bytes to its result to make the result of the complete operation non-deterministic. Currently supported algorithms are "3DES", "AES128", and "AES256"

DivideOperandDivide the variable by the value of an operand. This transformation could generate an error if either of the inputs is not an integer or if the value of the operand is zero (0).
EncryptAlgorithm: Picklist Encryption Key: String Initialization Vector: String Encryption Mode: Picklist Nonce: String Prepend Bytes: On/Off"Encrypt the variable. The output is the nonce followed by the base-64 encoded encrypted input.

πŸ“˜

In order to make the encryption non-deterministic, an 8-byte random string is prepended to the input before encryption. Therefore, when the value is decrypted, this 8-byte string must be removed to arrive at the true input string.

Epoch to StringFormat StringTransform a value taken to be in epoch time, int strftime format, into RFC2616 format or other user specified format. See also, string-to-epoch for the reverse transformation.
Extract ParameterParameter Name: String Separator: Character Case Sensitive: On/OffE xtract a value from a list of parameters.

A use case for this is to extract query parameters without having to write a regular expression, but it can be used to look up values in any name/value pair list.

If several occurrences of the parameter exist, only the first one is returned. If the parameter is not found, the transformation fails and the variable gets a blank value. The separator between the name and the value of a parameter is always '=', but the parameter separator can be specified.

Example: Value (lookup table) = "foo=123&bar=456&baz=789". If parameter name "bar" and Separator is "&", then the resulting variable value will be "456".

HashMin: Integer Max: IntegerHash the input string into an integer. This returns the string representation of (HASH(input) % (max-min+1)) + min , where HASH is an arbitrary function that hashes a string into an unsigned 32-bit integer.
Hex to DecimalConvert a hexadecimal string to a decimal integer.
Hex DecodeDecode a hex-encoded string.
Hex EncodeEncode input as hex-encoded string.
HMACHMAC Key: String HMAC Algorithm: PicklistProduce a base64 encoded digest value from the variable value and key.
Lower CaseConvert the string to lower case.
MD5 HashObtain the MD5 of the value provided in one of the attribute tags ( or ) or of the value of the assign:variable.value tag if none of the attribute tags is used. (This is backward-compatible with the behavior before the attribute tags existed.) If at least one parameter is provided, the md5 is performed on the parameters in the order in which they are provided. The transformation obtains the MD5 as a hexadecimal string of size 32 in uppercase.
MinusTransform the value into a negative value.
ModuloOperandReturn the remainder of division of the value with an operand. This transformation can fail if either of the input values is not an integer or if operand is zero (0).
MultiplyOperandMultiply the value of an operand with the variable. The transformation could fail if either of the input values are not integers.
Normalize Path WindowsRemove multiple slashes, self-references, and directory back-references.
Remove WhitespacesRemove all whitespace characters.
SHA1Calculate an SHA1 hash from the value.

πŸ“˜

The computed hash is in a raw binary form and may need to be further encoded to be usable.

SHA256Calculate an SHA256 hash from the value.

πŸ“˜

The computed hash is in a raw binary form and may need to be further encoded to be usable.

String IndexSubstring: StringReturns the position of the first occurrence of a substring inside the input string, or -1 if it is not found. This comparison is case sensitive. This operation never fails, it simply returns -1 when the substring is not found.
String LengthReturns the string length of the input variable.
String to EpochFormat String: StringConvert a string value from strptime format, or a custom defined format, into epoch time. You can specify the format of the string-to-epoch transformation. If no value is specified, or the if is set to RFC2616, the format of the input string is interpreted as RFC2616 format. You can specify a custom format using strftime variables. See the strftime(3) man page for proper format variables: https://www.linux.com/learn/docs/man/4184-strftime3
SubstituteRegex: String Replacement: String Case Sensitive: On/Off Global Substitution: On/OffPerform a regular expression-based substitution (similar to Perl's =~ s/regex/replacement/flags). Specify the regex, replacement string and global+case-sensitive options.
SubstringStart Index: Integer End Index: IntegerExtracts a substring from the input variable/value. The start index is the position of the first character of the desired substring (0 for first character, 1 for second character, etc.). Negative values are relative to the right side of the input string. The end index is the position of the last character of the desired substring. -1 represents the last character of the string.
SubtractOperandSubtract the value of an operand from the variable. The operation could fail if either of the input values are not integers.
TrimRemoves leading and trailing white spaces from the input.
Upper CaseConvert the input to upper case characters.
URL DecodeURL decode the variable. All sequences of '%' followed by 2 hexadecimal characters are replaced with the corresponding ASCII value. The sequence '%%' is replaced with '%'. The sequence '%00' causes the transformation to fail, since the value of a variable is a null-terminated string and therefore cannot contain any null characters.

πŸ“˜

'+' is NOT replaced with a space. Substitution of a + sign for a space is a feature of application/x-www-form-urlencoded POST bodies. It is not a feature of url-encoding. You can swap the + for a space with a separate substitution transformation.

URL EncodeExcept Chars: String Force Chars: StringURL encode the variable. All characters deemed unsafe or reserved by RFC 1738 are escaped. That is, they are replaced with '%' followed by their 2-character hexadecimal value.

Unsafe characters are:

ASCII characters between 0x00 and 0x1F ASCII characters between 0x7F and 0xFF The following characters: < > " # % { } | \ ^ ~ [ ] ' ` and space Reserved characters are: ; / ? : @ = &

URL Decode UnicodeURL decode the variable value, including unicode encoding. All sequences of '%' followed by 2 hexadecimal characters are replaced with the corresponding ASCII value. The sequence '%%' is replaced with '%'. The sequence '%00' causes the transformation to fail, since the value of a variable is a null-terminated string and therefore cannot contain any null characters.

πŸ“˜

'+' is NOT replaced with a space. Substitution of a + sign for a space is a feature of application/x-www-form-urlencoded POST bodies. It is not a feature of url-encoding. You can swap the + for a space with a separate substitution transformation.

UTC SecondsConvert a string in ISO 8601 time format to UTC seconds.
XML DecodeXML-decode the variable value. This operates in the reverse of XML Encode. Invalid entities cause the operation to fail.
XML EncodeXML-encode the variable value. Characters <", ">" and "&" are replaced with their entities (respectively "<", ">" and "&"), and non-ASCII values are replaced with their escaped counterparts ("&#xNN;", where NN is the hexadecimal value)

Did this page help you?