Skip to main content

Overview

Built-ins are the core language features that let you filter, transform, and make assertions across collections of data. They are the difference between just retrieving raw data and turning that data into meaningful answers.

Think of built-ins as the verbs of MQL:

  • .where() narrows down what you’re looking at.
  • .map() transforms the results.
  • .all(), .any(), .none(), .one() let you assert truth over collections.
  • .list, .length, and .containsOnly help you structure and compare results.

In the following sections we’ll explore each built-in in detail, with examples you can run in the shell. You’ll see both policy-style checks and inventory-style queries so you can use them in compliance scenarios as well as live investigation.

MQL Built-in Functions

This page gives an overview of all built-in functions available in MQL, grouped by type. Each function links to a dedicated documentation page with examples.


Array Functions

FunctionSummary
firstReturn the first element of an array
lastReturn the last element of an array
lengthNumber of elements in the array
whereFilter by predicate
mapTransform each element
flatFlatten nested arrays
sampleReturn a random sample of elements
duplicatesReturn duplicate values (optionally by key)
uniqueReturn unique values (optionally by key)
containsCheck if array contains a value or matches predicate
containsAllCheck that array contains all specified values
containsNoneCheck that array contains none of the specified values
containsOnlyCheck that array contains only specified values
allAssert all elements satisfy predicate
anyAssert at least one element satisfies predicate
oneAssert exactly one element satisfies predicate
noneAssert no elements satisfy predicate

Map Functions

FunctionSummary
lengthNumber of entries in the map
keysReturn the keys of the map
valuesReturn the values of the map
whereFilter map entries by predicate
sampleReturn a random sample of entries
containsCheck if any entry matches a value or predicate
allAssert all entries satisfy predicate
anyAssert at least one entry satisfies predicate
oneAssert exactly one entry satisfies predicate
noneAssert no entry satisfies predicate

String Functions

FunctionSummary
lengthNumber of characters in the string
containsCheck if string contains a substring or matches regex
findFind all regex matches in the string
inCheck if string is in a list
notInCheck if string is not in a list
inRangeCheck if string represents a number within a range
camelcaseConvert string to camelCase
downcaseConvert string to lowercase
upcaseConvert string to uppercase
linesSplit string into lines
splitSplit string by a delimiter
trimTrim whitespace or specified characters

Number Functions

FunctionSummary
inRangeCheck if a number is within a range

FunctionSummary
secondsExtract seconds or convert to seconds
minutesExtract minutes or convert to minutes
hoursExtract hours or convert to hours
daysExtract days or convert to days
unixConvert to Unix epoch seconds
inRangeCheck if time is within a range

IP / Network Functions

FunctionSummary
addressReturn network address of CIDR
cidrReturn the CIDR block
prefixReturn the network prefix
prefixLengthReturn prefix length
subnetReturn subnet from CIDR
suffixReturn suffix (host bits)
versionReturn IP version (4 or 6)
isUnspecifiedCheck if IP is unspecified (0.0.0.0 or ::)
inRangeCheck if IP/network is within another