Examples - check_type
EXAMPLE 1
Input:
CODE
{{ 42 | check_type }}
Return Data:
EXAMPLE 2
Input:
CODE
{% set cert_text = "-----BEGIN CERTIFICATE-----MIIBsjCCARugAwIBAgIU...-----END CERTIFICATE-----" %}
{% set cert_bytes = cert_text.encode("utf-8") %}
{{ cert_bytes | check_type }}
Return Data:
EXAMPLE 3
Input:
CODE
{% set html_output = "<b>Alert Confirmed</b>" | safe %}
{{ html_output | check_type }}
Return Data:
EXAMPLE 4
Input:
CODE
{% for i in [1, 2, 3] %}
{{ loop | check_type }}
{% endfor %}
Return Data:
TEXT
LoopContext
LoopContext
LoopContext
default(default_value)
Returns a fallback value when the provided variable is undefined or empty. If the variable is defined, the original value is returned unchanged.
Examples - default
EXAMPLE 1
Input:
CODE
{% set num = 42 %}
{{ num | default("Variable is not defined.") }}
Return Data:
Input:
CODE
{{ num | default("Variable is not defined.") }}
Return Data:
TEXT
Variable is not defined.
EXAMPLE 2
Input:
CODE
{% set alert = {"type": "Phishing Email", "severity": "high"} %}
{{ alert.severity | default("medium") }}
Return Data:
Input:
CODE
{% set alert = {"type": "Phishing Email", "severity": "high"} %}
{{ alert.non_existent_attribute | default("medium") }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ arr | default("Array is not defined.") }}
Return Data:
TEXT
Array is not defined.
divide_by(divisor)
Returns the numeric result of dividing the piped input by the divisor.
Examples - divide_by
EXAMPLE 1
Input:
CODE
{{ -1 | divide_by(2) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ [-3,-2,-1][2] | divide_by(-4) }}
Return Data:
EXAMPLE 3
Input:
CODE
{% set obj = {'x':1,'y':2} %}
{{ obj.x | divide_by(3) }}
Return Data:
equals(value)
Returns a Boolean that indicates whether the piped input and the comparison value are equivalent in content. Supports comparison of numbers, strings, objects, and arrays.
Examples - equals
EXAMPLE 1
Input:
CODE
{{ 3 | equals(3) }}
{{ 3 | equals('3') }}
{{ '3' | equals(3) }}
Return Data:
EXAMPLE 2
Input:
CODE
{% set alert1 = {
"alert_id": "INC-48392",
"threat_type": "phishing",
"severity": "high",
"source": "splunk"
} %}
{% set alert2 = {
"alert_id": "INC-48392",
"threat_type": "phishing",
"severity": "high",
"source": "splunk"
} %}
{{ alert1 | equals(alert2) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ "D3Security" | equals("d3security") }}
Return Data:
EXAMPLE 4
Input:
CODE
{% set baseline_hashes = [
"b7f9a3d2e4c6f8b92a47d5c1aa12bb34ef9c8902e2345ab19f37da7c1234eac1",
"9a81b02f4cc5b7a0fbc21c5a923e2d3aa87f02b5cc99e3311a9f7df25f91d2c4",
"a7d2c09fbd11e3b9b4a56f9320e57dfb88e5fa17d0b14a7bcd90a0f7adcefa91"
] %}
{% set recent_hashes = [
"b7f9a3d2e4c6f8b92a47d5c1aa12bb34ef9c8902e2345ab19f37da7c1234eac1",
"9a81b02f4cc5b7a0fbc21c5a923e2d3aa87f02b5cc99e3311a9f7df25f91d2c4",
"a7d2c09fbd11e3b9b4a56f9320e57dfb88e5fa17d0b14a7bcd90a0f7adcefa91"
] %}
{{ baseline_hashes | equals(recent_hashes) }}
Return Data:
Returns a human-readable file-size string, scaling the piped byte count to an appropriate unit. By default, the filter uses decimal units. When the parameter is set to True, the filter applies binary units.
Examples - filesizeformat
EXAMPLE 1
Input:
CODE
{{ 1 | filesizeformat }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 1000 | filesizeformat }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 1e6 | int | filesizeformat }}
Return Data:
EXAMPLE 4
Input:
CODE
{{ (10**9) | filesizeformat }}
Return Data:
EXAMPLE 5
Input:
CODE
{{ (2**0) | filesizeformat(True) }}
{{ (2**10) | filesizeformat(True) }}
{{ (2**20) | filesizeformat(True) }}
{{ (2**30) | filesizeformat(True) }}
Return Data:
TEXT
1 Byte
1.0 KiB
1.0 MiB
1.0 GiB
floor(decimal_places)
Returns the piped numeric value rounded downward to the specified number of decimal places.
Examples - floor
EXAMPLE 1
Input:
CODE
{{ 1.234 | floor(2) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 2.01 | floor(1) }}
{{ 2.10 | floor(1) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 2.19999 | floor(2) }}
{{ 2.20001 | floor(2) }}
Return Data:
EXAMPLE 4
Input:
CODE
{{ -1.001 | floor(0) }}
{{ -1.001 | floor(1) }}
Return Data:
EXAMPLE 5
Input:
Return Data:
greater_or_equal(comparison_value)
Returns a Boolean indicating whether the piped numeric value is greater than or equal to the comparison value.
Examples - greater_or_equal
EXAMPLE 1
Input:
CODE
{{ 1 | greater_or_equal(3) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ [2,3,4][1] | greater_or_equal(3) }}
Return Data:
EXAMPLE 3
Input:
CODE
{% set obj = {'x':100, 'y':101} %}
{{ obj.x | greater_or_equal(obj.y) }}
Return Data:
greater_than(comparison_value)
Returns a Boolean indicating whether the piped numeric value is greater than the comparison value.
Examples - greater_or_equal
EXAMPLE 1
Input:
CODE
{{ 0 | greater_than(-1) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ [1.1,1.2,1.3][1] | greater_than(1.21) }}
Return Data:
EXAMPLE 3
Input:
CODE
{% set obj = {'x':100, 'y':101} %}
{{ obj.y | greater_than(obj.x) }}
Return Data:
less_or_equal(comparison_value)
Returns a Boolean indicating whether the piped input is less than or equal to the comparison value.
Examples - less_or_equal
EXAMPLE 1
Input:
CODE
{{ 0 | less_or_equal(0) }}
{{ 1 | less_or_equal(0) }}
{{ 0 | less_or_equal(1) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ -1 | less_or_equal(0) }}
{{ -5 | less_or_equal(-5) }}
{{ -3 | less_or_equal(-5) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 1.1 | less_or_equal(2.2) }}
{{ 1 | less_or_equal(1.0) }}
{{ 0.000001 | less_or_equal(0.0) }}
Return Data:
less_than(comparison_value)
Returns a Boolean indicating whether the piped input is numerically less than the comparison value.
Examples - less_than
EXAMPLE 1
Input:
CODE
{{ 0 | less_than(0) }}
{{ 1 | less_than(0) }}
{{ 0 | less_than(1) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ -1 | less_than(0) }}
{{ -5 | less_than(-5) }}
{{ -3 | less_than(-5) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 1.1 | less_than(2.2) }}
{{ 1 | less_than(1.0) }}
{{ 0.000001 | less_than(0.0) }}
Return Data:
minus(subtraction_value)
Returns the difference between subtracting the subtraction value from the piped input.
Examples - minus
EXAMPLE 1
Input:
CODE
{{ 3 | minus(2) }}
{{ 0 | minus(0) }}
{{ 1 | minus(0) }}
{{ 0 | minus(1) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ -1 | minus(1) }}
{{ -5 | minus(-3) }}
{{ -3 | minus(-5) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 1.5 | minus(0.5) }}
{{ 0.5 | minus(1.5) }}
{{ 1.5 | minus(1.5) }}
Return Data:
modulo(divisor_value)
Returns the numeric remainder of dividing the piped input by the divisor value.
Examples - modulo
EXAMPLE 1
Input:
CODE
{{ 14 | modulo(7) }}
{{ 14 | modulo(4) }}
{{ 14 | modulo(5) }}
Return Data:
Explanation: The modulo result is obtained after performing the following four steps:
Divide the dividend (piped input) by the divisor (modulo parameter).
Apply floor to the quotient.
Multiply the divisor by the floored quotient.
Subtract that product from the dividend.
EXAMPLE 2
Input:
CODE
{{ -3 | modulo(2) }}
{{ 3 | modulo(-2) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 2.5 | modulo(2) }}
Return Data:
not_equal(comparison_value)
Returns a Boolean indicating whether the piped input differs from the comparison value.
Examples - not_equal
EXAMPLE 1
Input:
CODE
{{ 1 | not_equal(-2) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 1.0 | not_equal(1) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ "3" | not_equal(3) }}
Return Data:
plus(added_value)
Returns the sum for numeric inputs or a combined sequence for strings, arrays, or objects. For objects with shared keys, values from the added value override those in the piped input.
Examples - plus
EXAMPLE 1
Input:
CODE
{{ 1 | plus(2) }}
{{ 1.5 | plus(-2.5) }}
{{ -3 | plus(2) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ [1,2,3] | plus([1,2]) }}
Return Data:
EXAMPLE 3
Input:
CODE
{% set numbers = {"a": 2, "b": 3} %}
{{ numbers.a | plus(numbers.b) }}
Return Data:
EXAMPLE 4
Input:
CODE
{{ {"x":1,"y":2} | plus({"y":5,"z":9}) }}
Return Data:
JSON
{
"x": 1,
"y": 5,
"z": 9
}
EXAMPLE 5
Input:
CODE
{{ 'D3' | plus( ' Security' ) }}
Return Data:
round(decimal_places)
Returns the numeric result of rounding the piped input to the specified number of decimal places. Decimal places are omitted when the rounded value is an integer. Non-integer decimal-place values are treated as 0.
Examples - round
EXAMPLE 1
Input:
CODE
{{ 1.357 | round(0) }}
{{ 1.357 | round(1) }}
{{ 1.357 | round(2) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ -1.44 | round(0) }}
{{ -1.44 | round(1) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ 1 | round(2) }}
{{ 1.0 | round(2) }}
{{ 1.00 | round(2) }}
Return Data:
times(multiplier_value)
Returns a result where numeric inputs and numeric strings are multiplied, strings are repeated, and arrays are concatenated.
Examples - times
EXAMPLE 1
Input:
CODE
{{ 3 | times(2) }}
{{ -2 | times(3) }}
{{ 1.5 | times(4) }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D' | times(3) }}
{{ '1' | times(3) }}
{{ '-1' | times(3) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ {"k": {"x": {"y": "n", "z": 1 | times(3)}}} }}
{{ {"k": {"x": {"y": "n", "z": "2" | times(3)}}} }}
{{ {"k": {"x": {"y": "n", "z": "D" | times(3)}}} }}
Return Data:
JSON
{'k': {'x': {'y': 'n', 'z': 3}}}
{'k': {'x': {'y': 'n', 'z': 6}}}
{'k': {'x': {'y': 'n', 'z': 'DDD'}}}
EXAMPLE 4
Input:
CODE
{{ [1] | times(2) }}
{{ ['a'] | times(2) }}
{{ [1,2] | times(2) }}
Return Data:
JSON
[1, 1]
['a', 'a']
[1, 2, 1, 2]
to_float(default)
Returns a floating-point number converted from the piped input. If conversion is not possible, meaning the value is not a plain decimal number or a string that represents one, the filter returns the specified default value. By default, this value is 0.0.
Examples - to_float
EXAMPLE 1
Input:
Return Data:
EXAMPLE 2
Input:
CODE
{% obj = {'x':' 7 '}%}
{{ obj.x | to_float }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ "" | to_float }}
{{ "" | to_float(-1) }}
Return Data:
to_int(default, base).
Returns an integer converted from the piped input, with the default value returned when the conversion fails. The base 10 method of interpreting the input is replaced when:
Examples - to_int
EXAMPLE 1
Input:
CODE
{{ -13.3 | to_int }}
Return Data:
EXAMPLE 2
Input:
CODE
{{ 'D' | to_int(3) }}
Return Data:
EXAMPLE 3
Input:
CODE
{{ '0b1000000' | to_int(0, 2) }}
{{ '0o107' | to_int(0, 8) }}
{{ '0x4F' | to_int(0, 16) }}
Return Data:
Explanation: The prefixes 0b, 0o, or 0x are supported (optional) syntactic forms used to emphasize that the input values are in binary, octal, or hexadecimal notation, respectively, without altering how the supplied base value controls the conversion.
EXAMPLE 4
Input:
CODE
{{ '1' | to_int(999, 2) }}
{{ '1' | to_int(999, 3) }}
{{ 'A' | to_int(999, 35) }}
{{ 'A' | to_int(999, 36) }}
{{ 'A' | to_int(999, 37) }}
Return Data: