Components of a QQL query

A QQL query is comprised of the following elements:

Search token

Operator

Token value

Search token

We provide you thousands of search tokens to select from. All you need to do is click the Search bar wherein you will create your query, start typing, and the auto-suggest feature will list down all the possible tokens that you can use. Help on token and syntax usage is available in the right pane.

Operator

An operator is a mandatory character or a word reserved in a database query. In QQL, operators are used to perform operations for the search conditions that you set in a query. In QQL, we mainly use logical or Boolean operators such as AND, OR and NOT, and the operators used in comparisons such as a colon (:), greater than sign (>), less than sign (<), and their several combinations. Let’s know more:

Operator

Result

AND

Returns query results that include all the free-text values and values with the restricted searches that you combine with the AND operator in your query.

For example, to find the assets with both the Shellshock vulnerability and the Heartbleed vulnerability, form the following query:

vulnerabilities.vulnerability.title: shellshock AND vulnerabilities.vulnerability.title: heartbleed

NOT

Returns query results that don't include the free-text values or values with restricted search that you combine with the NOT operator in your query. So, when you use the NOT operator, you are telling the database to exclude the value that follows the NOT operator from search.

For example, to exclude assets from Passive Sensor, you form the following query:

not inventory.source: `Passive Sensor`

Note: We recommend that you reduce, or eliminate, the use of the NOT operator in a query. So, to exclude vulnerabilities of the type “Information Gathered” from search, form the following query instead:

vulnerabilities.typedetected:[CONFIRMED, POTENTIAL]

OR

Returns query results that include one or more of the free-text values or values with search restrictors that you conditionalize with the OR operator in your query.

For example, to find vulnerabilities from Rockwell automation or Omron, form the following query:

vulnerabilities.hardware.vendor: "Rockwell Automation" or vulnerabilities.hardware.vendor:"Omron"

Note: It’s a good practice to use double-quote characters around your character string values, especially those that contain blank space.

:

A colon (:) separates a query search token from token value. After the colon, you can use various search restrictors with the token value and conditionalize your search query to get the most relevant results.

=

Returns results where the property value stored in the database is equal to the search token value that you specify in your query. You must use the = operator with the < or the > operator. For example, if you build a query vulnerabilities.severity>4, you get all the results that have the vulnerability severity 5. But if you build a query vulnerabilities.severity>=4, the results are of both severity 4 and 5. We don't recommend using the = independently. Use the : operator instead.

<

Returns all the results where the property value stored in the database is less than the search token value that you specify in your query. You must replace the : operator after the token with <.

For example, to find out vulnerabilities that are older than last 30 days, form a query as vulnerabilities.lastFound<now-30d.

>

Returns all the results where the property value stored in the database is greater than the search token value that you specify in your query. You must replace the : operator after the token with >.

For example, to find out vulnerabilities that were detected in the last 30 days, form a query as vulnerabilities.lastFound>now-30d.

<=

Returns all the results that have the stored values less than or equal to the search token value that you specify in your query. You must replace the : operator after the token with <=.

For example, to find out vulnerabilities that were first detected on or before May 21, 2020, for a query as vulnerabilities.firstFound<=2020-05-21

>=

 

Returns all the results that have the stored values greater than or equal to the search token value that you specify in your query. You must replace the : operator after the token with >=.

For example, to find out vulnerabilities that were first detected on or after May 21, 2020, for a query as vulnerabilities.firstFound>=2020-05-21 .

 

Token Value

For the database query to return results, you must specify some value of the search token. You enter the token value after an operator. For some tokens, for example vulnerabilities.severity, which accept values from a fixed and finite set, you can select values from the available options.

Maximum character limit (including alphanumeric, special characters and spaces)

The length limit of a QQL query is 4096 characters. Maximum limit of a query field value is 256 characters. If your query exceeds the character limit, you see an error message. Spaces in between characters are counted as characters.

We've implemented controls in query parsing for queries containing the operators “AND” and “OR”. The maximum depth allowed for an AND/OR query cannot exceed 1000 levels. If you run a query having more than 1000 levels of depth, you see an error.

A simple query like this has level of depth 2

hardware.manufacturer:`Rockwell Automation` and inventory.source:`Passive Sensor`

A more complex query like this has level of depth 3

vulnerabilities.hardware.vendor:`Siemens` and vulnerabilities.vulnerability.threatIntel:`Active Attacks` and not vulnerabilities.vulnerability.criticality:[`HIGH`, `MEDIUM`]

Use the following characters as a part of your token value to narrow down your search:

Character

Result

..

Returns the results where the token value falls within the range that you specify. Ranges can be specified with the [lower .. upper] syntax using parentheses and brackets.

This is supported for numeric and date fields.

See Range Searches

*

When you use the wildcard operator (*) with a part of a word in your query value, you get the results based on the exact matches.

If you type a part of a word followed by the wildcard operator, you enable the prefix matching.

For example,

vulnerabilities.hardware.vendor: Rock*  will return the vulnerabilities from Rockwell

vulnerabilities.hardware.type: Communication*  will return the vulnerabilities from communication module

If you use the wildcard operator followed a part of a word, you enable the suffix matching.

For example,

hardware.category1:*Instruments

`<value>`

Returns all the results that contain the exact value string that you enclose in the grave accent marks (also called backticks) in your query.

You can also look for case-sensitive matches by using backticks.

For example,

To find out the asset with the name “ACMENVT7,” form the following query:

asset.name: `ACMENVT7`

“<value string>”

Returns all the results that contain the value string that you enclose in the double quotation marks in your query.

For example,

To list the vulnerabilities that contain “Remote” or “Code” or both in their title, form the following query:

vulnerabilities.vulnerability.title: “Remote Code”

[…]

Square brackets are typically used in range searches such as date ranges or IP address ranges. If you use brackets, the result includes all the values that fall between the lower limit value and the upper limit value in the range including both these values.

For example, to find out the open ports in your asset inventory, you create the following query:

openPorts.port: [123 .. 1234]

In this case, the result returns all the values that are greater than or equal to 123 and less than or equal to 1234.

(..)

Round brackets (parentheses) are also used in range searches.  the result includes all the values that fall between the lower limit value and the upper limit value in the range excluding both these values.

For example, to find out the open ports in your asset inventory, you create the following query:

openPorts.port:(123 .. 1234)

In this case, the result returns all the values that are greater than but not equal to 123 and less than but not equal to 1234.

See Use brackets [..] and parentheses (..) smartly

 

Additionally, you can also refer to the several Help topics in which we discuss various ways of using tokens.

See How to Search

See Boolean Queries

See Nested Search


 

 

Was this topic helpful?

success Thank you! We're glad to hear that this topic was useful.
success We appreciate your feedback. We'll work to make this topic better for you in the future.