For the complete documentation index, see llms.txt. This page is also available as Markdown.

RQL Operators

A list of operators supported by the resource query language (RQL) that enables you to modify the results.

An operator in RQL is one or more symbols or words that compare the value of a field on its left with one or more values on its right, such that only valid results are retrieved and displayed to you. You can use an RQL operator to find a specific term included as a value within an object or an array within a JSON structure.

You can use the following operators and conditions to compare or validate results:

Operators Within JSON Arrays

OPERATOR

DESCRIPTION

RQL EXAMPLE

?any

?any is an expression used to filter arrays.

It is used to specify conditions to return results when any single one of the array elements satisfy them.

?none

?none is an expression used to filter arrays.

It is used to specify conditions to return results when none one of the array elements are satisfied.

?all

?all is an expression used to filter arrays.

It is used to specify conditions to return results when all of the array elements satisfy them.

@ and ?

@ and ? are expressions used to filter arrays.

  • ? opens the array.

  • @ represents the current item being processed. It is used to hone in on a particular block in the json object so that you are only matching that block and no others.

&& and ||

Combine conditions within json.rule using && and ||.

Config and Event Operators

OPERATOR

DESCRIPTION

RQL EXAMPLE

greater than

Compares a path on the left-hand side against either a numeric value or another path on the right-hand side.

less than

Compares a path on the left-hand side against either a numeric value or another path on the right-hand side.

equals

Compares a path on the left-hand side against either a numeric value or another path on the right-hand side.

does not equal

Compares a path on the left-hand side against either a numeric value or another path on the right-hand side.

equal ignore case

Compares a path on the left-hand side against either a string or value or another path on the right-hand side.

The equal ignore case operator works exactly the same as equals, with the only difference that it disregards case sensitivity in the string match.

does not equal ignore case

Compares a path on the left-hand side against either a string or value or another path on the right-hand side.

starts with

The left-hand side must be a path with a string value.

does not start with

The left-hand side must be a path with a string value.

ends with

The left-hand side must be a path with a string value.

does not end with

The left-hand side must be a path with a string value.

contains

The left-hand side may be a single path or a set of paths with numeric or string value.

does not contain

The left-hand side may be a single path or a set of paths with numeric or string value.

is empty

The left-hand side must be a path leading to a string value.

is not empty

The left-hand side must be a path leading to a string value.

exists

The left-hand side must be a path.

does not exist

The left-hand side must be a path.

any start with

The left-hand side must be a set of paths leading to string values.

none start with

The left-hand side must be a set of paths leading to string values.

all start with

The left-hand side must be a set of paths leading to string values.

any end with

The left-hand side must be a set of paths leading to string values.

none end with

The left-hand side must be a set of paths leading to string values.

all end with

The left-hand side must be a set of paths leading to string values.

any equal

The left-hand side must be a set of paths leading to string or numeric values.

none equal

The left-hand side must be a set of paths leading to string or numeric values.

all equal

The left-hand side must be a set of paths leading to string or numeric values.

any empty

The left-hand side must be a set of paths leading to string values.

none empty

The left-hand side must be a set of paths leading to string values.

all empty

The left-hand side must be a set of paths leading to string values.

