reference

Flags

Flags can be given before or after the targets. A flag that takes a value accepts it as --flag=VALUE or as --flag VALUE. Some flags also have a one-letter form, such as -q for --quiet.

Environment variables

Some flags can also be set with an environment variable. When both are given, the flag takes precedence, and Opengrep logs a warning that names the ignored variable.

Flags accepted for compatibility

The following flags are accepted for compatibility with existing scripts and CI configurations. They have no effect, and Opengrep logs a warning for each of them:

Every command also accepts --experimental, which has no effect and logs no warning.

Index

Flag / EnvironmentAccepted bySummary
--allow-rule-timeout-controlscan, ciLet rules set their own time limits, which are otherwise ignored.
--audit-on
OPENGREP_AUDIT_ON
ciReport blocking findings but exit with status 0 when the CI event has one of these names.
--autofixscanApply the fixes of the rules to the scanned files.
--baseline-commit
OPENGREP_BASELINE_COMMIT
OPENGREP_BASELINE_REF
scan, ciReport only the findings that are not present in the given commit.
--config
OPENGREP_RULES
scan, ci, testLoad rules from a file, a directory, a URL, a git repository or the registry.
--dataflow-tracesscan, ciShow the path from source to sink in the findings of taint rules.
--debugscan, ci, test, validate, show, lspLog the messages of --verbose and the diagnostics of the engine.
--disable-intrafilescan, ci, testAnalyze every taint rule one function at a time, including rules that set taint_intrafile or taint_interfile.
--dryrunscanShow the fixes --autofix would make, without writing them to the files.
--dynamic-timeoutscan, ciScale the time limit of each rule with the size of the file.
--dynamic-timeout-max-multiplierscan, ciThe largest factor by which --dynamic-timeout multiplies the timeout.
--dynamic-timeout-unit-kbscan, ciThe file size, in KB, of one step of --dynamic-timeout.
--emacsscan, ciPrint one line per finding, in the format of Emacs compilation buffers.
--emacs-outputscan, ciWrite the findings in the Emacs format to a file as well.
--enable-interfilescan, ci, testRun cross-file taint analysis for the rules that set the taint_interfile option.
--enable-nosemscan, ciWhether nosem comments suppress findings; on by default.
--errorscanExit with status 1 when there are findings.
--excludescan, ciSkip files and directories whose path matches a gitignore-style pattern.
--exclude-minified-filesscanSkip files that look minified.
--exclude-rulescan, ciSkip the rule with this id.
--files-with-matchesscan, ciPrint only the paths of the files that have findings.
--force-color
OPENGREP_FORCE_COLOR
scan, ci, test, validateStyle the output even when it does not go to a terminal.
--force-excludescan, ciApply --include and --exclude to files named on the command line as well.
--gitlab-sastscan, ciPrint the findings as a GitLab SAST report.
--gitlab-sast-outputscan, ciWrite the findings as a GitLab SAST report to a file as well.
--gitlab-secretsscan, ciPrint the findings as a GitLab secret detection report.
--gitlab-secrets-outputscan, ciWrite the findings as a GitLab secret detection report to a file as well.
--guarded-taint-signaturesscanDrop a cross-function taint finding when the condition leading to the sink cannot hold for the call.
--htmlshowPrint the output of opengrep show as an HTML page.
--includescan, ciScan only the files whose path matches one of these patterns.
--incremental-outputscanPrint each finding as soon as it is found.
--inline-metavariablesscan, ciReplace the metavariables in the metadata of a rule with the code they matched.
--interfile-dedup-byscan, ciWhether a sink reached by several sources across files produces one finding or one per source.
--interfile-depthscan, ci, testThe longest call chain the cross-file taint analysis follows.
--interfile-timeoutscan, ciThe time a rule may spend on the cross-file taint analysis.
--jobsscan, ciThe number of workers that run rules in parallel.
--jsonscan, ci, test, showPrint the findings as a JSON document.
--json-outputscan, ciWrite the findings as JSON to a file as well.
--junit-xmlscan, ciPrint the findings as a JUnit XML report, one failed test per finding.
--junit-xml-outputscan, ciWrite the findings as a JUnit XML report to a file as well.
--langscanThe language of a pattern given on the command line.
--matching-diagnosistestExplain why a failing rule test did not match.
--matching-explanationsscan, ciAdd to the JSON output a record of how each part of a rule matched.
--max-chars-per-linescan, ciThe width at which lines of code are wrapped in the text output.
--max-lines-per-findingscan, ciThe number of lines of code shown for a finding in the text output.
--max-log-list-entriesscan, ciThe number of items above which a list in the logs is replaced by a note.
--max-match-per-filescan, ciThe number of matches in a file, across all rules, above which all its findings are dropped.
--max-memoryscan, ci, testThe memory that the analysis of one file may use before it is abandoned.
--max-target-bytesscan, ciSkip files larger than this size.
--no-progress-barscanDo not draw the status line that shows the progress of a scan.
--opengrep-ignore-patternscan, ci, testAn additional comment prefix that suppresses the findings on a line.
--optimizationsscan, ciTurn the optimizations of the engine, such as the prefilter, on or off.
--outputscan, ciWrite the output to a file instead of standard output.
--output-enclosing-contextscanRecord the function or class that contains each finding.
--patternscanSearch with a pattern given on the command line instead of a rule file.
--project-rootscanThe project root, where .gitignore and .semgrepignore are read.
--quietscan, ci, test, validate, show, lspPrint only the findings, and nothing on standard error.
--replacementscanThe fix of a pattern given on the command line.
--rewrite-rule-idsscan, ciWhether the ids of rules from a subdirectory are prefixed with its path; on by default.
--sarifscan, ciPrint the findings as a SARIF 2.1.0 document.
--sarif-outputscan, ciWrite the findings as SARIF to a file as well, including suppressed findings.
--scan-unknown-extensionsscan, ciScan a file named on the command line even when its extension belongs to no language.
--semgrepignore-filenamescanRead the ignored paths from a file with a name other than .semgrepignore.
--severityscanReport only the findings of rules with these severities.
--show-supported-languagesscanPrint the supported languages and exit.
--skin
OPENGREP_SKIN
scan, ci, validateThe layout of the text output.
--skip-invalid-configsscanSkip invalid rule files in a directory or a git repository instead of stopping.
--strictscan, testFail the run when a file cannot be parsed or another warning-level error occurs.
--subdirciScan only this directory, with the CI metadata of the whole repository.
--suppress-errors
OPENGREP_SUPPRESS_ERRORS
ciMake opengrep ci exit with status 0 on errors; on by default.
--taint-intrafilescan, ci, testFollow taint through calls to functions in the same file, for every taint rule.
--testscanRun the rule tests instead of scanning, as opengrep test does.
--textscan, ciPrint the text output, the default format.
--text-outputscan, ciWrite the text output to a file as well.
--timescan, ciReport the time the scan took, per rule and per file.
--timeout
OPENGREP_TIMEOUT
scan, ci, testThe time limit of a rule on a file, in seconds; 0 sets no limit.
--timeout-thresholdscan, ci, testThe number of rules that may time out on a file before the file is skipped.
--use-git-ignorescan, ciWhether files ignored by git are skipped; on by default.
--validatescanCheck the rules instead of scanning, as opengrep validate does.
--verbosescan, ci, test, validate, show, lspLog the progress of the run, at the info level.
--versionscanPrint the Opengrep version and exit.
--vimscan, ciPrint one line per finding, in the format of Vim quickfix lists.
--vim-outputscan, ciWrite the findings in the Vim quickfix format to a file as well.

Examples

Flag position and values

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

  warn  find-eval
  found eval

     1: eval(1)
$ opengrep scan app.py -q --config rule.yaml
app.py

  warn  find-eval
  found eval

     1: eval(1)

A flag accepted for compatibility

Command and result
$ opengrep scan --config rule.yaml --disable-version-check app.py 2>&1 >/dev/null | grep warning
warning  --disable-version-check is not supported by opengrep and has no effect