CSGREP(1)
π CSGREP β ok bestie, let's filter some defects π
the csgrep manual, page 1, user commands section, and yes we are doing this together π
β¨ NAME β¨
csgrep β filter the list of defects by the specified regex-based predicates π¦
No cap, that's the whole job. You feed it a pile of defects, you tell it what you're looking for with regexes, and it hands back only the ones that match. It's giving bouncer at the club but the club is your error log. π
πΈ SYNOPSIS πΈ
csgrep [options] [file1.err [...]], where options are:
yes bestie, <cyan>file1.err</cyan> is a placeholder, plug in ur actual files π«Ά
π DESCRIPTION π
Okay so here's the thing β every single one of these is a predicate. A defect either matches it or it doesn't. Stack them up and csgrep keeps only the defects that survive the vibe check. β
--checkerarg β a defect matches if its checker matches the given regex. Every defect has exactly one checker assigned, so this one's a one-to-one kinda situation.--patharg β a defect matches if the path of its key event matches the given regex. π--eventarg β a defect matches if its key event matches the given regex. Every defect has exactly one key event, and that key event is what decides where the defect lives in the code. That's its whole main-character job. π--errorarg β a defect matches if the message of its key event matches the given regex. π--hash-v1arg β a defect matches if itscsdiff/v1fingerprint starts with the given prefix. Prefix matching only, bestie, not a full match.--msgarg β a defect matches if any of its messages matches the given regex. Any of them!! It only takes one!!--toolarg β a defect matches if it was detected by a tool that matches the given regex. π§--annotarg β a defect matches if its annotation matches the given regex. π--src-annotarg β a defect matches if an annotation in the source file matches the given regex. (that's_source_file, not the error file, iykyk)--imp-levelarg β a defect matches if the importance level is greater than or equal to the given number. π--drop-scan-propsβ do not propagate scan properties. just... let them go π-U,--embed-contextarg β embed a number of lines of context from the source file for the key event. Snip snip, here's the receipts. βοΈ--prune-eventsarg β an event is preserved if its verbosity level is less than or equal to the given number. above that threshold? gone. bye. π--warning-rate-limitarg β stop processing a warning if the count of its occurrences exceeds the specified limit. okay this one literally taps out once a warning gets too loud.--limit-msg-lenarg β limit message length by a number provided. short king messages only π-u,--remove-duplicatesβ remove defects that are not unique by their key event. dedupe arc, we love to see it β¨--set-imp-levelarg β set importance level on all defects to the specified value. EVERYONE gets the same level, no favourites.--set-scan-proparg βNAME:VALUEpair to override the specified scan property. π--strip-path-prefixarg β string prefix to strip from path. Applied after all filters, so don't come for me about ordering.--prepend-path-prefixarg β string prefix to prepend to relative paths. Also applied after all filters. π«Ά--file-globβ expand glob patterns in the names of input files. π-i,--ignore-caseβ ignore case when matching regular expressions. case? never heard of her π--ignore-parser-warningsβ if enabled, parser warnings about the input files do not affect exit code. the warnings still happen, they just don't get to ruin the exit code, periodt.--record-input-locationsβ if enabled, events in json will containinput_lineandinput_filefields referencing the original location of input file/stream. π-v,--invert-matchβ select defects that do not match the selected criteria. flip the whole thing, chaos mode but make it intentional π¦-n,--invert-regexβ invert regular expressions in all predicates. not just one. ALL of them. π-f,--filter-filearg β read custom filtering rules from a file in JSON format. π--colorβ use colorized console output. (this is the default if you're connected to a terminal, so like, if you're reading this in a terminal, hi, you already have it)--no-colorβ do not use colorized console output. for when the vibes must be monochrome π-q,--quietβ do not report any parsing errors. π€«--modearg (=grep) β one of:grep,json,evtstat,files,filestat,grouped,sarif,stat, ordig_key_events. default isgrepbestie, you're already in it π--helpβ print the usage ofcsgrep. π«Ά--versionβ print the version ofcsgrep. β
π OPTIONS π
okay so this section is specifically about the --filter-file option, because that one has β¨loreβ¨
The --filter-file option takes a list of JSON files in the following format. A missing replace entry is equal to "replace" : "". π
{
"msg-filter" : [
{
"checker" : "DIVINE|SYMBIOTIC",
"regexp" : "memory"
},
{
"checker" : "COMPILER_WARNING",
"regexp" : "called on unallocated object",
"replace" : "called correctly, no UB here"
}
]
}
look at her. she's structured. she's specific. she has a msg-filter array and she's not sorry. π
π EXIT STATUS π
csgrep exits with status 0 if arguments are valid and input files are parsed successfully. It does not matter whether any defects were matched or not.
yes bestie, read that again. Zero matches is still a zero exit. csgrep is not out here being petty about whether your filter found anything. π«Ά
π₯ 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.
so to recap the cast list: checker = FORWARD_NULL, events = assign_zero and var_deref_op, key event = var_deref_op, message = that whole sentence about the null pointer. she's the one carrying the plot. π
π DESCRIPTION OF AVAILABLE MODES π
the mode buffet, let's go π
dig_key_eventsβ for each defect, print only the checker and key event. bare minimum, no extras π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. in goes the format, out comes the format π¦groupedβ print matched defects, grouped by error files they originate from. π§Ίjsonβ print matched defects in a JSON format. πsarifβ print matched defects in a SARIF format. βstatβ print overall statistics of the matched defects in given error files. π
and that's the whole page, bestie. every option, every mode, every regex, every caveat, exactly as written, just with β¨personalityβ¨ π
this was csgrep version 3.5.7, from March 2026, and honestly? iconic. ate. no crumbs. π
π«Άπ
π¦ where this page comes from
- epel 10: csdiff 3.5.7-1.el10_3 Β· GPL-3.0-or-later
- fedora 43: csdiff 3.5.7-1.fc43 Β· GPL-3.0-or-later
- fedora 44: csdiff 3.5.7-1.fc44 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms