paths
paths:
include: [GLOB, ...]
exclude: [GLOB, ...]A rule with paths runs only on the files that match at least one include glob, when include is given, and no exclude glob. A glob is matched against every directory in the file's path as well as the file name. So generated/ matches both generated/y.py and app/generated/x.py, and *_test.py matches a file with that name in any directory.
paths applies to files named on the command line as well as to the files found under directory targets. It accepts only include and exclude; any other key makes the rule invalid.
To filter files for all rules at once, use --exclude and --include.
Examples
Skip generated code and test files
rule.yaml
rules: - id: no-print pattern: print(...) message: use logging instead of print languages: [python] severity: INFO paths: exclude: - "generated/" - "*_test.py"app/main.py
print("hello")app/main_test.py
print("hello")app/generated/api.py
print("hello")generated/schema.py
print("hello")Command and result
$ opengrep scan -q --config rule.yaml .
app/main.py
info no-print
use logging instead of print
1: print("hello")