min-version, max-version
- See also
rules
Restricts a rule to the versions of the rule format it was written for. The values are version numbers of the form X.Y.Z, quoted when YAML would read them as numbers. They are compared with the version of Semgrep whose rule format Opengrep implements:
- a rule whose
min-versionis higher than that version is skipped; - a rule whose
max-versionis lower than that version is skipped.
A skipped rule is reported as an incompatible rule, with the version Opengrep is compatible with, and the scan continues with the other rules.
Examples
A rule for a newer rule format
rules.yaml
rules: - id: future-rule pattern: eval(...) message: found eval languages: [python] severity: WARNING min-version: 99.0.0 - id: find-eval pattern: eval(...) message: found eval languages: [python] severity: WARNINGapp.py
eval(1)Command and result
$ opengrep scan --config rules.yaml app.py 2>&1 >/dev/null | grep -A1 Incompatible
info Incompatible rule future-rule:
This rule requires upgrading Opengrep to a version compatible with Semgrep version 99.0.0 (current version is compatible with Semgrep 1.100.0)
$ opengrep scan -q --config rules.yaml app.py
app.py
warn find-eval
found eval
1: eval(1)