JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc


File Search Language

The CodeSonar file search language allows you to specify search conditions based on various file properties, and provides basic logical operators for combining multiple conditions. It can be used both to specify and to refine searches.



File-Specific Grammar

The file search language grammar is based on the standard CodeSonar search grammar, with several extensions:

Literal strings are displayed in pink text.

T : quoted-string
  | metric-condition
  | ilike-condition
  | imatch-condition
  | field-condition
  | ( T )
  | unary T
  | T binary T
  | T T
  | word
  | none
  
metric-condition : metric-tag ext-operator num
                 | metric-tag operator num-range

string-field : any field-name whose condition type is "word | quoted string" 

metric-tag : the tag of any file-granularity metric class (built-in or user-defined) on the hub 

ext-operator : <
             | <=
             | >=
             | >
                         
field-name : adesc 
           | aid
           | analysis          
           | directory
           | file
           | language
           | path
           | pdesc
           | pid
           | project
           | ptree_path 
           | sfhash
           | sql

field-condition terms

The following table shows the relationship between the file-specific field-name values and the properties of a source file, along with the expected type of the condition part of a field-condition.

field-name Contents Condition Type
adesc Instance Analysis . Analysis Description word | quoted-string, or special value none.
aid Instance Analysis . Analysis ID int-range, or special value last.
analysis Instance Analysis . Analysis word | quoted-string, or special value none.
directory Directory word | quoted-string, or special value none (*).
file File word | quoted-string, or special value none (*).
language Language word | quoted-string, or special value none.
path File Path word | quoted-string, or special value none (*).
pdesc Instance Analysis . Analysis Project . Project Description word | quoted-string, , or special value none.
pid Instance Analysis . Analysis Project . Project ID int-range
project Instance Analysis . Analysis Project . Name word | quoted-string, or special value none.
ptree_path Instance Analysis . Analysis Project . Project Path word | quoted-string, or special value none.
sql Introduces an SQL expression (see SQL Terms, below). word | quoted-string, or special value none.
sfhash reserved for use by generated searches

directory, file, and path searches

If field-name is directory, file, or path, comparison:

Plain text terms: word, quoted-string, and none

Plain text search terms—word, quoted-string, and none—are compared against File, with substring search (and see note above):

Examples

The following table shows simple example queries using field-names and metric-conditions from the file search language

example explanation
TL:100..200 Find files with Total Lines (TL) between 100 and 200 (inclusive).
  • Note that these files must belong to an analysis that computed TL[File].
adesc="Version 1.0 of the thingy management system" Find files belonging to analyses with exactly this description (case insensitively).
adesc:stable Find files belonging to analyses whose description contains the (case-insensitive) substring stable.
adesc:none Find files belonging to analyses for which either of the following is true of the analysis description.
  • The description contains (case-insensitive) substring none.
  • The description contains no text, either because it has never been set or because it has been set and subsequently deleted.

Note that the second of these is because none is a special value.

aid=5 Find files belonging to the analysis with Analysis ID 5.
aid=5 | main Find files that either belong to the analysis with Analysis ID 5 or have a basename that contains the (case-insensitive) substring main (or both).
analysis="tms analysis 5" Find files belonging to the analysis with this name (case insensitively).
directory=/u/src/mymodule Find files in (case-insensitive) directory /u/src/mymodule. (See also the note above.)
directory:module Find files in any directory whose path (case-insensitively) includes substring module. (See also the note above.)
file=foo.c Find files with basename foo.c (case insensitively). (See also the note above.)
file=~"get.*\\.c" Find files whose basename contains substring 'get' and subsequently substring '.c' (case insensitively).
file=~~get%.c Find files whose basename starts with 'g-e-t' and ends with '.c' (case-insensitively).
language=C Find files whose language is C (not C++).
path=/tmp/foo.c Find files with the (case-insensitive) absolute name /tmp/foo.c. (See also the note above.)
path:src/mod1/bar.c Find files whose (case-insensitive) absolute name contains the substring src/mod1/bar.c. (See also the note above.)
path="c:\\Program Files\\TMS\\foo.h" Find files with the (case-insensitive) absolute name c:\Program Files\TMS\foo.h. Note that backslashes must be escaped. (See also the note above.)
pdesc="thingy management system" Find files belonging to analyses of projects with this description (case-insensitively).
pid=2 Find files belonging to analyses of the project with Project ID 2.
project=tms Find files belonging to analyses of the project named tms (case-insensitively).
ptree_path:/TreeX/TreeA Find files belonging to analyses of:
TL:100.. & language=C Find C files with Total Lines (TL) 100 or greater.
  • Note that these files must belong to an analysis that computed TL[File].
-(aid=5 | aid=6) & language=C++ Find C++ files that don't belong to the analysis with Analysis ID 5 or the analysis with Analysis ID 6.
sql="EXISTS (SELECT 5)" This Boolean condition will be inserted as a term in the WHERE clause used to implement the search. Only results satisfying this term will be returned.

SQL Terms

The sql field-name is provided to allow extra search customization, but is not supported. It is only available to users with G_SQL_CONSOLE permission.

For a search that includes a field-condition of the form

sql:cond

CodeSonar will insert cond as a term in the WHERE clause used to implement the search. Only results satisfying this term will be returned.

 

To report problems with this documentation, please visit https://support.codesecure.com/.