reference

Commands

Opengrep is run as opengrep COMMAND [FLAGS] [ARGUMENTS]. When the first argument is not a command, scan is assumed: opengrep --config rule.yaml . is equivalent to opengrep scan --config rule.yaml .. The flags --debug and --profile can also be given before the command.

opengrep --help lists the commands, and opengrep COMMAND --help shows the built-in help of a command.

Index

NameSummary
opengrep ciScan a repository in a CI job: report the new findings and fail on blocking ones.
opengrep lspRun Opengrep as a language server over standard input and output.
opengrep scanRun rules on files and report the findings.
opengrep showPrint the version, the supported languages, or internal representations.
opengrep testTest rules against files annotated with the lines they must and must not match.
opengrep validateCheck that rule files are valid, without scanning any code.

Examples

scan is the default command

rule.yaml
rules:  - id: find-eval    pattern: eval(...)    message: found eval    languages: [python]    severity: WARNING
app.py
eval(1)
Command and result
$ opengrep -q --config rule.yaml app.py
app.py

  warn  find-eval
  found eval

     1: eval(1)