csgrep (1) Linux Manual Page
NAME
csgrep – filter the list of defects by the specified regex-based predicates
SYNOPSIS
csgrep [options] [file1.err […]], where options are:
DESCRIPTION
–checkerarg- defect matches if its checker matches the given regex (each defect has assigned exactly one checker)
–patharg- defect matches if the path of its key event matches the given regex
–eventarg- defect matches if its key event matches the given regex (each defect has exactly one key event, which determines its location in the code)
–errorarg- defect matches if the message of its key event matches the given regex
–msgarg- defect matches if any of its messages matches the given regex
–annotarg- defect matches if its annotation matches the given regex
–src-annotarg- defect matches if an annotation in the _source_ file matches the given regex
-U[–embed-context] arg- embed a number of lines of context from the source file for the key event
–prune-eventsarg- event is preserved if its verbosity level is below the given number
-u[–remove-duplicates]- remove defects that are not unique by their key event
–strip-path-prefixarg- string prefix to strip from path (applied after all filters)
-i[–ignore-case]- ignore case when matching regular expressions
-v[–invert-match]- select defects that do not match the selected criteria
-n[–invert-regex]- invert regular expressions in all predicates
–color- use colorized console output (default if connected to a terminal)
–no-color- do not use colorized console output
-q[–quiet]- do not report any parsing errors
–modearg (=grep)- grep, json, stat, grouped, files, filestat, or dig_key_events
–help- print the usage of csgrep
–version- print the version of csgrep
EXAMPLE – CHECKERS, EVENTS, MESSAGES
Error: FORWARD_NULL (CWE-476): libhsm.c:1168: assign_zero: Assigning: key_handles = NULL. libhsm.c:1210: var_deref_op: Dereferencing null pointer key_handles.
In the above example, FORWARD_NULL is the checker , assign_zero and var_deref_op are events , where var_deref_op is the key event and "Dereferencing null pointer key_handles." is the message associated with the key event.
DESCRIPTION OF AVAILABLE MODES
dig_key_events – for each defect, print only the checker and key event
evtstat – print overall checker/key_event statistics for the matched defects
files – print only names of error files that contain the matched defects
filestat – print statistics of matched defects per individual source files
grep – print matched defects using the same format as expected on the input
grouped – print matched defects, grouped by error files they originate from
json – print matched defects in a JSON format
stat – print overall statistics of the matched defects in given error files
