1CSGREP(1)                        User Commands                       CSGREP(1)
2
3
4

NAME

6       csgrep - filter the list of defects by the specified regex-based predi‐
7       cates
8

SYNOPSIS

10       csgrep [options] [file1.err [...]], where options are:
11

DESCRIPTION

13       --checker arg
14              defect matches if its checker matches the given regex (each  de‐
15              fect has assigned exactly one checker)
16
17       --path arg
18              defect  matches  if  the path of its key event matches the given
19              regex
20
21       --event arg
22              defect matches if its key event matches the  given  regex  (each
23              defect  has exactly one key event, which determines its location
24              in the code)
25
26       --error arg
27              defect matches if the message of its key event matches the given
28              regex
29
30       --msg arg
31              defect matches if any of its messages matches the given regex
32
33       --annot arg
34              defect matches if its annotation matches the given regex
35
36       --src-annot arg
37              defect matches if an annotation in the _source_ file matches the
38              given regex
39
40       --drop-scan-props
41              do not propagate scan properties
42
43       -U [ --embed-context ] arg
44              embed a number of lines of context from the source file for  the
45              key event
46
47       --prune-events arg
48              event  is  preserved  if  its verbosity level is below the given
49              number
50
51       -u [ --remove-duplicates ]
52              remove defects that are not unique by their key event
53
54       --strip-path-prefix arg
55              string prefix to strip from path (applied after all filters)
56
57       -i [ --ignore-case ]
58              ignore case when matching regular expressions
59
60       -v [ --invert-match ]
61              select defects that do not match the selected criteria
62
63       -n [ --invert-regex ]
64              invert regular expressions in all predicates
65
66       -f [ --filter-file ] arg
67              read custom filtering rules from a file in JSON format
68
69       --color
70              use colorized console output (default if connected to  a  termi‐
71              nal)
72
73       --no-color
74              do not use colorized console output
75
76       -q [ --quiet ]
77              do not report any parsing errors
78
79       --mode arg (=grep)
80              grep,   json,   evtstat,  files,  filestat,  grouped,  stat,  or
81              dig_key_events
82
83       --help print the usage of csgrep
84
85       --version
86              print the version of csgrep
87

OPTIONS

89       The --filter-file option takes a list of JSON files  in  the  following
90       format.  Missing replace entry is equal to replace : "".
91
92           {
93               "msg-filter" : [
94                   {
95                        "checker" : "DIVINE|SYMBIOTIC",
96                        "regexp" : "memory"
97                   },
98                   {
99                        "checker" : "COMPILER_WARNING",
100                        "regexp" : "called on unallocated object",
101                        "replace" : "called correctly, no UB here"
102                   }
103               ]
104           }
105

EXIT STATUS

107       csgrep  exits  with status 0 if arguments are valid and input files are
108       parsed successfully.  It does  not  matter  whether  any  defects  were
109       matched or not.
110

EXAMPLE - CHECKERS, EVENTS, MESSAGES

112       Error: FORWARD_NULL (CWE-476):
113       libhsm.c:1168: assign_zero: Assigning: key_handles = NULL.
114       libhsm.c:1210: var_deref_op: Dereferencing null pointer key_handles.
115
116       In  the  above  example,  FORWARD_NULL is the checker , assign_zero and
117       var_deref_op are events , where  var_deref_op  is  the  key  event  and
118       "Dereferencing  null  pointer  key_handles."  is the message associated
119       with the key event.
120

DESCRIPTION OF AVAILABLE MODES

122       dig_key_events - for each defect, print only the checker and key event
123
124       evtstat - print overall checker/key_event statistics  for  the  matched
125       defects
126
127       files  -  print  only names of error files that contain the matched de‐
128       fects
129
130       filestat - print statistics of matched defects  per  individual  source
131       files
132
133       grep  -  print matched defects using the same format as expected on the
134       input
135
136       grouped - print matched defects, grouped by error files they  originate
137       from
138
139       json - print matched defects in a JSON format
140
141       stat  -  print overall statistics of the matched defects in given error
142       files
143
144
145
146csgrep 2.2.0                      August 2021                        CSGREP(1)
Impressum