--use-git-ignore
- Accepted by
opengrep scan,opengrep ci- Also spelled
--no-git-ignore- Default
true- See also
--exclude,--semgrepignore-filename,--project-root
In a git repository, Opengrep skips the files that git ignores: those that .gitignore excludes, and git submodules. This is the default; --use-git-ignore requests it explicitly.
--no-git-ignore scans these files as well.
Outside a git repository, the flag has no effect. .semgrepignore applies in either case; see --semgrepignore-filename.
Examples
Scanning a directory that git ignores
rule.yaml
rules: - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGapp.py
eval(1)generated/gen.py
eval(2).gitignore
generated/Command and result
$ git init -q && git add -A && git commit -qm init
$ opengrep scan -q --config rule.yaml --files-with-matches .
app.py
$ opengrep scan -q --config rule.yaml --files-with-matches --no-git-ignore .
app.py
generated/gen.py