IN (

The left-hand side must be a string.

NOT IN (

The left-hand side must be a string.

size equals

The left-hand side must be an array.

The right-hand side must be an integer.

size does not equal

The left-hand side must be an array.

The right-hand side must be an integer.

size greater than

The left-hand side must be an array.

The right-hand side must be an integer.

size less than

The left-hand side must be an array.

The right-hand side must be an integer.

length equals

The left-hand side is a path with a string value.

The right-hand side must be an integer.

length does not equal

The left-hand side is a path with a string value.

The right-hand side must be an integer.

length greater than

The left-hand side is a path with a string value.

The right-hand side must be an integer.

length less than

The left-hand side is a path with a string value.

The right-hand side must be an integer.

number of words equals

The left-hand side is a path with a string value.

number of words does not equal

The left-hand side is a path with a string value.

number of words greater than

The left-hand side is a path with a string value.

number of words less than

The left-hand side is a path with a string value.

any true

The left-hand side is a set of paths with Boolean values.

none true

The left-hand side is a set of paths with Boolean values.

all true

The left-hand side is a set of paths with Boolean values.

any false

The left-hand side is a set of paths with Boolean values.

none false

The left-hand side is a set of paths with Boolean values.

all false

The left-hand side is a set of paths with Boolean values.

is true

The left-hand side is a path with Boolean value.

is false

The left-hand side is a path with Boolean value.

is not member of

The left-hand side is a path with string value, and the right-hand side is a set of values in parentheses and separated with commas.

is member of

The left-hand side is a path with string value, and the right-hand side is a set of values in parentheses and separated with commas.

matches

does not match

For Event queries, use the boolean operators matches and does not match to match or exclude field values against simple patterns and not full regex.

Patterns can have substrings and * for wild character search.

Use the matches or does not match operator instead of contains/does not contain or exists/does not exist operators.

In the following example, the value 'c*login' enables you to list activities that match clogin , cloudlogin , or consolelogin .

intersects

does not intersect

Checks if there are common elements between any two lists.

Both the left-hand and right-hand sides can be a path with a string or array, a string or IP address/CIDR block, a set of values in parentheses and separated with commas, or a function such as, _Port.inRange() .

The following example shows the _IPAddress.inRange function using the does not intersect operator:

like

Checks if the wildcard character (*) is used to grant access permissions at the account level on your cloud service provider. For example, you can check for wildcard permissions granted to delete all EC2 instances in every account.

The left-hand side is a path with string value, and the right-hand side is the name of a cloud account.

The like operator is currently only supported for iam queries; see IAM Query Attributes.

Joins

Joins allow you to get data from two different APIs where you have combined different conditions. You can use Joins only across config from cloud.resource where queries, and can include up to three configuration API resources with alias X, Y and Z, and you can optionally include a json.rule to match within the API resource alias. When you use the json.rule, joins across event, network, and config are not supported.

Nested Rules using the ?any quantifier limit the conditions you write on the elements of an array. For RQL policies that use nested rules, you can add a condition referencing an external JSON path inside the nested rule. This is useful when a Join operator is expressed among two different paths in a JSON specimen, which requires the nested rules to check on values outside the scope of the quantifier. In addition, when a Join is expressed among two different paths in a JSON specimen, which requires the nested rules to check on values outside the scope of the quantifier.

Use resource specific conditions inside json.rule of the alias and use the filter option only for comparison using operators ==, !=, contains, does not contains, not (negation).

Join basic syntax:

To find EC2 instances that have public IP addresses assigned at launch use this query:

Steps:

  1. List EC2 instances that have a public IP address as X:

  2. List instances that have security groups which allow unrestricted access from any source as Y:

  3. Set the filter:

  4. Complete the query to list all EC2 instances that have a public IP address and are accessible without any source IP restrictions:

Examples of Joins:

DESCRIPTION

RQL EXAMPLE

VPCs that are connected to internet gateways.

CloudTrail logs that are integrated with CloudWatch for all regions.

Show all AWS Lambda functions that are accessible with the RedlockReadOnly IAM role.

Find all EC2 instances that have a specified name, snapshot ID and image ID.

Find Azure SQL databases where audit log retention period is less that 90 days.

Find where bucket ACL owner ID and grantee ID do not match and display name does not contain awslogsdelivery

Cross-Account Joins

Prisma Cloud Investigate works differently from Policy when executing an RQL query specific to cloud accounts. You can facilitate cross-account comparisons from the Investigate page, but not from the Policy page. In case of cross-account JOINs, you must be careful when trying to correlate Alert counts with the Investigate page results.

If you do not specify the cloud.account parameter while running a query from Investigate, all cloud accounts will be open for JOIN. And since resources from one API in a query can potentially match with another, irrespective of the account, you can get inaccurate results. To achieve consistency with Policy (which generates alerts) and get precise results, Prisma Cloud recommends that you add the cloud.account parameter in your query. However, you do not need to apply the cloud account condition every time for JOIN RQLs. Usually, the results count on Investigate matches with that on Alerts.

For example:

  • If only the first part of an RQL has corresponding resources, and the second part does not, Investigate search displays results only from the first part. These are typically false positives. Prisma Cloud will not generate alerts for these instances.

  • When resources with the same name that are associated with a particular API exist across multiple cloud accounts, can also generate false positives.

Prisma Cloud recommends that you specify the cloud account for verification and help validate discrepancies.

Functions

A function performs a calculation on specific data that matches the clause contained in the function and displays results. Functions support auto-complete when you enter the prefix _ in a json.rule or addcolumn attribute.

Prisma Cloud supports following functions:

_DateTime Examples

Query time ranges are not part of RQL grammar, and the query time window is passed as a separate argument to the query APIs. The selection of the attributes or columns for a category are not part of the RQL grammar. The function accepts timestamps in the following formats only:

Zulu: "2011-08-13T20:17:46.384Z"

GSON/AWS: "Nov 7, 2016 9:34:21 AM"

ISO: "2011-12-04T10:15:30+01:00"

The query time ranges that are available are _DateTime.ageInDays , _DateTime.ageInMonths , _DateTime.ageInYears , and _DateTime.daysBetween . The _DateTime.daysBetween function looks for any information that falls in between two dates and takes two dates as arguments.

For example, the _DateTime.ageInDays returns the number of days until a date as a negative number.

  • For your query to work properly, ensure RQL json.rule functions are wrapped in single quotes (``). If single quotes are not added, the RQL will not be valid and cannot be executed.

  • When using the _DateTime function all json parameters are available as auto-complete options, you must select only parameters that have timestamps. The syntax for a function does not support spaces, so make sure to remove empty spaces before or after parenthesis, and also between comma-separated parameters.

DESCRIPTION

RQL EXAMPLE

List EC2 instances with age greater than 2 days.

List resource names where access keys are not rotated for 90 days.

Use the function today() to return the current day’s date.

_AWSCloudAccount.isRedLockMonitored Examples

When using this function to identify AWS accounts that are or are not monitored on Prisma Cloud, you can provide the AWS account ID in any of the following formats:

  • Standard AWS 12-digit account number.

    For example: 123456789012

  • Canonical user ID. You can use this ID to identify an AWS account when granting cross-account access to buckets and objects using Amazon S3.

    For example, an alpha-numeric identifier: 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be

  • 3. AWS account ID in ARN format.

    For example, arn:aws:iam::123456789012:role/test-1240-47

DESCRIPTION

RQL EXAMPLE

List any snapshots that are shared publicly and are not monitored by Prisma Cloud.

_IPAddress.inRange Examples

To check if a particular IP address is part of an IP address range, use _IPAddress.inRange and in the argument specify the octets, along with the <fromInteger> , <toInteger> . For example ("172.%d.",16,31) or (”172.10.%d.”,10,255).

DESCRIPTION

RQL EXAMPLE

List AWS Route53 Public Zones that have Private Records.

In this example, the IPAddress.inRange("172.%d.",16,31) allows you to search for IP addresses that are in the range "172.16.x.x" to "172.31.x.x":

_Port.inRange Examples

To check if a particular port number is part of a specific range, use class Port and method inRange . This method takes three arguments <fromInteger> , <toInteger> , and you can optionally include an <offset>.

By default, the <offset> is 1.

DESCRIPTION

RQL EXAMPLE

Use the inRange function with the contains and does not contain operators to check for conditions on a port range.

Specify <fromInteger> and <toInteger> to find all ports within the specified range.

Example using contains to check for ports numbers between 22 and 33 with an offset of 1:

The example above checks for all ports between 22 and 33.

Example using Does not Contain :

The example above checks for ports 350, 355, 360, …​..5390, 5395, 5600.

Example using no offset, to find all ports within the specified range:

_IPAddress.inCIDRRange Examples

To check if a specific IPv4 or IPv6 address or subnet is a part of a specific CIDR block or supernetwork, use the _IPAddress.inCIDRRange function. This function takes two arguments, the first is the CIDR address or array of CIDR addresses extracted from the JSON payload where you must specify whether it is an ipv4Ranges or an ipv6Ranges and the second is the CIDR block (either IPv4 or IPv6) cidrIp or cidripv6 followed by the IP address that you want to match on.The result returns the resources that contain the IP addresses in the JSON payload that fall within the CIDR range you entered, in the case when it is true, and the resources that do not match when it is false.

DESCRIPTION

RQL EXAMPLE

Define multiple CIDR blocks that you want to match on.

Find an IPv6 address within a CIDR block.

Specify multiple match conditions to find all CIDRs within the JSON metadata.

_IPAddress.areAllInCIDRRange() Examples

The _IPAddress.areAllInCIDRRange(Resource, CIDR) function checks to see if all of the IP addresses assigned to a resource are within a specified CIDR block. The result of executing the function will be a boolean. For example, if you had the question “Do my databases have all IP addresses in the 10.0.0.0./24 IP range,” the answer will be yes or no. The function accepts two arguments which are Resource and CIDR .

Resource describes meta data within the configuration file that contains the IP address(es), and CIDR represents the value of the CIDR block that you define.

Description

Example

Find all resources that contain CIDR addresses within the 10.0.0.0/8 range.

Find all IP addresses that fall within the a specified range.

Find all the IPv6 addresses within the CIDR block.

_IPAddress.areAnyOutsideCIDRRange() Examples

The _IPAddress.areAnyOutsideCIDRRange() function enables you to write config RQL queries that check if any IP/CIDR addresses are outside of a given list of permitted CIDR blocks. You can use this function to check if any resources have exposure to IP addresses outside of the RFC 1918 private CIDR blocks.

The first argument is a JSON expression that evaluates against one or more IP/CIDR addresses. The second and subsequent arguments list the IP/CIDR addresses and/or ranges to test against. You can use IPV4 and IPV6 address formats. However, the two function arguments should be either both in IPV4 or both in IPV6.

Description

Example

Check a valid IP against an invalid range to indicate the IP is outside of the range. If the address is not a valid IP or CIDR it is not considered to be a match.

_Set Examples

The _Set function enables you to compare the values between lists on the Left Hand Side and Right Hand Side using the properties of union or intersection, and identify whether a specific value or comma separated list of values are included within that result set. The methods supported are _Set.intersection, _Set.union, and Set_isSubset. For [_Set.intersection], _Set.union, you can use the boolean operators intersects and contains to verify whether the values you want to look for are included in the result or if the result set contains the specified value(s).

For Set_isSubset, enables you to identify whether a specific value or comma separated list of values returned by the JSON path of the resource is fully contained within the target list. The syntax is: `Set.isSubset(<path>, <targelist>) is [ true | false `] where <path> = JSON path

<target_list> = a set of strings without any whitespace within. For example, neither use of whitepace is valid: _Set.isSubset(<path>, (a, "b1 b2",c)) where there are spaces within the second string, nor _Set.isSubset(<path>, (a, b, c)) with space between the strings in a list.

If the result dataset is huge, use limit search records to at the end of the query.

Description

Example

Compare a list on the RHS [as X] with another dynamic list of items in LHS [as Y] and take the intersection ones into a subset list and then compare this against a static, comma separated list you provide.

Combine two lists to include all elements of X and Y and find a match against a comma separated list you provide.

Check if a result set contains a specific value.

Detects Internet exposed instances with public IP and firewall rule with 0.0.0.0/0 and destination is specified target tags:

Checks that the SQS policy statement does not include the list of IP addresses specified

Checks that for the specified groupName, the IP address ranges in the path ipPermissions[].ipRanges[] are fully contained in the target list of strings

Last updated

Was this helpful?