Logical Operations
User-entered logical operations are a key component of Salem's learning architecture and are referred to in the Salem nomenclature as "eval strings." These operations are created by users to inform Salem actions related to context-building workloads, alert categorization, and other logic-based evaluations.
Definition: Eval strings are logical operations used by Salem to add and apply context to alerts based on their details. Salem can be taught to evaluate complex Boolean expressions using the and
and or
operators and the match() function. These expressions can be used to filter alerts, extract relevant information, and generate new context.
Eval Operators
==
- Equal to!=
- Not equal to>
- Greater than<
- Less thanand
or
not
in
Eval Functions
Accepts a logical string, and returns True or False. This function can be used to assess truthiness.
Accepts an object and returns its length
Returns a num rounded to pos digits
Accepts any number of inputs and returns the first non null value
If the bool statement evaluates to true, the value of the true case is returned, otherwise the value of the false case is returned
The first bool value that returns true will return the next value. If no bools return true, then the default value is returned.
Returns a string comprised of the list values concatenated by the value of str
Accepts a list of strings, and returns a list with duplicate values removed
Returns True or False based on the evaluation of the match expression.
Match types:
in
<list>: Returns true if the test is contained in the object.is
<str>: Returns true if the test is equal to the object.beginsWith
<str> : Returns true if the object starts with the test.endsWith
<str>: Returns true if the object ends with the test.contains
<str>: Returns true if the object contains the test.regex
<str>: Returns true if the object matches the test regular expression.CIDR
<str>: Returns true if the object’s IP address is within the CIDR range specified by the test.
Returns a date object that is the current UTC time offset by the value of seconds
returns a match value based on the regex exp evaluated over str
Accepts a string and returns a list of str components split by the value of exp
Accepts a datetime object and a time format string. Returns a str representing time in the format provided
Accepts a time str and format, and returns a datetime object
Accepts a JSON formatted string and returns an object
Accepts and object and returns a JSON formatted string
Accepts an object and returns a str formatted version of that object
Accepts a string and returns a number formatted version of that string
Accepts a url quoted string and returns a unquoted version
Accepts a string and returns a url quoted version of that string
Accepts a series of iterators and returns a zip object, which is an iterator of tuples where the nth position value of each input iterator is paired together.
A dictionary that allows you to access the set of variables accessable by an eval. Most commonly, bag_of_fields would contain the fields from an alert.
Salem eval supports loop and iterator operations. This can be useful when you want to extract, manipulate or test data from a list or dictionary.
List Comprehension
List Comprehension creates a new list by looping through an iterator. This can be useful if you want to construct a new list based on the values of another list or dictionary. This implementation is similar to the implementation in Python (doc).
Dictionary Comprehension
Dictionary Comprehension creates a new dictionary by looping through an iterator. This implementation is similar to the implementation in Python (doc).
The any() function can be used to return True if any of the values in the iterator treturn True for the given test
All
The all() function can be used to return True if all of the values in the iterator treturn True for the given test
alert filters
Last updated