How to Search in CSAM
This topic describes the search syntax that you can use in CSAM. For the list of search tokens, refer to Search Tokens for IT Assets.
Search by Field
Enter the field name, a colon, and your query. Nested fields are separated by periods.
For example:
asset.netbiosName: WIN7PATCH69-85compute.lastLoggedOnUser: .\Administratorcompute.hostId: 43954857
String Matching
To match a string, enclose your query in single or double quotation marks.
For example:
operatingSystem: "Windows 7 SP2 Enterprise"compute.service:(description: "Certificate Propagation")
To use a wildcard, add an asterisk (*). For example, to find assets whose name starts with WINDOWS2008, use the following query:
asset.name: WINDOWS2008*
String matching works as expected for prefix searches. For substrings in the middle of a word, string matching may not return the correct result, because of an Elasticsearch limitation.
- Single-word search string: The string must be the prefix of a word in the search field. For example, to find "RedHat Linux", search for "Red" or "lin". Searching for "Hat" or "inu" does not return the result.
- Multiple-word search string: The results contain the parts of the search string in the same order. The last string is treated as a prefix. For example, to find "Windows SP1 Enterprise", search for "Windows SP" or "Windows Enter". Searching for "Enterprise SP" does not return the result.
Exact Matching
To match a string exactly, enclose it in backticks. The results include only the assets with the exact value.
For example:
operatingSystem: `Windows 7 Ultimate Service Pack 1`hardware.name: `Dell Latitude e7470`
Full Text Search
Many asset fields that contain text support full text search and advanced search capabilities. For more information, refer to Full Text Search on Certain Fields.
| To Find | Query |
|---|---|
| Findings with this OS name | operatingSystem: Windows |
| Findings that contain the components of the OS name | operatingSystem: "Windows 2008 r2 service pack 2" |
| Findings that match the exact value Windows 2002 | operatingSystem: `Windows 2002` |
Is Null Queries
To match an empty or null value in a field, remove the colon and enter is null. For example, you can find assets whose operating system is not identified.
For example:
operatingSystem is nullasset.interface:(macAddress is null)asset.biosDescription is null
Range Searches
To specify a range, use the [lower .. upper] syntax with parentheses, square brackets, or both. Range searches are supported for numeric and date fields.
For example, the following query finds assets created between August 1, 2018, and September 1, 2018:
inventory.created: [2018-08-01 .. 2018-09-01]
The following table describes the range options:
| Query | Range |
|---|---|
inventory.created:(date1 .. date2) | Greater than date1 and less than date2 |
inventory.created:(date1 .. date2] | Greater than date1 and less than or equal to date2 |
inventory.created:[date1 .. date2) | Greater than or equal to date1 and less than date2 |
inventory.created:[date1 .. date2] | Greater than or equal to date1 and less than or equal to date2 |
inventory.created > date1 | Greater than date1 |
inventory.created >= date1 | Greater than or equal to date1 |
inventory.created < date1 | Less than date1 |
inventory.created <= date1 | Less than or equal to date1 |
Time Units
In range searches, you can use the following time units in time-based queries:
s: secondsm: minutesh: hoursd: daysw: weeksM: monthsy: years
The time units are case-sensitive. For example, S is not supported for seconds.
The following examples show correct and incorrect syntax:
| Example | Correct Syntax | Incorrect Syntax |
|---|---|---|
| A token from another application, such as Vulnerability Management, Detection and Response (VMDR), that is also supported in CSAM | vulnerabilities.lastFound:[now-2M ... now-1s] |
vulnerabilities.lastFound:[now-2M ... now-1S] |
| A CSAM token that may also be supported in other applications | asset.lastUpdated:[now-2w ... now-1s] |
asset.lastUpdated:[now-2w ... now-1S] |
Date Searches
Use a date range, [start date .. end date], or a specific date. Several date variables are also available. For more information, refer to Date Formats in Queries.
For example:
openPorts.lastFound: "2018-10-20"openPorts.lastFound <= "2018-11-20"openPorts.lastFound: ["2018-10-20" .. "2018-10-24"]openPorts.lastFound: [now-3d .. now-1s]
Match Multiple Values
To match field values that are in, or not in, a list, enclose the values in square brackets. This is available for all fields except analyzed fields, meaning full text search fields.
| To Find | Query |
|---|---|
| Assets with at least one of these three scanner appliance locations | inventory.scannerLocation: [SanJose1, SanJose2, SanJose3] |
| Assets not last booted on 2018-08-31 or 2018-09-12 | NOT asset.lastBoot: ["2018-08-31","2018-09-12"] |
The following date formats are supported:
| Format | Example | Matches |
|---|---|---|
| YYYY | asset.lastBoot:["2017","2018"] | In 2017 or 2018 |
| YYYY-MM | asset.lastBoot:["2018-08","2018-09"] | In August or September 2018 |
| YYYY-MM-DD | asset.lastBoot:["2018-10-30","2018-11-05"] | On one of the exact dates |
Partial values are not supported in square brackets. You must enter the exact values. For example, asset.interface:(hostname: [win7-181, bridge.vuln.qa.qualys.com]) is correct, and asset.interface:(hostname: [win7, bridge.vuln.qa]) is incorrect.
Suffix Matching
Some search tokens support suffix matching, which returns results faster, for example, when you search for assets by asset name, tag name, or NetBIOS name. Enter the wildcard character (*), followed by the string. The search returns the values that end with the string. Suffix matches are not case-sensitive.
When you use a wildcard search on fields that contain a very large number of different values, the number of results may vary slightly between searches. The search system is distributed across multiple servers, and wildcard searches expand into many possible matches. This does not mean that data is missing or corrupted. To get exact and consistent result counts, use exact-match searches instead of wildcard searches.
| Query | Returns |
|---|---|
asset.name: *110 |
Asset names that end with 110, such as bw2012-35-110, vsweblogic12110, or stvsp2-32-110. |
asset.tag.name:*Region East |
Assets with tag names that end with Region East, region east, or Region EAST. |
The asset.interface:(hostname token supports suffix and domain matching with a different syntax. For example:
asset.interface:(hostname:qualys.com)asset.interface:(hostname:sjc01.qualys.com)asset.interface:(hostname:eng.sjc01.qualys.com)asset.interface:(hostname:*lys.com)
Prefix Matching
Some search tokens support prefix matching, which returns results faster, for example, when you search for assets by asset name, tag name, or NetBIOS name. Enter the string, followed by the wildcard character (*). The search returns the values that begin with the string. Prefix matches are case-sensitive.
When you use a wildcard search on fields that contain a very large number of different values, the number of results may vary slightly between searches. To get exact and consistent result counts, use exact-match searches instead of wildcard searches.
| Query | Returns |
|---|---|
asset.name:xp* | Assets whose name starts with xp, such as xpsp2-jp-26-111. |
asset.tag.name:Win* | Assets with tag names that start with Win, such as Windows XP, Windows 2012, or Windows Hosts. |
asset.interface:(hostname:com-pa30*) | Assets whose hostname starts with com-pa30, such as com-pa3020-36.eng.sjc01.qualys.com. |
operatingSystem:Lin* | Assets whose operating system starts with Lin, such as Linux 2.4-2.6. |
Boolean Operators
Use the AND, OR, and NOT keywords to narrow or broaden your search. For information about the maximum query depth and using NOT in queries, refer to Boolean Queries.
| To Find | Query |
|---|---|
| Findings with one of these operating systems | operatingSystem: `Windows 2002` OR operatingSystem: `Windows 7 Ultimate Service Pack 1` |
| Assets not created on or before a date | AND NOT inventory.created <= "2018-11-05" |
Nested Queries
To include multiple fields in one query, use a single nested query with parentheses. Nested queries are supported only for certain tokens, such as asset, hardware, and interfaces. For more information, refer to Nested Queries.
For example, the following query finds assets that were last booted on a certain date and have 2 CPUs:
asset: (lastBoot: '2018-10-10' AND cpuCount: 2)
Nested Queries with NOT on the Software Tab
When you run a nested query with the NOT operator and multiple values in square brackets on the Inventory > Software tab, the position of NOT is important.
software:(not authorization:[`Unauthorized`,`Authorized`,`Needs Review`])returns the software that does not match the authorization criteria.not software:(authorization:[`Unauthorized`,`Authorized`,`Needs Review`])filters out the assets that do not match the authorization. This query is correct, but it behaves differently on the software inventory page.